public void doUnAttTask(final Father host) { if (mUser != null) { String cancelId = ""; AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); RequestParams params = new RequestParams(); params.put("uid", mUser.getUid()); params.put("token", mUser.getToken()); for (int i = 0; i < hostAtts.size(); i++) { Host hosts = hostAtts.get(i); if (hosts.getUid().equals(host.getUid())) { cancelId = hosts.getHostAttId(); break; } } params.put("cancleId", cancelId); asyncHttpClient.post( AppConstants.PAY_HOST_UNATTE, params, new AsyncHttpResponseHandler() { @Override public void onStart() { super.onStart(); mDialog = Utils.showProgressDialog(TraceHostSeeActivity.this, "操作中……"); mDialog.show(); } @Override public void onSuccess(String content) { super.onSuccess(content); mDialog.dismiss(); if (content != null) { JSONObject jsonObject; try { jsonObject = new JSONObject(content); boolean success = jsonObject.getBoolean("success"); if (success == true) { Utils.MakeToast(getApplicationContext(), "取消成功"); getHostAtt(); } else { String message = jsonObject.optString("msg"); Utils.MakeToast(getApplicationContext(), message); } } catch (Exception e) { e.printStackTrace(); } } } @Override public void onFailure(Throwable error, String content) { super.onFailure(error, content); mDialog.dismiss(); Utils.MakeToast(getApplicationContext(), "网络连接超时"); } }); } else { Utils.MakeToast(getApplicationContext(), "请先登录"); } }
private void getHostAtt() { AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); RequestParams params = new RequestParams(); params.put("uid", mUser.getUid()); params.put("token", mUser.getToken()); asyncHttpClient.post( AppConstants.GET_ALL_ATT_LIST, params, new AsyncHttpResponseHandler() { @Override public void onStart() { super.onStart(); } @Override public void onSuccess(String content) { super.onSuccess(content); if (content != null) { JSONObject jsonObject; try { jsonObject = new JSONObject(content); boolean success = jsonObject.optBoolean("success"); if (success == true) { JSONObject object = jsonObject.optJSONObject("retval"); JSONArray array = object.optJSONArray("myfollowers"); hostAtts.clear(); for (int i = 0; i < array.length(); i++) { JSONObject jsonObject2 = array.getJSONObject(i); Host host = new Host(); host.setUid(jsonObject2.optString("followuid")); // 主播自己的ID host.setHostAttId(jsonObject2.optString("id")); host.setAvatar(jsonObject2.optString("avatar")); host.setNickName(jsonObject2.optString("nickname")); host.setUserNum(jsonObject2.optString("usernum")); host.setWeath(jsonObject2.optString("wealth")); host.setRoomTag(jsonObject2.optString("room_ext1")); host.setRoomId(jsonObject2.optString("rid")); hostAtts.add(host); } adapter.notifyDataSetChanged(); } else { String msg = jsonObject.optString("msg"); Utils.MakeToast(getApplicationContext(), msg); } } catch (Exception e) { e.printStackTrace(); } } } @Override public void onFailure(Throwable error, String content) { super.onFailure(error, content); } }); }
/* * 添加关注 */ protected void doAttTask(final Father host) { if (mUser != null) { AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); RequestParams params = new RequestParams(); params.put("uid", mUser.getUid()); params.put("token", mUser.getToken()); params.put("follwerId", host.getUid()); asyncHttpClient.post( AppConstants.PAY_HOST_ATTE, params, new AsyncHttpResponseHandler() { @Override public void onStart() { super.onStart(); mDialog = Utils.showProgressDialog(TraceHostSeeActivity.this, "操作中……"); mDialog.show(); } @Override public void onSuccess(String content) { super.onSuccess(content); mDialog.dismiss(); if (content != null) { JSONObject jsonObject; try { jsonObject = new JSONObject(content); boolean success = jsonObject.getBoolean("success"); if (success == true) { Utils.MakeToast(getApplicationContext(), "关注成功"); getHostAtt(); } else { String message = jsonObject.optString("msg"); Utils.MakeToast(getApplicationContext(), message); } } catch (Exception e) { e.printStackTrace(); } } } @Override public void onFailure(Throwable error, String content) { super.onFailure(error, content); mDialog.dismiss(); Utils.MakeToast(getApplicationContext(), "网络连接超时"); } }); } else { // Utils.MakeToast(getApplicationContext(), "请先登录"); Intent intent = new Intent(TraceHostSeeActivity.this, ChatRoomActivity.class); intent.putExtra("host", host); startActivity(intent); } }
private void doOpenSourceLoginTask(String opendId, String source) { AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); RequestParams params = new RequestParams(); params.put("openid", opendId); params.put("source", source); params.put("os", 1 + ""); asyncHttpClient.post( AppConstants.OPEN_SOURCE_LOGIN, params, new AsyncHttpResponseHandler() { @Override public void onStart() { super.onStart(); } @Override public void onSuccess(String content) { super.onSuccess(content); if (!TextUtils.isEmpty(content)) { try { JSONObject jsonObject = new JSONObject(content); boolean isSuccess = jsonObject.getBoolean("success"); if (isSuccess == true) { JSONObject jsonObject2 = jsonObject.getJSONObject("retval"); ApplicationEx.get().getUserManager().parseJSONUser(jsonObject2); } } catch (Exception e) { e.printStackTrace(); } } } @Override public void onFailure(Throwable error, String content) { super.onFailure(error, content); Utils.MakeToast(getApplicationContext(), "连接超时"); } }); }
private void doLoginTask() { AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); RequestParams params = new RequestParams(); params.put("uname", MoccaPreferences.USERNAME.get()); params.put("passwd", MoccaPreferences.USERPWD.get()); params.put("os", 1 + ""); asyncHttpClient.post( AppConstants.USER_LOGIN_URL, params, new AsyncHttpResponseHandler() { @Override public void onStart() { super.onStart(); } @Override public void onSuccess(String content) { super.onSuccess(content); if (!TextUtils.isEmpty(content)) { try { JSONObject jsonObject = new JSONObject(content); boolean isSuccess = jsonObject.getBoolean("success"); if (isSuccess == true) { JSONObject jsonObject2 = jsonObject.getJSONObject("retval"); ApplicationEx.get().getUserManager().parseJSONUser(jsonObject2); } } catch (Exception e) { e.printStackTrace(); } } } @Override public void onFailure(Throwable error, String content) { super.onFailure(error, content); } }); }