update:2020.05.23

fix:toast显示问题
add:
This commit is contained in:
2020-05-23 18:29:09 +08:00
parent 3bd4a64371
commit 8976698729
3 changed files with 15 additions and 11 deletions

View File

@@ -88,18 +88,16 @@ public class GuardService extends Service implements NetStateChangeObserver {
return START_STICKY;
}
long time1 = 0L;
long time2 = 0L;
//在这里处理任务执行中的状态,如进度进度条的刷新
@Download.onTaskRunning
protected void running(DownloadTask task) {
Log.e("aria", "正在下载=--------------::" + task.getState() + "-------" + task.getPercent() + "-------" + task.getExtendField());
time2 = System.currentTimeMillis();
if ((time2 - time1) > 3499) {
ToastUtil.show("正在下载:" + task.getExtendField() + "--" + task.getPercent() + "%" + "\t" + Formatter.formatFileSize(GuardService.this, task.getSpeed()) + "/s");
time1 = time2;
}
}
@Download.onTaskComplete

View File

@@ -28,14 +28,20 @@ public class ToastUtil {
}
private static long time1 = 0L;
private static long time2 = 0L;
public static void show(final String msg) {
mainHandler.post(new Runnable() {
@Override
public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
showToast(mContext, msg, Toast.LENGTH_LONG);
Log.e("fht", "LENGTH_LONG");
time2 = System.currentTimeMillis();
if ((time2 - time1) > 3499) {
showToast(mContext, msg, Toast.LENGTH_LONG);
Log.e("fht", "LENGTH_LONG");
time1 = time2;
}
} else {
if (toast != null) {
toast.setText(msg);