diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java index 9ab7e5ed..bd328262 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java @@ -33,7 +33,9 @@ import java.util.ArrayList; import java.util.Collections; -/** 滑动TabLayout,对于ViewPager的依赖性强 */ +/** + * 滑动TabLayout,对于ViewPager的依赖性强 + */ public class SlidingTabLayout extends HorizontalScrollView implements ViewPager.OnPageChangeListener { private Context mContext; private ViewPager mViewPager; @@ -42,9 +44,13 @@ public class SlidingTabLayout extends HorizontalScrollView implements ViewPager. private int mCurrentTab; private float mCurrentPositionOffset; private int mTabCount; - /** 用于绘制显示器 */ + /** + * 用于绘制显示器 + */ private Rect mIndicatorRect = new Rect(); - /** 用于实现滚动居中 */ + /** + * 用于实现滚动居中 + */ private Rect mTabRect = new Rect(); private GradientDrawable mIndicatorDrawable = new GradientDrawable(); @@ -61,7 +67,9 @@ public class SlidingTabLayout extends HorizontalScrollView implements ViewPager. private boolean mTabSpaceEqual; private float mTabWidth; - /** indicator */ + /** + * indicator + */ private int mIndicatorColor; private float mIndicatorHeight; private float mIndicatorWidth; @@ -73,17 +81,23 @@ public class SlidingTabLayout extends HorizontalScrollView implements ViewPager. private int mIndicatorGravity; private boolean mIndicatorWidthEqualTitle; - /** underline */ + /** + * underline + */ private int mUnderlineColor; private float mUnderlineHeight; private int mUnderlineGravity; - /** divider */ + /** + * divider + */ private int mDividerColor; private float mDividerWidth; private float mDividerPadding; - /** title */ + /** + * title + */ private static final int TEXT_BOLD_NONE = 0; private static final int TEXT_BOLD_WHEN_SELECT = 1; private static final int TEXT_BOLD_BOTH = 2; @@ -168,7 +182,9 @@ private void obtainAttributes(Context context, AttributeSet attrs) { ta.recycle(); } - /** 关联ViewPager */ + /** + * 关联ViewPager + */ public void setViewPager(ViewPager vp) { if (vp == null || vp.getAdapter() == null) { throw new IllegalStateException("ViewPager or ViewPager adapter can not be NULL !"); @@ -181,7 +197,9 @@ public void setViewPager(ViewPager vp) { notifyDataSetChanged(); } - /** 关联ViewPager,用于不想在ViewPager适配器中设置titles数据的情况 */ + /** + * 关联ViewPager,用于不想在ViewPager适配器中设置titles数据的情况 + */ public void setViewPager(ViewPager vp, String[] titles) { if (vp == null || vp.getAdapter() == null) { throw new IllegalStateException("ViewPager or ViewPager adapter can not be NULL !"); @@ -204,7 +222,9 @@ public void setViewPager(ViewPager vp, String[] titles) { notifyDataSetChanged(); } - /** 关联ViewPager,用于连适配器都不想自己实例化的情况 */ + /** + * 关联ViewPager,用于连适配器都不想自己实例化的情况 + */ public void setViewPager(ViewPager vp, String[] titles, FragmentActivity fa, ArrayList fragments) { if (vp == null) { throw new IllegalStateException("ViewPager can not be NULL !"); @@ -222,7 +242,9 @@ public void setViewPager(ViewPager vp, String[] titles, FragmentActivity fa, Arr notifyDataSetChanged(); } - /** 更新数据 */ + /** + * 更新数据 + */ public void notifyDataSetChanged() { mTabsContainer.removeAllViews(); this.mTabCount = mTitles == null ? mViewPager.getAdapter().getCount() : mTitles.size(); @@ -249,7 +271,9 @@ public void addNewTab(String title) { updateTabStyles(); } - /** 创建并添加tab */ + /** + * 创建并添加tab + */ private void addTab(final int position, String title, View tabView) { TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title); if (tv_tab_title != null) { @@ -334,7 +358,9 @@ public void onPageSelected(int position) { public void onPageScrollStateChanged(int state) { } - /** HorizontalScrollView滚到当前tab,并且居中显示 */ + /** + * HorizontalScrollView滚到当前tab,并且居中显示 + */ private void scrollToCurrentTab() { if (mTabCount <= 0) { return; @@ -387,8 +413,8 @@ private void calcIndicatorRect() { if (mIndicatorStyle == STYLE_NORMAL && mIndicatorWidthEqualTitle) { TextView tab_title = (TextView) currentTabView.findViewById(R.id.tv_tab_title); mTextPaint.setTextSize(mTextsize); - float textWidth = mTextPaint.measureText(tab_title.getText().toString()); - margin = (right - left - textWidth) / 2; + float contentWidth = tab_title.getMeasuredWidth() - tab_title.getPaddingLeft() - tab_title.getPaddingRight(); + margin = (right - left - contentWidth) / 2; } if (this.mCurrentTab < mTabCount - 1) { @@ -799,7 +825,9 @@ public void showDot(int position) { showMsg(position, 0); } - /** 隐藏未读消息 */ + /** + * 隐藏未读消息 + */ public void hideMsg(int position) { if (position >= mTabCount) { position = mTabCount - 1; @@ -812,7 +840,9 @@ public void hideMsg(int position) { } } - /** 设置未读消息偏移,原点为文字的右上角.当控件高度固定,消息提示位置易控制,显示效果佳 */ + /** + * 设置未读消息偏移,原点为文字的右上角.当控件高度固定,消息提示位置易控制,显示效果佳 + */ public void setMsgMargin(int position, float leftPadding, float bottomPadding) { if (position >= mTabCount) { position = mTabCount - 1; @@ -831,7 +861,9 @@ public void setMsgMargin(int position, float leftPadding, float bottomPadding) { } } - /** 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取MsgView对象从而各种设置 */ + /** + * 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取MsgView对象从而各种设置 + */ public MsgView getMsgView(int position) { if (position >= mTabCount) { position = mTabCount - 1; diff --git a/build.gradle b/build.gradle index 062f3830..5e2f118b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:2.3.3' // classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' // classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.2' // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle.properties b/gradle.properties index 1d3591c8..539ed0c8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,17 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. - +## Project-wide Gradle settings. +# # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html - +# # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx10248m -XX:MaxPermSize=256m +# Default value: -Xmx1024m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - +# # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file +# org.gradle.parallel=true +#Fri Aug 25 15:19:52 CST 2017 +systemProp.http.proxyHost=127.0.0.1 +systemProp.http.proxyPort=6153 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 77c260b9..356eb557 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Oct 10 13:13:42 CST 2015 +#Fri Aug 25 15:20:13 CST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip