Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新项目依赖至最新版本 #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ android {
])
// 调试模式下只保留一种架构的 so 库,提升打包速度
ndk {
abiFilters 'armeabi-v7a'
abiFilters 'armeabi-v7a','x86_64'
}
}

Expand Down Expand Up @@ -95,7 +95,7 @@ android {
// armeabi:万金油架构平台(占用率:0%)
// armeabi-v7a:曾经主流的架构平台(占用率:10%)
// arm64-v8a:目前主流架构平台(占用率:95%)
abiFilters 'armeabi-v7a', 'arm64-v8a'
abiFilters 'armeabi-v7a', 'arm64-v8a','x86_64'
}
}
}
Expand Down Expand Up @@ -139,16 +139,16 @@ dependencies {
implementation project(':library:umeng')

// 权限请求框架:https://github.com/getActivity/XXPermissions
implementation 'com.github.getActivity:XXPermissions:12.3'
implementation 'com.github.getActivity:XXPermissions:20.0'

// 标题栏框架:https://github.com/getActivity/TitleBar
implementation 'com.github.getActivity:TitleBar:9.2'
implementation 'com.github.getActivity:TitleBar:10.5'

// 吐司框架:https://github.com/getActivity/ToastUtils
implementation 'com.github.getActivity:ToastUtils:9.5'
// 吐司框架:https://github.com/getActivity/Toaster
implementation 'com.github.getActivity:Toaster:12.6'

// 网络请求框架:https://github.com/getActivity/EasyHttp
implementation 'com.github.getActivity:EasyHttp:10.2'
implementation 'com.github.getActivity:EasyHttp:13.0'
// OkHttp 框架:https://github.com/square/okhttp
// noinspection GradleDependency
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
Expand All @@ -159,7 +159,7 @@ dependencies {
implementation 'com.github.getActivity:GsonFactory:5.2'

// Shape 框架:https://github.com/getActivity/ShapeView
implementation 'com.github.getActivity:ShapeView:6.0'
implementation 'com.github.getActivity:ShapeView:9.3'

// AOP 插件库:https://mvnrepository.com/artifact/org.aspectj/aspectjrt
implementation 'org.aspectj:aspectjrt:1.9.6'
Expand All @@ -170,7 +170,7 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'

// 沉浸式框架:https://github.com/gyf-dev/ImmersionBar
implementation 'com.gyf.immersionbar:immersionbar:3.0.0'
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2'

// 手势 ImageView:https://github.com/Baseflow/PhotoView
implementation 'com.github.Baseflow:PhotoView:2.3.0'
Expand All @@ -194,7 +194,7 @@ dependencies {
implementation 'me.relex:circleindicator:2.1.6'

// 腾讯 MMKV:https://github.com/Tencent/MMKV
implementation 'com.tencent:mmkv-static:1.2.10'
implementation 'com.tencent:mmkv:2.0.2'

// 内存泄漏监测框架:https://github.com/square/leakcanary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/hjq/demo/action/TitleBarAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ public interface TitleBarAction extends OnTitleBarListener {
/**
* 左项被点击
*
* @param view 被点击的左项View
* @param titleBar 被点击的左项View
*/
@Override
default void onLeftClick(View view) {}
default void onLeftClick(TitleBar titleBar) {}

/**
* 标题被点击
*
* @param view 被点击的标题View
* @param titleBar 被点击的标题View
*/
@Override
default void onTitleClick(View view) {}
default void onTitleClick(TitleBar titleBar) {}

/**
* 右项被点击
*
* @param view 被点击的右项View
* @param titleBar 被点击的右项View
*/
@Override
default void onRightClick(View view) {}
default void onRightClick(TitleBar titleBar) {}

/**
* 设置标题栏的标题
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/java/com/hjq/demo/action/ToastAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import androidx.annotation.StringRes;

import com.hjq.toast.ToastUtils;
import com.hjq.toast.Toaster;


/**
* author : Android 轮子哥
Expand All @@ -13,14 +14,14 @@
public interface ToastAction {

default void toast(CharSequence text) {
ToastUtils.show(text);
Toaster.show(text);
}

default void toast(@StringRes int id) {
ToastUtils.show(id);
Toaster.show(id);
}

default void toast(Object object) {
ToastUtils.show(object);
Toaster.show(object);
}
}
5 changes: 3 additions & 2 deletions app/src/main/java/com/hjq/demo/aop/CheckNetAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import com.hjq.demo.R;
import com.hjq.demo.manager.ActivityManager;
import com.hjq.toast.ToastUtils;

import com.hjq.toast.Toaster;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
Expand Down Expand Up @@ -42,7 +43,7 @@ public void aroundJoinPoint(ProceedingJoinPoint joinPoint, CheckNet checkNet) th
NetworkInfo info = manager.getActiveNetworkInfo();
// 判断网络是否连接
if (info == null || !info.isConnected()) {
ToastUtils.show(R.string.common_network_hint);
Toaster.show(R.string.common_network_hint);
return;
}
}
Expand Down
45 changes: 21 additions & 24 deletions app/src/main/java/com/hjq/demo/app/AppActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.hjq.demo.action.ToastAction;
import com.hjq.demo.http.model.HttpData;
import com.hjq.demo.ui.dialog.WaitDialog;
import com.hjq.http.config.IRequestApi;
import com.hjq.http.listener.OnHttpListener;

import okhttp3.Call;
Expand Down Expand Up @@ -178,7 +179,7 @@ public TitleBar getTitleBar() {
}

@Override
public void onLeftClick(View view) {
public void onLeftClick(TitleBar titleBar) {
onBackPressed();
}

Expand All @@ -194,33 +195,29 @@ public void finish() {
overridePendingTransition(R.anim.left_in_activity, R.anim.left_out_activity);
}

/**
* {@link OnHttpListener}
*/
@Override
public void onHttpStart(@NonNull IRequestApi api) {
showDialog();
}

@Override
public void onStart(Call call) {
showDialog();
}
@Override
public void onHttpSuccess(@NonNull Object result) {
if (result instanceof HttpData) {
toast(((HttpData<?>) result).getMessage());
}
}

@Override
public void onSucceed(Object result) {
if (result instanceof HttpData) {
toast(((HttpData<?>) result).getMessage());
}
}
@Override
public void onHttpFail(@NonNull Throwable throwable) {
toast(throwable.getMessage());
}

@Override
public void onFail(Exception e) {
toast(e.getMessage());
}

@Override
public void onEnd(Call call) {
hideDialog();
}
@Override
public void onHttpEnd(@NonNull IRequestApi api) {
hideDialog();
}

@Override
@Override
protected void onDestroy() {
super.onDestroy();
if (isShowDialog()) {
Expand Down
44 changes: 29 additions & 15 deletions app/src/main/java/com/hjq/demo/app/AppApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@
import com.hjq.http.config.IRequestInterceptor;
import com.hjq.http.model.HttpHeaders;
import com.hjq.http.model.HttpParams;
import com.hjq.http.request.HttpRequest;
import com.hjq.permissions.XXPermissions;
import com.hjq.toast.ToastUtils;

import com.hjq.toast.Toaster;
import com.hjq.umeng.UmengClient;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.mmkv.MMKV;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import timber.log.Timber;

/**
Expand Down Expand Up @@ -104,11 +108,9 @@ public static void initSdk(Application application) {
});

// 初始化吐司
ToastUtils.init(application, new ToastStyle());
// 设置调试模式
ToastUtils.setDebugMode(AppConfig.isDebug());
// 设置 Toast 拦截器
ToastUtils.setInterceptor(new ToastLogInterceptor());
Toaster.init(application);
// 设置 Toast 拦截器(全局生效)
Toaster.setInterceptor(new ToastLogInterceptor());

// 本地异常捕捉
CrashHandler.register(application);
Expand Down Expand Up @@ -138,14 +140,26 @@ public static void initSdk(Application application) {
.setHandler(new RequestHandler(application))
// 设置请求重试次数
.setRetryCount(1)
.setInterceptor((api, params, headers) -> {
// 添加全局请求头
headers.put("token", "66666666666");
headers.put("deviceOaid", UmengClient.getDeviceOaid());
headers.put("versionName", AppConfig.getVersionName());
headers.put("versionCode", String.valueOf(AppConfig.getVersionCode()));
// 添加全局请求参数
// params.put("6666666", "6666666");
.setInterceptor(new IRequestInterceptor() {
@Override
public void interceptArguments(@NonNull HttpRequest<?> httpRequest, @NonNull HttpParams params, @NonNull HttpHeaders headers) {
// 请求参数拦截
IRequestInterceptor.super.interceptArguments(httpRequest, params, headers);
}

@NonNull
@Override
public Request interceptRequest(@NonNull HttpRequest<?> httpRequest, @NonNull Request request) {
// 请求拦截
return IRequestInterceptor.super.interceptRequest(httpRequest, request);
}

@NonNull
@Override
public Response interceptResponse(HttpRequest<?> httpRequest, Response response) {
// 响应拦截
return IRequestInterceptor.super.interceptResponse(httpRequest, response);
}
})
.into();

Expand Down Expand Up @@ -177,7 +191,7 @@ public void onLost(@NonNull Network network) {
return;
}

ToastUtils.show(R.string.common_network_error);
Toaster.show(R.string.common_network_error);
}
});
}
Expand Down
45 changes: 22 additions & 23 deletions app/src/main/java/com/hjq/demo/app/AppFragment.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.hjq.demo.app;

import androidx.annotation.NonNull;

import com.hjq.base.BaseFragment;
import com.hjq.demo.action.ToastAction;
import com.hjq.demo.http.model.HttpData;
import com.hjq.http.config.IRequestApi;
import com.hjq.http.listener.OnHttpListener;

import okhttp3.Call;
Expand Down Expand Up @@ -49,30 +52,26 @@ public void hideDialog() {
activity.hideDialog();
}

/**
* {@link OnHttpListener}
*/

@Override
public void onStart(Call call) {
showDialog();
}
@Override
public void onHttpStart(@NonNull IRequestApi api) {
showDialog();
}

@Override
public void onSucceed(Object result) {
if (!(result instanceof HttpData)) {
return;
}
toast(((HttpData<?>) result).getMessage());
}
@Override
public void onHttpSuccess(@NonNull Object result) {
if (!(result instanceof HttpData)) {
return;
}
toast(((HttpData<?>) result).getMessage());
}

@Override
public void onFail(Exception e) {
toast(e.getMessage());
}
@Override
public void onHttpFail(@NonNull Throwable throwable) {
toast(throwable.getMessage());
}

@Override
public void onEnd(Call call) {
hideDialog();
}
@Override
public void onHttpEnd(@NonNull IRequestApi api) {
hideDialog();
}
}
Loading