Skip to content

Commit

Permalink
1、修复fixed模式下tab点击事件范围过小的问题
Browse files Browse the repository at this point in the history
2、修复TabView.setBadge某些情况下会重复添加BadgeView的问题
3、优化TabView
  • Loading branch information
rorbin committed Jun 23, 2017
1 parent 15a8795 commit c9de0fe
Show file tree
Hide file tree
Showing 17 changed files with 493 additions and 527 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.novoda:bintray-release:0.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
6 changes: 3 additions & 3 deletions verticaltablayout/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ publish {
userOrg = 'qstumn'
groupId = 'q.rorbin'
artifactId = 'VerticalTabLayout'
publishVersion = '1.2.2'
publishVersion = '1.2.3'
desc = 'This is a vertical direction TabLayout'
website = 'https://github.com/qstumn/VerticalTabLayout'
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:support-v4:25.2.0'
compile 'q.rorbin:badgeview:1.1.0'
provided 'com.android.support:support-v4:25.3.0'
compile 'q.rorbin:badgeview:1.1.2'
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package q.rorbin.verticaltablayout;

import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.content.Context;
Expand All @@ -25,7 +26,6 @@
import q.rorbin.verticaltablayout.util.DisplayUtil;
import q.rorbin.verticaltablayout.util.TabFragmentManager;
import q.rorbin.verticaltablayout.widget.QTabView;
import q.rorbin.verticaltablayout.widget.TabIndicator;
import q.rorbin.verticaltablayout.widget.TabView;

import static android.support.v4.view.ViewPager.SCROLL_STATE_IDLE;
Expand All @@ -44,7 +44,6 @@ public class VerticalTabLayout extends ScrollView {
private int mIndicatorWidth;
private int mIndicatorGravity;
private float mIndicatorCorners;
private TabIndicator mIndicator;
private int mTabMode;
private int mTabHeight;

Expand Down Expand Up @@ -245,6 +244,10 @@ public void setTabBadge(int tabPosition, int badgeNum) {
getTabAt(tabPosition).getBadgeView().setBadgeNumber(badgeNum);
}

public void setTabBadge(int tabPosition, String badgeText) {
getTabAt(tabPosition).getBadgeView().setBadgeText(badgeText);
}

public void setTabMode(int mode) {
if (mode != TAB_MODE_FIXED && mode != TAB_MODE_SCROLLABLE) {
throw new IllegalStateException("only support TAB_MODE_FIXED or TAB_MODE_SCROLLABLE");
Expand Down Expand Up @@ -344,6 +347,14 @@ public void setIndicatorGravity(int gravity) {
}
}

// public void setTabPadding(int padding) {
//
// }
//
// public void setTabPadding(int start, int top, int end, int bottom) {
//
// }

public void addOnTabSelectedListener(OnTabSelectedListener listener) {
if (listener != null) {
mTabSelectedListeners.add(listener);
Expand All @@ -365,8 +376,6 @@ public void setTabAdapter(TabAdapter adapter) {
.setTitle(adapter.getTitle(i)).setBadge(adapter.getBadge(i))
.setBackground(adapter.getBackground(i)));
}
} else {
removeAllTabs();
}
}

Expand Down Expand Up @@ -453,13 +462,10 @@ private void populateFromPagerAdapter() {
removeAllTabs();
if (mPagerAdapter != null) {
final int adapterCount = mPagerAdapter.getCount();
for (int i = 0; i < adapterCount; i++) {
if (mPagerAdapter instanceof TabAdapter) {
mTabAdapter = (TabAdapter) mPagerAdapter;
addTab(new QTabView(mContext).setIcon(mTabAdapter.getIcon(i))
.setTitle(mTabAdapter.getTitle(i)).setBadge(mTabAdapter.getBadge(i))
.setBackground(mTabAdapter.getBackground(i)));
} else {
if (mPagerAdapter instanceof TabAdapter) {
setTabAdapter((TabAdapter) mPagerAdapter);
} else {
for (int i = 0; i < adapterCount; i++) {
String title = mPagerAdapter.getPageTitle(i) == null ? "tab" + i : mPagerAdapter.getPageTitle(i).toString();
addTab(new QTabView(mContext).setTitle(
new QTabView.TabTitle.Builder().setContent(title).build()));
Expand Down Expand Up @@ -602,9 +608,11 @@ public void onAnimationUpdate(ValueAnimator animation) {
}
});
}
mIndicatorAnimatorSet = new AnimatorSet();
mIndicatorAnimatorSet.play(endAnime).after(startAnime);
mIndicatorAnimatorSet.start();
if (startAnime != null) {
mIndicatorAnimatorSet = new AnimatorSet();
mIndicatorAnimatorSet.play(endAnime).after(startAnime);
mIndicatorAnimatorSet.start();
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

public abstract class SimpleTabAdapter implements TabAdapter {
@Override
public int getCount() {
return 0;
}
public abstract int getCount();

@Override
public TabView.TabBadge getBadge(int position) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package q.rorbin.verticaltablayout.adapter;



import q.rorbin.verticaltablayout.widget.TabView;

/**
Expand Down
Loading

0 comments on commit c9de0fe

Please sign in to comment.