Skip to content

Commit

Permalink
修改 Toast 依赖项
Browse files Browse the repository at this point in the history
  • Loading branch information
getActivity committed Feb 19, 2023
1 parent 32d5d4b commit a3b83c4
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
22 changes: 11 additions & 11 deletions HelpDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ EasyHttp.post(this)

@Override
public void onSucceed(HttpData<LoginBean> data) {
ToastUtils.show("登录成功");
toast("登录成功");
}
});
```
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -461,9 +461,9 @@ try {
.api(new SearchBlogsApi()
.setKeyword("搬砖不再有"))
.execute(new ResponseClass<HttpData<SearchBean>>() {});
ToastUtils.show("请求成功,请看日志");
toast("请求成功,请看日志");
} catch (Exception e) {
ToastUtils.show(e.getMessage());
toast(e.getMessage());
}
```

Expand Down Expand Up @@ -645,7 +645,7 @@ lifecycleScope.launch(Dispatchers.IO) {
// 在这里进行 UI 刷新
}
} catch (e: Exception) {
ToastUtils.show(e.message)
toast(e.message)
}
}
```
Expand Down Expand Up @@ -1660,7 +1660,7 @@ Observable.create(new ObservableOnSubscribe<HttpData<SearchBean>>() {

@Override
public void accept(Throwable throwable) throws Exception {
ToastUtils.show(throwable.getMessage());
toast(throwable.getMessage());
}
});
```
Expand Down Expand Up @@ -1743,7 +1743,7 @@ Observable.create(new ObservableOnSubscribe<HttpData<SearchBean>>() {
@Override
public void accept(Throwable throwable) throws Exception {
ToastUtils.show(throwable.getMessage());
toast(throwable.getMessage());
}
});
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/hjq/easy/demo/AppApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

// 网络请求框架初始化
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/hjq/easy/demo/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions app/src/main/java/com/hjq/easy/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -97,10 +97,10 @@ public void onGranted(@NonNull List<String> permissions, boolean allGranted) {}
@Override
public void onDenied(@NonNull List<String> permissions, boolean doNotAskAgain) {
if (doNotAskAgain) {
ToastUtils.show("授权失败,请手动授予存储权限");
Toaster.show("授权失败,请手动授予存储权限");
XXPermissions.startPermissionActivity(this, permissions);
} else {
ToastUtils.show("请先授予存储权限");
Toaster.show("请先授予存储权限");
requestPermission();
}
}
Expand All @@ -127,7 +127,7 @@ public void onClick(View view) {

@Override
public void onSucceed(HttpData<List<SearchAuthorApi.Bean>> result) {
ToastUtils.show("Get 请求成功,请看日志");
Toaster.show("Get 请求成功,请看日志");
}
});

Expand All @@ -140,7 +140,7 @@ public void onSucceed(HttpData<List<SearchAuthorApi.Bean>> result) {

@Override
public void onSucceed(HttpData<SearchBlogsApi.Bean> result) {
ToastUtils.show("Post 请求成功,请看日志");
Toaster.show("Post 请求成功,请看日志");
}
});

Expand All @@ -154,17 +154,17 @@ public void onSucceed(HttpData<SearchBlogsApi.Bean> result) {
.api(new SearchBlogsApi()
.setKeyword("搬砖不再有"))
.execute(new ResponseClass<HttpData<SearchBlogsApi.Bean>>() {});
ToastUtils.show("同步请求成功,请看日志");
Toaster.show("同步请求成功,请看日志");
} catch (Exception e) {
ToastUtils.show(e.getMessage());
Toaster.show(e.getMessage());
}
runOnUiThread(this::hideDialog);
}).start();

} else if (viewId == R.id.btn_main_update) {

if (mProgressBar.getVisibility() == View.VISIBLE) {
ToastUtils.show("当前正在上传或者下载,请等待完成之后再进行操作");
Toaster.show("当前正在上传或者下载,请等待完成之后再进行操作");
return;
}

Expand Down Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit a3b83c4

Please sign in to comment.