UpDataManager.java
2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.chudiangameplay.android.manager;
import android.content.Context;
import com.chudiangameplay.android.R;
import com.chudiangameplay.android.dialog.Update_Dialog;
import com.chudiangameplay.android.interface_.OkHttpCallBack;
import com.chudiangameplay.android.responce.BaseResponce;
import com.chudiangameplay.android.responce.GetVersionResponce;
import com.chudiangameplay.android.tool.CommToast;
import com.chudiangameplay.android.util.Util;
/**
* Created by Administrator on 2019/1/24.
*/
public class UpDataManager {
public static void getVersion(final Context context, final boolean showToast) {
API_HomeManager.version(context, new OkHttpCallBack() {
@Override
public void onSuccess(BaseResponce baseResponce) {
try {
if (BaseResponce.Status_Success.equals(baseResponce.status)) {
GetVersionResponce responce = (GetVersionResponce) baseResponce;
if (responce.data == null) {
if (showToast) {
CommToast.showToast(context, "当前已是最新版本");
}
} else {
String currentVersionStr = Util.getVersionName(context);
int newVersion = Integer.parseInt(responce.data.newestVersion.replace(".", ""));
int currentVersion = Integer.parseInt(currentVersionStr.replace(".", ""));
if (newVersion > currentVersion) {
Update_Dialog dialog = new Update_Dialog(context, R.style.myDialog);
dialog.setData(responce.data);
dialog.show();
} else {
if (showToast) {
CommToast.showToast(context, "当前已是最新版本");
}
}
}
}
} catch (Exception e) {
}
}
@Override
public void onFailure(BaseResponce baseResponce) {
}
});
}
}