4
4
import android .content .Context ;
5
5
import android .support .design .widget .AppBarLayout ;
6
6
import android .support .design .widget .CoordinatorLayout ;
7
+ import android .support .design .widget .FloatingActionButton ;
7
8
import android .support .v4 .view .ViewCompat ;
8
9
import android .support .v4 .view .animation .FastOutSlowInInterpolator ;
9
10
import android .util .AttributeSet ;
10
11
import android .util .TypedValue ;
11
12
import android .view .View ;
12
13
import android .view .ViewPropertyAnimator ;
13
14
import android .view .animation .Interpolator ;
15
+ import com .zulip .android .R ;
14
16
15
17
/**
16
18
* This hides the {@link AppBarLayout} and {@link android.support.design.widget.FloatingActionButton} when the
@@ -22,13 +24,13 @@ public class RemoveViewsOnScroll extends CoordinatorLayout.Behavior<View> {
22
24
private boolean mIsShowing ;
23
25
private boolean isViewHidden ;
24
26
private static float toolbarHeight ;
27
+ private View chatBox ;
25
28
26
29
public RemoveViewsOnScroll (Context context , AttributeSet attrs ) {
27
30
super (context , attrs );
28
31
TypedValue tv = new TypedValue ();
29
32
if (context .getTheme ().resolveAttribute (android .R .attr .actionBarSize , tv , true ))
30
33
toolbarHeight = TypedValue .complexToDimensionPixelSize (tv .data , context .getResources ().getDisplayMetrics ());
31
-
32
34
}
33
35
34
36
@ Override
@@ -46,8 +48,16 @@ public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, View child, V
46
48
changeInYDir += dy ;
47
49
if (changeInYDir > toolbarHeight && child .getVisibility () == View .VISIBLE && !isViewHidden )
48
50
hideView (child );
49
- else if (changeInYDir < 0 && child .getVisibility () == View .GONE && !mIsShowing )
51
+ else if (changeInYDir < 0 && child .getVisibility () == View .GONE && !mIsShowing ) {
52
+ if (child instanceof FloatingActionButton ) {
53
+ if (chatBox == null )
54
+ chatBox = coordinatorLayout .findViewById (R .id .messageBoxContainer );
55
+ if (chatBox .getVisibility () == View .VISIBLE ) {
56
+ return ;
57
+ }
58
+ }
50
59
showView (child );
60
+ }
51
61
52
62
}
53
63
0 commit comments