diff --git a/CHNAGELOG.md b/CHNAGELOG.md index 43b26371..c38564ef 100644 --- a/CHNAGELOG.md +++ b/CHNAGELOG.md @@ -47,4 +47,8 @@ Version 1.4.2 *(2015-12-9)* Version 1.4.4 *(2015-12-11)* ---------------------------- +* fix bug: CommonTabLayout first setCurrentTab() cause indicator not show + +Version 1.4.6 *(2015-12-11)* +---------------------------- * fix bug: CommonTabLayout first setCurrentTab() cause indicator not show \ No newline at end of file diff --git a/FlycoTabLayout_Lib/build.gradle b/FlycoTabLayout_Lib/build.gradle index 9d7ba67f..c6c4544e 100644 --- a/FlycoTabLayout_Lib/build.gradle +++ b/FlycoTabLayout_Lib/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.library' //apply plugin: 'com.jfrog.bintray' // 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version -version = "1.4.4" +version = "1.4.6" android { compileSdkVersion 23 buildToolsVersion "22.0.1" @@ -11,7 +11,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 23 - versionCode 144 + versionCode 146 versionName version } buildTypes { diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java index 37f3f150..9d23a817 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java @@ -242,7 +242,6 @@ private void addTab(final int position, View tabView) { public void onClick(View v) { int position = (Integer) v.getTag(); if (currentTab != position) { - isFirstSet = false; setCurrentTab(position); if (listener != null) { listener.onTabSelect(position); @@ -327,16 +326,22 @@ private void calcOffset() { lp.left = lastTabView.getLeft(); lp.right = lastTabView.getRight(); - valueAnimator.setObjectValues(lp, cp); - if (indicatorBounceEnable) { - valueAnimator.setInterpolator(interpolator); - } +// Log.d("AAA", "lp--->" + lp.left + "&" + lp.right); +// Log.d("AAA", "cp--->" + cp.left + "&" + cp.right); + if (lp.left == cp.left && lp.right == cp.right) { + invalidate(); + } else { + valueAnimator.setObjectValues(lp, cp); + if (indicatorBounceEnable) { + valueAnimator.setInterpolator(interpolator); + } - if (indicatorAnimDuration < 0) { - indicatorAnimDuration = indicatorBounceEnable ? 500 : 250; + if (indicatorAnimDuration < 0) { + indicatorAnimDuration = indicatorBounceEnable ? 500 : 250; + } + valueAnimator.setDuration(indicatorAnimDuration); + valueAnimator.start(); } - valueAnimator.setDuration(indicatorAnimDuration); - valueAnimator.start(); } private void calcIndicatorRect() { @@ -363,6 +368,7 @@ public void onAnimationUpdate(ValueAnimator animation) { IndicatorPoint p = (IndicatorPoint) animation.getAnimatedValue(); indicatorRect.left = (int) p.left; indicatorRect.right = (int) p.right; + if (indicatorWidth < 0) { //indicatorWidth小于0时,原jpardogo's PagerSlidingTabStrip } else {//indicatorWidth大于0时,圆角矩形以及三角形 @@ -375,7 +381,6 @@ public void onAnimationUpdate(ValueAnimator animation) { } private boolean isFirstDraw = true; - private boolean isFirstSet = true; @Override protected void onDraw(Canvas canvas) { @@ -481,12 +486,7 @@ public void setCurrentTab(int currentTab) { fragmentChangeManager.setFragments(currentTab); } if (indicatorAnimEnable) { - if (isFirstSet) { - invalidate(); - isFirstSet = false; - } else { - calcOffset(); - } + calcOffset(); } else { invalidate(); } diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java index ea99a196..536f7920 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java @@ -12,6 +12,7 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.util.AttributeSet; +import android.util.Log; import android.util.SparseArray; import android.util.TypedValue; import android.view.Gravity; @@ -198,7 +199,6 @@ private void addTab(final int position, View tabView) { public void onClick(View v) { int position = (Integer) v.getTag(); if (currentTab != position) { - isFirstSet = false; setCurrentTab(position); if (listener != null) { listener.onTabSelect(position); @@ -257,16 +257,22 @@ private void calcOffset() { lp.left = lastTabView.getLeft(); lp.right = lastTabView.getRight(); - valueAnimator.setObjectValues(lp, cp); - if (indicatorBounceEnable) { - valueAnimator.setInterpolator(interpolator); - } +// Log.d("AAA", "lp--->" + lp.left + "&" + lp.right); +// Log.d("AAA", "cp--->" + cp.left + "&" + cp.right); + if (lp.left == cp.left && lp.right == cp.right) { + invalidate(); + } else { + valueAnimator.setObjectValues(lp, cp); + if (indicatorBounceEnable) { + valueAnimator.setInterpolator(interpolator); + } - if (indicatorAnimDuration < 0) { - indicatorAnimDuration = indicatorBounceEnable ? 500 : 250; + if (indicatorAnimDuration < 0) { + indicatorAnimDuration = indicatorBounceEnable ? 500 : 250; + } + valueAnimator.setDuration(indicatorAnimDuration); + valueAnimator.start(); } - valueAnimator.setDuration(indicatorAnimDuration); - valueAnimator.start(); } private void calcIndicatorRect() { @@ -331,7 +337,6 @@ public void onAnimationUpdate(ValueAnimator animation) { } private boolean isFirstDraw = true; - private boolean isFirstSet = true; @Override protected void onDraw(Canvas canvas) { @@ -398,12 +403,7 @@ public void setCurrentTab(int currentTab) { fragmentChangeManager.setFragments(currentTab); } if (indicatorAnimEnable) { - if (isFirstSet) { - invalidate(); - isFirstSet = false; - } else { - calcOffset(); - } + calcOffset(); } else { invalidate(); } diff --git a/README.md b/README.md index abd52177..e794eb7a 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ dependencies{ compile 'com.android.support:support-v4:23.1.1' compile 'com.nineoldandroids:library:2.4.0' compile 'com.flyco.roundview:FlycoRoundView_Lib:1.1.2@aar' - compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.4@aar' + compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.6@aar' } ``` diff --git a/README_CN.md b/README_CN.md index 786e8501..e03e1daa 100644 --- a/README_CN.md +++ b/README_CN.md @@ -44,7 +44,7 @@ dependencies{ compile 'com.android.support:support-v4:23.1.1' compile 'com.nineoldandroids:library:2.4.0' compile 'com.flyco.roundview:FlycoRoundView_Lib:1.1.2@aar' - compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.4@aar' + compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.6@aar' } ``` diff --git a/app/build.gradle b/app/build.gradle index 849c3e3c..5dcaf085 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,8 +23,7 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.1.1' compile project(':FlycoTabLayout_Lib') - -// compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.4@aar' +// compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.6@aar' // compile 'com.flyco.roundview:FlycoRoundView_Lib:1.1.2@aar' // compile 'com.nineoldandroids:library:2.4.0' } diff --git a/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java b/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java index 61974555..89a51986 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java @@ -108,6 +108,7 @@ public void onTabReselect(int position) { } }); tl_8.setCurrentTab(2); + tl_3.setCurrentTab(1); //显示未读红点 tl_1.showDot(2);