Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
maning0303 committed Oct 16, 2020
1 parent a6edd76 commit 4f02e48
Show file tree
Hide file tree
Showing 49 changed files with 2,039 additions and 1,253 deletions.
34 changes: 29 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'channel'

channel{
channel {
//指定渠道文件
channelFile = file("channel.txt")
//多渠道包的输出目录,默认为new File(project.buildDir,"channel")
baseOutputDir = new File(project.buildDir,"channel")
baseOutputDir = new File(project.buildDir, "channel")
//多渠道包的命名规则,默认为:${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}
apkNameFormat ='${appName}-${versionName}-${flavorName}-${buildType}'
apkNameFormat = '${appName}-${versionName}-${flavorName}-${buildType}'
//快速模式:生成渠道包时不进行校验(速度可以提升10倍以上)
isFastMode = true
}
Expand Down Expand Up @@ -50,6 +50,25 @@ android {
}
}

packagingOptions {
exclude 'lib/mips64/*.so'
exclude 'lib/mips/*.so'
exclude 'META-INF/proguard/androidx-annotations.pro'
exclude 'META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version'
exclude 'META-INF/androidx.customview_customview.version'
exclude 'META-INF/androidx.legacy_legacy-support-core-ui.version'
exclude 'META-INF/androidx.*'

exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'

exclude 'META-INF/maven/com.belerweb/pinyin4j/pom.xml'
exclude 'META-INF/maven/com.belerweb/pinyin4j/pom.properties'
}

File customerproguardFile = file('src/proguard.cfg')
buildTypes {
release {
Expand Down Expand Up @@ -101,14 +120,16 @@ dependencies {
/*RecycleView的间隔线*/
implementation 'com.yqritc:recyclerview-flexibledivider:1.2.9'
/*解析Json*/
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.google.code.gson:gson:2.8.5'
/*网络相关*/
implementation 'com.squareup.okhttp3:okhttp:3.3.1'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
/*图片加载Glide*/
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'jp.wasabeef:glide-transformations:2.0.2'
/*数据存储*/
implementation 'com.tencent:mmkv-static:1.2.2'
/*日志*/
implementation 'com.github.zhaokaiqiang.klog:library:1.6.0'
/*注解*/
Expand Down Expand Up @@ -138,6 +159,7 @@ dependencies {
/* 模糊 */
implementation 'jp.wasabeef:blurry:2.1.1'
/*网络监测*/
implementation 'com.android.support.constraint:constraint-layout:2.0.2'
debugImplementation 'com.readystatesoftware.chuck:library:1.1.0'
releaseImplementation 'com.readystatesoftware.chuck:library-no-op:1.1.0'
/* 表格 */
Expand All @@ -162,6 +184,8 @@ dependencies {
implementation 'com.github.chrisbanes:PhotoView:2.0.0'

/* ----------自己------------ */
/*二维码扫描*/
implementation 'com.github.maning0303:MNZXingCode:V2.1.4'
/*翻滚广告条TextView*/
implementation 'com.github.maning0303:SwitcherView:v1.0.4'
/* 提示框 */
Expand Down
294 changes: 121 additions & 173 deletions app/src/main/AndroidManifest.xml

Large diffs are not rendered by default.

14 changes: 4 additions & 10 deletions app/src/main/java/com/maning/gankmm/app/MyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

import com.leon.channel.helper.ChannelReaderUtil;
import com.maning.gankmm.BuildConfig;
import com.maning.gankmm.utils.ACache;
import com.maning.gankmm.utils.MyToast;
import com.maning.gankmm.utils.CacheDiskUtils;
import com.maning.gankmm.utils.NetUtils;
import com.maning.librarycrashmonitor.MCrashMonitor;
import com.readystatesoftware.chuck.ChuckInterceptor;
import com.socks.library.KLog;
import com.tencent.mmkv.MMKV;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;

Expand All @@ -42,7 +42,6 @@ public class MyApplication extends Application {

private static MyApplication application;
private static Handler mHandler;
private static ACache aCache;

@Override
protected void attachBaseContext(Context base) {
Expand Down Expand Up @@ -118,15 +117,10 @@ private void initJpush() {
private void initBase() {
application = this;
mHandler = new Handler();
//初始化ACache类
aCache = ACache.get(this);
CacheDiskUtils.init(this);
MMKV.initialize(this);
}

public static ACache getACache() {
return aCache;
}


private void initCrash() {
/**
* 初始化日志系统
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/maning/gankmm/http/mob/MobApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ public void onResponse(Call<CitysEntity> call, Response<CitysEntity> response) {
if (response.isSuccessful()) {
CitysEntity citysEntity = response.body();
if (citysEntity != null) {
//保存
UserUtils.saveCitysCache(citysEntity);
if (citysEntity.getMsg().equals("success")) {
KLog.i("getCitys---success:" + citysEntity.toString());
myCallBack.onSuccessList(what, citysEntity.getResult());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.maning.gankmm.skin.SkinManager;
import com.maning.gankmm.ui.adapter.RecycleCitysAdapter;
import com.maning.gankmm.ui.base.BaseActivity;
import com.maning.gankmm.utils.UserUtils;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -24,6 +23,7 @@
import butterknife.Bind;
import butterknife.ButterKnife;

@Deprecated
public class CitysActivity extends BaseActivity {

@Bind(R.id.toolbar)
Expand Down Expand Up @@ -58,7 +58,7 @@ protected void onCreate(Bundle savedInstanceState) {

private void initAdapter() {
//获取数据
CitysEntity citysCache = UserUtils.getCitysCache();
CitysEntity citysCache = null;
if (citysCache != null) {
List<CitysEntity.ResultBean> cityList = citysCache.getResult();
for (int i = 0; i < cityList.size(); i++) {
Expand Down Expand Up @@ -124,12 +124,7 @@ private void initViews() {


private void initMyToolBar() {
int currentSkinType = SkinManager.getCurrentSkinType(this);
if (SkinManager.THEME_DAY == currentSkinType) {
initToolBar(toolbar, "城市选择", R.drawable.gank_ic_back_white);
} else {
initToolBar(toolbar, "城市选择", R.drawable.gank_ic_back_night);
}
initBackToolBar(toolbar, "城市选择");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
* 泡在网上的日子的数据的抓取
* 网站异常,废弃
*/
@Deprecated
public class CodesActivity extends BaseActivity implements OnRefreshListener, OnLoadMoreListener, ICodesView {

@Bind(R.id.toolbar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
import com.luck.picture.lib.entity.LocalMedia;
import com.maning.gankmm.R;
import com.maning.gankmm.bean.mob.MobUserInfo;
import com.maning.gankmm.http.mob.MobApi;
import com.maning.gankmm.http.callback.MyCallBack;
import com.maning.gankmm.http.mob.MobApi;
import com.maning.gankmm.skin.SkinManager;
import com.maning.gankmm.ui.base.BaseActivity;
import com.maning.gankmm.utils.AppDateMgr;
import com.maning.gankmm.utils.DialogUtils;
import com.maning.gankmm.utils.MySnackbar;
import com.maning.gankmm.utils.UserUtils;
import com.socks.library.KLog;

import java.text.ParseException;
Expand All @@ -43,6 +42,7 @@
/**
* 编辑用户信息页面
*/
@Deprecated
public class EditUserInfoActivity extends BaseActivity {

@Bind(R.id.toolbar)
Expand Down Expand Up @@ -78,7 +78,7 @@ protected void onCreate(Bundle savedInstanceState) {

private void initDatas() {
//获取信息
mUserCache = UserUtils.getUserCache();
// mUserCache = UserUtils.getUserCache();
//设置头像
RequestOptions options = new RequestOptions();
options.placeholder(R.drawable.icon_default_avatar);
Expand Down Expand Up @@ -267,8 +267,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
public void onSuccess(int what, Object result) {
dissmissProgressDialog();
if (what == 0x001) {
//保存用户信息
UserUtils.saveUserCache(mUserCache);
//保存成功
MySnackbar.makeSnackBarGreen(mToolbar, "数据更新成功");

Expand All @@ -285,12 +283,12 @@ public void onSuccess(int what, Object result) {
String signature = values[2];

//本地数据更新
MobUserInfo userCache = UserUtils.getUserCache();
userCache.setSex(sex);
userCache.setBirth(birth);
userCache.setSignature(signature);
//保存用户信息
UserUtils.saveUserCache(userCache);
// MobUserInfo userCache = UserUtils.getUserCache();
// userCache.setSex(sex);
// userCache.setBirth(birth);
// userCache.setSignature(signature);
// //保存用户信息
// UserUtils.saveUserCache(userCache);
//刷新界面
initDatas();
}
Expand Down Expand Up @@ -331,39 +329,39 @@ private void queryUserInfo() {
@Override
public void onBackPressed() {
//对比数据
MobUserInfo userCacheBefore = UserUtils.getUserCache();

String avatarLocal = userCacheBefore.getAvatarLocal();
String sex = userCacheBefore.getSex();
String birth = userCacheBefore.getBirth();
String signature = userCacheBefore.getSignature();

String avatarLocal_new = mUserCache.getAvatarLocal();
String sex_new = mUserCache.getSex();
String birth_new = mUserCache.getBirth();
String signature_new = mUserCache.getSignature();

if (
(TextUtils.isEmpty(avatarLocal) ? "" : avatarLocal).equals((TextUtils.isEmpty(avatarLocal_new) ? "" : avatarLocal_new)) &&
(TextUtils.isEmpty(sex) ? "" : sex).equals((TextUtils.isEmpty(sex_new) ? "" : sex_new)) &&
(TextUtils.isEmpty(birth) ? "" : birth).equals((TextUtils.isEmpty(birth_new) ? "" : birth_new)) &&
(TextUtils.isEmpty(signature) ? "" : signature).equals((TextUtils.isEmpty(signature_new) ? "" : signature_new))
) {
//关闭页面
EditUserInfoActivity.this.finish();
} else {
DialogUtils.showMyDialog(mContext, "提示", "您有数据发生了修改,需要保存吗?", "不修改了,关闭页面", "去保存", new DialogUtils.OnDialogClickListener() {
@Override
public void onConfirm() {
//关闭页面
EditUserInfoActivity.this.finish();
}

@Override
public void onCancel() {

}
});
}
// MobUserInfo userCacheBefore = UserUtils.getUserCache();

// String avatarLocal = userCacheBefore.getAvatarLocal();
// String sex = userCacheBefore.getSex();
// String birth = userCacheBefore.getBirth();
// String signature = userCacheBefore.getSignature();
//
// String avatarLocal_new = mUserCache.getAvatarLocal();
// String sex_new = mUserCache.getSex();
// String birth_new = mUserCache.getBirth();
// String signature_new = mUserCache.getSignature();
//
// if (
// (TextUtils.isEmpty(avatarLocal) ? "" : avatarLocal).equals((TextUtils.isEmpty(avatarLocal_new) ? "" : avatarLocal_new)) &&
// (TextUtils.isEmpty(sex) ? "" : sex).equals((TextUtils.isEmpty(sex_new) ? "" : sex_new)) &&
// (TextUtils.isEmpty(birth) ? "" : birth).equals((TextUtils.isEmpty(birth_new) ? "" : birth_new)) &&
// (TextUtils.isEmpty(signature) ? "" : signature).equals((TextUtils.isEmpty(signature_new) ? "" : signature_new))
// ) {
// //关闭页面
// EditUserInfoActivity.this.finish();
// } else {
// DialogUtils.showMyDialog(mContext, "提示", "您有数据发生了修改,需要保存吗?", "不修改了,关闭页面", "去保存", new DialogUtils.OnDialogClickListener() {
// @Override
// public void onConfirm() {
// //关闭页面
// EditUserInfoActivity.this.finish();
// }
//
// @Override
// public void onCancel() {
//
// }
// });
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.maning.gankmm.ui.base.BaseActivity;
import com.maning.gankmm.utils.KeyboardUtils;
import com.maning.gankmm.utils.MySnackbar;
import com.maning.gankmm.utils.UserUtils;

import java.util.List;

Expand All @@ -27,6 +26,7 @@
/**
* 登录页面
*/
@Deprecated
public class LoginActivity extends BaseActivity {

@Bind(R.id.toolbar)
Expand Down Expand Up @@ -97,7 +97,7 @@ public void onSuccess(int what, Object result) {
userInfo.setUserPsd(userPsd);

//保存用户信息
UserUtils.saveUserCache(userInfo);
// UserUtils.saveUserCache(userInfo);

//关闭当前页面。
closeAcitivity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import butterknife.OnClick;
import de.hdodenhof.circleimageview.CircleImageView;

@Deprecated
public class UserInfoActivity extends BaseActivity {

@Bind(R.id.avatar)
Expand Down Expand Up @@ -108,14 +109,14 @@ protected void onResume() {
}

private void refreshUserInfo() {
//刷新数据
mUserCache = UserUtils.getUserCache();
//设置头像
RequestOptions options = new RequestOptions();
options.placeholder(R.drawable.icon_default_avatar);
options.error(R.drawable.icon_default_avatar);
Glide.with(mContext).load(mUserCache.getAvatarLocal()).apply(options).into(mAvatar);
//设置用户名
mTvUserName.setText(mUserCache.getUserName());
// //刷新数据
// mUserCache = UserUtils.getUserCache();
// //设置头像
// RequestOptions options = new RequestOptions();
// options.placeholder(R.drawable.icon_default_avatar);
// options.error(R.drawable.icon_default_avatar);
// Glide.with(mContext).load(mUserCache.getAvatarLocal()).apply(options).into(mAvatar);
// //设置用户名
// mTvUserName.setText(mUserCache.getUserName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/**
* 银行卡查询
*/
@Deprecated
public class BankCardActivity extends BaseActivity {

@Bind(R.id.toolbar)
Expand Down Expand Up @@ -59,12 +60,7 @@ private void initRecyclerView() {
}

private void initMyToolBar() {
int currentSkinType = SkinManager.getCurrentSkinType(this);
if (SkinManager.THEME_DAY == currentSkinType) {
initToolBar(toolbar, "银行卡查询", R.drawable.gank_ic_back_white);
} else {
initToolBar(toolbar, "银行卡查询", R.drawable.gank_ic_back_night);
}
initBackToolBar(toolbar, "银行卡查询");
}

@Override
Expand Down
Loading

0 comments on commit 4f02e48

Please sign in to comment.