Commit d7d37f2d authored by fallenstardust's avatar fallenstardust

添加备用先行卡下载地址

parent 9cdf0cc3
......@@ -155,6 +155,7 @@ public interface Constants {
String URL_YGO233_ADVANCE = "https://ygo233.com/pre";
String URL_YGO233_DATAVER = "https://ygo233.com/pre/dataver";
String URL_YGO233_FILE = "https://ygo233.com/pre/download-ygomobile";
String URL_YGO233_FILE_ALT = "https://ygo233.com/pre/download-ygomobile/alt";
String SERVER_FILE = "server_list.xml";
String SHARE_FILE = ".share_deck.png";
......
......@@ -3,6 +3,7 @@ package cn.garymb.ygomobile.ui.activities;
import static cn.garymb.ygomobile.Constants.ASSET_SERVER_LIST;
import static cn.garymb.ygomobile.Constants.URL_YGO233_ADVANCE;
import static cn.garymb.ygomobile.Constants.URL_YGO233_FILE;
import static cn.garymb.ygomobile.Constants.URL_YGO233_FILE_ALT;
import static cn.garymb.ygomobile.utils.DownloadUtil.TYPE_DOWNLOAD_EXCEPTION;
import android.annotation.SuppressLint;
......@@ -33,8 +34,6 @@ import cn.garymb.ygomobile.bean.ServerInfo;
import cn.garymb.ygomobile.bean.ServerList;
import cn.garymb.ygomobile.lite.BuildConfig;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.home.HomeActivity;
import cn.garymb.ygomobile.ui.home.HomeFragment;
import cn.garymb.ygomobile.ui.home.MainActivity;
import cn.garymb.ygomobile.ui.home.ServerListManager;
import cn.garymb.ygomobile.ui.plus.VUiKit;
......@@ -42,6 +41,7 @@ import cn.garymb.ygomobile.ui.widget.WebViewPlus;
import cn.garymb.ygomobile.utils.DownloadUtil;
import cn.garymb.ygomobile.utils.FileUtils;
import cn.garymb.ygomobile.utils.IOUtils;
import cn.garymb.ygomobile.utils.SharedPreferenceUtil;
import cn.garymb.ygomobile.utils.SystemUtils;
import cn.garymb.ygomobile.utils.UnzipUtils;
import cn.garymb.ygomobile.utils.XmlUtils;
......@@ -50,6 +50,7 @@ import ocgcore.DataManager;
import ocgcore.data.Card;
public class WebActivity extends BaseActivity {
public static String dataVer = "";
private WebViewPlus mWebViewPlus;
private String mUrl;
private String mTitle;
......@@ -57,6 +58,7 @@ public class WebActivity extends BaseActivity {
private List<ServerInfo> serverInfos;
private ServerInfo mServerInfo;
private File xmlFile;
private int FailedCount;
@SuppressLint("HandlerLeak")
Handler handler = new Handler() {
......@@ -68,6 +70,11 @@ public class WebActivity extends BaseActivity {
btn_download.setText(msg.arg1 + "%");
break;
case DownloadUtil.TYPE_DOWNLOAD_EXCEPTION:
++FailedCount;
if (FailedCount <= 2) {
Toast.makeText(getActivity(), R.string.Ask_to_Change_Other_Way, Toast.LENGTH_SHORT).show();
downloadfromWeb(URL_YGO233_FILE_ALT);
}
YGOUtil.show("error" + msg.obj);
break;
case UnzipUtils.ZIP_READY:
......@@ -92,6 +99,7 @@ public class WebActivity extends BaseActivity {
servername = "Mercury23333 OCG/TCG Pre-release";
AddServer(servername, "s1.ygo233.com", 23333, "Knight of Hanoi");
btn_download.setVisibility(View.GONE);
SharedPreferenceUtil.setExpansionDataVer(WebActivity.dataVer);
break;
case UnzipUtils.ZIP_UNZIP_EXCEPTION:
Toast.makeText(getContext(), getString(R.string.install_failed_bcos) + msg.obj, Toast.LENGTH_SHORT).show();
......@@ -221,7 +229,7 @@ public class WebActivity extends BaseActivity {
btn_download.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
downloadfromWeb();
downloadfromWeb(URL_YGO233_FILE);
}
});
}
......@@ -277,12 +285,12 @@ public class WebActivity extends BaseActivity {
}
}
private void downloadfromWeb() {
File file = new File(AppsSettings.get().getResourcePath() + ".zip");
private void downloadfromWeb(String fileUrl) {
File file = new File(AppsSettings.get().getResourcePath() + "-preRlease.zip");
if (file.exists()) {
FileUtils.deleteFile(file);
}
DownloadUtil.get().download(URL_YGO233_FILE, file.getParent(), file.getName(), new DownloadUtil.OnDownloadListener() {
DownloadUtil.get().download(fileUrl, file.getParent(), file.getName(), new DownloadUtil.OnDownloadListener() {
@Override
public void onDownloadSuccess(File file) {
Message message = new Message();
......@@ -291,7 +299,7 @@ public class WebActivity extends BaseActivity {
File ydks = new File(AppsSettings.get().getDeckDir());
File[] subYdks = ydks.listFiles();
for (File files : subYdks) {
if(files.getName().contains("-") && files.getName().contains(" new cards"))
if (files.getName().contains("-") && files.getName().contains(" new cards"))
files.delete();
}
UnzipUtils.upZipFile(file, AppsSettings.get().getResourcePath());
......@@ -316,7 +324,6 @@ public class WebActivity extends BaseActivity {
public void onDownloadFailed(Exception e) {
//下载失败后删除下载的文件
FileUtils.deleteFile(file);
// downloadCardImage(code, file);
Message message = new Message();
message.what = TYPE_DOWNLOAD_EXCEPTION;
message.obj = e.toString();
......
......@@ -252,7 +252,7 @@
<string name="Cancel">취소</string>
<string name="Checking_Update">업데이트를 확인하는 중입니다. 잠시 기다려 주십시오.</string>
<string name="Checking_Update_Failed">업데이트 확인 실패</string>
<string name="Ask_to_Change_Other_Way">, 다른 방법으로 다운로드하겠습니까?</string>
<string name="Ask_to_Change_Other_Way">다른 방식을 시도해 봐...</string>
<string name="DuelAssistant">듀얼 어시스턴트가 활성화되었습니다</string>
<string name="masterrule">마스터 룰 알아보기</string>
<string name="tutorial">튜토리얼 보기</string>
......
......@@ -252,7 +252,7 @@
<string name="Cancel">取消</string>
<string name="Checking_Update">检查更新中,请稍候</string>
<string name="Checking_Update_Failed">检查更新失败</string>
<string name="Ask_to_Change_Other_Way">,是否跳转到备用下载方式?</string>
<string name="Ask_to_Change_Other_Way">主线下载失败,尝试备选线路中...</string>
<string name="DuelAssistant">决斗助手启用中</string>
<string name="masterrule">学习大师规则</string>
<string name="tutorial">查看软件教程</string>
......@@ -260,7 +260,7 @@
<string name="to_open">去开启</string>
<string name="crashed">软件错误退出</string>
<string name="invalid_shortcut">无效的快捷方式</string>
<string name="return_to_duel">点此返回决斗</string>
<string name="return_to_duel">点此返回决斗</string>
<string name="Start_ServiceDuelAssistant">开启决斗助手</string>
<string name="about_DuelAssistant">复制约战房间号直接加房
\n复制卡组文本直接保存为卡组并在卡组编辑打开它</string>
......
......@@ -250,7 +250,7 @@
<string name="Cancel">Cancel</string>
<string name="Checking_Update">Now Checking Update</string>
<string name="Checking_Update_Failed">Checking Update Failed</string>
<string name="Ask_to_Change_Other_Way">\, would you like to change other way</string>
<string name="Ask_to_Change_Other_Way">trying other way...</string>
<string name="DuelAssistant">DuelAssiatant is On</string>
<string name="masterrule">Master Rule</string>
<string name="tutorial">Soft Tutorial</string>
......@@ -333,7 +333,7 @@
<string name="label_ot_SC_OCG">SChinese OCG</string>
<string name="settings_screen_padding">Reserved height of curved screen</string>
<string name="tip_load_cdb_error">Load database error</string>
<string name="action_download_expansions">download\\nexpansions</string>
<string name="action_download_expansions">download\nexpansions</string>
<string name="replay">Watch replay</string>
<string name="bot_mode">Bot game</string>
<string name="personal">My</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment