Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Commit f587a81

Browse files
committed
重构闪存,我的
1 parent d06e9a6 commit f587a81

File tree

240 files changed

+27247
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+27247
-275
lines changed

.idea/modules.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dependencies.gradle

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ext {
33

44
// Android 扩展配置
55
android = [
6+
versionCode : 8, // 版本号
67
compileSdkVersion: 27,
78
targetSdkVersion : 27,
89
minSdkVersion : 17,
@@ -13,6 +14,7 @@ ext {
1314
dependencies = [
1415
appcompat : 'com.android.support:appcompat-v7:' + ext.android.supportVersion,
1516
design : 'com.android.support:design:' + ext.android.supportVersion,
17+
recyclerview : 'com.android.support:recyclerview-v7:' + ext.android.supportVersion,
1618
annotations : 'com.android.support:support-annotations:' + ext.android.supportVersion,
1719
cardview : 'com.android.support:cardview-v7:' + ext.android.supportVersion,
1820
rxjava : 'io.reactivex.rxjava2:rxjava:2.1.0',
@@ -26,24 +28,34 @@ ext {
2628
raeSession : 'com.github.raee:AndroidSessionManager:1.0.0',
2729
okhttpUrlconnection: 'com.squareup.okhttp3:okhttp-urlconnection:3.9.0',
2830
retrofit : 'com.squareup.retrofit2:retrofit:2.3.0',
29-
// activeandroid : 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT',
3031
retrofitRxAdapter : 'com.squareup.retrofit2:adapter-rxjava2:2.2.0',
3132
gson : 'com.google.code.gson:gson:2.8.0',
3233
bugly : 'com.tencent.bugly:crashreport_upgrade:1.3.4',
3334
rxlifecycle : 'com.trello.rxlifecycle2:rxlifecycle-android-lifecycle:2.2.1',
34-
skin : 'skin.support:skin-support:2.1.2',
35-
skinDesign : 'skin.support:skin-support-design:1.2.5',
35+
skin : 'skin.support:skin-support:3.1.0-beta',
36+
skinDesign : 'skin.support:skin-support-design:3.1.0-beta',
3637
raeDesignExt : 'com.rae.widget:design-ext:1.0.1',
3738
ptr : 'in.srain.cube:ultra-ptr:1.0.11',
38-
recyclerView : 'com.github.raee:XRecyclerView:1.3.3',
39+
xRecyclerView : 'com.github.raee:XRecyclerView:1.3.3',
3940
roundedImage : 'com.makeramen:roundedimageview:2.3.0',
40-
multidex : 'com.android.support:multidex:1.0.3',
41+
multidex : 'com.android.support:multidex:1.0.2',
4142
glide : 'com.github.bumptech.glide:glide:4.0.0',
4243
// 友盟统计-公共库
4344
umengCommon : 'com.umeng.sdk:common:1.4.1',
4445
// 友盟统计-APP分析库
4546
umengAnalytics : 'com.umeng.sdk:analytics:7.4.1',
4647
greendao : 'org.greenrobot:greendao:3.2.2',
48+
// 美团渠道包库
49+
walle : 'com.meituan.android.walle:library:1.1.6',
50+
// IOS 切换按钮
51+
switchbutton : 'com.kyleduo.switchbutton:library:1.4.6',
52+
// LeanCloud 基础包
53+
avoscloudSdk : 'cn.leancloud.android:avoscloud-sdk:v4.4.3',
54+
// LeanCloud 用户反馈包
55+
avoscloudFeedback : 'cn.leancloud.android:avoscloud-feedback:v4.4.3@aar',
56+
// 滑动返回
57+
swipebacklayout : 'me.imid.swipebacklayout.lib:library:1.1.0',
58+
photoView : 'com.github.chrisbanes:PhotoView:2.1.2',
4759
]
4860

4961
// 注解配置

module-basic/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ dependencies {
2727
implementation rootProject.ext.dependencies.butterknife
2828
implementation rootProject.ext.dependencies.rxlifecycle
2929
implementation rootProject.ext.dependencies.multidex
30-
implementation rootProject.ext.dependencies.glide
3130
implementation rootProject.ext.dependencies.umengCommon
3231
implementation rootProject.ext.dependencies.umengAnalytics
32+
implementation rootProject.ext.dependencies.walle
33+
api rootProject.ext.dependencies.glide
34+
api(rootProject.ext.dependencies.recyclerview, {
35+
exclude group: 'com.android.support'
36+
})
3337

38+
api rootProject.ext.dependencies.eventBus
3439
api(rootProject.ext.dependencies.arouter, {
3540
exclude group: 'com.android.support'
3641
})
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
package com.rae.cnblogs.basic;
2+
3+
import android.content.Context;
4+
import android.os.Build;
5+
import android.os.Environment;
6+
import android.os.StatFs;
7+
8+
import java.io.File;
9+
10+
/**
11+
* 应用程序数据管理器
12+
* Created by ChenRui on 2017/7/28 0028 21:57.
13+
*/
14+
public final class AppDataManager {
15+
16+
private Context mContext;
17+
18+
public AppDataManager(Context context) {
19+
mContext = context;
20+
}
21+
22+
/**
23+
* 清除应用缓存
24+
*/
25+
public void clearCache() {
26+
// 清除文件缓存
27+
deleteDir(mContext.getExternalCacheDir());
28+
deleteDir(mContext.getCacheDir());
29+
clearWebViewCache();
30+
}
31+
32+
//清理WebView缓存数据库
33+
public void clearWebViewCache() {
34+
try {
35+
36+
// 兼容高版本:/data/data/com.rae.cnblogs/app_webview
37+
deleteDir(new File(mContext.getCacheDir().getParent(), "app_webview"));
38+
39+
mContext.deleteDatabase("webview.db");
40+
mContext.deleteDatabase("webviewCache.db");
41+
// 清除文件缓存
42+
//WebView 缓存文件
43+
File appCacheDir = new File(mContext.getFilesDir().getAbsolutePath() + "/webcache");
44+
File webviewCacheDir = new File(mContext.getCacheDir().getAbsolutePath() + "/webviewCache");
45+
deleteDir(appCacheDir);
46+
deleteDir(webviewCacheDir);
47+
48+
} catch (Exception e) {
49+
e.printStackTrace();
50+
}
51+
}
52+
53+
/**
54+
* 获取SDCard总大小
55+
*
56+
* @return 单位MB
57+
*/
58+
public long getSDCardTotalSize() {
59+
File file = Environment.getExternalStorageDirectory();
60+
if (!file.exists() || !file.canRead()) return -1;
61+
StatFs stat = new StatFs(file.getPath());
62+
if (Build.VERSION.SDK_INT > 18) {
63+
return (stat.getBlockSizeLong() * stat.getBlockCountLong()) / 1048576;
64+
} else {
65+
return (stat.getBlockSize() * stat.getBlockCount()) / 1048576;
66+
}
67+
}
68+
69+
/**
70+
* 获取SDCard可用空间
71+
*
72+
* @return 单位MB
73+
*/
74+
public long getSDCardFreeSpace() {
75+
File file = Environment.getExternalStorageDirectory();
76+
if (!file.exists() || !file.canRead()) return -1;
77+
StatFs stat = new StatFs(file.getPath());
78+
if (Build.VERSION.SDK_INT > 18) {
79+
return (stat.getAvailableBlocksLong() * stat.getBlockSizeLong()) / 1048576;
80+
} else {
81+
return (stat.getAvailableBlocks() * stat.getBlockSize()) / 1048576;
82+
}
83+
}
84+
85+
/**
86+
* 获取缓存大小
87+
*
88+
* @return 返回单位MB
89+
*/
90+
public long getCacheSize() {
91+
File cacheDir = mContext.getCacheDir();
92+
File extCacheDir = mContext.getExternalCacheDir();
93+
return (getDirectorySize(cacheDir) + getDirectorySize(extCacheDir)) / 1048576;
94+
}
95+
96+
/**
97+
* 是否空间不足,条件:可用空间小于1GB
98+
*/
99+
public boolean isInsufficient() {
100+
long size = getSDCardFreeSpace();
101+
return size < 1024 && size != -1;
102+
}
103+
104+
/**
105+
* 数据库总大小
106+
*
107+
* @return 返回单位MB
108+
*/
109+
public double getDatabaseTotalSize() {
110+
File dbFile = mContext.getDatabasePath("cnblogs").getParentFile();
111+
return getDirectorySize(dbFile) / 1048576.0f; // MB
112+
}
113+
114+
115+
/**
116+
* 获取文件夹大小
117+
*
118+
* @param file 文件
119+
*/
120+
public long getDirectorySize(File file) {
121+
if (!file.exists() || !file.canRead()) {
122+
return 0;
123+
}
124+
125+
if (!file.isDirectory()) {
126+
return file.length();
127+
}
128+
129+
long size = 0;
130+
File[] files = file.listFiles();
131+
if (files == null) return 0;
132+
for (File item : files) {
133+
if (item.isDirectory()) {
134+
size += getDirectorySize(item);
135+
} else {
136+
size += item.length();
137+
}
138+
}
139+
return size;
140+
}
141+
142+
/**
143+
* 递归删除文件夹
144+
*
145+
* @param file
146+
* @return
147+
*/
148+
public void deleteDir(File file) {
149+
if (file != null && file.exists()) {
150+
try {
151+
if (file.isDirectory()) {
152+
// 删除文件夹
153+
File[] files = file.listFiles();
154+
if (files.length <= 0) {
155+
file.delete(); // 文件夹类型
156+
return;
157+
}
158+
for (File item : files) {
159+
deleteDir(item); // 递归删除子文件夹
160+
}
161+
} else {
162+
file.delete(); // 文件类型
163+
}
164+
} catch (Exception e) {
165+
e.printStackTrace();
166+
}
167+
}
168+
}
169+
170+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.rae.cnblogs.basic;
2+
3+
import android.content.Context;
4+
import android.content.pm.PackageManager;
5+
import android.text.TextUtils;
6+
7+
import com.meituan.android.walle.WalleChannelReader;
8+
9+
/**
10+
* 应用程序扩展类
11+
*/
12+
public final class ApplicationCompat {
13+
14+
/**
15+
* 获取版本号
16+
*/
17+
public static int getVersionCode(Context context) {
18+
try {
19+
return context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_META_DATA).versionCode;
20+
} catch (PackageManager.NameNotFoundException e) {
21+
e.printStackTrace();
22+
}
23+
return 1;
24+
}
25+
26+
/**
27+
* 获取版本名称
28+
*/
29+
public static String getVersionName(Context context) {
30+
try {
31+
return context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_META_DATA).versionName;
32+
} catch (PackageManager.NameNotFoundException e) {
33+
e.printStackTrace();
34+
}
35+
return "1.0.0";
36+
}
37+
38+
/**
39+
* 获取渠道包,如果没有定义渠道包默认返回official
40+
*/
41+
public static String getChannel(Context context) {
42+
String channel = WalleChannelReader.getChannel(context);
43+
return TextUtils.isEmpty(channel) ? "official" : channel;
44+
}
45+
}

0 commit comments

Comments
 (0)