first commit
[bylock.git] / sources / android / support / v4 / widget / SlidingPaneLayout.java
blob8e94dca660a39d9e166ca5298f889128f8db6c6b
1 package android.support.v4.widget;
3 import android.graphics.Bitmap;
4 import android.graphics.Canvas;
5 import android.graphics.Paint;
6 import android.graphics.PorterDuff;
7 import android.graphics.PorterDuffColorFilter;
8 import android.graphics.Rect;
9 import android.graphics.drawable.Drawable;
10 import android.os.Build;
11 import android.os.Parcel;
12 import android.os.Parcelable;
13 import android.support.v4.view.ak;
14 import android.support.v4.view.av;
15 import android.util.AttributeSet;
16 import android.util.Log;
17 import android.view.MotionEvent;
18 import android.view.View;
19 import android.view.ViewGroup;
20 import java.util.ArrayList;
22 /* compiled from: MyApp */
23 public class SlidingPaneLayout extends ViewGroup {
24 static final ab a;
25 private int b;
26 private int c;
27 private Drawable d;
28 private final int e;
29 private boolean f;
30 private View g;
31 private float h;
32 private float i;
33 private int j;
34 private boolean k;
35 private int l;
36 private float m;
37 private float n;
38 private z o;
39 private final af p;
40 private boolean q;
41 private boolean r;
42 private final Rect s;
43 private final ArrayList t;
45 static {
46 int i2 = Build.VERSION.SDK_INT;
47 if (i2 >= 17) {
48 a = new ae();
49 } else if (i2 >= 16) {
50 a = new ad();
51 } else {
52 a = new ac();
56 public void setParallaxDistance(int i2) {
57 this.l = i2;
58 requestLayout();
61 public int getParallaxDistance() {
62 return this.l;
65 public void setSliderFadeColor(int i2) {
66 this.b = i2;
69 public int getSliderFadeColor() {
70 return this.b;
73 public void setCoveredFadeColor(int i2) {
74 this.c = i2;
77 public int getCoveredFadeColor() {
78 return this.c;
81 public void setPanelSlideListener(z zVar) {
82 this.o = zVar;
85 /* access modifiers changed from: package-private */
86 public void a(View view) {
87 int i2;
88 int i3;
89 int i4;
90 int i5;
91 int i6;
92 int paddingLeft = getPaddingLeft();
93 int width = getWidth() - getPaddingRight();
94 int paddingTop = getPaddingTop();
95 int height = getHeight() - getPaddingBottom();
96 if (view == null || !c(view)) {
97 i2 = 0;
98 i3 = 0;
99 i4 = 0;
100 i5 = 0;
101 } else {
102 i5 = view.getLeft();
103 i4 = view.getRight();
104 i3 = view.getTop();
105 i2 = view.getBottom();
107 int childCount = getChildCount();
108 for (int i7 = 0; i7 < childCount; i7++) {
109 View childAt = getChildAt(i7);
110 if (childAt != view) {
111 int max = Math.max(paddingLeft, childAt.getLeft());
112 int max2 = Math.max(paddingTop, childAt.getTop());
113 int min = Math.min(width, childAt.getRight());
114 int min2 = Math.min(height, childAt.getBottom());
115 if (max < i5 || max2 < i3 || min > i4 || min2 > i2) {
116 i6 = 0;
117 } else {
118 i6 = 4;
120 childAt.setVisibility(i6);
121 } else {
122 return;
127 /* access modifiers changed from: package-private */
128 public void a() {
129 int childCount = getChildCount();
130 for (int i2 = 0; i2 < childCount; i2++) {
131 View childAt = getChildAt(i2);
132 if (childAt.getVisibility() == 4) {
133 childAt.setVisibility(0);
138 private static boolean c(View view) {
139 if (av.f(view)) {
140 return true;
142 if (Build.VERSION.SDK_INT >= 18) {
143 return false;
145 Drawable background = view.getBackground();
146 if (background != null) {
147 return background.getOpacity() == -1;
149 return false;
152 /* access modifiers changed from: protected */
153 public void onAttachedToWindow() {
154 super.onAttachedToWindow();
155 this.r = true;
158 /* access modifiers changed from: protected */
159 public void onDetachedFromWindow() {
160 super.onDetachedFromWindow();
161 this.r = true;
162 int size = this.t.size();
163 for (int i2 = 0; i2 < size; i2++) {
164 ((x) this.t.get(i2)).run();
166 this.t.clear();
169 /* access modifiers changed from: protected */
170 public void onMeasure(int i2, int i3) {
171 int i4;
172 int i5;
173 int i6;
174 int i7;
175 int paddingTop;
176 int makeMeasureSpec;
177 int makeMeasureSpec2;
178 int makeMeasureSpec3;
179 int makeMeasureSpec4;
180 int i8;
181 int i9;
182 boolean z;
183 float f2;
184 int mode = View.MeasureSpec.getMode(i2);
185 int size = View.MeasureSpec.getSize(i2);
186 int mode2 = View.MeasureSpec.getMode(i3);
187 int size2 = View.MeasureSpec.getSize(i3);
188 if (mode == 1073741824) {
189 if (mode2 == 0) {
190 if (!isInEditMode()) {
191 throw new IllegalStateException("Height must not be UNSPECIFIED");
192 } else if (mode2 == 0) {
193 i4 = Integer.MIN_VALUE;
194 i5 = size;
195 i6 = 300;
198 i4 = mode2;
199 i5 = size;
200 i6 = size2;
201 } else if (!isInEditMode()) {
202 throw new IllegalStateException("Width must have an exact value or MATCH_PARENT");
203 } else if (mode == Integer.MIN_VALUE) {
204 i4 = mode2;
205 i5 = size;
206 i6 = size2;
207 } else {
208 if (mode == 0) {
209 i4 = mode2;
210 i5 = 300;
211 i6 = size2;
213 i4 = mode2;
214 i5 = size;
215 i6 = size2;
217 switch (i4) {
218 case Integer.MIN_VALUE:
219 i7 = 0;
220 paddingTop = (i6 - getPaddingTop()) - getPaddingBottom();
221 break;
222 case 1073741824:
223 i7 = (i6 - getPaddingTop()) - getPaddingBottom();
224 paddingTop = i7;
225 break;
226 default:
227 i7 = 0;
228 paddingTop = -1;
229 break;
231 boolean z2 = false;
232 int paddingLeft = (i5 - getPaddingLeft()) - getPaddingRight();
233 int childCount = getChildCount();
234 if (childCount > 2) {
235 Log.e("SlidingPaneLayout", "onMeasure: More than two child views are not supported.");
237 this.g = null;
238 int i10 = 0;
239 int i11 = i7;
240 float f3 = 0.0f;
241 while (i10 < childCount) {
242 View childAt = getChildAt(i10);
243 y yVar = (y) childAt.getLayoutParams();
244 if (childAt.getVisibility() == 8) {
245 yVar.c = false;
246 i8 = paddingLeft;
247 f2 = f3;
248 i9 = i11;
249 z = z2;
250 } else {
251 if (yVar.a > 0.0f) {
252 f3 += yVar.a;
253 if (yVar.width == 0) {
254 i8 = paddingLeft;
255 f2 = f3;
256 i9 = i11;
257 z = z2;
260 int i12 = yVar.leftMargin + yVar.rightMargin;
261 if (yVar.width == -2) {
262 makeMeasureSpec3 = View.MeasureSpec.makeMeasureSpec(i5 - i12, Integer.MIN_VALUE);
263 } else if (yVar.width == -1) {
264 makeMeasureSpec3 = View.MeasureSpec.makeMeasureSpec(i5 - i12, 1073741824);
265 } else {
266 makeMeasureSpec3 = View.MeasureSpec.makeMeasureSpec(yVar.width, 1073741824);
268 if (yVar.height == -2) {
269 makeMeasureSpec4 = View.MeasureSpec.makeMeasureSpec(paddingTop, Integer.MIN_VALUE);
270 } else if (yVar.height == -1) {
271 makeMeasureSpec4 = View.MeasureSpec.makeMeasureSpec(paddingTop, 1073741824);
272 } else {
273 makeMeasureSpec4 = View.MeasureSpec.makeMeasureSpec(yVar.height, 1073741824);
275 childAt.measure(makeMeasureSpec3, makeMeasureSpec4);
276 int measuredWidth = childAt.getMeasuredWidth();
277 int measuredHeight = childAt.getMeasuredHeight();
278 if (i4 == Integer.MIN_VALUE && measuredHeight > i11) {
279 i11 = Math.min(measuredHeight, paddingTop);
281 int i13 = paddingLeft - measuredWidth;
282 boolean z3 = i13 < 0;
283 yVar.b = z3;
284 boolean z4 = z3 | z2;
285 if (yVar.b) {
286 this.g = childAt;
288 i8 = i13;
289 i9 = i11;
290 z = z4;
291 f2 = f3;
293 i10++;
294 z2 = z;
295 i11 = i9;
296 f3 = f2;
297 paddingLeft = i8;
299 if (z2 || f3 > 0.0f) {
300 int i14 = i5 - this.e;
301 for (int i15 = 0; i15 < childCount; i15++) {
302 View childAt2 = getChildAt(i15);
303 if (childAt2.getVisibility() != 8) {
304 y yVar2 = (y) childAt2.getLayoutParams();
305 if (childAt2.getVisibility() != 8) {
306 boolean z5 = yVar2.width == 0 && yVar2.a > 0.0f;
307 int measuredWidth2 = z5 ? 0 : childAt2.getMeasuredWidth();
308 if (!z2 || childAt2 == this.g) {
309 if (yVar2.a > 0.0f) {
310 if (yVar2.width != 0) {
311 makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(childAt2.getMeasuredHeight(), 1073741824);
312 } else if (yVar2.height == -2) {
313 makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(paddingTop, Integer.MIN_VALUE);
314 } else if (yVar2.height == -1) {
315 makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(paddingTop, 1073741824);
316 } else {
317 makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(yVar2.height, 1073741824);
319 if (z2) {
320 int i16 = i5 - (yVar2.rightMargin + yVar2.leftMargin);
321 int makeMeasureSpec5 = View.MeasureSpec.makeMeasureSpec(i16, 1073741824);
322 if (measuredWidth2 != i16) {
323 childAt2.measure(makeMeasureSpec5, makeMeasureSpec);
325 } else {
326 childAt2.measure(View.MeasureSpec.makeMeasureSpec(((int) ((yVar2.a * ((float) Math.max(0, paddingLeft))) / f3)) + measuredWidth2, 1073741824), makeMeasureSpec);
329 } else if (yVar2.width < 0 && (measuredWidth2 > i14 || yVar2.a > 0.0f)) {
330 if (!z5) {
331 makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(childAt2.getMeasuredHeight(), 1073741824);
332 } else if (yVar2.height == -2) {
333 makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(paddingTop, Integer.MIN_VALUE);
334 } else if (yVar2.height == -1) {
335 makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(paddingTop, 1073741824);
336 } else {
337 makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(yVar2.height, 1073741824);
339 childAt2.measure(View.MeasureSpec.makeMeasureSpec(i14, 1073741824), makeMeasureSpec2);
345 setMeasuredDimension(i5, i11);
346 this.f = z2;
347 if (!(this.p.a() == 0 || z2)) {
348 this.p.f();
352 /* access modifiers changed from: protected */
353 public void onLayout(boolean z, int i2, int i3, int i4, int i5) {
354 int i6;
355 int i7;
356 int i8 = i4 - i2;
357 int paddingLeft = getPaddingLeft();
358 int paddingRight = getPaddingRight();
359 int paddingTop = getPaddingTop();
360 int childCount = getChildCount();
361 if (this.r) {
362 this.h = (!this.f || !this.q) ? 0.0f : 1.0f;
364 int i9 = 0;
365 int i10 = paddingLeft;
366 while (i9 < childCount) {
367 View childAt = getChildAt(i9);
368 if (childAt.getVisibility() == 8) {
369 i7 = i10;
370 } else {
371 y yVar = (y) childAt.getLayoutParams();
372 int measuredWidth = childAt.getMeasuredWidth();
373 if (yVar.b) {
374 int min = (Math.min(paddingLeft, (i8 - paddingRight) - this.e) - i10) - (yVar.leftMargin + yVar.rightMargin);
375 this.j = min;
376 yVar.c = ((yVar.leftMargin + i10) + min) + (measuredWidth / 2) > i8 - paddingRight;
377 i7 = yVar.leftMargin + ((int) (((float) min) * this.h)) + i10;
378 i6 = 0;
379 } else if (!this.f || this.l == 0) {
380 i6 = 0;
381 i7 = paddingLeft;
382 } else {
383 i6 = (int) ((1.0f - this.h) * ((float) this.l));
384 i7 = paddingLeft;
386 int i11 = i7 - i6;
387 childAt.layout(i11, paddingTop, i11 + measuredWidth, childAt.getMeasuredHeight() + paddingTop);
388 paddingLeft += childAt.getWidth();
390 i9++;
391 i10 = i7;
393 if (this.r) {
394 if (this.f) {
395 if (this.l != 0) {
396 a(this.h);
398 if (((y) this.g.getLayoutParams()).c) {
399 a(this.g, this.h, this.b);
401 } else {
402 for (int i12 = 0; i12 < childCount; i12++) {
403 a(getChildAt(i12), 0.0f, this.b);
406 a(this.g);
408 this.r = false;
411 /* access modifiers changed from: protected */
412 public void onSizeChanged(int i2, int i3, int i4, int i5) {
413 super.onSizeChanged(i2, i3, i4, i5);
414 if (i2 != i4) {
415 this.r = true;
419 public void requestChildFocus(View view, View view2) {
420 super.requestChildFocus(view, view2);
421 if (!isInTouchMode() && !this.f) {
422 this.q = view == this.g;
426 /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
427 public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
428 boolean z;
429 View childAt;
430 int a2 = ak.a(motionEvent);
431 if (!this.f && a2 == 0 && getChildCount() > 1 && (childAt = getChildAt(1)) != null) {
432 this.q = !this.p.b(childAt, (int) motionEvent.getX(), (int) motionEvent.getY());
434 if (!this.f || (this.k && a2 != 0)) {
435 this.p.e();
436 return super.onInterceptTouchEvent(motionEvent);
437 } else if (a2 == 3 || a2 == 1) {
438 this.p.e();
439 return false;
440 } else {
441 switch (a2) {
442 case 0:
443 this.k = false;
444 float x = motionEvent.getX();
445 float y = motionEvent.getY();
446 this.m = x;
447 this.n = y;
448 if (this.p.b(this.g, (int) x, (int) y) && b(this.g)) {
449 z = true;
450 break;
452 z = false;
453 break;
454 case 1:
455 default:
456 z = false;
457 break;
458 case 2:
459 float x2 = motionEvent.getX();
460 float y2 = motionEvent.getY();
461 float abs = Math.abs(x2 - this.m);
462 float abs2 = Math.abs(y2 - this.n);
463 if (abs > ((float) this.p.d()) && abs2 > abs) {
464 this.p.e();
465 this.k = true;
466 return false;
468 z = false;
469 break;
471 return this.p.a(motionEvent) || z;
475 public boolean onTouchEvent(MotionEvent motionEvent) {
476 if (!this.f) {
477 return super.onTouchEvent(motionEvent);
479 this.p.b(motionEvent);
480 switch (motionEvent.getAction() & 255) {
481 case 0:
482 float x = motionEvent.getX();
483 float y = motionEvent.getY();
484 this.m = x;
485 this.n = y;
486 return true;
487 case 1:
488 if (!b(this.g)) {
489 return true;
491 float x2 = motionEvent.getX();
492 float y2 = motionEvent.getY();
493 float f2 = x2 - this.m;
494 float f3 = y2 - this.n;
495 int d2 = this.p.d();
496 if ((f2 * f2) + (f3 * f3) >= ((float) (d2 * d2)) || !this.p.b(this.g, (int) x2, (int) y2)) {
497 return true;
499 a(this.g, 0);
500 return true;
501 default:
502 return true;
506 private boolean a(View view, int i2) {
507 if (!this.r && !a(0.0f, i2)) {
508 return false;
510 this.q = false;
511 return true;
514 private boolean b(View view, int i2) {
515 if (!this.r && !a(1.0f, i2)) {
516 return false;
518 this.q = true;
519 return true;
522 public boolean b() {
523 return b(this.g, 0);
526 public boolean c() {
527 return a(this.g, 0);
530 public boolean d() {
531 return !this.f || this.h == 1.0f;
534 public boolean e() {
535 return this.f;
538 private void a(View view, float f2, int i2) {
539 y yVar = (y) view.getLayoutParams();
540 if (f2 > 0.0f && i2 != 0) {
541 int i3 = (((int) (((float) ((-16777216 & i2) >>> 24)) * f2)) << 24) | (16777215 & i2);
542 if (yVar.d == null) {
543 yVar.d = new Paint();
545 yVar.d.setColorFilter(new PorterDuffColorFilter(i3, PorterDuff.Mode.SRC_OVER));
546 if (av.d(view) != 2) {
547 av.a(view, 2, yVar.d);
549 d(view);
550 } else if (av.d(view) != 0) {
551 if (yVar.d != null) {
552 yVar.d.setColorFilter(null);
554 x xVar = new x(this, view);
555 this.t.add(xVar);
556 av.a(this, xVar);
560 /* access modifiers changed from: protected */
561 public boolean drawChild(Canvas canvas, View view, long j2) {
562 boolean drawChild;
563 y yVar = (y) view.getLayoutParams();
564 int save = canvas.save(2);
565 if (this.f && !yVar.b && this.g != null) {
566 canvas.getClipBounds(this.s);
567 this.s.right = Math.min(this.s.right, this.g.getLeft());
568 canvas.clipRect(this.s);
570 if (Build.VERSION.SDK_INT >= 11) {
571 drawChild = super.drawChild(canvas, view, j2);
572 } else if (!yVar.c || this.h <= 0.0f) {
573 if (view.isDrawingCacheEnabled()) {
574 view.setDrawingCacheEnabled(false);
576 drawChild = super.drawChild(canvas, view, j2);
577 } else {
578 if (!view.isDrawingCacheEnabled()) {
579 view.setDrawingCacheEnabled(true);
581 Bitmap drawingCache = view.getDrawingCache();
582 if (drawingCache != null) {
583 canvas.drawBitmap(drawingCache, (float) view.getLeft(), (float) view.getTop(), yVar.d);
584 drawChild = false;
585 } else {
586 Log.e("SlidingPaneLayout", "drawChild: child view " + view + " returned null drawing cache");
587 drawChild = super.drawChild(canvas, view, j2);
590 canvas.restoreToCount(save);
591 return drawChild;
594 /* access modifiers changed from: private */
595 public void d(View view) {
596 a.a(this, view);
599 /* access modifiers changed from: package-private */
600 public boolean a(float f2, int i2) {
601 if (!this.f) {
602 return false;
604 int paddingLeft = getPaddingLeft();
605 if (!this.p.a(this.g, (int) (((float) (((y) this.g.getLayoutParams()).leftMargin + paddingLeft)) + (((float) this.j) * f2)), this.g.getTop())) {
606 return false;
608 a();
609 av.b(this);
610 return true;
613 public void computeScroll() {
614 if (!this.p.a(true)) {
615 return;
617 if (!this.f) {
618 this.p.f();
619 } else {
620 av.b(this);
624 public void setShadowDrawable(Drawable drawable) {
625 this.d = drawable;
628 public void setShadowResource(int i2) {
629 setShadowDrawable(getResources().getDrawable(i2));
632 public void draw(Canvas canvas) {
633 super.draw(canvas);
634 View childAt = getChildCount() > 1 ? getChildAt(1) : null;
635 if (childAt != null && this.d != null) {
636 int intrinsicWidth = this.d.getIntrinsicWidth();
637 int left = childAt.getLeft();
638 this.d.setBounds(left - intrinsicWidth, childAt.getTop(), left, childAt.getBottom());
639 this.d.draw(canvas);
643 private void a(float f2) {
644 y yVar = (y) this.g.getLayoutParams();
645 boolean z = yVar.c && yVar.leftMargin <= 0;
646 int childCount = getChildCount();
647 for (int i2 = 0; i2 < childCount; i2++) {
648 View childAt = getChildAt(i2);
649 if (childAt != this.g) {
650 this.i = f2;
651 childAt.offsetLeftAndRight(((int) ((1.0f - this.i) * ((float) this.l))) - ((int) ((1.0f - f2) * ((float) this.l))));
652 if (z) {
653 a(childAt, 1.0f - this.i, this.c);
659 /* access modifiers changed from: package-private */
660 public boolean b(View view) {
661 if (view == null) {
662 return false;
664 return this.f && ((y) view.getLayoutParams()).c && this.h > 0.0f;
667 /* access modifiers changed from: protected */
668 public ViewGroup.LayoutParams generateDefaultLayoutParams() {
669 return new y();
672 /* access modifiers changed from: protected */
673 @Override // android.view.ViewGroup
674 public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
675 return layoutParams instanceof ViewGroup.MarginLayoutParams ? new y((ViewGroup.MarginLayoutParams) layoutParams) : new y(layoutParams);
678 /* access modifiers changed from: protected */
679 public boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
680 return (layoutParams instanceof y) && super.checkLayoutParams(layoutParams);
683 @Override // android.view.ViewGroup
684 public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
685 return new y(getContext(), attributeSet);
688 /* access modifiers changed from: protected */
689 public Parcelable onSaveInstanceState() {
690 SavedState savedState = new SavedState(super.onSaveInstanceState());
691 savedState.a = e() ? d() : this.q;
692 return savedState;
695 /* access modifiers changed from: protected */
696 public void onRestoreInstanceState(Parcelable parcelable) {
697 SavedState savedState = (SavedState) parcelable;
698 super.onRestoreInstanceState(savedState.getSuperState());
699 if (savedState.a) {
700 b();
701 } else {
702 c();
704 this.q = savedState.a;
707 /* access modifiers changed from: package-private */
708 /* compiled from: MyApp */
709 public class SavedState extends View.BaseSavedState {
710 public static final Parcelable.Creator CREATOR = new aa();
711 boolean a;
713 SavedState(Parcelable parcelable) {
714 super(parcelable);
717 private SavedState(Parcel parcel) {
718 super(parcel);
719 this.a = parcel.readInt() != 0;
722 public void writeToParcel(Parcel parcel, int i) {
723 super.writeToParcel(parcel, i);
724 parcel.writeInt(this.a ? 1 : 0);