admin
6 天以前 7f0825f8195a522ed7e8bcdb6347f3a719e06c74
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.yeshi.appupdate;
 
import android.content.Context;
 
import com.loopj.android.http.TextHttpResponseHandler;
import com.yeshi.appupdate.api.AppUpdateAPI;
 
import org.apache.http.Header;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONObject;
 
/**
 * 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) {
                            if (jsonObject.optString("data").equalsIgnoreCase("0")) {
                                isReview = false;
                            } else {
                                isReview = true;
                            }
                        }
                        EventBus.getDefault().post(isReview);
                    }
 
                    @Override
                    public void onFailure(int statusCode, Header[] headers,
                                          String responseString, Throwable throwable) {
                        isReview = false;
                    }
                });
        return isReview;
    }
}