From 55894ea949caff3f21127f0f813ea18d3fb1277b Mon Sep 17 00:00:00 2001 From: H07000223 <867318349@qq.com> Date: Fri, 28 Oct 2016 15:47:32 +0800 Subject: [PATCH] remove Application label in manifest add method to make viewpager snap on tab click --- CHNAGELOG.md | 5 +++++ FlycoTabLayout_Lib/build.gradle | 4 ++-- FlycoTabLayout_Lib/src/main/AndroidManifest.xml | 10 +--------- .../java/com/flyco/tablayout/SlidingTabLayout.java | 13 +++++++++++-- README.md | 2 +- README_CN.md | 2 +- app/build.gradle | 2 +- build.gradle | 4 ++-- 8 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CHNAGELOG.md b/CHNAGELOG.md index 84ade8f7..a699ba6d 100644 --- a/CHNAGELOG.md +++ b/CHNAGELOG.md @@ -75,4 +75,9 @@ Version 2.0.8 *(2016.7.26)* --------------------------- * Fix #27,#31(new added method 'setCurrentTab(int currentTab, boolean smoothScroll)' for SlidingTabLayout and redefine attr 'tl_textBold') +Version 2.1.0 *(2016.10.28)* +---------------------------- +* remove Application label in manifest +* add method to make viewpager snap on tab click + diff --git a/FlycoTabLayout_Lib/build.gradle b/FlycoTabLayout_Lib/build.gradle index da8100a2..34e6feb0 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 = "2.0.8" +version = "2.1.0" android { compileSdkVersion 23 buildToolsVersion "23.0.3" @@ -11,7 +11,7 @@ android { defaultConfig { minSdkVersion 11 targetSdkVersion 23 - versionCode 208 + versionCode 210 versionName version } buildTypes { diff --git a/FlycoTabLayout_Lib/src/main/AndroidManifest.xml b/FlycoTabLayout_Lib/src/main/AndroidManifest.xml index 0cb7523c..65a3365c 100644 --- a/FlycoTabLayout_Lib/src/main/AndroidManifest.xml +++ b/FlycoTabLayout_Lib/src/main/AndroidManifest.xml @@ -1,11 +1,3 @@ - - - - - + package="com.flyco.tablayout"> 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 31ea2599..9ab7e5ed 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java @@ -95,6 +95,7 @@ public class SlidingTabLayout extends HorizontalScrollView implements ViewPager. private int mLastScrollX; private int mHeight; + private boolean mSnapOnTabClick; public SlidingTabLayout(Context context) { this(context, null, 0); @@ -120,7 +121,6 @@ public SlidingTabLayout(Context context, AttributeSet attrs, int defStyleAttr) { //get layout_height String height = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "layout_height"); - //create ViewPager if (height.equals(ViewGroup.LayoutParams.MATCH_PARENT + "")) { } else if (height.equals(ViewGroup.LayoutParams.WRAP_CONTENT + "")) { } else { @@ -262,7 +262,12 @@ public void onClick(View v) { int position = mTabsContainer.indexOfChild(v); if (position != -1) { if (mViewPager.getCurrentItem() != position) { - mViewPager.setCurrentItem(position); + if (mSnapOnTabClick) { + mViewPager.setCurrentItem(position, false); + } else { + mViewPager.setCurrentItem(position); + } + if (mListener != null) { mListener.onTabSelect(position); } @@ -644,6 +649,10 @@ public void setTextAllCaps(boolean textAllCaps) { updateTabStyles(); } + public void setSnapOnTabClick(boolean snapOnTabClick) { + mSnapOnTabClick = snapOnTabClick; + } + public int getTabCount() { return mTabCount; diff --git a/README.md b/README.md index 2c790e89..49717dc5 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ dependencies{ After v2.0.2(support 3.0+) dependencies{ compile 'com.android.support:support-v4:23.1.1' - compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.8@aar' + compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.0@aar' } ``` diff --git a/README_CN.md b/README_CN.md index 419d1fa7..3200bf46 100644 --- a/README_CN.md +++ b/README_CN.md @@ -67,7 +67,7 @@ dependencies{ After v2.0.2(support 3.0+) dependencies{ compile 'com.android.support:support-v4:23.1.1' - compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.8@aar' + compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.0@aar' } ``` diff --git a/app/build.gradle b/app/build.gradle index a9f79410..0f686592 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,7 +25,7 @@ dependencies { compile project(':FlycoTabLayout_Lib') //--->support 3.0+ -// compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.8@aar' +// compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.0@aar' //--->support 2.2+ // compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.0@aar' // compile 'com.nineoldandroids:library:2.4.0' diff --git a/build.gradle b/build.gradle index b434b2e3..fb34b949 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,8 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.2.2' -// classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' -// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1' +// 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 // in the individual module build.gradle files }