Skip to content

Commit 143bb94

Browse files
committed
fix bug: CommonTabLayout first setCurrentTab() cause indicator not show
1 parent a11b5de commit 143bb94

File tree

7 files changed

+23
-11
lines changed

7 files changed

+23
-11
lines changed

CHNAGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ Version 1.4.0 *(2015-11-11)*
4343

4444
Version 1.4.2 *(2015-12-9)*
4545
----------------------------
46-
* new added tablayout
46+
* new added tablayout
47+
48+
Version 1.4.4 *(2015-12-11)*
49+
----------------------------
50+
* fix bug: CommonTabLayout first setCurrentTab() cause indicator not show

FlycoTabLayout_Lib/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ apply plugin: 'com.android.library'
33
//apply plugin: 'com.jfrog.bintray'
44

55
// 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version
6-
version = "1.4.2"
6+
version = "1.4.4"
77
android {
88
compileSdkVersion 23
99
buildToolsVersion "22.0.1"
1010

1111
defaultConfig {
1212
minSdkVersion 8
1313
targetSdkVersion 23
14-
versionCode 142
14+
versionCode 144
1515
versionName version
1616
}
1717
buildTypes {

FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private void obtainAttributes(Context context, AttributeSet attrs) {
149149
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CommonTabLayout);
150150

151151
indicatorStyle = ta.getInt(R.styleable.CommonTabLayout_tl_indicator_style, 0);
152-
indicatorColor = ta.getColor(R.styleable.CommonTabLayout_tl_indicator_color, Color.parseColor(indicatorStyle == STYLE_BLOCK ? "#4B6A87" : "#ffffff"));
152+
indicatorColor = ta.getColor(R.styleable.CommonTabLayout_tl_indicator_color, Color.parseColor(indicatorStyle == STYLE_BLOCK ? "#4B6A87" : "#ffffff"));
153153
indicatorHeight = ta.getDimension(R.styleable.CommonTabLayout_tl_indicator_height,
154154
dp2px(indicatorStyle == STYLE_TRIANGLE ? 4 : (indicatorStyle == STYLE_BLOCK ? -1 : 2)));
155155
indicatorWidth = ta.getDimension(R.styleable.CommonTabLayout_tl_indicator_width, dp2px(indicatorStyle == STYLE_TRIANGLE ? 10 : -1));
@@ -242,6 +242,7 @@ private void addTab(final int position, View tabView) {
242242
public void onClick(View v) {
243243
int position = (Integer) v.getTag();
244244
if (currentTab != position) {
245+
isFirstSet = false;
245246
setCurrentTab(position);
246247
if (listener != null) {
247248
listener.onTabSelect(position);
@@ -374,6 +375,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
374375
}
375376

376377
private boolean isFirstDraw = true;
378+
private boolean isFirstSet = true;
377379

378380
@Override
379381
protected void onDraw(Canvas canvas) {
@@ -479,7 +481,12 @@ public void setCurrentTab(int currentTab) {
479481
fragmentChangeManager.setFragments(currentTab);
480482
}
481483
if (indicatorAnimEnable) {
482-
calcOffset();
484+
if (isFirstSet) {
485+
invalidate();
486+
isFirstSet = false;
487+
} else {
488+
calcOffset();
489+
}
483490
} else {
484491
invalidate();
485492
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dependencies{
4545
compile 'com.android.support:support-v4:23.1.1'
4646
compile 'com.nineoldandroids:library:2.4.0'
4747
compile 'com.flyco.roundview:FlycoRoundView_Lib:1.1.2@aar'
48-
compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.2@aar'
48+
compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.4@aar'
4949
}
5050
```
5151

README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dependencies{
4444
compile 'com.android.support:support-v4:23.1.1'
4545
compile 'com.nineoldandroids:library:2.4.0'
4646
compile 'com.flyco.roundview:FlycoRoundView_Lib:1.1.2@aar'
47-
compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.2@aar'
47+
compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.4@aar'
4848
}
4949
```
5050

app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ android {
2222
dependencies {
2323
compile fileTree(dir: 'libs', include: ['*.jar'])
2424
compile 'com.android.support:appcompat-v7:23.1.1'
25-
// compile project(':FlycoTabLayout_Lib')
25+
compile project(':FlycoTabLayout_Lib')
2626

27-
compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.2@aar'
28-
compile 'com.flyco.roundview:FlycoRoundView_Lib:1.1.2@aar'
29-
compile 'com.nineoldandroids:library:2.4.0'
27+
// compile 'com.flyco.tablayout:FlycoTabLayout_Lib:1.4.4@aar'
28+
// compile 'com.flyco.roundview:FlycoRoundView_Lib:1.1.2@aar'
29+
// compile 'com.nineoldandroids:library:2.4.0'
3030
}

app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public void onTabReselect(int position) {
107107

108108
}
109109
});
110+
tl_8.setCurrentTab(2);
110111

111112
//显示未读红点
112113
tl_1.showDot(2);

0 commit comments

Comments
 (0)