@Override public void isFav(String nid) { model.isfavAnswer( nid, new ResultCallback<String>() { @Override public void onError(Request request, Exception e) { view.getStateFail("获取状态失败"); } @Override public void onResponse(String response) { try { JSONObject jsonObject = new JSONObject(response); int status = jsonObject.getInt("status"); String result = jsonObject.getString("result"); if (status == 1 && !result.equals("[]")) { FavAndGoodState fav = GsonUtils.changeGsonToBean(result, FavAndGoodState.class); view.getStateSuccess(fav); } else if (status == 2) { view.checkToken(); view.getStateFail("获取状态失败"); } else { view.getStateFail("获取状态失败"); } } catch (Exception e) { view.getStateFail("获取状态失败"); e.printStackTrace(); } } }); }
@Override public void UnFav(CompanyAnswer article) { model.UnfavAnswer( article, new ResultCallback<String>() { @Override public void onError(Request request, Exception e) { view.UnFavFail(ApiException.getApiExceptionMessage(e.getMessage())); } @Override public void onResponse(String response) { try { JSONObject jsonObject = new JSONObject(response); int status = jsonObject.getInt("status"); String message = jsonObject.getString("message"); if (status == 1) { view.UnFavSuccess(); } else if (status == 2) { view.UnFavFail(message); view.checkToken(); } else { view.UnFavFail(message); } } catch (Exception e) { view.UnFavFail(ApiException.getApiExceptionMessage(e.getMessage())); e.printStackTrace(); } } }); }
@Override public void getContent(String mid) { view.getLoading(); model.getContent( mid, new ResultCallback<String>() { @Override public void onError(Request request, Exception e) { view.getDataFail(ApiException.getApiExceptionMessage(e.getMessage())); } @Override public void onResponse(String response) { try { JSONObject jsonObject = new JSONObject(response); int status = jsonObject.getInt("status"); String message = jsonObject.getString("message"); if (status == 1) { String result = jsonObject.getString("result"); AnswerContent answerContent = GsonUtils.changeGsonToBean(result, AnswerContent.class); view.getDataSuccess(answerContent); } else if (status == 2) { view.getDataFail(message); view.checkToken(); } else { view.getDataFail(message); } } catch (Exception e) { view.getDataFail(ApiException.getApiExceptionMessage(e.getMessage())); e.printStackTrace(); } } }); }