From c5bceca57d8a765bfb54434ae3daea64ab0f1703 Mon Sep 17 00:00:00 2001 From: lizk Date: Wed, 1 Nov 2017 11:33:43 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=A2=9E=E5=8A=A0drawable=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/flyco/tablayout/CommonTabLayout.java | 17 ++++-- .../tablayout/listener/CustomTabEntity.java | 4 ++ .../flyco/tablayout/listener/TabEntity.java | 53 +++++++++++++++++++ 3 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/TabEntity.java 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 b0db9cd1..df4dc23d 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java @@ -9,6 +9,7 @@ import android.graphics.Paint; import android.graphics.Path; import android.graphics.Rect; +import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.os.Bundle; import android.os.Parcelable; @@ -235,7 +236,7 @@ private void addTab(final int position, View tabView) { TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title); tv_tab_title.setText(mTabEntitys.get(position).getTabTitle()); ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon); - iv_tab_icon.setImageResource(mTabEntitys.get(position).getTabUnselectedIcon()); + updateTabIcon(iv_tab_icon, mTabEntitys.get(position), false); tabView.setOnClickListener(new OnClickListener() { @Override @@ -286,7 +287,7 @@ private void updateTabStyles() { if (mIconVisible) { iv_tab_icon.setVisibility(View.VISIBLE); CustomTabEntity tabEntity = mTabEntitys.get(i); - iv_tab_icon.setImageResource(i == mCurrentTab ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon()); + updateTabIcon(iv_tab_icon, tabEntity, i == mCurrentTab); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( mIconWidth <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconWidth, mIconHeight <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconHeight); @@ -315,13 +316,23 @@ private void updateTabSelection(int position) { tab_title.setTextColor(isSelect ? mTextSelectColor : mTextUnselectColor); ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon); CustomTabEntity tabEntity = mTabEntitys.get(i); - iv_tab_icon.setImageResource(isSelect ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon()); + updateTabIcon(iv_tab_icon, tabEntity, isSelect); if (mTextBold == TEXT_BOLD_WHEN_SELECT) { tab_title.getPaint().setFakeBoldText(isSelect); } } } + protected void updateTabIcon(ImageView tabIcon, CustomTabEntity tabEntity, boolean isSelected) { + Drawable d = isSelected ? tabEntity.getTabSelectedDrawable() : tabEntity.getTabUnselectedDrawable(); + if (d != null) { + tabIcon.setImageDrawable(d); + } else { + int resId = isSelected ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon(); + tabIcon.setImageResource(resId); + } + } + private void calcOffset() { final View currentTabView = mTabsContainer.getChildAt(this.mCurrentTab); mCurrentP.left = currentTabView.getLeft(); diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/CustomTabEntity.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/CustomTabEntity.java index 52da607a..364587c8 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/CustomTabEntity.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/CustomTabEntity.java @@ -1,5 +1,6 @@ package com.flyco.tablayout.listener; +import android.graphics.drawable.Drawable; import android.support.annotation.DrawableRes; public interface CustomTabEntity { @@ -10,4 +11,7 @@ public interface CustomTabEntity { @DrawableRes int getTabUnselectedIcon(); + + Drawable getTabSelectedDrawable(); + Drawable getTabUnselectedDrawable(); } \ No newline at end of file diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/TabEntity.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/TabEntity.java new file mode 100644 index 00000000..7e86f8ad --- /dev/null +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/TabEntity.java @@ -0,0 +1,53 @@ +package com.flyco.tablayout.listener; + +import android.graphics.drawable.Drawable; + +/** + * Created by lizk on 2017/11/1. + */ + +public class TabEntity implements CustomTabEntity { + + private String tabTitle; + private Drawable selectedDrawable; + private Drawable unselectedDrawable; + private int selectedIcon; + private int unSelectedIcon; + + public TabEntity(String tabTitle, Drawable selectedDrawable, Drawable unselectedDrawable) { + this.tabTitle = tabTitle; + this.selectedDrawable = selectedDrawable; + this.unselectedDrawable = unselectedDrawable; + } + + public TabEntity(String tabTitle, int selectedIcon, int unselectedIcon) { + this.tabTitle = tabTitle; + this.selectedIcon = selectedIcon; + this.unSelectedIcon = unselectedIcon; + } + + @Override + public String getTabTitle() { + return tabTitle; + } + + @Override + public int getTabSelectedIcon() { + return selectedIcon; + } + + @Override + public int getTabUnselectedIcon() { + return unSelectedIcon; + } + + @Override + public Drawable getTabSelectedDrawable() { + return selectedDrawable; + } + + @Override + public Drawable getTabUnselectedDrawable() { + return unselectedDrawable; + } +} From bdf356b6004a9caebfbffa015f592a05c47825f2 Mon Sep 17 00:00:00 2001 From: lizk Date: Wed, 1 Nov 2017 14:23:10 +0800 Subject: [PATCH 2/9] =?UTF-8?q?app=E9=A1=B9=E7=9B=AE=EF=BC=8C=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 ++-- .../flyco/tablayoutsamples/entity/TabEntity.java | 16 ++++++++++++++++ .../tablayoutsamples/ui/CommonTabActivity.java | 8 +++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f2f86d4d..9d16d63e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,10 +22,10 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:25.1.0' -// compile project(':FlycoTabLayout_Lib') + compile project(':FlycoTabLayout_Lib') //--->support 3.0+ - compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' +// compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' //--->support 2.2+ // compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.0@aar' // compile 'com.nineoldandroids:library:2.4.0' diff --git a/app/src/main/java/com/flyco/tablayoutsamples/entity/TabEntity.java b/app/src/main/java/com/flyco/tablayoutsamples/entity/TabEntity.java index 3fb20139..00fdeb4f 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/entity/TabEntity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/entity/TabEntity.java @@ -1,5 +1,7 @@ package com.flyco.tablayoutsamples.entity; +import android.graphics.drawable.Drawable; + import com.flyco.tablayout.listener.CustomTabEntity; public class TabEntity implements CustomTabEntity { @@ -7,6 +9,9 @@ public class TabEntity implements CustomTabEntity { public int selectedIcon; public int unSelectedIcon; + public Drawable selectedDrawable; + public Drawable unselectedDrawable; + public TabEntity(String title, int selectedIcon, int unSelectedIcon) { this.title = title; this.selectedIcon = selectedIcon; @@ -27,4 +32,15 @@ public int getTabSelectedIcon() { public int getTabUnselectedIcon() { return unSelectedIcon; } + + @Override + public Drawable getTabSelectedDrawable() { + return selectedDrawable; + } + + @Override + public Drawable getTabUnselectedDrawable() { + return unselectedDrawable; + } + } 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 b898c2ce..f6927234 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java @@ -6,6 +6,7 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.view.View; @@ -58,7 +59,12 @@ protected void onCreate(Bundle savedInstanceState) { for (int i = 0; i < mTitles.length; i++) { - mTabEntities.add(new TabEntity(mTitles[i], mIconSelectIds[i], mIconUnselectIds[i])); + TabEntity tabEntity = new TabEntity(mTitles[i], mIconSelectIds[i], mIconUnselectIds[i]); + mTabEntities.add(tabEntity); + if (i == 1) { + tabEntity.selectedDrawable = ContextCompat.getDrawable(this, mIconUnselectIds[i]); + tabEntity.unselectedDrawable = ContextCompat.getDrawable(this, mIconSelectIds[i]); + } } mDecorView = getWindow().getDecorView(); From 11f4efd647b2af0d7df34faa81dbc80e1e44b0c7 Mon Sep 17 00:00:00 2001 From: lizk Date: Wed, 1 Nov 2017 16:28:01 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/flyco/tablayoutsamples/ui/CommonTabActivity.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) 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 f6927234..1be82467 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java @@ -59,12 +59,7 @@ protected void onCreate(Bundle savedInstanceState) { for (int i = 0; i < mTitles.length; i++) { - TabEntity tabEntity = new TabEntity(mTitles[i], mIconSelectIds[i], mIconUnselectIds[i]); - mTabEntities.add(tabEntity); - if (i == 1) { - tabEntity.selectedDrawable = ContextCompat.getDrawable(this, mIconUnselectIds[i]); - tabEntity.unselectedDrawable = ContextCompat.getDrawable(this, mIconSelectIds[i]); - } + mTabEntities.add(new TabEntity(mTitles[i], mIconSelectIds[i], mIconUnselectIds[i])); } mDecorView = getWindow().getDecorView(); From 3bfa5ced9f49c993acddfb94ce2278505959552b Mon Sep 17 00:00:00 2001 From: lizk Date: Wed, 1 Nov 2017 16:31:01 +0800 Subject: [PATCH 4/9] add drawable constructor --- .../java/com/flyco/tablayoutsamples/entity/TabEntity.java | 6 ++++++ .../com/flyco/tablayoutsamples/ui/CommonTabActivity.java | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/flyco/tablayoutsamples/entity/TabEntity.java b/app/src/main/java/com/flyco/tablayoutsamples/entity/TabEntity.java index 00fdeb4f..c861469a 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/entity/TabEntity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/entity/TabEntity.java @@ -18,6 +18,12 @@ public TabEntity(String title, int selectedIcon, int unSelectedIcon) { this.unSelectedIcon = unSelectedIcon; } + public TabEntity(String title, Drawable selectedDrawable, Drawable unselectedDrawable) { + this.title = title; + this.selectedDrawable = selectedDrawable; + this.unselectedDrawable= unselectedDrawable; + } + @Override public String getTabTitle() { return title; 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 1be82467..b898c2ce 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java @@ -6,7 +6,6 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.view.View; From f2ba75b6e89ef8a6f8cdae9d36a472c83acda332 Mon Sep 17 00:00:00 2001 From: lizk Date: Mon, 22 Nov 2021 15:50:17 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0gradle=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FlycoTabLayout_Lib/build.gradle | 27 ++++++++++++++----- .../tablayout/listener/CustomTabEntity.java | 2 +- app/build.gradle | 13 +++++---- build.gradle | 12 ++++++--- gradle/wrapper/gradle-wrapper.properties | 3 +-- 5 files changed, 36 insertions(+), 21 deletions(-) diff --git a/FlycoTabLayout_Lib/build.gradle b/FlycoTabLayout_Lib/build.gradle index 166f8c62..c937e59a 100644 --- a/FlycoTabLayout_Lib/build.gradle +++ b/FlycoTabLayout_Lib/build.gradle @@ -1,16 +1,16 @@ apply plugin: 'com.android.library' //apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'maven-publish' //apply plugin: 'com.jfrog.bintray' // 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version -version = "2.1.2" +version = "2.1.3" android { - compileSdkVersion 25 - buildToolsVersion "25.0.1" + compileSdkVersion 30 defaultConfig { minSdkVersion 11 - targetSdkVersion 25 + targetSdkVersion 30 versionCode 212 versionName version } @@ -23,13 +23,26 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:25.1.0' + api fileTree(dir: 'libs', include: ['*.jar']) + api 'androidx.legacy:legacy-support-v4:1.0.0' +} + +group = "com.github.lizhongkan" // Maven Group ID for the artifact,一般填你唯一的包名 +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + from components.release + groupId = 'com.github.lizhongkan' + artifactId = 'FlycoTableLayout' + version = '2.1.3' + } + } + } } //def siteUrl = 'https://github.com/H07000223' // 项目的主页 //def gitUrl = 'https://github.com/H07000223' // Git仓库的url -//group = "com.flyco.tablayout" // Maven Group ID for the artifact,一般填你唯一的包名 //install { // repositories.mavenInstaller { // // This generates POM.xml with proper parameters diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/CustomTabEntity.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/CustomTabEntity.java index 364587c8..e41d0056 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/CustomTabEntity.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/listener/CustomTabEntity.java @@ -1,7 +1,7 @@ package com.flyco.tablayout.listener; import android.graphics.drawable.Drawable; -import android.support.annotation.DrawableRes; +import androidx.annotation.DrawableRes; public interface CustomTabEntity { String getTabTitle(); diff --git a/app/build.gradle b/app/build.gradle index 9d16d63e..26479487 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 30 defaultConfig { applicationId "com.flyco.tablayoutsamples" - minSdkVersion 11 - targetSdkVersion 25 + minSdkVersion 23 + targetSdkVersion 30 versionCode 1 versionName "1.0" } @@ -20,9 +19,9 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:25.1.0' - compile project(':FlycoTabLayout_Lib') + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:25.1.0' + implementation project(':FlycoTabLayout_Lib') //--->support 3.0+ // compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' diff --git a/build.gradle b/build.gradle index 062f3830..dc1bb7b4 100644 --- a/build.gradle +++ b/build.gradle @@ -2,11 +2,13 @@ buildscript { repositories { - jcenter() + mavenCentral() + google() + maven { url 'https://repo1.maven.org/maven2/' } } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' -// classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' + classpath 'com.android.tools.build:gradle:7.0.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.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 @@ -15,7 +17,9 @@ buildscript { allprojects { repositories { - jcenter() + mavenCentral() + google() + maven { url 'https://repo1.maven.org/maven2/' } // maven { // url "http://dl.bintray.com/h07000223/maven" // } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 77c260b9..0f80bbf5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Sat Oct 10 13:13:42 CST 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip From a830f5629fd72d419142b808c8b4df710ff156f3 Mon Sep 17 00:00:00 2001 From: lizk Date: Mon, 22 Nov 2021 16:45:52 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E9=81=BF=E5=85=8Djitpack=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 5 +++++ jitpack.yml | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 jitpack.yml diff --git a/app/build.gradle b/app/build.gradle index 26479487..f0262ccd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,6 +16,11 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } dependencies { diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 00000000..46c85291 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +jdk: + - openjdk11 \ No newline at end of file From 4bc72b5634608e0b03253a237e037984228ef196 Mon Sep 17 00:00:00 2001 From: lizk Date: Mon, 22 Nov 2021 16:56:41 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E4=B8=8D=E8=B5=B7=E4=BD=9C=E7=94=A8?= =?UTF-8?q?=E3=80=82=E3=80=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 5 ----- jitpack.yml | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f0262ccd..26479487 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,11 +16,6 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } } dependencies { diff --git a/jitpack.yml b/jitpack.yml index 46c85291..a367222d 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -1,2 +1,3 @@ jdk: - - openjdk11 \ No newline at end of file + - openjdk11 + \ No newline at end of file From 0a789d7d04f969595d8837a4f55844649f5a755c Mon Sep 17 00:00:00 2001 From: lizk Date: Mon, 22 Nov 2021 16:57:28 +0800 Subject: [PATCH 8/9] version --- FlycoTabLayout_Lib/build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/FlycoTabLayout_Lib/build.gradle b/FlycoTabLayout_Lib/build.gradle index c937e59a..55064a83 100644 --- a/FlycoTabLayout_Lib/build.gradle +++ b/FlycoTabLayout_Lib/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'maven-publish' //apply plugin: 'com.jfrog.bintray' // 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version -version = "2.1.3" android { compileSdkVersion 30 @@ -35,7 +34,7 @@ afterEvaluate { from components.release groupId = 'com.github.lizhongkan' artifactId = 'FlycoTableLayout' - version = '2.1.3' + version = '2.1.4' } } } From fb162624823e4b24ad4340afd2b7683fff540394 Mon Sep 17 00:00:00 2001 From: lizk Date: Mon, 22 Nov 2021 17:10:10 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E9=80=82=E9=85=8Dandroidx=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FlycoTabLayout_Lib/build.gradle | 2 +- .../java/com/flyco/tablayout/CommonTabLayout.java | 5 +++-- .../java/com/flyco/tablayout/SegmentTabLayout.java | 5 +++-- .../java/com/flyco/tablayout/SlidingTabLayout.java | 13 +++++++------ .../tablayout/utils/FragmentChangeManager.java | 7 ++++--- .../tablayoutsamples/ui/CommonTabActivity.java | 11 ++++++----- .../tablayoutsamples/ui/SegmentTabActivity.java | 11 ++++++----- .../tablayoutsamples/ui/SimpleCardFragment.java | 3 ++- .../tablayoutsamples/ui/SimpleHomeActivity.java | 3 ++- .../tablayoutsamples/ui/SlidingTabActivity.java | 11 ++++++----- gradle.properties | 4 +++- 11 files changed, 43 insertions(+), 32 deletions(-) diff --git a/FlycoTabLayout_Lib/build.gradle b/FlycoTabLayout_Lib/build.gradle index 55064a83..bbd7d235 100644 --- a/FlycoTabLayout_Lib/build.gradle +++ b/FlycoTabLayout_Lib/build.gradle @@ -34,7 +34,7 @@ afterEvaluate { from components.release groupId = 'com.github.lizhongkan' artifactId = 'FlycoTableLayout' - version = '2.1.4' + version = '2.1.5' } } } 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 df4dc23d..317c2e17 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java @@ -13,8 +13,6 @@ import android.graphics.drawable.GradientDrawable; import android.os.Bundle; import android.os.Parcelable; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; import android.util.AttributeSet; import android.util.SparseArray; import android.util.TypedValue; @@ -35,6 +33,9 @@ import java.util.ArrayList; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; + /** 没有继承HorizontalScrollView不能滑动,对于ViewPager无依赖 */ public class CommonTabLayout extends FrameLayout implements ValueAnimator.AnimatorUpdateListener { private Context mContext; 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 e9df2953..da93f3e1 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java @@ -11,8 +11,6 @@ import android.graphics.drawable.GradientDrawable; import android.os.Bundle; import android.os.Parcelable; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; import android.util.AttributeSet; import android.util.SparseArray; import android.util.TypedValue; @@ -30,6 +28,9 @@ import java.util.ArrayList; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; + public class SegmentTabLayout extends FrameLayout implements ValueAnimator.AnimatorUpdateListener { private Context mContext; private String[] mTitles; 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..c2b18d82 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java @@ -10,12 +10,6 @@ import android.graphics.drawable.GradientDrawable; import android.os.Bundle; import android.os.Parcelable; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.util.SparseArray; import android.util.TypedValue; @@ -33,6 +27,13 @@ import java.util.ArrayList; import java.util.Collections; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.viewpager.widget.PagerAdapter; +import androidx.viewpager.widget.ViewPager; + /** 滑动TabLayout,对于ViewPager的依赖性强 */ public class SlidingTabLayout extends HorizontalScrollView implements ViewPager.OnPageChangeListener { private Context mContext; diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/utils/FragmentChangeManager.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/utils/FragmentChangeManager.java index dcba1688..3706aec9 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/utils/FragmentChangeManager.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/utils/FragmentChangeManager.java @@ -1,11 +1,12 @@ package com.flyco.tablayout.utils; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentTransaction; import java.util.ArrayList; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; + public class FragmentChangeManager { private FragmentManager mFragmentManager; private int mContainerViewId; 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 b898c2ce..a72bcdfa 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java @@ -3,11 +3,6 @@ import android.content.Context; import android.graphics.Color; import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; import android.view.View; import com.flyco.tablayout.CommonTabLayout; @@ -22,6 +17,12 @@ import java.util.ArrayList; import java.util.Random; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.viewpager.widget.ViewPager; + public class CommonTabActivity extends AppCompatActivity { private Context mContext = this; private ArrayList mFragments = new ArrayList<>(); diff --git a/app/src/main/java/com/flyco/tablayoutsamples/ui/SegmentTabActivity.java b/app/src/main/java/com/flyco/tablayoutsamples/ui/SegmentTabActivity.java index 9ac154cc..2b1802be 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/SegmentTabActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/SegmentTabActivity.java @@ -2,11 +2,6 @@ import android.graphics.Color; import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; import android.view.View; import com.flyco.tablayout.SegmentTabLayout; @@ -17,6 +12,12 @@ import java.util.ArrayList; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.viewpager.widget.ViewPager; + public class SegmentTabActivity extends AppCompatActivity { private ArrayList mFragments = new ArrayList<>(); private ArrayList mFragments2 = new ArrayList<>(); diff --git a/app/src/main/java/com/flyco/tablayoutsamples/ui/SimpleCardFragment.java b/app/src/main/java/com/flyco/tablayoutsamples/ui/SimpleCardFragment.java index c4aeed2b..54075b22 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/SimpleCardFragment.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/SimpleCardFragment.java @@ -2,7 +2,6 @@ import android.annotation.SuppressLint; import android.os.Bundle; -import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -10,6 +9,8 @@ import com.flyco.tablayoutsamples.R; +import androidx.fragment.app.Fragment; + @SuppressLint("ValidFragment") public class SimpleCardFragment extends Fragment { private String mTitle; diff --git a/app/src/main/java/com/flyco/tablayoutsamples/ui/SimpleHomeActivity.java b/app/src/main/java/com/flyco/tablayoutsamples/ui/SimpleHomeActivity.java index 087c3e7a..fc5b6a72 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/SimpleHomeActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/SimpleHomeActivity.java @@ -4,13 +4,14 @@ import android.content.Intent; import android.graphics.Color; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; import com.flyco.tablayoutsamples.adapter.SimpleHomeAdapter; +import androidx.appcompat.app.AppCompatActivity; + public class SimpleHomeActivity extends AppCompatActivity { private Context mContext = this; private final String[] mItems = {"SlidingTabLayout", "CommonTabLayout", "SegmentTabLayout"}; diff --git a/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java b/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java index 290c9b03..82fd03f0 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java @@ -3,11 +3,6 @@ import android.content.Context; import android.graphics.Color; import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Toast; @@ -19,6 +14,12 @@ import java.util.ArrayList; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.viewpager.widget.ViewPager; + public class SlidingTabActivity extends AppCompatActivity implements OnTabSelectListener { private Context mContext = this; private ArrayList mFragments = new ArrayList<>(); diff --git a/gradle.properties b/gradle.properties index 1d3591c8..59d5aab6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,4 +15,6 @@ # 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 +android.useAndroidX=true +android.enableJetifier=true \ No newline at end of file