package com.sheep.gamegroup.util;

import com.sheep.gamegroup.greendao.download.DownLoadInfo;
import com.sheep.jiuyan.samllsheep.R;
import com.sheep.jiuyan.samllsheep.SheepApp;

import java.util.Locale;

/**
 * Created by realicing on 2018/11/1.
 * realicing@sina.com
 * 下载按钮显示的文本
 */
public class DownloadTextUtl {

    public static String getHasReservationText(boolean showSimpleText) {
        return showSimpleText ? "已预约" : "已经预约";
    }
    public static String getReservationText(boolean showSimpleText) {
        return showSimpleText ? "预约" : "预约下载";
    }

    public static String getStartDownloadText(boolean showSimpleText) {
        return showSimpleText ? "下载" : CommonUtil.START_DOWNLOAD;
    }
    public static String getStartInstallText(boolean showSimpleText) {
        return showSimpleText ? "安装" : CommonUtil.START_INSTALL;
    }
    public static String getStartOpenText(boolean showSimpleText) {
        return showSimpleText ? "打开" : CommonUtil.GAME_OPEN;
    }
    public static String getOpenApplyText(boolean showSimpleText) {
        return showSimpleText ? "打开" : CommonUtil.OPEN_APPLY;
    }

    public static String getContinueDownloadText(boolean showSimpleText) {
        return showSimpleText ? "继续" : CommonUtil.CONTINUE_DOWNLOAD;
    }
    public static String getFailDownloadText(boolean showSimpleText) {
        return showSimpleText ? "失败" : CommonUtil.FAIL_DOWNLOAD;
    }
    public static String getTaskCancelText(boolean showSimpleText) {
        return showSimpleText ? "已取消" : "已经取消";
    }

    public static String getProgressText(boolean showSimpleText, DownLoadInfo task) {
        if(showSimpleText)
            return String.format(Locale.CHINA, "%d%%", Math.abs(task.getMPercent()));
        else
            return String.format(Locale.CHINA, "%d%%(%s)", Math.abs(task.getMPercent()), task.getAverageSpeed());//添加下载速度;
    }

    public static String getNoDownloadText(boolean showSimpleText) {
        return showSimpleText ? "无下载" : SheepApp.getInstance().getResources().getString(R.string.error_download_link);
    }
}
