admin
2021-07-28 c0269fcfa876b9c5cf309b2006462b4d09c5ef95
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
package com.ysh.wpc.appupdate;
 
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.telephony.TelephonyManager;
 
import com.loopj.android.http.TextHttpResponseHandler;
import com.ysh.wpc.appupdate.api.AppUpdateAPI;
 
import org.apache.http.Header;
import org.json.JSONObject;
 
import de.greenrobot.event.EventBus;
 
/**
 * Created by weikou2015 on 2017/9/15.
 */
 
public class GoReview {
    /**
     * 获取更新信息
     */
    static boolean isReview = false;
 
    public static boolean getGoReview(final Context mActivity, String mKey) {
 
        AppUpdateAPI.getGoReview(mActivity, mKey
                , new TextHttpResponseHandler() {
                    @Override
                    public void onSuccess(int statusCode, Header[] headers,
                                          String responseString) {
                        JSONObject jsonObject = null;
                        try {
                            jsonObject = new JSONObject(responseString);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (Integer.parseInt(jsonObject.optString("code")) == 0) {
                            isReview = !jsonObject.optString("data").equalsIgnoreCase("0");
                        }
                        EventBus.getDefault().post(isReview);
                    }
 
                    @Override
                    public void onFailure(int statusCode, Header[] headers,
                                          String responseString, Throwable throwable) {
                        isReview = false;
                    }
                });
        return isReview;
    }
}