Skip to content

Commit 94070bf

Browse files
committed
fix issues #14
1 parent 339c97f commit 94070bf

File tree

6 files changed

+104
-20
lines changed

6 files changed

+104
-20
lines changed

.idea/markdown-navigator.xml

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/markdown-navigator/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ Add the dependency
2424
```groovy
2525
2626
dependencies {
27-
compile 'com.github.niorgai:StatusBarCompat:2.1.1'
27+
compile ('com.github.niorgai:StatusBarCompat:2.1.1', {
28+
exclude group: 'com.android.support'
29+
})
2830
}
2931
```
3032

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.2'
8+
classpath 'com.android.tools.build:gradle:2.2.3'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files
@@ -24,13 +24,13 @@ task clean(type: Delete) {
2424

2525
ext {
2626
configs = [
27-
buildToolsVersion : "24.0.2",
28-
compileSdkVersion : 24,
29-
targetSdkVersion : 24
27+
buildToolsVersion : "25.0.1",
28+
compileSdkVersion : 25,
29+
targetSdkVersion : 25
3030
]
3131

3232
libs = [
33-
supportVersion : "24.2.1"
33+
supportVersion : "25.1.0"
3434
]
3535
}
3636

library/src/main/java/qiu/niorgai/StatusBarCompatKitKat.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,14 @@ static void setStatusBarColorForCollapsingToolbar(Activity activity, final AppBa
186186
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
187187
if (Math.abs(verticalOffset) > appBarLayout.getHeight() - collapsingToolbarLayout.getScrimVisibleHeightTrigger()) {
188188
if (statusView.getAlpha() == 0) {
189+
statusView.animate().cancel();
189190
statusView.animate().alpha(1f).setDuration(collapsingToolbarLayout.getScrimAnimationDuration()).start();
190191
}
191192
} else {
192-
statusView.animate().cancel();
193-
statusView.setAlpha(0);
193+
if (statusView.getAlpha() == 1) {
194+
statusView.animate().cancel();
195+
statusView.animate().alpha(0f).setDuration(collapsingToolbarLayout.getScrimAnimationDuration()).start();
196+
}
194197
}
195198
}
196199
});

library/src/main/java/qiu/niorgai/StatusBarCompatLollipop.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,31 +124,40 @@ static void setStatusBarColorForCollapsingToolbar(Activity activity, final AppBa
124124
toolbar.setTag(true);
125125
}
126126

127-
collapsingToolbarLayout.setFitsSystemWindows(false);
128127
ViewCompat.setOnApplyWindowInsetsListener(collapsingToolbarLayout, new OnApplyWindowInsetsListener() {
129128
@Override
130129
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
131130
return insets;
132131
}
133132
});
134-
final ValueAnimator animator = ValueAnimator.ofArgb(Color.TRANSPARENT, statusColor)
135-
.setDuration(collapsingToolbarLayout.getScrimAnimationDuration());
136-
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
137-
@Override
138-
public void onAnimationUpdate(ValueAnimator animation) {
139-
window.setStatusBarColor((Integer) animation.getAnimatedValue());
140-
}
141-
});
133+
collapsingToolbarLayout.setFitsSystemWindows(false);
142134
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
143135
@Override
144136
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
145137
if (Math.abs(verticalOffset) > appBarLayout.getHeight() - collapsingToolbarLayout.getScrimVisibleHeightTrigger()) {
146-
if (window.getStatusBarColor() == Color.TRANSPARENT && !animator.isRunning()) {
138+
if (window.getStatusBarColor() == Color.TRANSPARENT) {
139+
ValueAnimator animator = ValueAnimator.ofArgb(Color.TRANSPARENT, statusColor)
140+
.setDuration(collapsingToolbarLayout.getScrimAnimationDuration());
141+
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
142+
@Override
143+
public void onAnimationUpdate(ValueAnimator valueAnimator) {
144+
window.setStatusBarColor((Integer) valueAnimator.getAnimatedValue());
145+
}
146+
});
147147
animator.start();
148148
}
149149
} else {
150-
animator.end();
151-
window.setStatusBarColor(Color.TRANSPARENT);
150+
if (window.getStatusBarColor() == statusColor) {
151+
ValueAnimator animator = ValueAnimator.ofArgb(statusColor, Color.TRANSPARENT)
152+
.setDuration(collapsingToolbarLayout.getScrimAnimationDuration());
153+
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
154+
@Override
155+
public void onAnimationUpdate(ValueAnimator valueAnimator) {
156+
window.setStatusBarColor((Integer) valueAnimator.getAnimatedValue());
157+
}
158+
});
159+
animator.start();
160+
}
152161
}
153162
}
154163
});

0 commit comments

Comments
 (0)