光环助手V3.5-下载功能优化汇总

This commit is contained in:
kehaoyuan
2018-09-14 11:10:22 +08:00
parent 2ee3adef14
commit 9b7e8841c4
15 changed files with 202 additions and 128 deletions

View File

@ -13,6 +13,7 @@ import android.support.v7.app.AlertDialog;
import android.text.Html;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
@ -29,6 +30,7 @@ import com.gh.gamecenter.KcSelectGameActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.kuaichuan.WifiMgr;
import com.halo.assistant.HaloApp;
import com.lightgame.utils.Utils;
import java.io.File;
import java.text.DecimalFormat;
@ -351,10 +353,57 @@ public class DialogUtils {
}, null);
}
public static void showDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener) {
showWarningDialog(context, "下载提示", "您当前使用的网络为2G/3G/4G开始下载将会消耗移动流量确定下载", "取消", "确定", listener, cancelListener);
public static void checkDownload(Context context, String size, CheckDownloadCallBack callBack) {
if (NetworkUtils.isWifiConnected(context) || filter4GorSize(context, size)) {
callBack.onResponse(false);
} else {
showDownloadDialog(context, () -> {
callBack.onResponse(false);
}, () -> {
callBack.onResponse(true);
});
}
}
private static boolean filter4GorSize(Context context, String size) {
try {
if (TextUtils.isEmpty(size)) {
return false;
}
String mb = size.toUpperCase().replaceAll("MB", "").trim();
Integer i = Integer.valueOf(mb);
if (NetworkUtils.isWifiOr4GConnected(context) && i <= 50) {
Utils.toast(context, "当前使用移动流量下载");
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
public static void checkResumeDownload(Context context, CheckDownloadCallBack callBack) {
if (NetworkUtils.isWifiConnected(context)) {
callBack.onResponse(false);
} else {
showResumeDownloadDialog(context, () -> {
callBack.onResponse(false);
}, () -> {
callBack.onResponse(true);
});
}
}
public static void showDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener) {
showWarningDialog(context, "下载提示", "当前正在使用移动网络,立即下载会消耗手机流量", "连上WiFi后自动下载", "立即下载", listener, cancelListener);
}
public static void showResumeDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener) {
showWarningDialog(context, "下载提示", "当前正在使用移动网络,继续下载会消耗手机流量", "连上WiFi后自动下载", "继续下载", listener, cancelListener);
}
public static void showDownloadDialog(Context context, ConfirmListener listener) {
showWarningDialog(context, "下载提示", "您当前使用的网络为2G/3G/4G开始下载将会消耗移动流量确定下载", listener);
}
@ -736,4 +785,9 @@ public class DialogUtils {
void onCancel();
}
public interface CheckDownloadCallBack {
void onResponse(boolean isSubscribe);
}
}