fix tinker patch

This commit is contained in:
CsHeng
2017-11-07 11:31:41 +08:00
parent 7832cb810b
commit bcd32dde85

View File

@ -56,6 +56,7 @@ import com.gh.gamecenter.retrofit.ObservableUtil;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.halo.assistant.HaloApp;
import com.lightgame.config.CommonDebug;
import com.lightgame.download.DataWatcher;
@ -74,6 +75,7 @@ import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
@ -700,10 +702,6 @@ public class MainActivity extends BaseActivity {
// 2.1 显示更新信息弹窗记录tinkerId+newTinkerId
// 2.1.1 若tinkerId一致但newTinkerId不一致才能认为是一次补丁更新
Gson gson = new Gson();
Map<String, Set<String>> tinkerIdMap = new HashMap<>();
String tinkerId = TinkerManager.getTinkerId();
String newTinkerId = TinkerManager.getNewTinkerId();
@ -712,6 +710,19 @@ public class MainActivity extends BaseActivity {
return;
}
Gson gson = new Gson();
Type type = new TypeToken<HashMap<String, Set<String>>>() {
}.getType();
final Map<String, Set<String>> tinkerIdMap;
final String tinkerMapJson = sp.getString(Config.PATCHES, "");
if (!TextUtils.isEmpty(tinkerMapJson)) {
tinkerIdMap = gson.fromJson(tinkerMapJson, type);
} else {
tinkerIdMap = new HashMap<>();
}
Set<String> tinkerIdSet = tinkerIdMap.get(tinkerId);
if (tinkerIdSet == null) {
tinkerIdSet = new HashSet<>();