diff --git a/HelpDoc.md b/HelpDoc.md index 7dafaa8..a12092a 100644 --- a/HelpDoc.md +++ b/HelpDoc.md @@ -302,7 +302,7 @@ EasyHttp.post(this) @Override public void onSucceed(HttpData data) { - ToastUtils.show("登录成功"); + toast("登录成功"); } }); ``` @@ -358,12 +358,12 @@ EasyHttp.post(this) @Override public void onSucceed(Void result) { - ToastUtils.show("上传成功"); + toast("上传成功"); } @Override public void onFail(Exception e) { - ToastUtils.show("上传失败"); + toast("上传失败"); } @Override @@ -402,13 +402,13 @@ EasyHttp.download(this) @Override public void onComplete(File file) { - ToastUtils.show("下载完成:" + file.getPath()); - installApk(MainActivity.this, file); + toast("下载完成:" + file.getPath()); + installApk(XxxActivity.this, file); } @Override public void onError(File file, Exception e) { - ToastUtils.show("下载出错:" + e.getMessage()); + toast("下载出错:" + e.getMessage()); } @Override @@ -461,9 +461,9 @@ try { .api(new SearchBlogsApi() .setKeyword("搬砖不再有")) .execute(new ResponseClass>() {}); - ToastUtils.show("请求成功,请看日志"); + toast("请求成功,请看日志"); } catch (Exception e) { - ToastUtils.show(e.getMessage()); + toast(e.getMessage()); } ``` @@ -645,7 +645,7 @@ lifecycleScope.launch(Dispatchers.IO) { // 在这里进行 UI 刷新 } } catch (e: Exception) { - ToastUtils.show(e.message) + toast(e.message) } } ``` @@ -1660,7 +1660,7 @@ Observable.create(new ObservableOnSubscribe>() { @Override public void accept(Throwable throwable) throws Exception { - ToastUtils.show(throwable.getMessage()); + toast(throwable.getMessage()); } }); ``` @@ -1743,7 +1743,7 @@ Observable.create(new ObservableOnSubscribe>() { @Override public void accept(Throwable throwable) throws Exception { - ToastUtils.show(throwable.getMessage()); + toast(throwable.getMessage()); } }); ``` \ No newline at end of file diff --git a/README.md b/README.md index e26234c..0ea2d29 100644 --- a/README.md +++ b/README.md @@ -223,7 +223,7 @@ EasyHttp.post(this) * 权限框架:[XXPermissions](https://github.com/getActivity/XXPermissions) ![](https://img.shields.io/github/stars/getActivity/XXPermissions.svg) ![](https://img.shields.io/github/forks/getActivity/XXPermissions.svg) -* 吐司框架:[ToastUtils](https://github.com/getActivity/ToastUtils) ![](https://img.shields.io/github/stars/getActivity/ToastUtils.svg) ![](https://img.shields.io/github/forks/getActivity/ToastUtils.svg) +* 吐司框架:[Toaster](https://github.com/getActivity/Toaster) ![](https://img.shields.io/github/stars/getActivity/Toaster.svg) ![](https://img.shields.io/github/forks/getActivity/Toaster.svg) * 标题栏框架:[TitleBar](https://github.com/getActivity/TitleBar) ![](https://img.shields.io/github/stars/getActivity/TitleBar.svg) ![](https://img.shields.io/github/forks/getActivity/TitleBar.svg) diff --git a/app/build.gradle b/app/build.gradle index 51cfaca..6a47839 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,8 +72,8 @@ dependencies { // noinspection GradleDependency implementation 'com.squareup.okhttp3:okhttp:3.12.13' - // 吐司框架:https://github.com/getActivity/ToastUtils - implementation 'com.github.getActivity:ToastUtils:11.2' + // 吐司框架:https://github.com/getActivity/Toaster + implementation 'com.github.getActivity:Toaster:12.0' // 权限请求框架:https://github.com/getActivity/XXPermissions implementation 'com.github.getActivity:XXPermissions:16.6' diff --git a/app/src/main/java/com/hjq/easy/demo/AppApplication.java b/app/src/main/java/com/hjq/easy/demo/AppApplication.java index de8fe1f..9c82ab8 100644 --- a/app/src/main/java/com/hjq/easy/demo/AppApplication.java +++ b/app/src/main/java/com/hjq/easy/demo/AppApplication.java @@ -13,7 +13,7 @@ import com.hjq.http.model.HttpHeaders; import com.hjq.http.model.HttpParams; import com.hjq.http.request.HttpRequest; -import com.hjq.toast.ToastUtils; +import com.hjq.toast.Toaster; import com.tencent.mmkv.MMKV; import okhttp3.OkHttpClient; @@ -29,7 +29,7 @@ public final class AppApplication extends Application { @Override public void onCreate() { super.onCreate(); - ToastUtils.init(this); + Toaster.init(this); MMKV.initialize(this); // 网络请求框架初始化 diff --git a/app/src/main/java/com/hjq/easy/demo/BaseActivity.java b/app/src/main/java/com/hjq/easy/demo/BaseActivity.java index 53011f5..ee93f2b 100644 --- a/app/src/main/java/com/hjq/easy/demo/BaseActivity.java +++ b/app/src/main/java/com/hjq/easy/demo/BaseActivity.java @@ -6,7 +6,7 @@ import com.hjq.easy.demo.http.model.HttpData; import com.hjq.http.listener.OnHttpListener; -import com.hjq.toast.ToastUtils; +import com.hjq.toast.Toaster; import okhttp3.Call; @@ -68,13 +68,13 @@ public void onStart(Call call) { @Override public void onSucceed(Object result) { if (result instanceof HttpData) { - ToastUtils.show(((HttpData) result).getMessage()); + Toaster.show(((HttpData) result).getMessage()); } } @Override public void onFail(Exception e) { - ToastUtils.show(e.getMessage()); + Toaster.show(e.getMessage()); } @Override diff --git a/app/src/main/java/com/hjq/easy/demo/MainActivity.java b/app/src/main/java/com/hjq/easy/demo/MainActivity.java index 749048e..205a63d 100644 --- a/app/src/main/java/com/hjq/easy/demo/MainActivity.java +++ b/app/src/main/java/com/hjq/easy/demo/MainActivity.java @@ -35,7 +35,7 @@ import com.hjq.permissions.OnPermissionCallback; import com.hjq.permissions.Permission; import com.hjq.permissions.XXPermissions; -import com.hjq.toast.ToastUtils; +import com.hjq.toast.Toaster; import java.io.File; import java.io.IOException; @@ -97,10 +97,10 @@ public void onGranted(@NonNull List permissions, boolean allGranted) {} @Override public void onDenied(@NonNull List permissions, boolean doNotAskAgain) { if (doNotAskAgain) { - ToastUtils.show("授权失败,请手动授予存储权限"); + Toaster.show("授权失败,请手动授予存储权限"); XXPermissions.startPermissionActivity(this, permissions); } else { - ToastUtils.show("请先授予存储权限"); + Toaster.show("请先授予存储权限"); requestPermission(); } } @@ -127,7 +127,7 @@ public void onClick(View view) { @Override public void onSucceed(HttpData> result) { - ToastUtils.show("Get 请求成功,请看日志"); + Toaster.show("Get 请求成功,请看日志"); } }); @@ -140,7 +140,7 @@ public void onSucceed(HttpData> result) { @Override public void onSucceed(HttpData result) { - ToastUtils.show("Post 请求成功,请看日志"); + Toaster.show("Post 请求成功,请看日志"); } }); @@ -154,9 +154,9 @@ public void onSucceed(HttpData result) { .api(new SearchBlogsApi() .setKeyword("搬砖不再有")) .execute(new ResponseClass>() {}); - ToastUtils.show("同步请求成功,请看日志"); + Toaster.show("同步请求成功,请看日志"); } catch (Exception e) { - ToastUtils.show(e.getMessage()); + Toaster.show(e.getMessage()); } runOnUiThread(this::hideDialog); }).start(); @@ -164,7 +164,7 @@ public void onSucceed(HttpData result) { } else if (viewId == R.id.btn_main_update) { if (mProgressBar.getVisibility() == View.VISIBLE) { - ToastUtils.show("当前正在上传或者下载,请等待完成之后再进行操作"); + Toaster.show("当前正在上传或者下载,请等待完成之后再进行操作"); return; } @@ -219,12 +219,12 @@ public void onProgress(int progress) { @Override public void onSucceed(Void result) { - ToastUtils.show("上传成功"); + Toaster.show("上传成功"); } @Override public void onFail(Exception e) { - ToastUtils.show("上传失败"); + Toaster.show("上传失败"); } @Override @@ -236,7 +236,7 @@ public void onEnd(Call call) { } else if (viewId == R.id.btn_main_download) { if (mProgressBar.getVisibility() == View.VISIBLE) { - ToastUtils.show("当前正在上传或者下载,请等待完成之后再进行操作"); + Toaster.show("当前正在上传或者下载,请等待完成之后再进行操作"); return; } @@ -281,13 +281,13 @@ public void onProgress(File file, int progress) { @Override public void onComplete(File file) { - ToastUtils.show("下载完成:" + file.getPath()); + Toaster.show("下载完成:" + file.getPath()); installApk(MainActivity.this, file); } @Override public void onError(File file, Exception e) { - ToastUtils.show(e.getMessage()); + Toaster.show(e.getMessage()); if (e instanceof FileMD5Exception) { // 如果是文件 md5 校验失败,则删除文件 file.delete();