public static void getBlogList(String type, int pageIndex, AsyncHttpResponseHandler handler) { RequestParams params = new RequestParams(); params.put("type", type); params.put("pageIndex", pageIndex); params.put("pageSize", AppContext.PAGE_SIZE); ApiHttpClient.get("action/api/blog_list", params, handler); }
private void removeMyCoach(int position) { RequestParams params = new RequestParams(); params.put("user_id", userId); params.put("video_id", list1.get(position).coach_id); HttpUtils.post( Constants.VIDEO_PRAISE, params, new TextHttpResponseHandler() { @Override public void onSuccess(int arg0, Header[] arg1, String arg2) { Gson gson = new Gson(); InfoBean fromJson = gson.fromJson(arg2, InfoBean.class); if ("0".equals(fromJson.code)) { Utils.showToast(getActivity(), "移除成功"); } else { Utils.showToast(getActivity(), "移除失败"); } } @Override public void onFailure(int arg0, Header[] arg1, String arg2, Throwable arg3) { Utils.showToast(getActivity(), "网络连接失败"); } }); }
@Override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, " onCreate"); super.onCreate(savedInstanceState); RequestParams params = new RequestParams(); String stream; if (getArguments() != null) { stream = getArguments().getString("streamKey"); } else { stream = "5629499534213120"; } Log.i(TAG, " Display Stream for: " + stream); params.put("stream", stream); jsonHandler = new MyImagesJsonHandler(this); MyConnexusClientUsage client = new MyConnexusClientUsage(); try { // default client.getStream(jsonHandler, params, "Stream.json"); } catch (JSONException e) { e.printStackTrace(); } if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } }
// Fetch Home Timeline public void getUserTimeLine(String screen_name, AsyncHttpResponseHandler handler) { String apiUrl = getApiUrl("statuses/user_timeline.json"); RequestParams params = new RequestParams(); params.put("count", 50); params.put("screen_name", String.valueOf(screen_name)); client.get(apiUrl, params, handler); }
public void getSelfFeed(String url, JsonHttpResponseHandler responseHandler) { RequestParams params = new RequestParams(); params.put("access_token", client.getAccessToken().getToken()); mSyncClient.get(url, params, responseHandler); // client.get(REST_URL + SELF_FEED_URL, params, responseHandler); // client.get(REST_URL + SELF_FEED_URL, null, responseHandler); }
private void startRequest() { if (httpRequestHandle != null) { return; } if (!UserCenterModuleEngine.getInstance().checkUserIsLogin()) { return; } if (!srl_refresh.isRefreshing()) { srl_refresh.post( new Runnable() { @Override public void run() { srl_refresh.setRefreshing(true); } }); } RequestParams requestParams = new RequestParams(); requestParams.put( NetConfig.UserCenterModule_MyLevel.RequestKey.sessionId, UserCenterModuleEngine.getInstance().getSessionIdFromCache()); httpRequestHandle = NetUtil.funHttpRequest( NetConfig.UserCenterModule_MyLevel.requestModel, baseActivity, null, NetConfig.UserCenterModule_MyLevel.ACTION, requestParams, new CusHttpResponseHandler()); }
private void callRefreshToken(final USUProgressDialog mProgressDialog) { PrintLog.debug("RefreshToken Called..."); final RequestParams params = new RequestParams(); params.put("refresh_token", userPreference.getRefreshToken().trim()); getUsuApp() .getAsyncHttpClient() .loginHttpRequest( getActivity(), params, "refresh_token", new USUHttpClient.RequestListener() { @Override public void onComplete() { getMemberDetails(mProgressDialog); } @Override public void onExpired(int statusCode) { PrintLog.debug("DiscountFragments --> From LoginHttpRequest2"); if (statusCode == 5000) { callLoginScreen(); } } @Override public void onError(String message) { if (mProgressDialog != null && mProgressDialog.isShowing()) { mProgressDialog.dismiss(); } AlertUtils.showAlert(getActivity(), message); } }); }
private void getFriend() { AsyncHttpClient myClient; myClient = new AsyncHttpClient(); myClient.setTimeout(SingleToneData.getInstance().getTimeOutValue()); PersistentCookieStore myCookieStore = new PersistentCookieStore(context); myClient.setCookieStore(myCookieStore); String url = context.getString(R.string.url_gift_list); RequestParams params = new RequestParams(); LoginUtils loginUtils = new LoginUtils(context); params.put("id", loginUtils.getId()); params.put("pw", loginUtils.getPw()); myClient.post( url, params, new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { Log.i("(friend fragment)", new String(responseBody)); getGiftFinish(new String(responseBody)); } @Override public void onFailure( int statusCode, Header[] headers, byte[] responseBody, Throwable error) { Toast.makeText( context, getResources().getString(R.string.on_failure), Toast.LENGTH_SHORT) .show(); } }); }
public void getUserCredentials(AsyncHttpResponseHandler handler) { String apiUrl = getApiUrl("account/verify_credentials.json"); RequestParams params = new RequestParams(); params.put("skip_status", 1); params.put("include_entities", "false"); getClient().get(apiUrl, params, handler); }
public static void getTweetTopicList(int page, String topic, AsyncHttpResponseHandler handler) { RequestParams params = new RequestParams(); params.put("pageIndex", page); params.put("title", topic); params.put("pageSize", AppContext.PAGE_SIZE); ApiHttpClient.get("action/api/tweet_topic_list", params, handler); }
/** * * 使用第三方账号注册 * * @param catalog 类别(qq、wechat) * @param openIdInfo 第三方info * @param handler handler */ public static void openid_reg( String catalog, String openIdInfo, AsyncHttpResponseHandler handler) { RequestParams params = new RequestParams(); params.put("catalog", catalog); params.put("openid_info", openIdInfo); ApiHttpClient.post("action/api/openid_reg", params, handler); }
public static void getTweetList(int uid, int page, AsyncHttpResponseHandler handler) { RequestParams params = new RequestParams(); params.put("uid", uid); params.put("pageIndex", page); params.put("pageSize", AppContext.PAGE_SIZE); ApiHttpClient.get("action/api/tweet_list", params, handler); }
public static void getPostListByTag(String tag, int page, AsyncHttpResponseHandler handler) { RequestParams params = new RequestParams(); params.put("tag", tag); params.put("pageIndex", page); params.put("pageSize", AppContext.PAGE_SIZE); ApiHttpClient.get("action/api/post_list", params, handler); }
private static void uploadLog(String data, String report, AsyncHttpResponseHandler handler) { RequestParams params = new RequestParams(); params.put("app", "1"); params.put("report", report); params.put("msg", data); ApiHttpClient.post("action/api/user_report_to_admin", params, handler); }
public void makeVoipCall(final String number) { AudioManagerUtils.setLoudSpeaker(false); ((BaseActivity) getActivity()).showProgressDialog("Connecting VOIP Call"); RequestParams params = new RequestParams(); params.put("smartPagerID", SmartPagerApplication.getInstance().getPreferences().getUserID()); params.put("uberPassword", SmartPagerApplication.getInstance().getPreferences().getPassword()); AsyncHttpClient httpClient = new AsyncHttpClient(); httpClient.post( getActivity().getApplicationContext(), Constants.BASE_REST_URL + "/getTwilioClientToken", params, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { System.out.println("successful response: " + response); ((BaseActivity) getActivity()).hideProgressDialog(); VoipPhone voipPhone = new VoipPhone( ((BaseActivity) getActivity()).getApplicationContext(), response.optString("token")); voipPhone.connect(number); } @Override public void onFailure( int statusCode, Header[] headers, String responseBody, Throwable error) { System.out.println("failure response: " + responseBody); ((BaseActivity) getActivity()).hideProgressDialog(); } }); }
public void getPerfPpofDayData(final Integer page) { RequestParams params1 = new RequestParams(); params1.put("cycle", "4"); params1.put("ppid", ppid); params1.put("date", dayStr.toString()); params1.put("begin", page.toString()); params1.put("count", 20 + ""); final MzbProgressDialog pd = new MzbProgressDialog(getActivity(), "请稍后...."); pd.show(); RequestUtils.ClientTokenPost( getActivity(), MzbUrlFactory.BASE_URL + MzbUrlFactory.BRAND_PERFPP, params1, new NetCallBack() { @TargetApi(Build.VERSION_CODES.KITKAT) @Override public void onMzbSuccess(String result) { try { JSONObject obj = new JSONObject(result); Gson gson = new Gson(); if (obj.getInt("code") == 0) { if (page == 0) { data.clear(); } jsonArray = new JSONArray(obj.getString("data")); for (int i = 0; i < jsonArray.length(); i++) { JSONObject object = jsonArray.getJSONObject(i); PerfPpData perfPpData = gson.fromJson(object.toString(), PerfPpData.class); data.add(perfPpData); } curPage = data.size(); view = Utility.getInstance() .getDataLayout( getActivity(), curPage != 0, ground, "暂无数据", R.mipmap.nodata_err, view); add2removeFooterView(); listView.onRefreshComplete(); pd.dismiss(); } else { listView.onRefreshComplete(); pd.dismiss(); } } catch (JSONException e) { e.printStackTrace(); } } @Override public void onMzbFailues(Throwable arg0) { pd.dismiss(); } }); }
public void startArmCallback(final String number) { Bundle extras = new Bundle(); extras.putString(WebSendParam.phoneNumber.name(), number); // SmartPagerApplication.getInstance().startWebAction(WebAction.armCallback, extras); ((BaseActivity) getActivity()).showProgressDialog(getString(R.string.sending_request)); RequestParams params = new RequestParams(); params.put("smartPagerID", SmartPagerApplication.getInstance().getPreferences().getUserID()); params.put("uberPassword", SmartPagerApplication.getInstance().getPreferences().getPassword()); params.put("phoneNumber", number); httpClient.post( getActivity().getApplicationContext(), Constants.BASE_REST_URL + "/armCallback", params, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { System.out.println("successful response: " + response); ((BaseActivity) getActivity()).hideProgressDialog(); makeArmCallBack(number); } @Override public void onFailure( int statusCode, Header[] headers, String responseBody, Throwable error) { System.out.println("failure response: " + responseBody); ((BaseActivity) getActivity()).hideProgressDialog(); } }); }
// 获取企业的类型 public void companytypelist(final OnAsynGetListListener listener) { RequestParams params = new RequestParams(); params.put("pageSize", 10000); params.put("thisPage", 1); if (NetUtil.isNetworkAvailable()) { HttpUtil.post( "api/system/companytypelist", true, params, new AsyncHttpResponseHandler() { @Override public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { if (arg0 != 200) { listener.OnAsynRequestFail( "-1", GezitechApplication.getContext().getString(R.string.data_error)); } try { Response response = new Response(new String(arg2)); JSONObject root = response.asJSONObject(); if (root.getInt("state") != 1) { // 0 if (listener != null) listener.OnAsynRequestFail("-1", root.getString("msg")); return; } JSONObject data = root.getJSONObject("data"); JSONArray ja = data.getJSONArray("datas"); PageList pl = new PageList(); Companytype ct = null; for (int i = 0; i < ja.length(); i++) { JSONObject jo = ja.getJSONObject(i); ct = new Companytype(jo); ct.childtype = jo.has("childtype") ? jo.getJSONArray("childtype") : null; pl.add(ct); } listener.OnGetListDone(pl); } catch (Exception ex) { listener.OnAsynRequestFail( "-1", GezitechApplication.getContext().getString(R.string.data_error)); } } @Override public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { listener.OnAsynRequestFail( "-1", GezitechApplication.getContext().getString(R.string.data_error)); } @Override public void onFinish() { // 完成后调用,失败,成功,都要掉 } }); } else { if (listener != null) { listener.OnAsynRequestFail( "-1", GezitechApplication.getContext().getString(R.string.network_error)); } } }
/** 请求服务器数据---首页 */ private void requestData() { // 获取轮播图 HttpUtils.getSpecialList( new EntityHandler<Gift>(Gift.class) { @Override public void onReadSuccess(List<Gift> list) { specialList = list; for (int i = 0; i < list.size(); i++) { imageList.add(list.get(i).getGoods_image()); } // 设置轮播 viewPager.setAdapter(adapter); // 设置选中的标识 LinearLayout pointLinear = (LinearLayout) findViewById(R.id.gallery_point_linear); for (int i = 0; i < imageList.size(); i++) { ImageView pointView = new ImageView(IndexActivity.this); if (i == 0) { pointView.setBackgroundResource(R.drawable.feature_point_cur); } else { pointView.setBackgroundResource(R.drawable.feature_point); } pointLinear.addView(pointView); } } }); // 获取首页新闻资讯列表 RequestParams params = new RequestParams(); params.put("page", page); // 当前第几页 params.put("per_page", NUM); // 每页条数 HttpUtils.getnewslist(rel_getnewslist, params); }
public void postTweet(AsyncHttpResponseHandler handler, String status) { String apiUrl = getApiUrl("statuses/update.json"); RequestParams params = new RequestParams(); params.put("status", status); client.post(apiUrl, params, handler); }
// Fetch MentionsFragment public void getMentions(int page, AsyncHttpResponseHandler handler) { String apiUrl = getApiUrl("statuses/mentions_timeline.json"); RequestParams params = new RequestParams(); params.put("count", 5); params.put("page", String.valueOf(page)); client.get(apiUrl, params, handler); }
public void onSuccess(JSONObject jo) { customDismissDialog(); try { int status = jo.getInt(URL.STATUS); switch (status) { case 0: if (index == (fragment.getCount() - 1)) { showCustomToast("上传成功"); setResult(1); isOk = false; finish(); } else { uploadImg(index + 1); } break; default: isOk = true; showCustomToast(jo.getJSONObject(URL.RESPONSE).getString(URL.INFO)); RequestParams aap = getAjaxParams(); aap.put("dyid", dyid); ac.finalHttp.post(URL.DEL_DONGTAI, aap, new JsonHttpResponseHandler()); break; } } catch (Exception e) { e.printStackTrace(); } };
public void getUserTimeline(String screenName, AsyncHttpResponseHandler handler) { String apiUrl = getApiUrl("statuses/user_timeline.json"); RequestParams params = new RequestParams(); params.put("count", 25); params.put("screen_name", screenName); getClient().get(apiUrl, params, handler); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.rl_youyaoqing: // 有邀请ID rl_youyaoqing.setVisibility(View.GONE); ll_yaoqingid.setVisibility(View.VISIBLE); break; case R.id.rl_wuyaoqing: // 无邀请ID、 rl_youyaoqing.setVisibility(View.GONE); ll_yaoqingid.setVisibility(View.GONE); rl_wuyaoqing.setVisibility(View.GONE); ll_text_t.setVisibility(View.VISIBLE); ll_text_s.setVisibility(View.VISIBLE); params = new RequestParams(); params.put("deviceId", BaseApp.getModel().getDeviceId()); // deviceId没有获得, HttpUtils.getPointsFromInvite( new HttpErrorHandler() { @Override public void onRecevieSuccess(JSONObject json) { Tools.toast(FirstLoginActivity.this, "无邀请ID获得20积分"); } }, params); /** 提交数据 */ break; case R.id.rl_yaoqingyes: // 有邀请ID,并输入ID后的确定 shifuID = et_inputid.getText().toString().trim(); if (StringUtil.isEmpty(shifuID)) { Tools.toast(FirstLoginActivity.this, "邀请ID不能为空,如没有请选择无邀请!"); return; } rl_youyaoqing.setVisibility(View.GONE); rl_wuyaoqing.setVisibility(View.GONE); ll_yaoqingid.setVisibility(View.GONE); ll_text_t.setVisibility(View.VISIBLE); ll_text_s.setVisibility(View.VISIBLE); params = new RequestParams(); params.put("deviceId", BaseApp.getModel().getDeviceId()); // deviceId没有获得, params.put("parentid", shifuID); HttpUtils.getPointsFromInvite( new HttpErrorHandler() { @Override public void onRecevieSuccess(JSONObject json) { Tools.toast(FirstLoginActivity.this, "有邀请ID获得30积分"); } }, params); /** 提交数据 */ break; case R.id.rl_huodeyes: startActivity(new Intent(FirstLoginActivity.this, MainActivity.class)); finish(); break; default: break; } }
@Override public void onClick(View v) { if (mMaopaoObject == null) { showButtomToast(R.string.maopao_load_fail_comment); return; } EditText content = mEnterLayout.content; String input = content.getText().toString(); if (EmojiFilter.containsEmptyEmoji(v.getContext(), input)) { return; } Maopao.Comment comment = (Maopao.Comment) content.getTag(); String uri = String.format(ADD_COMMENT, comment.tweet_id); RequestParams params = new RequestParams(); String contentString; if (comment.id == 0) { contentString = Global.encodeInput("", input); } else { contentString = Global.encodeInput(comment.owner.name, input); } params.put("content", contentString); postNetwork(uri, params, ADD_COMMENT, 0, comment); showProgressBar(R.string.sending_comment); }
public void clickGetAcc() { RequestParams params = new RequestParams(); params.put("j_username", firstparameter.trim()); params.put("j_password", secondparameter.trim()); System.out.println(params.toString()); httpClient.post( METRO_STEP2, params, new AsyncHttpResponseHandler() { @Override public void onSuccess(String response) { System.out.println("metrobank5 response " + response); // myProgressDialog.dismiss(); clickJavier(); } public void onFailure(Throwable error, String content) { System.out.println("metrobank2 e1rror " + content); myProgressDialog.dismiss(); } }); }
// CHANGE THIS // DEFINE METHODS for different API endpoints here public void getInterestingnessList(AsyncHttpResponseHandler handler) { String apiUrl = getApiUrl("?nojsoncallback=1&method=flickr.interestingness.getList"); // Can specify query string params directly or through RequestParams. RequestParams params = new RequestParams(); params.put("format", "json"); client.get(apiUrl, params, handler); }
public void setProfileInfo(User user) { params = new RequestParams(); username = user.getScreenName(); name = user.getName(); params.put("uid", user.getUserId()); params.put("username", username); params.put("name", name); savePreferences("username", username); handler = new AsyncHttpResponseHandler() { @Override public void onSuccess(String response) { try { JSONObject object = new JSONObject(response); status = (String) object.get("auth"); } catch (JSONException e) { e.printStackTrace(); } next_step(status); } @Override public void onFailure(Throwable arg0, String arg1) { super.onFailure(arg0, arg1); } }; }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { System.out.println(resultCode); System.out.println(BraintreePaymentActivity.RESULT_OK); if (resultCode == BraintreePaymentActivity.BRAINTREE_RESULT_DEVELOPER_ERROR) { System.out.println("test"); } else if (resultCode == BraintreePaymentActivity.BRAINTREE_RESULT_SERVER_ERROR) { System.out.println("test2"); } if (resultCode == BraintreePaymentActivity.RESULT_OK) { System.out.println("hello"); String paymentMethodNonce = data.getStringExtra(BraintreePaymentActivity.EXTRA_PAYMENT_METHOD_NONCE); RequestParams requestParams = new RequestParams(); requestParams.put("payment_method_nonce", paymentMethodNonce); requestParams.put("amount", "10.00"); client.post( "https://pacific-tor-4300.herokuapp.com" + "/payment_methods", requestParams, new TextHttpResponseHandler() { @Override public void onSuccess(String content) { System.out.print("olala"); Toast.makeText(SearchActivity.this, "You've just bought a credit!", Toast.LENGTH_LONG) .show(); } }); } }
/** * 获取某活动已出席的人员列表 * * @param eventId * @param pageIndex * @param handler */ public static void getEventApplies(int eventId, int pageIndex, AsyncHttpResponseHandler handler) { RequestParams params = new RequestParams(); params.put("pageIndex", pageIndex); params.put("event_id", eventId); params.put("pageSize", AppContext.PAGE_SIZE); ApiHttpClient.get("action/api/event_attend_user", params, handler); }