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; } }