-B Pair 0: (nodes=7, depth=5, branch=3)
...
28:
29: public BlurringView(Context context, AttributeSet attrs) {
30: super(context, attrs);
31:
32: final Resources res = getResources();
33: final int defaultBlurRadius = res.getInteger(R.integer.default_blur_radius);
34: final int defaultDownsampleFactor = res.getInteger(R.integer.default_downsample_factor);
...
38:
39: TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PxBlurringView);
40: setBlurRadius(a.getInt(R.styleable.PxBlurringView_blurRadius, defaultBlurRadius));
41: setDownsampleFactor(a.getInt(R.styleable.PxBlurringView_downsampleFactor,
...
32:
33: public BlurringView(ThemedReactContext context, AttributeSet attrs) {
34: super(context, attrs);
35:
36: final Resources res = getResources();
37: final int defaultBlurRadius = res.getInteger(R.integer.default_blur_radius);
38: final int defaultDownsampleFactor = res.getInteger(R.integer.default_downsample_factor);
...
42:
43: TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PxBlurringView);
44: setBlurRadius(a.getInt(R.styleable.PxBlurringView_blurRadius, defaultBlurRadius));
45: setDownsampleFactor(a.getInt(R.styleable.PxBlurringView_downsampleFactor,
-A Pair 1: (nodes=8, depth=3, branch=3)
...
51: @Override
52: protected void onDraw(Canvas canvas) {
53: super.onDraw(canvas);
...
68: canvas.save();
69: canvas.translate(mBlurredView.getX() - getX(), mBlurredView.getY() - getY());
70: canvas.scale(mDownsampleFactor, mDownsampleFactor);
...
57: @Override
58: protected void onDraw(Canvas canvas) {
59: super.onDraw(canvas);
...
75: canvas.save();
76: canvas.translate(mBlurredView.getX() - getX(), mBlurredView.getY() - getY());
77: canvas.scale(mDownsampleFactor, mDownsampleFactor);
-A Pair 2: (nodes=5, depth=4, branch=2)
...
81:
82: public void setDownsampleFactor(int factor) {
83: if (factor <= 0) {
84: throw new IllegalArgumentException("Downsample factor must be greater than 0.");
85: }
...
89:
90: public void setDownsampleFactor(int factor) {
91: if (factor <= 0) {
92: throw new IllegalArgumentException("Downsample factor must be greater than 0.");
93: }
-B Pair 3: (nodes=6, depth=5, branch=2)
...
96:
97: private void initializeRenderScript(Context context) {
98: mRenderScript = RenderScript.create(context);
99: mBlurScript = ScriptIntrinsicBlur.create(mRenderScript, Element.U8_4(mRenderScript));
100: }
...
28: @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
29: public RenderScriptBlur(Context context) {
30: renderScript = RenderScript.create(context);
31: blurScript = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript));
32: }
-A Pair 4: (nodes=30, depth=13, branch=3)
...
102: protected boolean prepare() {
103: final int width = mBlurredView.getWidth();
104: final int height = mBlurredView.getHeight();
105:
106: if (mBlurringCanvas == null || mDownsampleFactorChanged
107: || mBlurredViewWidth != width || mBlurredViewHeight != height) {
108: mDownsampleFactorChanged = false;
...
119:
120: if (mBlurredBitmap == null
121: || mBlurredBitmap.getWidth() != scaledWidth
122: || mBlurredBitmap.getHeight() != scaledHeight) {
123: mBitmapToBlur = Bitmap.createBitmap(scaledWidth, scaledHeight,
124: Bitmap.Config.ARGB_8888);
125: if (mBitmapToBlur == null) {
126: return false;
...
128:
129: mBlurredBitmap = Bitmap.createBitmap(scaledWidth, scaledHeight,
130: Bitmap.Config.ARGB_8888);
131: if (mBlurredBitmap == null) {
132: return false;
...
137: mBlurringCanvas.scale(1f / mDownsampleFactor, 1f / mDownsampleFactor);
138: mBlurInput = Allocation.createFromBitmap(mRenderScript, mBitmapToBlur,
139: Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
140: mBlurOutput = Allocation.createTyped(mRenderScript, mBlurInput.getType());
141: }
...
114: protected boolean prepare() {
115: final int width = mBlurredView.getWidth();
116: final int height = mBlurredView.getHeight();
117:
118: if (mBlurringCanvas == null || mDownsampleFactorChanged
119: || mBlurredViewWidth != width || mBlurredViewHeight != height) {
120: mDownsampleFactorChanged = false;
...
133:
134: if (mBlurredBitmap == null
135: || mBlurredBitmap.getWidth() != scaledWidth
136: || mBlurredBitmap.getHeight() != scaledHeight) {
137: mBitmapToBlur = Bitmap.createBitmap(scaledWidth, scaledHeight,
138: Bitmap.Config.ARGB_8888);
139: if (mBitmapToBlur == null) {
140: return false;
...
142:
143: mBlurredBitmap = Bitmap.createBitmap(scaledWidth, scaledHeight,
144: Bitmap.Config.ARGB_8888);
145: if (mBlurredBitmap == null) {
146: return false;
...
151: mBlurringCanvas.scale(1f / mDownsampleFactor, 1f / mDownsampleFactor);
152: mBlurInput = Allocation.createFromBitmap(mRenderScript, mBitmapToBlur,
153: Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
154: mBlurOutput = Allocation.createTyped(mRenderScript, mBlurInput.getType());
155: }
-D Pair 5: (nodes=24, depth=20, branch=2)
...
32: mImageViews[0] = (ImageView) findViewById(R.id.image0);
33: mImageViews[1] = (ImageView) findViewById(R.id.image1);
34: mImageViews[2] = (ImageView) findViewById(R.id.image2);
35: mImageViews[3] = (ImageView) findViewById(R.id.image3);
36: mImageViews[4] = (ImageView) findViewById(R.id.image4);
37: mImageViews[5] = (ImageView) findViewById(R.id.image5);
38: mImageViews[6] = (ImageView) findViewById(R.id.image6);
39: mImageViews[7] = (ImageView) findViewById(R.id.image7);
40: mImageViews[8] = (ImageView) findViewById(R.id.image8);
41: }
...
61: mConfirm = (Button) view.findViewById(android.R.id.button1);
62: mCards[0] = (ImageView) view.findViewById(R.id.theme_pink);
63: mCards[1] = (ImageView) view.findViewById(R.id.theme_purple);
64: mCards[2] = (ImageView) view.findViewById(R.id.theme_blue);
65: mCards[3] = (ImageView) view.findViewById(R.id.theme_green);
66: mCards[4] = (ImageView) view.findViewById(R.id.theme_green_light);
67: mCards[5] = (ImageView) view.findViewById(R.id.theme_yellow);
68: mCards[6] = (ImageView) view.findViewById(R.id.theme_orange);
69: mCards[7] = (ImageView) view.findViewById(R.id.theme_red);
70: setImageButtons(mCurrentTheme);
-D Pair 6: (nodes=6, depth=3, branch=3)
...
85: for (ImageView imageView : mImageViews) {
86: ObjectAnimator tx = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, 0);
87: tx.addUpdateListener(listener);
88: ObjectAnimator ty = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_Y, 0);
89: ty.addUpdateListener(listener);
90: AnimatorSet set = new AnimatorSet();
91: set.playTogether(tx, ty);
92: set.setDuration(3000);
...
488: int contentHeight = screenHeight - actionBarHeight;
489: AnimatorSet animation = new AnimatorSet();
490: animation.setDuration(Const.DURATION_ACTIVITY);
491: animation.playTogether(
492: ObjectAnimator.ofFloat(mToolbarLayout, "translationY", 0, -actionBarHeight),
493: ObjectAnimator.ofFloat(mScrollView, "translationY", 0, contentHeight)
494: );
495: animation.addListener(new Animator.AnimatorListener() {
-D Pair 7: (nodes=5, depth=5, branch=2)
...
17: curIndex++;
18: int indexCh = subStr.indexOf(ch);
19: if (indexCh == -1) {
20: subStr.append(ch);
...
27: }
28: resultCache.put(start, curIndex);
29: }
...
115: String subname = name.substring(prefixLen);
116: int pos = subname.indexOf(separator);
117: if (pos == -1) {
118: if (!entry.isDirectory()) {
...
127: AbstractDirectory dir = new ZipRODirectory(getZipFile(), getPath() + subname + separator);
128: mDirs.put(subname, dir);
129: }
-D Pair 8: (nodes=6, depth=5, branch=3)
...
34: int maxLength = 0;
35: int resultStart = 0;
36: int resultEnd = 0;
...
40: int length = end - start + 1;
41: if (length > maxLength) {
42: maxLength = length;
43: resultStart = start;
44: resultEnd = end;
45: }
...
47: StringBuffer sb = new StringBuffer();
48: for (int i = resultStart; i <= resultEnd; i++) {
49:
...
41: int size = mMeasurements.size();
42: int startIndex = 0;
43: int endIndex = size -1;
44: if (size > 2) {
45: startIndex = size/10+1;
46: endIndex = size-size/10-2;
47: }
...
49: double sum = 0;
50: for (int i = startIndex; i <= endIndex; i++) {
51: sum += mMeasurements.get(i).rssi;
-D Pair 9: (nodes=5, depth=3, branch=3)
...
31: assertThat(result, hasSize(11));
32: assertThat(result, contains("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"));
33: }
...
16: Map<Boolean, List<String>> result = P17.split(Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "k"), 3);
17: assertThat(result.get(true), contains("a", "b", "c"));
18: assertThat(result.get(false), contains("d", "e", "f", "g", "h", "i", "k"));
-C Pair 10: (nodes=5, depth=6, branch=2)
...
12:
13: private static void swap(int[] arr, int i, int min) {
14: int tmp = arr[i];
15: arr[i] = arr[min];
16: arr[min] = tmp;
17: }
...
33:
34: private void swap(int[] a, int n, int i) {
35: int temp = a[n];
36: a[n] = a[i];
37: a[i] = temp;
38: }
-D Pair 11: (nodes=5, depth=5, branch=2)
...
18:
19: private static int findMinIndex(int[] arr, int i) {
20: int min = i;
21: for (int j = i + 1; j < arr.length; j++) {
22: if (arr[j] < arr[min]) {
...
13:
14: public static <T extends Comparable> void sort(T[] a){
15: for (int i = 0; i < a.length; i++) {
16: int minIndex=i;
17: for (int j = i+1; j <a.length ; j++) // find min
18: if(a[minIndex].compareTo(a[j])>0)
-D Pair 12: (nodes=5, depth=3, branch=3)
...
17: assertThat(compressedList, hasSize(5));
18: assertThat(compressedList, contains("a", "b", "c", "d", "e"));
19: }
...
16: Map<Boolean, List<String>> result = P17.split(Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "k"), 3);
17: assertThat(result.get(true), contains("a", "b", "c"));
18: assertThat(result.get(false), contains("d", "e", "f", "g", "h", "i", "k"));
-D Pair 13: (nodes=5, depth=3, branch=3)
...
24: assertThat(compressedList, hasSize(6));
25: assertThat(compressedList, contains("a", "b", "c", "a", "d", "e"));
26: }
...
16: Map<Boolean, List<String>> result = P17.split(Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "k"), 3);
17: assertThat(result.get(true), contains("a", "b", "c"));
18: assertThat(result.get(false), contains("d", "e", "f", "g", "h", "i", "k"));
-D Pair 14: (nodes=5, depth=4, branch=3)
...
14:
15: public <T extends Comparable<? super T>> Tree<T> search(Tree<T> tree, T item) {
16: if (Objects.equals(tree.item, item)) {
...
18: }
19: if (tree.item.compareTo(item) < 0) {
20: return search(tree.left, item);
21: } else {
22: return search(tree.right, item);
23: }
...
233: */
234: private static int search(int[] arrayI, byte[] oldBuf, int oldSize, byte[] newBuf, int newSize, int newBufOffset, int start, int end, IntByRef pos) {
235:
...
250: int x = start + (end - start) / 2;
251: if (memcmp(oldBuf, oldSize, arrayI[x], newBuf, newSize, newBufOffset) < 0) {
252: return search(arrayI, oldBuf, oldSize, newBuf, newSize, newBufOffset, x, end, pos); // Calls itself recursively
253: } else {
254: return search(arrayI, oldBuf, oldSize, newBuf, newSize, newBufOffset, start, x, pos);
255: }
-D Pair 15: (nodes=6, depth=4, branch=2)
...
29: int rem = 0;
30: while (first != null && second != null) {
31: int a = first.val;
32: int b = second.val;
33: first = first.next;
34: second = second.next;
...
14: ListNode fast = head.next;
15: while (fast != null && fast.next != null) {
16: slow = slow.next;
17: fast = fast.next.next;
18: }
-D Pair 16: (nodes=10, depth=4, branch=3)
...
15: public void shouldDuplicateElementsInAList() throws Exception {
16: List<String> duplicates = P14.duplicate(Arrays.asList("a", "b", "c", "d"));
17: assertThat(duplicates, hasSize(8));
18: assertThat(duplicates, contains("a", "a", "b", "b", "c", "c", "d", "d"));
19: }
...
15: public void shouldDuplicateElementsInAList() throws Exception {
16: List<String> duplicates = P15.duplicate(Arrays.asList("a", "b", "c"), 3);
17: assertThat(duplicates, hasSize(9));
18: assertThat(duplicates, contains("a", "a", "a", "b", "b", "b", "c", "c", "c"));
19: }
-D Pair 17: (nodes=7, depth=5, branch=3)
...
6:
7: public static int mode(int[] numbers) {
8: Arrays.sort(numbers);
...
11: int prev = numbers[0];
12: int currentCount = 0;
13: for (int i = 1; i < numbers.length; i++) {
14: int cur = numbers[i];
15: if (prev == cur) {
16: currentCount++;
17: } else {
...
22: prev = cur;
23: currentCount = 0;
24: }
...
6:public class MaxConsecutiveZeros {
7: int findMaxConsecutiveOnes(int[] a) {
8: int max = 0;
9: int counter = 0;
10: for (int i = 0; i < a.length; i++) {
11: if (a[i] == 1) {
12: counter++;
13: max = Math.max(counter, max);
14: } else
15: counter = 0;
16: }
-D Pair 18: (nodes=5, depth=6, branch=2)
...
18: public static List<Integer> goldbach(int number) {
19: if (number == 2) {
20: return Collections.emptyList();
21: } else if (number % 2 != 0) {
22: return Collections.emptyList();
...
368: }
369: if (elements.length % 2 != 0) {
370: LOG.warn("Illegal value: the number of elements in \"" + s + "\" is " + elements.length
...
380: final int sleep = parsePositiveInt(elements, i++, s);
381: if (sleep == -1) {
382: return null; // parse fails
-B Pair 19: (nodes=10, depth=4, branch=3)
...
23: @Override
24: public boolean equals(Object o) {
25: if (this == o) return true;
26: if (o == null || getClass() != o.getClass()) return false;
27: IntPair intPair = (IntPair) o;
...
35: @Override
36: public boolean equals(Object o) {
37: if (this == o) return true;
38: if (o == null || getClass() != o.getClass()) return false;
39: Player player = (Player) o;
-D Pair 20: (nodes=6, depth=4, branch=2)
...
7:
8: public static int gcd(int first, int second) {
9: if (first == 0) {
10: return second;
11: } else if (second == 0) {
12: return first;
...
59:
60: public int getItemViewType(int row, int column) {
61: if (column == 0 && row == 0) {
...
63: }
64: if (column == 0) {
65: return ROOM_TYPE;
66: }
67: if (row == 0) {
68: return DATE_TYPE;
-D Pair 21: (nodes=6, depth=5, branch=2)
...
23: assertThat(encodedList.get(2), is(equalTo(new SimpleEntry<>(2, "c"))));
24: assertThat(encodedList.get(3), is(equalTo(new SimpleEntry<>(2, "a"))));
25: assertThat(encodedList.get(4), is(equalTo(new SimpleEntry<>(1, "d"))));
...
21: assertThat(encodedList.get(1), is(equalTo("b")));
22: assertThat(encodedList.get(2), is(equalTo(new SimpleEntry<>(2, "c"))));
23: assertThat(encodedList.get(3), is(equalTo(new SimpleEntry<>(2, "a"))));
-D Pair 22: (nodes=5, depth=7, branch=2)
...
22: String[] chars = input.split("");
23: String palindrome = null;
24: for (int i = 0; i < chars.length; i++) {
...
30: if (Objects.equals(first, reverse(first))) {
31: if (palindrome == null || first.length() > palindrome.length()) {
32: palindrome = first;
33: }
...
280: }
281: Constructor<T> result = null;
282: /*
...
295: MemberUtils.setAccessibleWorkaround(ctor);
296: if (result == null
297: || MemberUtils.compareParameterTypes(ctor.getParameterTypes(), result
298: .getParameterTypes(), parameterTypes) < 0) {
299: // temporary variable for annotation, see comment above (1)
...
302: Constructor<T> constructor = (Constructor<T>) ctor;
303: result = constructor;
304: }
-D Pair 23: (nodes=5, depth=4, branch=2)
...
40:
41: private static String reverse(String in) {
42: char[] chrs = new char[in.length()];
43: for (int i = 0; i < in.length(); i++) {
44: chrs[in.length() - i - 1] = in.charAt(i);
...
32:
33: int hash(String s) {
34: int h = 0;
35: for (int i = 0; i < s.length(); i++) {
36: h += s.charAt(i);
-D Pair 24: (nodes=7, depth=7, branch=2)
...
60: String longest = String.valueOf(chars[0]);
61: for (int middle = 1; middle < input.length(); middle++) {
62: int left = middle - 1;
63: int right = middle + 1;
64: if (left >= 0 && right < input.length() && chars[left] == chars[right]) {
65: String possibleLongest = findLongest(chars, left, right);
...
69: }
70: if (middle >= 0 && right < input.length() && chars[middle] == chars[right]) {
71: String possibleLongest = findLongest(chars, middle, right);
...
9: for (int i = 0; i < a.length; i++) {
10: for (int j = 0; j < a[i].length; j++) {
11: if (a[i][j] == 'X' && j == a[i].length - 1 && i == a.length - 1) counter++;
12: if (a[i][j] == 'X' && j == a[i].length - 1 && i < a.length - 1 && a[i + 1][j] == '.') counter++;
13: if (a[i][j] == 'X' && j < a[i].length - 1 && i < a.length - 1 && a[i + 1][j] == '.' && a[i][j + 1] == '.')
14: counter++;
15: if (a[i][j] == 'X' && j < a[i].length - 1 && i == a.length - 1 && a[i][j + 1] == '.') counter++;
16: }
-D Pair 25: (nodes=6, depth=5, branch=2)
...
83: int pRight = right + 1;
84: if (pLeft >= 0 && pRight < chars.length && chars[pLeft] == chars[pRight]) {
85: return findLongest(chars, pLeft, pRight);
...
1566: synchronized (this) {
1567: if (position >= 0 &&
1568: position < mPlaylist.size() &&
1569: mPlaylist.get(position).mId == id) {
1570:
-D Pair 26: (nodes=6, depth=5, branch=2)
...
14:
15: public static List<SimpleEntry<Integer, Integer>> pairs(int[] numbers) {
16: /*
...
30: List<SimpleEntry<Integer, Integer>> pairs = new ArrayList<>();
31: for (int i = 0; i < numbers.length / 2; i++) {
32: pairs.add(new SimpleEntry<>(numbers[i], numbers[(numbers.length - i) - 1]));
...
16: }
17: private void reverse(int input[]){
18: for(int i=0; i < input.length/2; i++){
19: swap(input,i, input.length-1-i);
-D Pair 27: (nodes=5, depth=4, branch=2)
...
32:
33: public int firstOffendingParenthesis(String input) {
34: /*
...
41: Stack<Integer> stack = new Stack<>();
42: for (int i = 0; i < input.length(); i++) {
43: if (input.charAt(i) == ')' && !stack.empty()) {
...
32:
33: int hash(String s) {
34: int h = 0;
35: for (int i = 0; i < s.length(); i++) {
36: h += s.charAt(i);
-C Pair 28: (nodes=8, depth=6, branch=2)
...
43: public boolean remove1(int el) {
44: int found = -1;
45: for (int i = 0; i < this.size; i++) {
46: if (this.arr[i] == el) {
47: found = i;
48: break;
...
55: this.size--;
56: System.arraycopy(this.arr, found + 1, this.arr, found, this.size - found);
57: for (int i = this.size; i < this.arr.length; i++) {
...
1102: int[] state = super.onCreateDrawableState(extraSpace + 1);
1103: int enabledPos = -1;
1104: for (int i = state.length - 1; i >= 0; i--) {
1105: if (state[i] == enabledState) {
1106: enabledPos = i;
1107: break;
...
1112: if (enabledPos >= 0) {
1113: System.arraycopy(state, enabledPos + 1, state, enabledPos,
1114: state.length - enabledPos - 1);
1115: }
-C Pair 29: (nodes=9, depth=6, branch=3)
...
67:
68: public boolean remove2(int el) {
69: /*
...
74: */
75: int found = -1;
76: for (int i = 0; i < this.size; i++) {
77: if (this.arr[i] == el) {
78: found = i;
79: break;
...
86: int[] copy = new int[size];
87: System.arraycopy(arr, 0, copy, 0, found);
88: System.arraycopy(this.arr, found + 1, copy, found, this.size - found);
...
100: @SuppressWarnings("unchecked")
101: void remove(PublishDisposable<T> ps) {
102: for (;;) {
...
108: int n = a.length;
109: int j = -1;
110: for (int i = 0; i < n; i++) {
111: if (a[i] == ps) {
112: j = i;
113: break;
...
126: b = new PublishDisposable[n - 1];
127: System.arraycopy(a, 0, b, 0, j);
128: System.arraycopy(a, j + 1, b, j, n - j - 1);
-C Pair 30: (nodes=7, depth=6, branch=2)
...
21:
22: public static <T> List<T> reverse_foreach(List<T> list) {
23: if (list == null) {
...
25: }
26: List<T> reversed = new ArrayList<>();
27: for (int i = list.size() - 1; i >= 0; i--) {
28: reversed.add(list.get(i));
29: }
...
241: */
242: public static <V> List<V> invertList(List<V> sourceList) {
243: if (isEmpty(sourceList)) {
...
246:
247: List<V> invertList = new ArrayList<V>(sourceList.size());
248: for (int i = sourceList.size() - 1; i >= 0; i--) {
249: invertList.add(sourceList.get(i));
250: }
-D Pair 31: (nodes=5, depth=5, branch=2)
...
17: */
18: public static <T> T last(List<T> elements) {
19: int numberOfElements = elements.size();
20: return elements.get(numberOfElements - 1);
21: }
...
940:
941: private static Calendar maxDate(List<Calendar> selectedCals) {
942: if (selectedCals == null || selectedCals.size() == 0) {
...
945: Collections.sort(selectedCals);
946: return selectedCals.get(selectedCals.size() - 1);
947: }
-C Pair 32: (nodes=6, depth=4, branch=2)
...
35: */
36: public static <T> T lastRecursive(List<T> elements) {
37: if (elements == null || elements.isEmpty()) {
...
39: }
40: if (elements.size() == 1) {
41: return elements.get(0);
42: }
...
120: @SuppressWarnings("deprecation")
121: public static Size getPictureSize(List<Size> choices, @Configuration.MediaQuality int mediaQuality) {
122: if (choices == null || choices.isEmpty()) return null;
123: if (choices.size() == 1) return choices.get(0);
124:
-D Pair 33: (nodes=6, depth=5, branch=2)
...
24:
25: public static IntPair minimize_sorted(int[] sorted) {
26: int diff = sorted[1] - sorted[0];
27: IntPair pair = null;
28: for (int i = 1; i < sorted.length - 1; i++) {
29: int first = sorted[i];
...
7:
8: int findMaxConsecutiveOnes2(int[] a) {
9: int max = findMaxConsecutiveOnes(a);
10: if (max < a.length) max += 1;
11: for (int i = 1; i < a.length - 1; i++) {
12: if (a[i] == 0 && a[i - 1] == 1 && a[i + 1] == 1) {
-D Pair 34: (nodes=5, depth=8, branch=3)
...
21: private static int[] merge(int[] left, int[] right, int length) {
22: int[] sorted = new int[length];
23: int[] smaller = ((left.length < right.length) ? left : right);
24: for (int i = 0; i < smaller.length; i++) {
25: if (left[i] <= right[i]) {
...
31: int[] greater = ((left.length > right.length) ? left : right);
32: for (int i = smaller.length; i < greater.length; i++) {
33: sorted[i] = greater[i];
34: }
...
100: //取进程名的后缀
101: for(int i = 0; i < pkgNumber; i++)
102: {
...
156: List<PkgInfo> pkgInfos = TestSence.getInstance().pkgInfos;
157: String []pids = new String[pkgInfos.size()];
158: for(int i = 0; i < pids.length; i++)
159: {
160: pids[i] = pkgInfos.get(i).contents[PkgInfo.PID_INDEX];
161: }
-B Pair 35: (nodes=10, depth=4, branch=3)
...
35: @Override
36: public boolean equals(Object o) {
37: if (this == o) return true;
38: if (o == null || getClass() != o.getClass()) return false;
39: Player player = (Player) o;
...
26: @Override
27: public boolean equals(Object o) {
28: if (this == o) return true;
29: if (o == null || getClass() != o.getClass()) return false;
30:
-C Pair 36: (nodes=5, depth=5, branch=2)
...
32: int[] pairs = Problem01.twoSum(numbers, 100);
33: long end = System.currentTimeMillis();
34: System.out.println(String.format("Total time taken %d sec(s)", (end - start) / 1000));
35: System.out.println(Arrays.toString(pairs));
...
47: private static void printElapsed(long start) {
48: long now = System.currentTimeMillis();
49: System.out.println(String.format("Took %.2f seconds", (now - start) / 1000.0));
50: }
-D Pair 37: (nodes=5, depth=5, branch=2)
...
10: */
11: public static int sumOfNNumbers(int n) {
12: int sum = 0;
13: for (int i = 1; i <= n; i++) {
14: sum += i;
15: }
...
173: */
174: public double getLength(int segments)
175: {
176: double totalLength = 0;
177:
...
181:
182: for (int i = 1; i <= segments; i++)
183: {
...
186: double dist = mTempPrevLen.distanceTo(mTempPointLen);
187: totalLength += dist;
188: mSegmentLengths[i] = dist;
-D Pair 38: (nodes=5, depth=5, branch=2)
...
22: */
23: public static int squareOfANumber(int n) {
24: int square = 0;
25: for (int i = 1; i <= n; i++) {
26: for (int j = 1; j <= n; j++) {
27: square += 1;
28: }
...
173: */
174: public double getLength(int segments)
175: {
176: double totalLength = 0;
177:
...
181:
182: for (int i = 1; i <= segments; i++)
183: {
...
186: double dist = mTempPrevLen.distanceTo(mTempPointLen);
187: totalLength += dist;
188: mSegmentLengths[i] = dist;
-D Pair 39: (nodes=6, depth=5, branch=2)
...
7:
8: public static boolean patternExistInText(String text, String pattern) {
9: /*
...
16: */
17: int n = text.length();
18: int m = pattern.length();
19: for (int i = 0; i < n - m; i++) {
20: int j = 0;
...
84:
85: private SpannableStringBuilder getSpacedOutString(CharSequence text) {
86: final SpannableStringBuilder builder = new SpannableStringBuilder();
87: final int textLength = text.length();
88: int lastSpaceIndex = -1;
...
91: //Scale the space without scaling the character to preserve font appearance
92: for (int i = 0; i < textLength - 1; i++) {
93: builder.append(text.charAt(i));
-D Pair 40: (nodes=7, depth=6, branch=3)
...
21: public static <T> List<List<T>> pack(List<T> list) {
22: T lastElement = null;
23: List<List<T>> packedList = new ArrayList<>();
24: List<T> elements = new ArrayList<>();
25: for (T el : list) {
26: if (!Objects.equals(lastElement, el)) {
27: elements = new ArrayList<>();
28: packedList.add(elements);
29: }
30: elements.add(el);
31: lastElement = el;
...
376: BufferedReader br = new BufferedReader(new FileReader("./res/testdata/trec/trec15answers_other"));
377: String targetID = null;
378: ArrayList<TRECNugget> nuggets = new ArrayList<TRECNugget>();
379:
...
386:
387: if (!nugget.targetID.equals(targetID)) {
388: if (targetID != null) nuggetsByTargetID.put(targetID, nuggets);
389: targetID = nugget.targetID;
390: nuggets = new ArrayList<TRECNugget>();
391: }
392:
393: nuggets.add(nugget);
394: }
-D Pair 41: (nodes=5, depth=3, branch=2)
...
19: assertThat(encodedList, hasSize(6));
20: assertThat(encodedList.get(0), is(equalTo(new SimpleEntry<>(4, "a"))));
21: assertThat(encodedList.get(1), is(equalTo("b")));
...
127: List<Account> values = argumentCaptor.getAllValues();
128: assertThat(values.get(0), is(equalTo(accounts[0])));
129: assertThat(values.get(1), is(equalTo(accounts[1])));
-D Pair 42: (nodes=5, depth=5, branch=2)
...
18: public static List<Integer> primeNumbers_sieve(final int start, final int end) {
19: boolean[] primes = new boolean[end + 1];
20: Arrays.fill(primes, true);
21: for (int i = 2; i < primes.length; i++) {
22: for (int j = i + 1; j < primes.length; j++) {
23: primes[j] = !primes[j] || j % i == 0 ? false : true;
...
9: assert ticket != null && ticket.length > 0 && ticket.length == ticket[0].length;
10: int T[] = new int[ticket.length];
11: int T1[] = new int[ticket.length];
...
18: for(int i=1; i < T.length; i++){
19: for(int j=i+1; j < T.length; j++){
20: if(T[j] > T[i] + ticket[i][j]){
-D Pair 43: (nodes=5, depth=5, branch=3)
...
17: }
18: int[][] result = new int[rowsA][colsB];
19:
20: for (int i = 0; i < rowsA; i++) {
21: for (int j = 0; j < colsB; j++) {
22: int fValue = 0;
...
25: }
26: result[i][j] = fValue;
27: }
...
32: int numFeature = dataStore.featureMeta.numFeature;
33: float[][] splitSet = new float[numFeature][splitNum];
34:
...
43: // 2. calculate the candidate split value
44: for (int fid = 0; fid < numFeature; fid++) {
45: for (int j = 0; j < splitNum; j++) {
46: splitSet[fid][j] = dataStore.featureMeta.minFeatures[fid] + binWidths[fid] * j;
47: }
-D Pair 44: (nodes=7, depth=5, branch=2)
...
40:
41: public void insert(T t) {
42: if (t.compareTo(this.node.data) < 0) {
43: this.node.leftCount++;
...
48: }
49: } else if (t.compareTo(this.node.data) > 0) {
50: this.node.rightCount++;
...
135: */
136: protected Node<T> getNode(T value) {
137: Node<T> node = root;
138: while (node != null && node.id != null) {
139: if (value.compareTo(node.id) < 0) {
140: node = node.lesser;
141: } else if (value.compareTo(node.id) > 0) {
142: node = node.greater;
-D Pair 45: (nodes=7, depth=5, branch=2)
...
62:
63: public boolean member(T t) {
64: if (t.compareTo(this.node.data) < 0) {
65: return this.left != null && this.left.member(t);
66: } else if (t.compareTo(this.node.data) > 0) {
67: return this.right != null && this.right.member(t);
...
135: */
136: protected Node<T> getNode(T value) {
137: Node<T> node = root;
138: while (node != null && node.id != null) {
139: if (value.compareTo(node.id) < 0) {
140: node = node.lesser;
141: } else if (value.compareTo(node.id) > 0) {
142: node = node.greater;
-D Pair 46: (nodes=5, depth=3, branch=2)
...
19: assertThat(encodedList, hasSize(6));
20: assertThat(encodedList.get(0), is(equalTo(new SimpleEntry<>(4, "a"))));
21: assertThat(encodedList.get(1), is(equalTo(new SimpleEntry<>(1, "b"))));
...
127: List<Account> values = argumentCaptor.getAllValues();
128: assertThat(values.get(0), is(equalTo(accounts[0])));
129: assertThat(values.get(1), is(equalTo(accounts[1])));
-B Pair 47: (nodes=6, depth=5, branch=2)
...
30: public static void initImageLoader(Context context) {
31: ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
32: .threadPriority(Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory()
33: .memoryCache(new LruMemoryCache(2 * 1024 * 1024)).discCacheSize(10 * 1024 * 1024)
34: .discCacheFileNameGenerator(new Md5FileNameGenerator())
35: .tasksProcessingOrder(QueueProcessingType.LIFO)
36: .build();
37: ImageLoader.getInstance().init(config);
38: }
...
35: public static void init(Context context) {
36: ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
37: .threadPriority(Thread.NORM_PRIORITY - 2)
38: .denyCacheImageMultipleSizesInMemory()
39: .discCacheFileNameGenerator(new Md5FileNameGenerator())
40: .tasksProcessingOrder(QueueProcessingType.LIFO)
41: .build();
42: ImageLoader.getInstance().init(config);
43:
-D Pair 48: (nodes=7, depth=7, branch=3)
...
30: public LoadingFooter(Context context) {
31: mLoadingFooter = LayoutInflater.from(context).inflate(R.layout.loading_footer, null);
32: mLoadingFooter.setOnClickListener(new View.OnClickListener() {
...
37: });
38: mLoadingText = (TextView) mLoadingFooter.findViewById(R.id.textView);
39: mTitanicText = (TitanicTextView) mLoadingFooter.findViewById(R.id.tv_titanic);
...
40:
41: convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, null);
42: holder.tvName = (TextView) convertView.findViewById(R.id.tvName);
43: holder.tvDesc = (TextView) convertView.findViewById(R.id.tvDesc);
44: holder.tvNew = (TextView) convertView.findViewById(R.id.tvNew);
45:
-A Pair 49: (nodes=6, depth=5, branch=2)
...
359: private static final Interpolator sInterpolator = new Interpolator() {
360: public float getInterpolation(float t) {
361: t -= 1.0f;
362: return t * t * t * t * t + 1.0f;
363: }
...
122: private static final Interpolator sInterpolator = new Interpolator() {
123: public float getInterpolation(float t) {
124: t -= 1.0f;
125: return t * t * t * t * t + 1.0f;
126: }
-A Pair 50: (nodes=9, depth=7, branch=2)
...
392: */
393: public static ViewDragHelper create(ViewGroup forParent, float sensitivity, Callback cb) {
394: final ViewDragHelper helper = create(forParent, cb);
395: helper.mTouchSlop = (int) (helper.mTouchSlop * (1 / sensitivity));
396: return helper;
...
371: */
372: public static ViewDragHelper create(ViewGroup forParent, float sensitivity, Callback cb) {
373: final ViewDragHelper helper = create(forParent, cb);
374: helper.mTouchSlop = (int) (helper.mTouchSlop * (1 / sensitivity));
375: return helper;
-A Pair 51: (nodes=7, depth=7, branch=2)
...
406: */
407: private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
408: if (forParent == null) {
...
418: final ViewConfiguration vc = ViewConfiguration.get(context);
419: final float density = context.getResources().getDisplayMetrics().density;
420: mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
421:
...
403: */
404: private ViewDragHelper(Context context, ViewGroup forParent, Interpolator interpolator, Callback cb) {
405: if (forParent == null) {
...
415: final ViewConfiguration vc = ViewConfiguration.get(context);
416: final float density = context.getResources().getDisplayMetrics().density;
417: mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
418:
-A Pair 52: (nodes=13, depth=7, branch=2)
...
434: */
435: public void setSensitivity(Context context, float sensitivity) {
436: float s = Math.max(0f, Math.min(1.0f, sensitivity));
437: ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
438: mTouchSlop = (int) (viewConfiguration.getScaledTouchSlop() * (1 / s));
439: }
...
438: */
439: public void setSensitivity(Context context, float sensitivity) {
440: float s = Math.max(0f, Math.min(1.0f, sensitivity));
441: ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
442: mTouchSlop = (int) (viewConfiguration.getScaledTouchSlop() * (1 / s));
443: }
-A Pair 53: (nodes=8, depth=6, branch=2)
...
525: */
526: public void captureChildView(View childView, int activePointerId) {
527: if (childView.getParent() != mParentView) {
528: throw new IllegalArgumentException("captureChildView: parameter must be a descendant "
529: + "of the ViewDragHelper's tracked parent view (" + mParentView + ")");
530: }
...
489: */
490: public void captureChildView(View childView, int activePointerId) {
491: if (childView.getParent() != mParentView) {
492: throw new IllegalArgumentException("captureChildView: parameter must be a descendant " +
493: "of the ViewDragHelper's tracked parent view (" + mParentView + ")");
494: }
-A Pair 54: (nodes=7, depth=3, branch=4)
...
583: if (mDragState == STATE_SETTLING) {
584: final int oldX = mScroller.getCurrX();
585: final int oldY = mScroller.getCurrY();
586: mScroller.abortAnimation();
587: final int newX = mScroller.getCurrX();
588: final int newY = mScroller.getCurrY();
589: mCallback.onViewPositionChanged(mCapturedView, newX, newY, newX - oldX, newY - oldY);
590: }
...
544: if (mDragState == STATE_SETTLING) {
545: final int oldX = mScroller.getCurrX();
546: final int oldY = mScroller.getCurrY();
547: mScroller.abortAnimation();
548: final int newX = mScroller.getCurrX();
549: final int newY = mScroller.getCurrY();
550: mCallback.onViewPositionChanged(mCapturedView, newX, newY, newX - oldX, newY - oldY);
551: }
-A Pair 55: (nodes=5, depth=3, branch=4)
...
611: */
612: public boolean smoothSlideViewTo(View child, int finalLeft, int finalTop) {
613: mCapturedView = child;
...
615:
616: return forceSettleCapturedViewAt(finalLeft, finalTop, 0, 0);
617: }
...
568: */
569: public boolean smoothSlideViewTo(View child, int finalLeft, int finalTop) {
570: mCapturedView = child;
...
572:
573: return forceSettleCapturedViewAt(finalLeft, finalTop, 0, 0);
574: }
-A Pair 56: (nodes=7, depth=4, branch=4)
...
631: */
632: public boolean settleCapturedViewAt(int finalLeft, int finalTop) {
633: if (!mReleaseInProgress) {
...
637:
638: return forceSettleCapturedViewAt(finalLeft, finalTop,
639: (int) VelocityTrackerCompat.getXVelocity(mVelocityTracker, mActivePointerId),
640: (int) VelocityTrackerCompat.getYVelocity(mVelocityTracker, mActivePointerId));
641: }
...
586: */
587: public boolean settleCapturedViewAt(int finalLeft, int finalTop) {
588: if (!mReleaseInProgress) {
...
592:
593: return forceSettleCapturedViewAt(finalLeft, finalTop,
594: (int) VelocityTrackerCompat.getXVelocity(mVelocityTracker, mActivePointerId),
595: (int) VelocityTrackerCompat.getYVelocity(mVelocityTracker, mActivePointerId));
596: }
-A Pair 57: (nodes=12, depth=5, branch=2)
...
652: */
653: private boolean forceSettleCapturedViewAt(int finalLeft, int finalTop, int xvel, int yvel) {
654: final int startLeft = mCapturedView.getLeft();
655: final int startTop = mCapturedView.getTop();
656: final int dx = finalLeft - startLeft;
657: final int dy = finalTop - startTop;
658:
659: if (dx == 0 && dy == 0) {
660: // Nothing to do. Send callbacks, be done.
...
662: setDragState(STATE_IDLE);
663: return false;
664: }
...
606: */
607: private boolean forceSettleCapturedViewAt(int finalLeft, int finalTop, int xvel, int yvel) {
608: final int startLeft = mCapturedView.getLeft();
609: final int startTop = mCapturedView.getTop();
610: final int dx = finalLeft - startLeft;
611: final int dy = finalTop - startTop;
612:
613: if (dx == 0 && dy == 0) {
614: // Nothing to do. Send callbacks, be done.
...
616: setDragState(STATE_IDLE);
617: return false;
618: }
-A Pair 58: (nodes=39, depth=11, branch=3)
...
672:
673: private int computeSettleDuration(View child, int dx, int dy, int xvel, int yvel) {
674: xvel = clampMag(xvel, (int) mMinVelocity, (int) mMaxVelocity);
675: yvel = clampMag(yvel, (int) mMinVelocity, (int) mMaxVelocity);
676: final int absDx = Math.abs(dx);
677: final int absDy = Math.abs(dy);
678: final int absXVel = Math.abs(xvel);
679: final int absYVel = Math.abs(yvel);
680: final int addedVel = absXVel + absYVel;
681: final int addedDistance = absDx + absDy;
682:
683: final float xweight = xvel != 0 ? (float) absXVel / addedVel : (float) absDx
684: / addedDistance;
685: final float yweight = yvel != 0 ? (float) absYVel / addedVel : (float) absDy
686: / addedDistance;
687:
688: int xduration = computeAxisDuration(dx, xvel, mCallback.getViewHorizontalDragRange(child));
689: int yduration = computeAxisDuration(dy, yvel, mCallback.getViewVerticalDragRange(child));
690:
691: return (int) (xduration * xweight + yduration * yweight);
692: }
...
626:
627: private int computeSettleDuration(View child, int dx, int dy, int xvel, int yvel) {
628: xvel = clampMag(xvel, (int) mMinVelocity, (int) mMaxVelocity);
629: yvel = clampMag(yvel, (int) mMinVelocity, (int) mMaxVelocity);
630: final int absDx = Math.abs(dx);
631: final int absDy = Math.abs(dy);
632: final int absXVel = Math.abs(xvel);
633: final int absYVel = Math.abs(yvel);
634: final int addedVel = absXVel + absYVel;
635: final int addedDistance = absDx + absDy;
636:
637: final float xweight = xvel != 0 ? (float) absXVel / addedVel :
638: (float) absDx / addedDistance;
639: final float yweight = yvel != 0 ? (float) absYVel / addedVel :
640: (float) absDy / addedDistance;
641:
642: int xduration = computeAxisDuration(dx, xvel, mCallback.getViewHorizontalDragRange(child));
643: int yduration = computeAxisDuration(dy, yvel, mCallback.getViewVerticalDragRange(child));
644:
645: return (int) (xduration * xweight + yduration * yweight);
646: }
-A Pair 59: (nodes=35, depth=16, branch=3)
...
693:
694: private int computeAxisDuration(int delta, int velocity, int motionRange) {
695: if (delta == 0) {
...
698:
699: final int width = mParentView.getWidth();
700: final int halfWidth = width / 2;
701: final float distanceRatio = Math.min(1f, (float) Math.abs(delta) / width);
702: final float distance = halfWidth + halfWidth
703: * distanceInfluenceForSnapDuration(distanceRatio);
704:
705: int duration;
706: velocity = Math.abs(velocity);
707: if (velocity > 0) {
708: duration = 4 * Math.round(1000 * Math.abs(distance / velocity));
709: } else {
710: final float range = (float) Math.abs(delta) / motionRange;
711: duration = (int) ((range + 1) * BASE_SETTLE_DURATION);
712: }
713: return Math.min(duration, MAX_SETTLE_DURATION);
714: }
...
647:
648: private int computeAxisDuration(int delta, int velocity, int motionRange) {
649: if (delta == 0) {
...
652:
653: final int width = mParentView.getWidth();
654: final int halfWidth = width / 2;
655: final float distanceRatio = Math.min(1f, (float) Math.abs(delta) / width);
656: final float distance = halfWidth + halfWidth *
657: distanceInfluenceForSnapDuration(distanceRatio);
658:
659: int duration;
660: velocity = Math.abs(velocity);
661: if (velocity > 0) {
662: duration = 4 * Math.round(1000 * Math.abs(distance / velocity));
663: } else {
664: final float range = (float) Math.abs(delta) / motionRange;
665: duration = (int) ((range + 1) * BASE_SETTLE_DURATION);
666: }
667: return Math.min(duration, MAX_SETTLE_DURATION);
668: }
-B Pair 60: (nodes=10, depth=5, branch=3)
...
725: */
726: private int clampMag(int value, int absMin, int absMax) {
727: final int absValue = Math.abs(value);
728: if (absValue < absMin)
729: return 0;
730: if (absValue > absMax)
731: return value > 0 ? absMax : -absMax;
732: return value;
...
679: */
680: private int clampMag(int value, int absMin, int absMax) {
681: final int absValue = Math.abs(value);
682: if (absValue < absMin) return 0;
683: if (absValue > absMax) return value > 0 ? absMax : -absMax;
684: return value;
-B Pair 61: (nodes=10, depth=5, branch=3)
...
744: */
745: private float clampMag(float value, float absMin, float absMax) {
746: final float absValue = Math.abs(value);
747: if (absValue < absMin)
748: return 0;
749: if (absValue > absMax)
750: return value > 0 ? absMax : -absMax;
751: return value;
...
679: */
680: private int clampMag(int value, int absMin, int absMax) {
681: final int absValue = Math.abs(value);
682: if (absValue < absMin) return 0;
683: if (absValue > absMax) return value > 0 ? absMax : -absMax;
684: return value;
-A Pair 62: (nodes=10, depth=7, branch=2)
...
753:
754: private float distanceInfluenceForSnapDuration(float f) {
755: f -= 0.5f; // center the values about 0.
756: f *= 0.3f * Math.PI / 2.0f;
757: return (float) Math.sin(f);
758: }
...
780: // of travel has on the overall snap duration.
781: float distanceInfluenceForSnapDuration(float f) {
782: f -= 0.5f; // center the values about 0.
783: f *= 0.3f * Math.PI / 2.0f;
784: return (float) Math.sin(f);
785: }
-A Pair 63: (nodes=11, depth=3, branch=8)
...
769: */
770: public void flingCapturedView(int minLeft, int minTop, int maxLeft, int maxTop) {
771: if (!mReleaseInProgress) {
...
775:
776: mScroller.fling(mCapturedView.getLeft(), mCapturedView.getTop(),
777: (int) VelocityTrackerCompat.getXVelocity(mVelocityTracker, mActivePointerId),
778: (int) VelocityTrackerCompat.getYVelocity(mVelocityTracker, mActivePointerId),
779: minLeft, maxLeft, minTop, maxTop);
780:
...
719: */
720: public void flingCapturedView(int minLeft, int minTop, int maxLeft, int maxTop) {
721: if (!mReleaseInProgress) {
...
725:
726: mScroller.fling(mCapturedView.getLeft(), mCapturedView.getTop(),
727: (int) VelocityTrackerCompat.getXVelocity(mVelocityTracker, mActivePointerId),
728: (int) VelocityTrackerCompat.getYVelocity(mVelocityTracker, mActivePointerId),
729: minLeft, maxLeft, minTop, maxTop);
730:
-A Pair 64: (nodes=12, depth=6, branch=2)
...
796: if (mDragState == STATE_SETTLING) {
797: boolean keepGoing = mScroller.computeScrollOffset();
798: final int x = mScroller.getCurrX();
799: final int y = mScroller.getCurrY();
800: final int dx = x - mCapturedView.getLeft();
...
813:
814: if (keepGoing && x == mScroller.getFinalX() && y == mScroller.getFinalY()) {
815: // Close enough. The interpolator/scroller might think we're
...
818: mScroller.abortAnimation();
819: keepGoing = mScroller.isFinished();
820: }
821:
822: if (!keepGoing) {
823: if (deferCallbacks) {
...
750: if (mDragState == STATE_SETTLING) {
751: boolean keepGoing = mScroller.computeScrollOffset();
752: final int x = mScroller.getCurrX();
753: final int y = mScroller.getCurrY();
754: final int dx = x - mCapturedView.getLeft();
...
773:
774: if (keepGoing && x == mScroller.getFinalX() && y == mScroller.getFinalY()) {
775: // Close enough. The interpolator/scroller might think we're still moving
...
777: mScroller.abortAnimation();
778: keepGoing = mScroller.isFinished();
779: }
780:
781: if (!keepGoing) {
782: if (deferCallbacks) {
-A Pair 65: (nodes=17, depth=16, branch=2)
...
865:
866: private void clearMotionHistory(int pointerId) {
867: if (mInitialMotionX == null) {
868: return;
869: }
870: mInitialMotionX[pointerId] = 0;
871: mInitialMotionY[pointerId] = 0;
872: mLastMotionX[pointerId] = 0;
873: mLastMotionY[pointerId] = 0;
874: mInitialEdgeTouched[pointerId] = 0;
875: mEdgeDragsInProgress[pointerId] = 0;
876: mEdgeDragsLocked[pointerId] = 0;
877: mPointersDown &= ~(1 << pointerId);
...
880:
881: private void clearMotionHistory(int pointerId) {
882: if (mInitialMotionX == null) {
883: return;
884: }
885: mInitialMotionX[pointerId] = 0;
886: mInitialMotionY[pointerId] = 0;
887: mLastMotionX[pointerId] = 0;
888: mLastMotionY[pointerId] = 0;
889: mInitialEdgeTouched[pointerId] = 0;
890: mEdgeDragsInProgress[pointerId] = 0;
891: mEdgeDragsLocked[pointerId] = 0;
892: mPointersDown &= ~(1 << pointerId);
-A Pair 66: (nodes=7, depth=4, branch=2)
...
879:
880: private void ensureMotionHistorySizeForId(int pointerId) {
881: if (mInitialMotionX == null || mInitialMotionX.length <= pointerId) {
882: float[] imx = new float[pointerId + 1];
...
886: int[] iit = new int[pointerId + 1];
887: int[] edip = new int[pointerId + 1];
888: int[] edl = new int[pointerId + 1];
...
904: mInitialEdgeTouched = iit;
905: mEdgeDragsInProgress = edip;
906: mEdgeDragsLocked = edl;
...
837:
838: private void ensureMotionHistorySizeForId(int pointerId) {
839: if (mInitialMotionX == null || mInitialMotionX.length <= pointerId) {
840: float[] imx = new float[pointerId + 1];
...
844: int[] iit = new int[pointerId + 1];
845: int[] edip = new int[pointerId + 1];
846: int[] edl = new int[pointerId + 1];
...
862: mInitialEdgesTouched = iit;
863: mEdgeDragsInProgress = edip;
864: mEdgeDragsLocked = edl;
-A Pair 67: (nodes=11, depth=11, branch=2)
...
909:
910: private void saveInitialMotion(float x, float y, int pointerId) {
911: ensureMotionHistorySizeForId(pointerId);
912: mInitialMotionX[pointerId] = mLastMotionX[pointerId] = x;
913: mInitialMotionY[pointerId] = mLastMotionY[pointerId] = y;
914: mInitialEdgeTouched[pointerId] = getEdgeTouched((int) x, (int) y);
915: mPointersDown |= 1 << pointerId;
...
924:
925: private void saveInitialMotion(float x, float y, int pointerId) {
926: ensureMotionHistorySizeForId(pointerId);
927: mInitialMotionX[pointerId] = mLastMotionX[pointerId] = x;
928: mInitialMotionY[pointerId] = mLastMotionY[pointerId] = y;
929: mInitialEdgeTouched[pointerId] = getEdgeTouched((int) x, (int) y);
930: mPointersDown |= 1 << pointerId;
-A Pair 68: (nodes=7, depth=7, branch=2)
...
917:
918: private void saveLastMotion(MotionEvent ev) {
919: final int pointerCount = MotionEventCompat.getPointerCount(ev);
920: for (int i = 0; i < pointerCount; i++) {
921: final int pointerId = MotionEventCompat.getPointerId(ev, i);
922: final float x = MotionEventCompat.getX(ev, i);
923: final float y = MotionEventCompat.getY(ev, i);
924: mLastMotionX[pointerId] = x;
925: mLastMotionY[pointerId] = y;
926: }
...
932:
933: private void saveLastMotion(MotionEvent ev) {
934: final int pointerCount = MotionEventCompat.getPointerCount(ev);
935: for (int i = 0; i < pointerCount; i++) {
936: final int pointerId = MotionEventCompat.getPointerId(ev, i);
937: final float x = MotionEventCompat.getX(ev, i);
938: final float y = MotionEventCompat.getY(ev, i);
939: mLastMotionX[pointerId] = x;
940: mLastMotionY[pointerId] = y;
941: }
-C Pair 69: (nodes=6, depth=5, branch=2)
...
943: */
944: public boolean isPointerDown(int pointerId) {
945: return (mPointersDown & 1 << pointerId) != 0;
946: }
...
107: /** Returns true if a value has been assigned for the setting {@code id}. */
108: boolean isSet(int id) {
109: int bit = 1 << id;
110: return (set & bit) != 0;
111: }
-A Pair 70: (nodes=5, depth=4, branch=2)
...
947:
948: void setDragState(int state) {
949: if (mDragState != state) {
950: mDragState = state;
951: mCallback.onViewDragStateChanged(state);
952: if (state == STATE_IDLE) {
953: mCapturedView = null;
954: }
...
907:
908: void setDragState(int state) {
909: if (mDragState != state) {
910: mDragState = state;
911: mCallback.onViewDragStateChanged(state);
912: if (mDragState == STATE_IDLE) {
913: mCapturedView = null;
914: }
-A Pair 71: (nodes=11, depth=4, branch=3)
...
967: */
968: boolean tryCaptureViewForDrag(View toCapture, int pointerId) {
969: if (toCapture == mCapturedView && mActivePointerId == pointerId) {
970: // Already done!
971: return true;
972: }
973: if (toCapture != null && mCallback.tryCaptureView(toCapture, pointerId)) {
974: mActivePointerId = pointerId;
975: captureChildView(toCapture, pointerId);
976: return true;
977: }
...
926: */
927: boolean tryCaptureViewForDrag(View toCapture, int pointerId) {
928: if (toCapture == mCapturedView && mActivePointerId == pointerId) {
929: // Already done!
930: return true;
931: }
932: if (toCapture != null && mCallback.tryCaptureView(toCapture, pointerId)) {
933: mActivePointerId = pointerId;
934: captureChildView(toCapture, pointerId);
935: return true;
936: }
-B Pair 72: (nodes=38, depth=13, branch=5)
...
992: */
993: protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
994: if (v instanceof ViewGroup) {
995: final ViewGroup group = (ViewGroup) v;
996: final int scrollX = v.getScrollX();
997: final int scrollY = v.getScrollY();
998: final int count = group.getChildCount();
999: // Count backwards - let topmost views consume scroll distance
1000: // first.
1001: for (int i = count - 1; i >= 0; i--) {
1002: // TODO: Add versioned support here for transformed views.
1003: // This will not work for transformed views in Honeycomb+
1004: final View child = group.getChildAt(i);
1005: if (x + scrollX >= child.getLeft()
1006: && x + scrollX < child.getRight()
1007: && y + scrollY >= child.getTop()
1008: && y + scrollY < child.getBottom()
1009: && canScroll(child, true, dx, dy, x + scrollX - child.getLeft(), y
1010: + scrollY - child.getTop())) {
1011: return true;
1012: }
...
951: */
952: protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
953: if (v instanceof ViewGroup) {
954: final ViewGroup group = (ViewGroup) v;
955: final int scrollX = v.getScrollX();
956: final int scrollY = v.getScrollY();
957: final int count = group.getChildCount();
958: // Count backwards - let topmost views consume scroll distance first.
959: for (int i = count - 1; i >= 0; i--) {
960: // TODO: Add versioned support here for transformed views.
961: // This will not work for transformed views in Honeycomb+
962: final View child = group.getChildAt(i);
963: if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() &&
964: y + scrollY >= child.getTop() && y + scrollY < child.getBottom() &&
965: canScroll(child, true, dx, dy, x + scrollX - child.getLeft(),
966: y + scrollY - child.getTop())) {
967: return true;
968: }
-A Pair 73: (nodes=20, depth=9, branch=2)
...
1029: */
1030: public boolean shouldInterceptTouchEvent(MotionEvent ev) {
1031: final int action = MotionEventCompat.getActionMasked(ev);
...
1091: // report edge drags.
1092: final int pointerCount = MotionEventCompat.getPointerCount(ev);
1093: for (int i = 0; i < pointerCount; i++) {
1094: final int pointerId = MotionEventCompat.getPointerId(ev, i);
1095: final float x = MotionEventCompat.getX(ev, i);
1096: final float y = MotionEventCompat.getY(ev, i);
1097: final float dx = x - mInitialMotionX[pointerId];
1098: final float dy = y - mInitialMotionY[pointerId];
1099:
1100: reportNewEdgeDrags(dx, dy, pointerId);
1101: if (mDragState == STATE_DRAGGING) {
1102: // Callback might have started an edge drag
...
1105:
1106: final View toCapture = findTopChildUnder((int) x, (int) y);
1107: if (toCapture != null && checkTouchSlop(toCapture, dx, dy)
1108: && tryCaptureViewForDrag(toCapture, pointerId)) {
1109: break;
...
1044: */
1045: public boolean shouldInterceptTouchEvent(MotionEvent ev) {
1046: final int action = MotionEventCompat.getActionMasked(ev);
...
1106: // report edge drags.
1107: final int pointerCount = MotionEventCompat.getPointerCount(ev);
1108: for (int i = 0; i < pointerCount; i++) {
1109: final int pointerId = MotionEventCompat.getPointerId(ev, i);
1110: final float x = MotionEventCompat.getX(ev, i);
1111: final float y = MotionEventCompat.getY(ev, i);
1112: final float dx = x - mInitialMotionX[pointerId];
1113: final float dy = y - mInitialMotionY[pointerId];
1114:
1115: reportNewEdgeDrags(dx, dy, pointerId);
1116: if (mDragState == STATE_DRAGGING) {
1117: // Callback might have started an edge drag
...
1120:
1121: final View toCapture = findTopChildUnder((int) x, (int) y);
1122: if (toCapture != null && checkTouchSlop(toCapture, dx, dy)
1123: && tryCaptureViewForDrag(toCapture, pointerId)) {
1124: break;
-B Pair 74: (nodes=20, depth=9, branch=2)
...
1138: */
1139: public void processTouchEvent(MotionEvent ev) {
1140: final int action = MotionEventCompat.getActionMasked(ev);
1141: final int actionIndex = MotionEventCompat.getActionIndex(ev);
1142:
...
1246: case MotionEventCompat.ACTION_POINTER_UP: {
1247: final int pointerId = MotionEventCompat.getPointerId(ev, actionIndex);
1248: if (mDragState == STATE_DRAGGING && pointerId == mActivePointerId) {
1249: // Try to find another pointer that's still holding on to
...
1251: int newActivePointer = INVALID_POINTER;
1252: final int pointerCount = MotionEventCompat.getPointerCount(ev);
1253: for (int i = 0; i < pointerCount; i++) {
1254: final int id = MotionEventCompat.getPointerId(ev, i);
1255: if (id == mActivePointerId) {
1256: // This one's going away, skip.
...
1259:
1260: final float x = MotionEventCompat.getX(ev, i);
1261: final float y = MotionEventCompat.getY(ev, i);
1262: if (findTopChildUnder((int) x, (int) y) == mCapturedView
1263: && tryCaptureViewForDrag(mCapturedView, id)) {
1264: newActivePointer = mActivePointerId;
...
1092: */
1093: public void processTouchEvent(MotionEvent ev) {
1094: final int action = MotionEventCompat.getActionMasked(ev);
1095: final int actionIndex = MotionEventCompat.getActionIndex(ev);
1096:
...
1196: case MotionEventCompat.ACTION_POINTER_UP: {
1197: final int pointerId = MotionEventCompat.getPointerId(ev, actionIndex);
1198: if (mDragState == STATE_DRAGGING && pointerId == mActivePointerId) {
1199: // Try to find another pointer that's still holding on to the captured view.
1200: int newActivePointer = INVALID_POINTER;
1201: final int pointerCount = MotionEventCompat.getPointerCount(ev);
1202: for (int i = 0; i < pointerCount; i++) {
1203: final int id = MotionEventCompat.getPointerId(ev, i);
1204: if (id == mActivePointerId) {
1205: // This one's going away, skip.
...
1208:
1209: final float x = MotionEventCompat.getX(ev, i);
1210: final float y = MotionEventCompat.getY(ev, i);
1211: if (findTopChildUnder((int) x, (int) y) == mCapturedView &&
1212: tryCaptureViewForDrag(mCapturedView, id)) {
1213: newActivePointer = mActivePointerId;
-A Pair 75: (nodes=15, depth=7, branch=3)
...
1296:
1297: private void reportNewEdgeDrags(float dx, float dy, int pointerId) {
1298: int dragsStarted = 0;
1299: if (checkNewEdgeDrag(dx, dy, pointerId, EDGE_LEFT)) {
1300: dragsStarted |= EDGE_LEFT;
1301: }
1302: if (checkNewEdgeDrag(dy, dx, pointerId, EDGE_TOP)) {
1303: dragsStarted |= EDGE_TOP;
1304: }
1305: if (checkNewEdgeDrag(dx, dy, pointerId, EDGE_RIGHT)) {
1306: dragsStarted |= EDGE_RIGHT;
1307: }
1308: if (checkNewEdgeDrag(dy, dx, pointerId, EDGE_BOTTOM)) {
1309: dragsStarted |= EDGE_BOTTOM;
1310: }
1311:
1312: if (dragsStarted != 0) {
1313: mEdgeDragsInProgress[pointerId] |= dragsStarted;
1314: mCallback.onEdgeDragStarted(dragsStarted, pointerId);
...
1244:
1245: private void reportNewEdgeDrags(float dx, float dy, int pointerId) {
1246: int dragsStarted = 0;
1247: if (checkNewEdgeDrag(dx, dy, pointerId, EDGE_LEFT)) {
1248: dragsStarted |= EDGE_LEFT;
1249: }
1250: if (checkNewEdgeDrag(dy, dx, pointerId, EDGE_TOP)) {
1251: dragsStarted |= EDGE_TOP;
1252: }
1253: if (checkNewEdgeDrag(dx, dy, pointerId, EDGE_RIGHT)) {
1254: dragsStarted |= EDGE_RIGHT;
1255: }
1256: if (checkNewEdgeDrag(dy, dx, pointerId, EDGE_BOTTOM)) {
1257: dragsStarted |= EDGE_BOTTOM;
1258: }
1259:
1260: if (dragsStarted != 0) {
1261: mEdgeDragsInProgress[pointerId] |= dragsStarted;
1262: mCallback.onEdgeDragStarted(dragsStarted, pointerId);
-A Pair 76: (nodes=29, depth=10, branch=3)
...
1317:
1318: private boolean checkNewEdgeDrag(float delta, float odelta, int pointerId, int edge) {
1319: final float absDelta = Math.abs(delta);
1320: final float absODelta = Math.abs(odelta);
1321:
1322: if ((mInitialEdgeTouched[pointerId] & edge) != edge || (mTrackingEdges & edge) == 0
1323: || (mEdgeDragsLocked[pointerId] & edge) == edge
1324: || (mEdgeDragsInProgress[pointerId] & edge) == edge
1325: || (absDelta <= mTouchSlop && absODelta <= mTouchSlop)) {
1326: return false;
1327: }
1328: if (absDelta < absODelta * 0.5f && mCallback.onEdgeLock(edge)) {
1329: mEdgeDragsLocked[pointerId] |= edge;
1330: return false;
1331: }
...
1265:
1266: private boolean checkNewEdgeDrag(float delta, float odelta, int pointerId, int edge) {
1267: final float absDelta = Math.abs(delta);
1268: final float absODelta = Math.abs(odelta);
1269:
1270: if ((mInitialEdgesTouched[pointerId] & edge) != edge || (mTrackingEdges & edge) == 0 ||
1271: (mEdgeDragsLocked[pointerId] & edge) == edge ||
1272: (mEdgeDragsInProgress[pointerId] & edge) == edge ||
1273: (absDelta <= mTouchSlop && absODelta <= mTouchSlop)) {
1274: return false;
1275: }
1276: if (absDelta < absODelta * 0.5f && mCallback.onEdgeLock(edge)) {
1277: mEdgeDragsLocked[pointerId] |= edge;
1278: return false;
1279: }
-A Pair 77: (nodes=22, depth=7, branch=3)
...
1344: */
1345: private boolean checkTouchSlop(View child, float dx, float dy) {
1346: if (child == null) {
1347: return false;
1348: }
1349: final boolean checkHorizontal = mCallback.getViewHorizontalDragRange(child) > 0;
1350: final boolean checkVertical = mCallback.getViewVerticalDragRange(child) > 0;
1351:
1352: if (checkHorizontal && checkVertical) {
1353: return dx * dx + dy * dy > mTouchSlop * mTouchSlop;
1354: } else if (checkHorizontal) {
1355: return Math.abs(dx) > mTouchSlop;
1356: } else if (checkVertical) {
1357: return Math.abs(dy) > mTouchSlop;
1358: }
...
1292: */
1293: private boolean checkTouchSlop(View child, float dx, float dy) {
1294: if (child == null) {
1295: return false;
1296: }
1297: final boolean checkHorizontal = mCallback.getViewHorizontalDragRange(child) > 0;
1298: final boolean checkVertical = mCallback.getViewVerticalDragRange(child) > 0;
1299:
1300: if (checkHorizontal && checkVertical) {
1301: return dx * dx + dy * dy > mTouchSlop * mTouchSlop;
1302: } else if (checkHorizontal) {
1303: return Math.abs(dx) > mTouchSlop;
1304: } else if (checkVertical) {
1305: return Math.abs(dy) > mTouchSlop;
1306: }
-A Pair 78: (nodes=21, depth=9, branch=3)
...
1405: */
1406: public boolean checkTouchSlop(int directions, int pointerId) {
1407: if (!isPointerDown(pointerId)) {
1408: return false;
1409: }
1410:
1411: final boolean checkHorizontal = (directions & DIRECTION_HORIZONTAL) == DIRECTION_HORIZONTAL;
1412: final boolean checkVertical = (directions & DIRECTION_VERTICAL) == DIRECTION_VERTICAL;
1413:
1414: final float dx = mLastMotionX[pointerId] - mInitialMotionX[pointerId];
1415: final float dy = mLastMotionY[pointerId] - mInitialMotionY[pointerId];
1416:
1417: if (checkHorizontal && checkVertical) {
1418: return dx * dx + dy * dy > mTouchSlop * mTouchSlop;
1419: } else if (checkHorizontal) {
1420: return Math.abs(dx) > mTouchSlop;
1421: } else if (checkVertical) {
1422: return Math.abs(dy) > mTouchSlop;
1423: }
...
1348: */
1349: public boolean checkTouchSlop(int directions, int pointerId) {
1350: if (!isPointerDown(pointerId)) {
1351: return false;
1352: }
1353:
1354: final boolean checkHorizontal = (directions & DIRECTION_HORIZONTAL) == DIRECTION_HORIZONTAL;
1355: final boolean checkVertical = (directions & DIRECTION_VERTICAL) == DIRECTION_VERTICAL;
1356:
1357: final float dx = mLastMotionX[pointerId] - mInitialMotionX[pointerId];
1358: final float dy = mLastMotionY[pointerId] - mInitialMotionY[pointerId];
1359:
1360: if (checkHorizontal && checkVertical) {
1361: return dx * dx + dy * dy > mTouchSlop * mTouchSlop;
1362: } else if (checkHorizontal) {
1363: return Math.abs(dx) > mTouchSlop;
1364: } else if (checkVertical) {
1365: return Math.abs(dy) > mTouchSlop;
1366: }
-A Pair 79: (nodes=7, depth=5, branch=2)
...
1459: */
1460: public boolean isEdgeTouched(int edges, int pointerId) {
1461: return isPointerDown(pointerId) && (mInitialEdgeTouched[pointerId] & edges) != 0;
1462: }
...
1398: */
1399: public boolean isEdgeTouched(int edges, int pointerId) {
1400: return isPointerDown(pointerId) && (mInitialEdgesTouched[pointerId] & edges) != 0;
1401: }
-A Pair 80: (nodes=5, depth=3, branch=2)
...
1465: mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity);
1466: final float xvel = clampMag(
1467: VelocityTrackerCompat.getXVelocity(mVelocityTracker, mActivePointerId),
1468: mMinVelocity, mMaxVelocity);
1469: final float yvel = clampMag(
1470: VelocityTrackerCompat.getYVelocity(mVelocityTracker, mActivePointerId),
1471: mMinVelocity, mMaxVelocity);
1472: dispatchViewReleased(xvel, yvel);
1473: }
...
1408: mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity);
1409: final float xvel = clampMag(
1410: VelocityTrackerCompat.getXVelocity(mVelocityTracker, mActivePointerId),
1411: mMinVelocity, mMaxVelocity);
1412: final float yvel = clampMag(
1413: VelocityTrackerCompat.getYVelocity(mVelocityTracker, mActivePointerId),
1414: mMinVelocity, mMaxVelocity);
1415: dispatchViewReleased(xvel, yvel);
1416: }
-B Pair 81: (nodes=17, depth=4, branch=4)
...
1474:
1475: private void dragTo(int left, int top, int dx, int dy) {
1476: int clampedX = left;
1477: int clampedY = top;
1478: final int oldLeft = mCapturedView.getLeft();
1479: final int oldTop = mCapturedView.getTop();
1480: if (dx != 0) {
1481: clampedX = mCallback.clampViewPositionHorizontal(mCapturedView, left, dx);
1482: mCapturedView.offsetLeftAndRight(clampedX - oldLeft);
1483: }
1484: if (dy != 0) {
1485: clampedY = mCallback.clampViewPositionVertical(mCapturedView, top, dy);
1486: mCapturedView.offsetTopAndBottom(clampedY - oldTop);
...
1489: if (dx != 0 || dy != 0) {
1490: final int clampedDx = clampedX - oldLeft;
1491: final int clampedDy = clampedY - oldTop;
1492: mCallback
1493: .onViewPositionChanged(mCapturedView, clampedX, clampedY, clampedDx, clampedDy);
1494: }
...
1417:
1418: private void dragTo(int left, int top, int dx, int dy) {
1419: int clampedX = left;
1420: int clampedY = top;
1421: final int oldLeft = mCapturedView.getLeft();
1422: final int oldTop = mCapturedView.getTop();
1423: if (dx != 0) {
1424: clampedX = mCallback.clampViewPositionHorizontal(mCapturedView, left, dx);
1425: mCapturedView.offsetLeftAndRight(clampedX - oldLeft);
1426: }
1427: if (dy != 0) {
1428: clampedY = mCallback.clampViewPositionVertical(mCapturedView, top, dy);
1429: mCapturedView.offsetTopAndBottom(clampedY - oldTop);
...
1432: if (dx != 0 || dy != 0) {
1433: final int clampedDx = clampedX - oldLeft;
1434: final int clampedDy = clampedY - oldTop;
1435: mCallback.onViewPositionChanged(mCapturedView, clampedX, clampedY,
1436: clampedDx, clampedDy);
1437: }
-B Pair 82: (nodes=14, depth=7, branch=2)
...
1520: */
1521: public boolean isViewUnder(View view, int x, int y) {
1522: if (view == null) {
...
1524: }
1525: return x >= view.getLeft() && x < view.getRight() && y >= view.getTop()
1526: && y < view.getBottom();
1527: }
...
1461: */
1462: public boolean isViewUnder(View view, int x, int y) {
1463: if (view == null) {
...
1465: }
1466: return x >= view.getLeft() &&
1467: x < view.getRight() &&
1468: y >= view.getTop() &&
1469: y < view.getBottom();
1470: }
-B Pair 83: (nodes=18, depth=11, branch=2)
...
1538: */
1539: public View findTopChildUnder(int x, int y) {
1540: final int childCount = mParentView.getChildCount();
1541: for (int i = childCount - 1; i >= 0; i--) {
1542: final View child = mParentView.getChildAt(mCallback.getOrderedChildIndex(i));
1543: if (x >= child.getLeft() && x < child.getRight() && y >= child.getTop()
1544: && y < child.getBottom()) {
1545: return child;
...
1479: */
1480: public View findTopChildUnder(int x, int y) {
1481: final int childCount = mParentView.getChildCount();
1482: for (int i = childCount - 1; i >= 0; i--) {
1483: final View child = mParentView.getChildAt(mCallback.getOrderedChildIndex(i));
1484: if (x >= child.getLeft() && x < child.getRight() &&
1485: y >= child.getTop() && y < child.getBottom()) {
1486: return child;
-A Pair 84: (nodes=19, depth=8, branch=3)
...
1550:
1551: private int getEdgeTouched(int x, int y) {
1552: int result = 0;
1553:
1554: if (x < mParentView.getLeft() + mEdgeSize)
1555: result = EDGE_LEFT;
1556: if (y < mParentView.getTop() + mEdgeSize)
1557: result = EDGE_TOP;
1558: if (x > mParentView.getRight() - mEdgeSize)
1559: result = EDGE_RIGHT;
1560: if (y > mParentView.getBottom() - mEdgeSize)
1561: result = EDGE_BOTTOM;
1562:
...
1565:
1566: private int getEdgeTouched(int x, int y) {
1567: int result = 0;
1568:
1569: if (x < mParentView.getLeft() + mEdgeSize)
1570: result = EDGE_LEFT;
1571: if (y < mParentView.getTop() + mEdgeSize)
1572: result = EDGE_TOP;
1573: if (x > mParentView.getRight() - mEdgeSize)
1574: result = EDGE_RIGHT;
1575: if (y > mParentView.getBottom() - mEdgeSize)
1576: result = EDGE_BOTTOM;
1577:
-C Pair 85: (nodes=6, depth=3, branch=5)
...
28:
29: protected final Cursor query(Uri uri, String[] projection, String selection,
30: String[] selectionArgs, String sortOrder) {
31: return mContext.getContentResolver().query(uri, projection, selection, selectionArgs,
32: sortOrder);
33: }
...
26: @Override
27: public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
28: //noinspection ConstantConditions
29: return getContext().getContentResolver().query(getRealUri(uri), projection, selection, selectionArgs, sortOrder);
30: }
-C Pair 86: (nodes=5, depth=5, branch=2)
...
49:
50: public BaseFoldingLayout getFoldingLayout(View drawerView) {
51: if (!isDrawerView2(getRealDrawer(drawerView))) {
52: throw new IllegalArgumentException("View " + drawerView
53: + " is not a sliding drawer");
54: }
...
1261: */
1262: public void openDrawer(View drawerView) {
1263: if (!isDrawerView(drawerView)) {
1264: throw new IllegalArgumentException("View " + drawerView + " is not a sliding drawer");
1265: }
-B Pair 87: (nodes=9, depth=8, branch=2)
...
58:
59: boolean isDrawerView2(View child) {
60: final int gravity = ((LayoutParams) child.getLayoutParams()).gravity;
61: final int absGravity = GravityCompat.getAbsoluteGravity(gravity,
62: ViewCompat.getLayoutDirection(child));
63: return (absGravity & (Gravity.LEFT | Gravity.RIGHT)) != 0;
64: }
...
1098:
1099: boolean isDrawerView(View child) {
1100: final int gravity = ((LayoutParams) child.getLayoutParams()).gravity;
1101: final int absGravity = GravityCompat.getAbsoluteGravity(gravity,
1102: ViewCompat.getLayoutDirection(child));
1103: return (absGravity & (Gravity.LEFT | Gravity.RIGHT)) != 0;
1104: }
-C Pair 88: (nodes=12, depth=3, branch=7)
...
61: @Override
62: public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
63: synchronized (DBLock) {
64: SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
65: String table = matchTable(uri);
...
68: SQLiteDatabase db = getDBHelper().getReadableDatabase();
69: Cursor cursor = queryBuilder.query(db, // The database to
70: // queryFromDB
...
73: selectionArgs, // The values for the where clause
74: null, // don't group the rows
75: null, // don't filter by row groups
76: sortOrder // The sort order
77: );
78:
79: cursor.setNotificationUri(getContext().getContentResolver(), uri);
80: return cursor;
...
46: @Override
47: public Cursor query(Uri uri, String[] projection, String selection,
48: String[] selectionArgs, String sortOrder) {
49:
50: // Using SQLiteQueryBuilder instead of query() method
51: SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
52:
...
71: SQLiteDatabase db = database.getWritableDatabase();
72: Cursor cursor = queryBuilder.query(db, projection, selection,
73: selectionArgs, null, null, sortOrder);
74: // Make sure that potential listeners are getting notified
75: cursor.setNotificationUri(getContext().getContentResolver(), uri);
76:
-C Pair 89: (nodes=5, depth=3, branch=3)
...
94: @Override
95: public Uri insert(Uri uri, ContentValues values) {
96: synchronized (DBLock) {
...
110: Uri returnUri = ContentUris.withAppendedId(uri, rowId);
111: getContext().getContentResolver().notifyChange(uri, null);
112: return returnUri;
...
88: @Nullable
89: public Uri insert(@NonNull Uri uri, @Nullable ContentValues contentValues) {
90: SQLiteDatabase db = databaseHelper.getWritableDatabase();
...
94: if (id > 0) {
95: getContext().getContentResolver().notifyChange(uri, null);
96: return ContentUris.withAppendedId(TRANSACTION_URI, id);
-C Pair 90: (nodes=5, depth=3, branch=3)
...
118: @Override
119: public int delete(Uri uri, String selection, String[] selectionArgs) {
120: synchronized (DBLock) {
...
131: }
132: getContext().getContentResolver().notifyChange(uri, null);
133: return count;
...
188:
189: private void notifyChange(Uri uri) {
190: getContext().getContentResolver().notifyChange(uri, null);
191: }
-C Pair 91: (nodes=5, depth=3, branch=3)
...
137: @Override
138: public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
139: synchronized (DBLock) {
...
149: }
150: getContext().getContentResolver().notifyChange(uri, null);
151:
...
188:
189: private void notifyChange(Uri uri) {
190: getContext().getContentResolver().notifyChange(uri, null);
191: }
-C Pair 92: (nodes=5, depth=3, branch=3)
...
14:
15: private static void show(Context context, int resId, int duration) {
16: Toast.makeText(context, resId, duration).show();
17: }
...
376: */
377: public static void showText(Activity activity, CharSequence text, Style style) {
378: makeText(activity, text, style).show();
379: }
-C Pair 93: (nodes=5, depth=3, branch=3)
...
18:
19: private static void show(Context context, String message, int duration) {
20: Toast.makeText(context, message, duration).show();
21: }
...
376: */
377: public static void showText(Activity activity, CharSequence text, Style style) {
378: makeText(activity, text, style).show();
379: }
-C Pair 94: (nodes=6, depth=6, branch=2)
...
48: @Override
49: protected Response<T> parseNetworkResponse(NetworkResponse response) {
50: try {
51: String json = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
52: return Response.success(mGson.fromJson(json, mClazz),
53: HttpHeaderParser.parseCacheHeaders(response));
54: } catch (UnsupportedEncodingException e) {
...
59: @Override
60: protected Response<T> parseNetworkResponse(NetworkResponse response) {
61: try {
62: String jsonStr=new String(response.data,HttpHeaderParser.parseCharset(response.headers));
63: T data=gson.fromJson(jsonStr,mClass);
64: return Response.success(data,HttpHeaderParser.parseCacheHeaders(response));
65: } catch (UnsupportedEncodingException e) {
-C Pair 95: (nodes=6, depth=4, branch=4)
...
10: public static View findActionBarContainer(Activity activity) {
11: int id = activity.getResources().getIdentifier("action_bar_container", "id", "android");
12: return activity.findViewById(id);
13: }
...
583: View view = window.getDecorView();
584: int resId = getResources().getIdentifier("action_bar_container", "id", "android");
585:
586: return view.findViewById(resId);
587: }
-C Pair 96: (nodes=5, depth=4, branch=3)
...
15: public static View findSplitActionBar(Activity activity) {
16: int id = activity.getResources().getIdentifier("split_action_bar", "id", "android");
17: return activity.findViewById(id);
18: }
...
583: View view = window.getDecorView();
584: int resId = getResources().getIdentifier("action_bar_container", "id", "android");
585:
586: return view.findViewById(resId);
587: }
-C Pair 97: (nodes=6, depth=4, branch=3)
...
88:
89: protected void replaceFragment(int viewId, BaseFragment fragment) {
90: FragmentManager fragmentManager = getSupportFragmentManager();
91: fragmentManager.beginTransaction().replace(viewId, fragment).commit();
92: }
...
108:
109: protected <T extends Fragment> T initFragment(@IdRes int target,
110: @NonNull T fragment,
111: @NonNull MasterSecret masterSecret,
...
123: fragment.setArguments(args);
124: getSupportFragmentManager().beginTransaction()
125: .replace(target, fragment)
126: .commit();
127: return fragment;
-A Pair 98: (nodes=12, depth=6, branch=4)
...
105:
106: private void init(AttributeSet attributeSet) {
107:
108: reflectionColor = DEFAULT_REFLECTION_COLOR;
109:
110: if (attributeSet != null) {
111: TypedArray a = view.getContext().obtainStyledAttributes(attributeSet, R.styleable.ShimmerView, 0, 0);
112: if (a != null) {
113: try {
114: reflectionColor = a.getColor(R.styleable.ShimmerView_reflectionColor, DEFAULT_REFLECTION_COLOR);
115: } catch (Exception e) {
...
105:
106: private void init(AttributeSet attributeSet) {
107:
108: reflectionColor = DEFAULT_REFLECTION_COLOR;
109:
110: if (attributeSet != null) {
111: TypedArray a = view.getContext().obtainStyledAttributes(attributeSet, R.styleable.ShimmerView, 0, 0);
112: if (a != null) {
113: try {
114: reflectionColor = a.getColor(R.styleable.ShimmerView_reflectionColor, DEFAULT_REFLECTION_COLOR);
115: } catch (Exception e) {
-A Pair 99: (nodes=13, depth=5, branch=7)
...
130: // initially, the linear gradient is positioned on the left side of the view
131: linearGradient = new LinearGradient(-view.getWidth(), 0, 0, 0,
132: new int[]{
133: primaryColor,
...
135: primaryColor,
136: },
137: new float[]{
138: 0,
139: 0.5f,
140: 1
141: },
142: Shader.TileMode.CLAMP
143: );
144:
145: paint.setShader(linearGradient);
146: }
...
130: // initially, the linear gradient is positioned on the left side of the view
131: linearGradient = new LinearGradient(-view.getWidth(), 0, 0, 0,
132: new int[]{
133: primaryColor,
...
135: primaryColor,
136: },
137: new float[]{
138: 0,
139: 0.5f,
140: 1
141: },
142: Shader.TileMode.CLAMP
143: );
144:
145: paint.setShader(linearGradient);
146: }