BottomSheetBehavior.java
20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
package android.support.design.widget;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import android.support.annotation.NonNull;
import android.support.annotation.RestrictTo;
import android.support.design.R.dimen;
import android.support.design.R.styleable;
import android.support.v4.os.ParcelableCompat;
import android.support.v4.os.ParcelableCompatCreatorCallbacks;
import android.support.v4.view.AbsSavedState;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.NestedScrollingChild;
import android.support.v4.view.VelocityTrackerCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ViewDragHelper;
import android.support.v4.widget.ViewDragHelper.Callback;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
import m;
public class BottomSheetBehavior<V extends View>
extends CoordinatorLayout.Behavior<V>
{
public static final int PEEK_HEIGHT_AUTO = -1;
public static final int STATE_COLLAPSED = 4;
public static final int STATE_DRAGGING = 1;
public static final int STATE_EXPANDED = 3;
public static final int STATE_HIDDEN = 5;
public static final int STATE_SETTLING = 2;
int a;
int b;
boolean c;
int d = 4;
ViewDragHelper e;
int f;
WeakReference<V> g;
WeakReference<View> h;
int i;
boolean j;
private float k;
private int l;
private boolean m;
private int n;
private boolean o;
private boolean p;
private int q;
private boolean r;
private BottomSheetCallback s;
private VelocityTracker t;
private int u;
private final ViewDragHelper.Callback v = new ViewDragHelper.Callback()
{
public final int clampViewPositionHorizontal(View paramAnonymousView, int paramAnonymousInt1, int paramAnonymousInt2)
{
return paramAnonymousView.getLeft();
}
public final int clampViewPositionVertical(View paramAnonymousView, int paramAnonymousInt1, int paramAnonymousInt2)
{
int i = BottomSheetBehavior.this.a;
if (BottomSheetBehavior.this.c) {}
for (paramAnonymousInt2 = BottomSheetBehavior.this.f;; paramAnonymousInt2 = BottomSheetBehavior.this.b) {
return m.a(paramAnonymousInt1, i, paramAnonymousInt2);
}
}
public final int getViewVerticalDragRange(View paramAnonymousView)
{
if (BottomSheetBehavior.this.c) {
return BottomSheetBehavior.this.f - BottomSheetBehavior.this.a;
}
return BottomSheetBehavior.this.b - BottomSheetBehavior.this.a;
}
public final void onViewDragStateChanged(int paramAnonymousInt)
{
if (paramAnonymousInt == 1) {
BottomSheetBehavior.this.a(1);
}
}
public final void onViewPositionChanged(View paramAnonymousView, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3, int paramAnonymousInt4)
{
BottomSheetBehavior.this.b(paramAnonymousInt2);
}
public final void onViewReleased(View paramAnonymousView, float paramAnonymousFloat1, float paramAnonymousFloat2)
{
int j = 3;
int i;
if (paramAnonymousFloat2 < 0.0F) {
i = BottomSheetBehavior.this.a;
}
while (BottomSheetBehavior.this.e.settleCapturedViewAt(paramAnonymousView.getLeft(), i))
{
BottomSheetBehavior.this.a(2);
ViewCompat.postOnAnimation(paramAnonymousView, new BottomSheetBehavior.a(BottomSheetBehavior.this, paramAnonymousView, j));
return;
if ((BottomSheetBehavior.this.c) && (BottomSheetBehavior.this.a(paramAnonymousView, paramAnonymousFloat2)))
{
i = BottomSheetBehavior.this.f;
j = 5;
}
else if (paramAnonymousFloat2 == 0.0F)
{
i = paramAnonymousView.getTop();
if (Math.abs(i - BottomSheetBehavior.this.a) < Math.abs(i - BottomSheetBehavior.this.b))
{
i = BottomSheetBehavior.this.a;
}
else
{
i = BottomSheetBehavior.this.b;
j = 4;
}
}
else
{
i = BottomSheetBehavior.this.b;
j = 4;
}
}
BottomSheetBehavior.this.a(j);
}
public final boolean tryCaptureView(View paramAnonymousView, int paramAnonymousInt)
{
if (BottomSheetBehavior.this.d == 1) {
return false;
}
if (BottomSheetBehavior.this.j) {
return false;
}
if ((BottomSheetBehavior.this.d == 3) && (BottomSheetBehavior.this.i == paramAnonymousInt))
{
View localView = (View)BottomSheetBehavior.this.h.get();
if ((localView != null) && (ViewCompat.canScrollVertically(localView, -1))) {
return false;
}
}
return (BottomSheetBehavior.this.g != null) && (BottomSheetBehavior.this.g.get() == paramAnonymousView);
}
};
public BottomSheetBehavior() {}
public BottomSheetBehavior(Context paramContext, AttributeSet paramAttributeSet)
{
super(paramContext, paramAttributeSet);
paramAttributeSet = paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.BottomSheetBehavior_Layout);
TypedValue localTypedValue = paramAttributeSet.peekValue(R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight);
if ((localTypedValue != null) && (localTypedValue.data == -1)) {
setPeekHeight(localTypedValue.data);
}
for (;;)
{
setHideable(paramAttributeSet.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_hideable, false));
setSkipCollapsed(paramAttributeSet.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapsed, false));
paramAttributeSet.recycle();
this.k = ViewConfiguration.get(paramContext).getScaledMaximumFlingVelocity();
return;
setPeekHeight(paramAttributeSet.getDimensionPixelSize(R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight, -1));
}
}
private View a(View paramView)
{
if ((paramView instanceof NestedScrollingChild)) {
return paramView;
}
if ((paramView instanceof ViewGroup))
{
paramView = (ViewGroup)paramView;
int i2 = paramView.getChildCount();
int i1 = 0;
while (i1 < i2)
{
View localView = a(paramView.getChildAt(i1));
if (localView != null) {
return localView;
}
i1 += 1;
}
}
return null;
}
private void a()
{
this.i = -1;
if (this.t != null)
{
this.t.recycle();
this.t = null;
}
}
public static <V extends View> BottomSheetBehavior<V> from(V paramV)
{
paramV = paramV.getLayoutParams();
if (!(paramV instanceof CoordinatorLayout.LayoutParams)) {
throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
}
paramV = ((CoordinatorLayout.LayoutParams)paramV).getBehavior();
if (!(paramV instanceof BottomSheetBehavior)) {
throw new IllegalArgumentException("The view is not associated with BottomSheetBehavior");
}
return (BottomSheetBehavior)paramV;
}
final void a(int paramInt)
{
if (this.d == paramInt) {}
View localView;
do
{
return;
this.d = paramInt;
localView = (View)this.g.get();
} while ((localView == null) || (this.s == null));
this.s.onStateChanged(localView, paramInt);
}
final void a(View paramView, int paramInt)
{
int i1;
if (paramInt == 4) {
i1 = this.b;
}
for (;;)
{
a(2);
if (this.e.smoothSlideViewTo(paramView, paramView.getLeft(), i1)) {
ViewCompat.postOnAnimation(paramView, new a(paramView, paramInt));
}
return;
if (paramInt == 3)
{
i1 = this.a;
}
else
{
if ((!this.c) || (paramInt != 5)) {
break;
}
i1 = this.f;
}
}
throw new IllegalArgumentException("Illegal state argument: " + paramInt);
}
final boolean a(View paramView, float paramFloat)
{
if (this.o) {}
do
{
return true;
if (paramView.getTop() < this.b) {
return false;
}
} while (Math.abs(paramView.getTop() + 0.1F * paramFloat - this.b) / this.l > 0.5F);
return false;
}
final void b(int paramInt)
{
View localView = (View)this.g.get();
if ((localView != null) && (this.s != null))
{
if (paramInt > this.b) {
this.s.onSlide(localView, (this.b - paramInt) / (this.f - this.b));
}
}
else {
return;
}
this.s.onSlide(localView, (this.b - paramInt) / (this.b - this.a));
}
public final int getPeekHeight()
{
if (this.m) {
return -1;
}
return this.l;
}
public boolean getSkipCollapsed()
{
return this.o;
}
public final int getState()
{
return this.d;
}
public boolean isHideable()
{
return this.c;
}
public boolean onInterceptTouchEvent(CoordinatorLayout paramCoordinatorLayout, V paramV, MotionEvent paramMotionEvent)
{
if (!paramV.isShown()) {
this.p = true;
}
int i1;
do
{
return false;
i1 = MotionEventCompat.getActionMasked(paramMotionEvent);
if (i1 == 0) {
a();
}
if (this.t == null) {
this.t = VelocityTracker.obtain();
}
this.t.addMovement(paramMotionEvent);
switch (i1)
{
}
while ((!this.p) && (this.e.shouldInterceptTouchEvent(paramMotionEvent)))
{
return true;
this.j = false;
this.i = -1;
if (this.p)
{
this.p = false;
return false;
int i2 = (int)paramMotionEvent.getX();
this.u = ((int)paramMotionEvent.getY());
View localView = (View)this.h.get();
if ((localView != null) && (paramCoordinatorLayout.isPointInChildBounds(localView, i2, this.u)))
{
this.i = paramMotionEvent.getPointerId(paramMotionEvent.getActionIndex());
this.j = true;
}
if ((this.i == -1) && (!paramCoordinatorLayout.isPointInChildBounds(paramV, i2, this.u))) {}
for (boolean bool = true;; bool = false)
{
this.p = bool;
break;
}
}
}
paramV = (View)this.h.get();
} while ((i1 != 2) || (paramV == null) || (this.p) || (this.d == 1) || (paramCoordinatorLayout.isPointInChildBounds(paramV, (int)paramMotionEvent.getX(), (int)paramMotionEvent.getY())) || (Math.abs(this.u - paramMotionEvent.getY()) <= this.e.getTouchSlop()));
return true;
}
public boolean onLayoutChild(CoordinatorLayout paramCoordinatorLayout, V paramV, int paramInt)
{
if ((ViewCompat.getFitsSystemWindows(paramCoordinatorLayout)) && (!ViewCompat.getFitsSystemWindows(paramV))) {
ViewCompat.setFitsSystemWindows(paramV, true);
}
int i1 = paramV.getTop();
paramCoordinatorLayout.onLayoutChild(paramV, paramInt);
this.f = paramCoordinatorLayout.getHeight();
if (this.m)
{
if (this.n == 0) {
this.n = paramCoordinatorLayout.getResources().getDimensionPixelSize(R.dimen.design_bottom_sheet_peek_height_min);
}
paramInt = Math.max(this.n, this.f - paramCoordinatorLayout.getWidth() * 9 / 16);
this.a = Math.max(0, this.f - paramV.getHeight());
this.b = Math.max(this.f - paramInt, this.a);
if (this.d != 3) {
break label197;
}
ViewCompat.offsetTopAndBottom(paramV, this.a);
}
for (;;)
{
if (this.e == null) {
this.e = ViewDragHelper.create(paramCoordinatorLayout, this.v);
}
this.g = new WeakReference(paramV);
this.h = new WeakReference(a(paramV));
return true;
paramInt = this.l;
break;
label197:
if ((this.c) && (this.d == 5)) {
ViewCompat.offsetTopAndBottom(paramV, this.f);
} else if (this.d == 4) {
ViewCompat.offsetTopAndBottom(paramV, this.b);
} else if ((this.d == 1) || (this.d == 2)) {
ViewCompat.offsetTopAndBottom(paramV, i1 - paramV.getTop());
}
}
}
public boolean onNestedPreFling(CoordinatorLayout paramCoordinatorLayout, V paramV, View paramView, float paramFloat1, float paramFloat2)
{
return (paramView == this.h.get()) && ((this.d != 3) || (super.onNestedPreFling(paramCoordinatorLayout, paramV, paramView, paramFloat1, paramFloat2)));
}
public void onNestedPreScroll(CoordinatorLayout paramCoordinatorLayout, V paramV, View paramView, int paramInt1, int paramInt2, int[] paramArrayOfInt)
{
if (paramView != (View)this.h.get()) {
return;
}
paramInt1 = paramV.getTop();
int i1 = paramInt1 - paramInt2;
if (paramInt2 > 0) {
if (i1 < this.a)
{
paramArrayOfInt[1] = (paramInt1 - this.a);
ViewCompat.offsetTopAndBottom(paramV, -paramArrayOfInt[1]);
a(3);
}
}
for (;;)
{
b(paramV.getTop());
this.q = paramInt2;
this.r = true;
return;
paramArrayOfInt[1] = paramInt2;
ViewCompat.offsetTopAndBottom(paramV, -paramInt2);
a(1);
continue;
if ((paramInt2 < 0) && (!ViewCompat.canScrollVertically(paramView, -1))) {
if ((i1 <= this.b) || (this.c))
{
paramArrayOfInt[1] = paramInt2;
ViewCompat.offsetTopAndBottom(paramV, -paramInt2);
a(1);
}
else
{
paramArrayOfInt[1] = (paramInt1 - this.b);
ViewCompat.offsetTopAndBottom(paramV, -paramArrayOfInt[1]);
a(4);
}
}
}
}
public void onRestoreInstanceState(CoordinatorLayout paramCoordinatorLayout, V paramV, Parcelable paramParcelable)
{
paramParcelable = (SavedState)paramParcelable;
super.onRestoreInstanceState(paramCoordinatorLayout, paramV, paramParcelable.getSuperState());
if ((paramParcelable.a == 1) || (paramParcelable.a == 2))
{
this.d = 4;
return;
}
this.d = paramParcelable.a;
}
public Parcelable onSaveInstanceState(CoordinatorLayout paramCoordinatorLayout, V paramV)
{
return new SavedState(super.onSaveInstanceState(paramCoordinatorLayout, paramV), this.d);
}
public boolean onStartNestedScroll(CoordinatorLayout paramCoordinatorLayout, V paramV, View paramView1, View paramView2, int paramInt)
{
boolean bool = false;
this.q = 0;
this.r = false;
if ((paramInt & 0x2) != 0) {
bool = true;
}
return bool;
}
public void onStopNestedScroll(CoordinatorLayout paramCoordinatorLayout, V paramV, View paramView)
{
int i2 = 3;
if (paramV.getTop() == this.a) {
a(3);
}
while ((paramView != this.h.get()) || (!this.r)) {
return;
}
int i1;
if (this.q > 0)
{
i1 = this.a;
if (!this.e.smoothSlideViewTo(paramV, paramV.getLeft(), i1)) {
break label215;
}
a(2);
ViewCompat.postOnAnimation(paramV, new a(paramV, i2));
}
for (;;)
{
this.r = false;
return;
if (this.c)
{
this.t.computeCurrentVelocity(1000, this.k);
if (a(paramV, VelocityTrackerCompat.getYVelocity(this.t, this.i)))
{
i1 = this.f;
i2 = 5;
break;
}
}
if (this.q == 0)
{
i1 = paramV.getTop();
if (Math.abs(i1 - this.a) < Math.abs(i1 - this.b))
{
i1 = this.a;
break;
}
i1 = this.b;
i2 = 4;
break;
}
i1 = this.b;
i2 = 4;
break;
label215:
a(i2);
}
}
public boolean onTouchEvent(CoordinatorLayout paramCoordinatorLayout, V paramV, MotionEvent paramMotionEvent)
{
if (!paramV.isShown()) {}
do
{
return false;
int i1 = MotionEventCompat.getActionMasked(paramMotionEvent);
if ((this.d == 1) && (i1 == 0)) {
return true;
}
this.e.processTouchEvent(paramMotionEvent);
if (i1 == 0) {
a();
}
if (this.t == null) {
this.t = VelocityTracker.obtain();
}
this.t.addMovement(paramMotionEvent);
if ((i1 == 2) && (!this.p) && (Math.abs(this.u - paramMotionEvent.getY()) > this.e.getTouchSlop())) {
this.e.captureChildView(paramV, paramMotionEvent.getPointerId(paramMotionEvent.getActionIndex()));
}
} while (this.p);
return true;
}
public void setBottomSheetCallback(BottomSheetCallback paramBottomSheetCallback)
{
this.s = paramBottomSheetCallback;
}
public void setHideable(boolean paramBoolean)
{
this.c = paramBoolean;
}
public final void setPeekHeight(int paramInt)
{
int i1 = 1;
if (paramInt == -1)
{
if (this.m) {
break label104;
}
this.m = true;
paramInt = i1;
}
for (;;)
{
if ((paramInt != 0) && (this.d == 4) && (this.g != null))
{
View localView = (View)this.g.get();
if (localView != null) {
localView.requestLayout();
}
}
return;
if ((this.m) || (this.l != paramInt))
{
this.m = false;
this.l = Math.max(0, paramInt);
this.b = (this.f - paramInt);
paramInt = i1;
}
else
{
label104:
paramInt = 0;
}
}
}
public void setSkipCollapsed(boolean paramBoolean)
{
this.o = paramBoolean;
}
public final void setState(final int paramInt)
{
if (paramInt == this.d) {}
final View localView;
do
{
do
{
return;
if (this.g != null) {
break;
}
} while ((paramInt != 4) && (paramInt != 3) && ((!this.c) || (paramInt != 5)));
this.d = paramInt;
return;
localView = (View)this.g.get();
} while (localView == null);
ViewParent localViewParent = localView.getParent();
if ((localViewParent != null) && (localViewParent.isLayoutRequested()) && (ViewCompat.isAttachedToWindow(localView)))
{
localView.post(new Runnable()
{
public final void run()
{
BottomSheetBehavior.this.a(localView, paramInt);
}
});
return;
}
a(localView, paramInt);
}
public static abstract class BottomSheetCallback
{
public abstract void onSlide(@NonNull View paramView, float paramFloat);
public abstract void onStateChanged(@NonNull View paramView, int paramInt);
}
public static class SavedState
extends AbsSavedState
{
public static final Parcelable.Creator<SavedState> CREATOR = ParcelableCompat.newCreator(new ParcelableCompatCreatorCallbacks() {});
final int a;
public SavedState(Parcel paramParcel)
{
this(paramParcel, null);
}
public SavedState(Parcel paramParcel, ClassLoader paramClassLoader)
{
super(paramClassLoader);
this.a = paramParcel.readInt();
}
public SavedState(Parcelable paramParcelable, int paramInt)
{
super();
this.a = paramInt;
}
public void writeToParcel(Parcel paramParcel, int paramInt)
{
super.writeToParcel(paramParcel, paramInt);
paramParcel.writeInt(this.a);
}
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
public static @interface State {}
final class a
implements Runnable
{
private final View b;
private final int c;
a(View paramView, int paramInt)
{
this.b = paramView;
this.c = paramInt;
}
public final void run()
{
if ((BottomSheetBehavior.this.e != null) && (BottomSheetBehavior.this.e.continueSettling(true)))
{
ViewCompat.postOnAnimation(this.b, this);
return;
}
BottomSheetBehavior.this.a(this.c);
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/design/widget/BottomSheetBehavior.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/