|
@@ -1,7 +1,6 @@
|
1
|
1
|
package com.reactnativenavigation.views.collapsingToolbar;
|
2
|
2
|
|
3
|
3
|
import android.content.Context;
|
4
|
|
-import android.support.annotation.Nullable;
|
5
|
4
|
import android.view.MotionEvent;
|
6
|
5
|
import android.view.View;
|
7
|
6
|
|
|
@@ -9,14 +8,15 @@ import com.reactnativenavigation.params.CollapsingTopBarParams;
|
9
|
8
|
import com.reactnativenavigation.params.StyleParams;
|
10
|
9
|
import com.reactnativenavigation.utils.ViewUtils;
|
11
|
10
|
import com.reactnativenavigation.views.TitleBar;
|
12
|
|
-import com.reactnativenavigation.views.TranslucentAndSolidTitleBarBackground;
|
|
11
|
+import com.reactnativenavigation.views.TitleBarBackground;
|
|
12
|
+import com.reactnativenavigation.views.TranslucentTitleBarBackground;
|
13
|
13
|
|
14
|
14
|
public class CollapsingTitleBar extends TitleBar implements View.OnTouchListener {
|
15
|
15
|
private CollapsingTextView title;
|
16
|
16
|
private int collapsedHeight;
|
17
|
17
|
private final ScrollListener scrollListener;
|
18
|
18
|
private final CollapsingTopBarParams params;
|
19
|
|
- private @Nullable TranslucentAndSolidTitleBarBackground titleBarBackground;
|
|
19
|
+ private TitleBarBackground titleBarBackground;
|
20
|
20
|
|
21
|
21
|
public CollapsingTitleBar(Context context, int collapsedHeight, ScrollListener scrollListener, CollapsingTopBarParams params) {
|
22
|
22
|
super(context);
|
|
@@ -45,17 +45,13 @@ public class CollapsingTitleBar extends TitleBar implements View.OnTouchListener
|
45
|
45
|
@Override
|
46
|
46
|
public void hideTitle() {
|
47
|
47
|
super.hideTitle();
|
48
|
|
- if (titleBarBackground != null) {
|
49
|
|
- titleBarBackground.showTranslucentBackground();
|
50
|
|
- }
|
|
48
|
+ titleBarBackground.showTranslucentBackground();
|
51
|
49
|
}
|
52
|
50
|
|
53
|
51
|
@Override
|
54
|
52
|
public void showTitle() {
|
55
|
53
|
super.showTitle();
|
56
|
|
- if (titleBarBackground != null) {
|
57
|
|
- titleBarBackground.showSolidBackground();
|
58
|
|
- }
|
|
54
|
+ titleBarBackground.showSolidBackground();
|
59
|
55
|
}
|
60
|
56
|
|
61
|
57
|
private void addCollapsingTitle() {
|
|
@@ -92,12 +88,14 @@ public class CollapsingTitleBar extends TitleBar implements View.OnTouchListener
|
92
|
88
|
|
93
|
89
|
@Override
|
94
|
90
|
protected void setBackground(StyleParams params) {
|
95
|
|
- if (hasTranslucentAndSolidBackground(params)) {
|
96
|
|
- titleBarBackground = new TranslucentAndSolidTitleBarBackground(params.collapsingTopBarParams.scrimColor);
|
97
|
|
- setBackground(titleBarBackground);
|
98
|
|
- } else {
|
99
|
|
- setTranslucent(params);
|
100
|
|
- }
|
|
91
|
+ titleBarBackground = createBackground(params);
|
|
92
|
+ setBackground(titleBarBackground);
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+ private TitleBarBackground createBackground(StyleParams params) {
|
|
96
|
+ return hasTranslucentAndSolidBackground(params) ?
|
|
97
|
+ new TitleBarBackground(params.collapsingTopBarParams.scrimColor) :
|
|
98
|
+ new TranslucentTitleBarBackground();
|
101
|
99
|
}
|
102
|
100
|
|
103
|
101
|
private boolean hasTranslucentAndSolidBackground(StyleParams params) {
|