Skip to content

Commit 2e2e588

Browse files
AriesHooAriesHoo
AriesHoo
authored and
AriesHoo
committed
1、优化代理类避免内存泄露
2、升级三方库及gradle 3、新增Bugly功能
1 parent 345e462 commit 2e2e588

23 files changed

+161
-48
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ Demo中使用到的网络请求api来源于[豆瓣API V2](https://developers.dou
2424

2525
其它功能请在demo中发现
2626

27-
[[Download]](https://raw.githubusercontent.com/AriesHoo/FastLib/master/apk/sample.apk)
27+
[[Download-蒲公英]](https://www.pgyer.com/KmaF)
28+
29+
![Download-蒲公英](/apk/qr_pgyer.png)
30+
31+
[[Download-github]](https://raw.githubusercontent.com/AriesHoo/FastLib/master/apk/sample.apk)
2832

2933
![](/apk/qr.png)
3034

apk/qr_pgyer.png

1.24 KB
Loading

apk/sample.apk

-228 KB
Binary file not shown.

apk/update

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"versionCode": 238,
3-
"versionName": "2.2.11-androidx",
2+
"versionCode": 239,
3+
"versionName": "2.2.12",
44
"url": "https://raw.githubusercontent.com/AriesHoo/FastLib/master/apk/sample.apk",
55
"force": true,
66
"size": "3.80M",
7-
"message": "1、upgrade androidx\n2、优化:新增BasisActivity 事件派发全局控制\n3、修复:增加ToastUtil 判断华为手机Android 9.0快速弹出第二次不显示问题并增加全局控制ToastControl\n4、修改返回键操作逻辑避免快速点击造成页面崩溃问题"
7+
"message": "1、优化代理类避免内存泄露\n2、升级三方库及gradle \n3、新增Bugly功能"
88
}

app/build.gradle

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ android {
1313
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1414
buildConfigField "String", "BASE_URL", "\"https://api.douban.com/\""
1515
buildConfigField "String", "BASE__UPDATE_URL", "\"https://raw.githubusercontent.com/AriesHoo/FastLib/master/apk/\""
16+
manifestPlaceholders = [
17+
app_channel : "FastLib",
18+
bugly_id : "a66ee7eb32"
19+
]
1620
}
1721

1822
dexOptions {
@@ -63,12 +67,11 @@ android {
6367
dependencies {
6468
implementation fileTree(include: ['*.jar'], dir: 'libs')
6569
implementation project(':library')
66-
// implementation 'com.github.AriesHoo:FastLib:2.2.11-androidx'
67-
70+
// implementation 'com.github.AriesHoo:FastLib:2.2.12'
71+
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
72+
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
73+
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
6874
//以下库library里使用provided只是编译使用时需根据项目选择相应版本
69-
implementation 'com.google.android.material:material:'.concat(supportVersion)
70-
implementation 'androidx.appcompat:appcompat:'.concat(supportVersion)
71-
implementation 'androidx.recyclerview:recyclerview:'.concat(supportVersion)
7275
//万能适配器--一般都需要吧
7376
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.45-androidx'
7477
//webView库 继承FastWebActivity需要,不需要内置WebView可以不compile
@@ -92,5 +95,7 @@ dependencies {
9295
implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.2.3'
9396
//友盟统计
9497
implementation 'com.umeng.analytics:analytics:latest.integration'
95-
98+
//Bugly
99+
implementation 'com.tencent.bugly:crashreport:2.8.6.0'
100+
// implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
96101
}

app/src/main/AndroidManifest.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424
android:label="@string/app_name"
2525
android:supportsRtl="true"
2626
android:theme="@style/AppTheme">
27+
<!-- 配置APP渠道号 -->
28+
<meta-data
29+
android:name="BUGLY_APPID"
30+
android:value="${bugly_id}" />
31+
<meta-data
32+
android:name="BUGLY_APP_CHANNEL"
33+
android:value="${app_channel}" />
34+
<meta-data
35+
android:name="BaiduMobAd_CHANNEL"
36+
android:value="${app_channel}"/>
2737
<activity
2838
android:name=".module.SplashActivity"
2939
android:configChanges="locale|layoutDirection|mcc|mnc">

app/src/main/java/com/aries/library/fast/demo/App.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@
33
import android.app.Application;
44
import android.content.Context;
55
import android.os.Build;
6+
import android.text.TextUtils;
7+
import android.util.Log;
68

79
import com.aries.library.fast.FastManager;
810
import com.aries.library.fast.demo.constant.ApiConstant;
11+
import com.aries.library.fast.demo.constant.SPConstant;
912
import com.aries.library.fast.demo.impl.ActivityControlImpl;
1013
import com.aries.library.fast.demo.impl.AppImpl;
1114
import com.aries.library.fast.demo.impl.HttpRequestControlImpl;
1215
import com.aries.library.fast.demo.impl.SwipeBackControlImpl;
1316
import com.aries.library.fast.manager.LoggerManager;
1417
import com.aries.library.fast.retrofit.FastRetrofit;
18+
import com.aries.library.fast.util.SPUtil;
1519
import com.aries.library.fast.util.SizeUtil;
20+
import com.squareup.leakcanary.LeakCanary;
21+
import com.tencent.bugly.crashreport.CrashReport;
1622
import com.umeng.analytics.MobclickAgent;
1723

1824
/**
@@ -107,8 +113,24 @@ public void onCreate() {
107113

108114
//初始化友盟统计
109115
MobclickAgent.startWithConfigure(new MobclickAgent.UMAnalyticsConfig(mContext, "5b349499b27b0a085f000052", "FastLib"));
110-
116+
CrashReport.initCrashReport(getApplicationContext());
117+
String appChannel = (String) SPUtil.get(getApplicationContext(), SPConstant.SP_KEY_APP_CHANNEL, "");
118+
LoggerManager.i(TAG, "appChannel0:" + appChannel);
119+
if (TextUtils.isEmpty(appChannel)) {
120+
appChannel = CrashReport.getAppChannel();
121+
Log.i(TAG, "appChannel1:" + appChannel);
122+
SPUtil.put(getApplicationContext(), SPConstant.SP_KEY_APP_CHANNEL, appChannel);
123+
} else {
124+
CrashReport.setAppChannel(getApplicationContext(), appChannel);
125+
}
126+
LoggerManager.i(TAG, "appChannel2:" + appChannel);
111127
LoggerManager.i(TAG, "total:" + (System.currentTimeMillis() - start));
128+
if (LeakCanary.isInAnalyzerProcess(this)) {
129+
// This process is dedicated to LeakCanary for heap analysis.
130+
// You should not init your app in this process.
131+
return;
132+
}
133+
LeakCanary.install(this);
112134
}
113135

114136
/**

app/src/main/java/com/aries/library/fast/demo/constant/SPConstant.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ public class SPConstant {
1111
public static final String SP_KEY_ACTIVITY_ANIMATION_ALWAYS = "SP_KEY_ACTIVITY_ANIMATION_ALWAYS";
1212
public static final String SP_KEY_ACTIVITY_ANIMATION_INDEX = "SP_KEY_ACTIVITY_ANIMATION_INDEX";
1313
public static final String SP_KEY_HOME_TRANSITION_INDEX = "SP_KEY_HOME_TRANSITION_INDEX";
14+
public static final String SP_KEY_APP_CHANNEL = "SP_KEY_APP_CHANNEL";
1415
}

app/src/main/java/com/aries/library/fast/demo/module/mine/ThirdLibraryActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.aries.library.fast.demo.module.mine;
22

33
import android.os.Bundle;
4+
import android.text.TextUtils;
5+
import android.view.View;
6+
47
import androidx.recyclerview.widget.RecyclerView;
58
import androidx.recyclerview.widget.ItemTouchHelper;
69

@@ -9,6 +12,7 @@
912
import com.aries.library.fast.demo.constant.GlobalConstant;
1013
import com.aries.library.fast.demo.constant.SPConstant;
1114
import com.aries.library.fast.demo.entity.WidgetEntity;
15+
import com.aries.library.fast.demo.module.WebViewActivity;
1216
import com.aries.library.fast.demo.touch.ItemTouchHelperCallback;
1317
import com.aries.library.fast.demo.touch.OnItemTouchHelperListener;
1418
import com.aries.library.fast.manager.LoggerManager;
@@ -127,4 +131,13 @@ public void _onNext(List<WidgetEntity> entity) {
127131
});
128132
}
129133

134+
@Override
135+
public void onItemClicked(BaseQuickAdapter<WidgetEntity, BaseViewHolder> adapter, View view, int position) {
136+
super.onItemClicked(adapter, view, position);
137+
WidgetEntity item = adapter.getItem(position);
138+
if(item==null|| TextUtils.isEmpty(item.url)){
139+
return;
140+
}
141+
WebViewActivity.start(mContext,item.url,true);
142+
}
130143
}

app/src/main/res/layout/layout_activity_sliding.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
app:tl_textBold="SELECT"
2020
app:tl_textSelectColor="@color/colorTabTextSelect"
2121
app:tl_textUnSelectColor="@color/colorTabTextUnSelect"
22-
app:tl_textSize="16dp"/>
22+
app:tl_textSize="16dp"
23+
app:tl_textSelectSize="18dp"/>
2324
</LinearLayout>

app/src/main/res/values-zh/arrays.xml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@
8383
<item>RxLifeCycle</item>
8484
<item>BaseRecyclerViewAdapterHelper</item>
8585
<item>BGASwipeBackLayout</item>
86-
<item>FlycoTabLayout</item>
87-
<item>EasyStatusView</item>
86+
<item>TabLayout-forked from FlycoTabLayout</item>
87+
<item>StatusLayoutManager</item>
8888
<item>UIWidget</item>
8989
<item>SmartRefreshLayout</item>
9090
<item>AndroidEventBus</item>
@@ -121,8 +121,8 @@
121121
<item>https://github.com/trello/RxLifecycle</item>
122122
<item>https://github.com/CymChad/BaseRecyclerViewAdapterHelper</item>
123123
<item>https://github.com/bingoogolapple/BGASwipeBackLayout-Android</item>
124-
<item>https://github.com/H07000223/FlycoTabLayout</item>
125-
<item>https://github.com/MarnoDev/EasyStatusView</item>
124+
<item>https://github.com/AriesHoo/TabLayout</item>
125+
<item>https://github.com/Bakumon/StatusLayoutManager</item>
126126
<item>https://github.com/AriesHoo/UIWidget</item>
127127
<item>https://github.com/scwang90/SmartRefreshLayout</item>
128128
<item>https://github.com/hehonghui/AndroidEventBus</item>
@@ -137,12 +137,6 @@
137137
<item>https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1502192405268&amp;di=542a54fb3f2b50f1941965c25517869f&amp;imgtype=0&amp;src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F1%2F57a2fa3c59b53.jpg</item>
138138
<item>https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1502008608181&amp;di=09ad460e1c901ed3097d60d7c8461a92&amp;imgtype=0&amp;src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F3%2F5880197169c04.jpg</item>
139139
<item>https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2060246906,3265914169&amp;fm=26&amp;gp=0.jpg</item>
140-
<item>https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1171603568,246318761&amp;fm=26&amp;gp=0.jpg</item>
141-
<item>https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1502603809&amp;di=bbf8bf71aa136a510578d7152a374641&amp;imgtype=jpg&amp;er=1&amp;src=http%3A%2F%2Fwww.desktx.com%2Fd%2Ffile%2Fwallpaper%2FPeople%2Ffemales%2F20160825%2Ff26d5deaa7b92190a84b45769a28ab67.jpg</item>
142-
<item>https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1502009037206&amp;di=22099663ebd18901b9364f4381d1cab5&amp;imgtype=jpg&amp;src=http%3A%2F%2Fimg0.imgtn.bdimg.com%2Fit%2Fu%3D2616633398%2C643750943%26fm%3D214%26gp%3D0.jpg</item>
143-
<item>http://img1.xiazaizhijia.com/walls/20160621/mid_2f6f1fa9f9d5e3b.jpg</item>
144-
<item>http://img5.xiazaizhijia.com/walls/20160621/mid_31d8e8056e92272.jpg</item>
145-
<item>https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1502193302435&amp;di=08f48aec17d044f64bb53d6edd0bcdfc&amp;imgtype=0&amp;src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Ff%2F573bd3d1262cb.jpg</item>
146140
</array>
147141

148142
<array name="arrays_animation">

app/src/main/res/values/arrays.xml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@
8383
<item>RxLifeCycle</item>
8484
<item>BaseRecyclerViewAdapterHelper</item>
8585
<item>BGASwipeBackLayout</item>
86-
<item>FlycoTabLayout</item>
87-
<item>EasyStatusView</item>
86+
<item>TabLayout-forked from FlycoTabLayout</item>
87+
<item>StatusLayoutManager</item>
8888
<item>UIWidget</item>
8989
<item>SmartRefreshLayout</item>
9090
<item>AndroidEventBus</item>
@@ -121,8 +121,8 @@
121121
<item>https://github.com/trello/RxLifecycle</item>
122122
<item>https://github.com/CymChad/BaseRecyclerViewAdapterHelper</item>
123123
<item>https://github.com/bingoogolapple/BGASwipeBackLayout-Android</item>
124-
<item>https://github.com/H07000223/FlycoTabLayout</item>
125-
<item>https://github.com/MarnoDev/EasyStatusView</item>
124+
<item>https://github.com/AriesHoo/TabLayout</item>
125+
<item>https://github.com/Bakumon/StatusLayoutManager</item>
126126
<item>https://github.com/AriesHoo/UIWidget</item>
127127
<item>https://github.com/scwang90/SmartRefreshLayout</item>
128128
<item>https://github.com/hehonghui/AndroidEventBus</item>
@@ -137,12 +137,6 @@
137137
<item>https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1502192405268&amp;di=542a54fb3f2b50f1941965c25517869f&amp;imgtype=0&amp;src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F1%2F57a2fa3c59b53.jpg</item>
138138
<item>https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1502008608181&amp;di=09ad460e1c901ed3097d60d7c8461a92&amp;imgtype=0&amp;src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F3%2F5880197169c04.jpg</item>
139139
<item>https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2060246906,3265914169&amp;fm=26&amp;gp=0.jpg</item>
140-
<item>https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1171603568,246318761&amp;fm=26&amp;gp=0.jpg</item>
141-
<item>https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1502603809&amp;di=bbf8bf71aa136a510578d7152a374641&amp;imgtype=jpg&amp;er=1&amp;src=http%3A%2F%2Fwww.desktx.com%2Fd%2Ffile%2Fwallpaper%2FPeople%2Ffemales%2F20160825%2Ff26d5deaa7b92190a84b45769a28ab67.jpg</item>
142-
<item>https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1502009037206&amp;di=22099663ebd18901b9364f4381d1cab5&amp;imgtype=jpg&amp;src=http%3A%2F%2Fimg0.imgtn.bdimg.com%2Fit%2Fu%3D2616633398%2C643750943%26fm%3D214%26gp%3D0.jpg</item>
143-
<item>http://img1.xiazaizhijia.com/walls/20160621/mid_2f6f1fa9f9d5e3b.jpg</item>
144-
<item>http://img5.xiazaizhijia.com/walls/20160621/mid_31d8e8056e92272.jpg</item>
145-
<item>https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1502193302435&amp;di=08f48aec17d044f64bb53d6edd0bcdfc&amp;imgtype=0&amp;src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Ff%2F573bd3d1262cb.jpg</item>
146140
</array>
147141

148142
<array name="arrays_animation">

app/src/main/res/values/fast_dimens.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<dimen name="dp_title_height">48dp</dimen>
55

66
<!--主页tab高度-->
7-
<dimen name="dp_tab_height">48dp</dimen>
7+
<dimen name="dp_tab_height">50dp</dimen>
88
<!--主页tab icon宽高-->
99
<dimen name="dp_tab_icon">24dp</dimen>
1010
<!--主页tab 文字与icon边距-->
1111
<dimen name="dp_tab_margin">0dp</dimen>
1212
<!--主页tab文字字号-->
13-
<dimen name="dp_tab_text_size">11dp</dimen>
13+
<dimen name="dp_tab_text_size">12dp</dimen>
1414
<!--主页tab 上划线宽度-->
1515
<dimen name="dp_tab_underline">0.5dp</dimen>
1616

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
mavenCentral()
99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.2.1'
11+
classpath 'com.android.tools.build:gradle:3.3.1'
1212
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1313
}
1414
}
@@ -35,5 +35,5 @@ ext{
3535
// supportVersion = "28.0.0"
3636
supportVersion = "1.0.0"
3737
versionCode = 239
38-
versionName = "2.2.11-androidx"
38+
versionName = "2.2.12"
3939
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

library/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ dependencies {
6060
//图片加载
6161
compileOnly 'com.github.bumptech.glide:glide:4.8.0'
6262
//常用UI控件(TitleBarView、RadiusView等)
63-
api 'com.github.AriesHoo.UIWidget:widget-core:3.2.7-androidx'
63+
api 'com.github.AriesHoo.UIWidget:widget-core:3.2.9'
6464
//日志打印
6565
api 'com.orhanobut:logger:2.2.0'
6666
//注解
@@ -79,8 +79,7 @@ dependencies {
7979
//滑动返回Activity
8080
api 'cn.bingoogolapple:bga-swipebacklayout:1.2.0@aar'
8181
//快速Tab库
82-
api 'com.github.AriesHoo:TabLayout:1.0.1'
83-
// api project(':lib')
82+
api 'com.github.AriesHoo:TabLayout:1.0.2'
8483
//页面事件交互
8584
api 'org.simple:androideventbus:1.0.5.1'
8685
//多状态视图切换

library/src/main/java/com/aries/library/fast/FastManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
2626

2727
import androidx.annotation.Nullable;
28+
import androidx.core.content.ContextCompat;
2829
import cn.bingoogolapple.swipebacklayout.BGASwipeBackHelper;
2930

3031
/**
@@ -137,7 +138,7 @@ public FastLoadDialog createLoadingDialog(@Nullable Activity activity) {
137138
//初始化Toast工具
138139
ToastUtil.init(mApplication);
139140
//初始化Glide
140-
GlideManager.setPlaceholderColor(mApplication.getResources().getColor(R.color.colorPlaceholder));
141+
GlideManager.setPlaceholderColor(ContextCompat.getColor(mApplication,R.color.colorPlaceholder));
141142
GlideManager.setPlaceholderRoundRadius(mApplication.getResources().getDimension(R.dimen.dp_placeholder_radius));
142143
}
143144
return getInstance();

library/src/main/java/com/aries/library/fast/delegate/FastMainTabDelegate.java

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.aries.library.fast.R;
1111
import com.aries.library.fast.entity.FastTabEntity;
1212
import com.aries.library.fast.i.IFastMainView;
13+
import com.aries.library.fast.manager.LoggerManager;
1314
import com.aries.library.fast.manager.TabLayoutManager;
1415
import com.aries.ui.util.FindViewUtil;
1516
import com.aries.ui.view.tab.CommonTabLayout;
@@ -34,16 +35,16 @@
3435
* 3、2018-11-29 16:08:12 新增Activity被系统回收相关处理
3536
*/
3637
public class FastMainTabDelegate {
37-
38+
private Context mContext;
39+
private Object mObject;
40+
private FragmentManager mFragmentManager;
41+
private IFastMainView mIFastMainView;
3842
public CommonTabLayout mTabLayout;
3943
public ViewPager mViewPager;
4044
public List<FastTabEntity> mListFastTab = new ArrayList<>();
41-
private IFastMainView mIFastMainView;
4245
private ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();
43-
private Context mContext;
44-
private Object mObject;
4546
private Bundle mSavedInstanceState;
46-
private FragmentManager mFragmentManager;
47+
4748
public static final String SAVED_INSTANCE_STATE_CURRENT_TAB = "saved_instance_state_current_tab";
4849
/**
4950
* 存放历史主页Tab数量
@@ -101,6 +102,7 @@ private void initTabLayout() {
101102
.setTextUnSelectColor(ContextCompat.getColor(mContext, R.color.colorTabTextUnSelect))
102103
.setUnderlineColor(ContextCompat.getColor(mContext, R.color.colorTabUnderline))
103104
.setTextSize(TypedValue.COMPLEX_UNIT_PX, mContext.getResources().getDimensionPixelSize(R.dimen.dp_tab_text_size))
105+
.setTextSelectSize(TypedValue.COMPLEX_UNIT_PX, mContext.getResources().getDimensionPixelSize(R.dimen.dp_tab_text_size))
104106
.setUnderlineGravity(Gravity.TOP)
105107
.setUnderlineHeight(mContext.getResources().getDimension(R.dimen.dp_tab_underline))
106108
.setIconMargin(mContext.getResources().getDimensionPixelSize(R.dimen.dp_tab_margin))
@@ -214,4 +216,29 @@ private void getSaveState() {
214216
mListFastTab = mIFastMainView.getTabList();
215217
}
216218
}
219+
220+
/**
221+
* 与Activity 及Fragment onDestroy 及时解绑释放避免内存泄露
222+
*/
223+
public void onDestroy() {
224+
mContext = null;
225+
mObject = null;
226+
mFragmentManager = null;
227+
mIFastMainView = null;
228+
mTabLayout = null;
229+
mViewPager = null;
230+
if (mListFastTab != null) {
231+
mListFastTab.clear();
232+
mListFastTab = null;
233+
}
234+
if (mTabEntities != null) {
235+
mTabEntities.clear();
236+
mTabEntities = null;
237+
}
238+
if (mSavedInstanceState != null) {
239+
mSavedInstanceState.clear();
240+
mSavedInstanceState = null;
241+
}
242+
LoggerManager.i("FastMainTabDelegate", "onDestroy");
243+
}
217244
}

0 commit comments

Comments
 (0)