com.loopj.android.http.RequestParams Java Examples

The following examples show how to use com.loopj.android.http.RequestParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegisterFragment.java    From school_shop with MIT License 6 votes vote down vote up
@Click
void submit(){
    RequestParams params = new RequestParams();
    String username = editUsername.getText().toString();
    String password = editPassword.getText().toString();
    String repasswordstr = rePassword.getText().toString();
    if (TextUtils.isEmpty(username)){
        showMiddleToast("昵称不能为空");
    }else if (password.length()<6){
        showMiddleToast("密码不能少于6位");
    }else if(!repasswordstr.equals(password)){
        showMiddleToast("两次输入密码不一致");
    }else {
        loadingProgressDialog.show();
        params.put("username",username);
        params.put("userpass",password);
        params.put("phone",phone);
        postNetwork(URLs.REGIRSTER,params,URLs.REGIRSTER);
    }
}
 
Example #2
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public static void sendLoginResult(LoginInfo logininfo, String s, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = new RequestParams();
    requestparams.put("access_token", (new StringBuilder()).append("").append(logininfo.accessToken).toString());
    requestparams.put("expiresIn", logininfo.expiresIn);
    requestparams.put("mac_token", logininfo.macToken);
    requestparams.put("miid", logininfo.miid);
    requestparams.put("aliasNick", logininfo.aliasNick);
    requestparams.put("miliaoNick", logininfo.miliaoNick);
    String s1;
    if (logininfo.miliaoIcon_320 != null && logininfo.miliaoIcon_320.length() > 0)
    {
        requestparams.put("miliaoIcon", logininfo.miliaoIcon_320);
    } else
    {
        requestparams.put("miliaoIcon", logininfo.miliaoIcon);
    }
    requestparams.put("friends", logininfo.friends);
    requestparams.put("deviceid", s);
    requestparams.put("devicetype", "0");
    s1 = BraceletHttpClient.getUrl("huami.health.apklogin.json");
    Debug.i(TAG, (new StringBuilder()).append("send login url= ").append(s1).toString());
    BraceletHttpClient.client.post(s1, requestparams, asynchttpresponsehandler);
}
 
Example #3
Source File: WriteClient.java    From StreamHub-Android-SDK with MIT License 6 votes vote down vote up
/**
 * @param action
 * @param contentId
 * @param collectionId The Id of the collection.
 * @param userToken    The token of the logged in user.
 * @param parameters
 * @param networkID    Livefyre provided network name
 * @param handler      Response handler
 * @throws MalformedURLException
 */
public static void featureMessage(String action, String contentId,
                                  String collectionId, String userToken,
                                  HashMap<String, Object> parameters, String networkID, JsonHttpResponseHandler handler)
        throws MalformedURLException {
    RequestParams bodyParams = new RequestParams();
    bodyParams.put("lftoken", userToken);

    final Builder uriBuilder = new Uri.Builder().scheme(LivefyreConfig.scheme)
            .authority(LivefyreConfig.quillDomain + "." + networkID)
            .appendPath("api").appendPath("v3.0").appendPath("collection")
            .appendPath(collectionId).appendPath(action)
            .appendPath(contentId).appendPath("")
            .appendQueryParameter("lftoken", userToken)
            .appendQueryParameter("collection_id", collectionId);

    Log.d("SDK", "" + uriBuilder);
    HttpClient.client.post(uriBuilder.toString(), bodyParams, handler);
}
 
Example #4
Source File: ImageLoadActivity.java    From android-opensource-library-56 with Apache License 2.0 6 votes vote down vote up
private void startLoad() {
    AsyncHttpClient client = new AsyncHttpClient();

    client.get(
            "http://farm3.staticflickr.com/2004/2249945112_caa85476ef_o.jpg",
            new BinaryHttpResponseHandler() {
                @Override
                public void onSuccess(byte[] binaryData) {
                    Log.d(TAG, "onSuccess");
                    Bitmap bitmap = BitmapFactory.decodeByteArray(
                            binaryData, 0, binaryData.length);
                    ImageView imageView = ((ImageView) findViewById(R.id.image));
                    imageView.setImageBitmap(bitmap);
                    imageView.setVisibility(View.VISIBLE);
                    findViewById(R.id.progress).setVisibility(View.GONE);
                }

                @Override
                public void onFailure(Throwable error, String content) {
                    error.printStackTrace();
                    Log.d(TAG, "onFailure");
                }
            });

    RequestParams param = new RequestParams();
    param.put("hpge", "fuga");

}
 
Example #5
Source File: ArticleContentFragment.java    From ONE-Unofficial with Apache License 2.0 6 votes vote down vote up
@Override
public void init() {

    lvArticle.addOnLikeChangeListener(this);

    Bundle bundle = getArguments();
    String date = bundle.getString(Constants.KEY_DATE);
    index = bundle.getInt(Constants.KEY_INDEX);

    curDate = TimeUtil.getPreviousDate(date, index);

    RequestParams params = new RequestParams();
    params.put("strMS", 1);
    params.put("strDate", date);
    params.put("strRow", index);
    getHttpData(Api.URL_ARTICLE, params, new HttpData("result", "contentEntity"));
}
 
Example #6
Source File: WriteClient.java    From StreamHub-Android-SDK with MIT License 6 votes vote down vote up
/**
 * @param collectionId The Id of the collection.
 * @param contentId
 * @param token        The token of the logged in user.
 * @param action
 * @param parameters
 * @param networkID    Livefyre provided network name.
 * @param handler      Response handler
 */
public static void flagContent(String collectionId, String contentId,
                               String token, LFSFlag action, RequestParams parameters,
                               String networkID, JsonHttpResponseHandler handler) {

    String url = (new Uri.Builder().scheme(LivefyreConfig.scheme)
            .authority(LivefyreConfig.quillDomain + "." + networkID)
            .appendPath("api").appendPath("v3.0").appendPath("message").appendPath("")) +
            contentId + (new Uri.Builder().appendPath("").appendPath("flag")
            .appendPath(flags[action.value()])
            .appendQueryParameter("lftoken", token)
            .appendQueryParameter("collection_id", collectionId));

    Log.d("Action SDK call", "" + url);
    Log.d("Action SDK call", "" + parameters);
    HttpClient.client.post(url, parameters, handler);
}
 
Example #7
Source File: FlowApiRequests.java    From flow-android with MIT License 6 votes vote down vote up
public static void login(String facebookId, String facebookAccessToken,
                         final FlowApiRequestCallback callback) {
    RequestParams params = new RequestParams();
    params.put(Constants.FBID, facebookId);
    params.put(Constants.FACEBOOK_ACCESS_TOKEN, facebookAccessToken);

    FlowAsyncClient.post(Constants.API_LOGIN, params, new JsonHttpResponseHandler() {
        @Override
        public void onSuccess(JSONObject response) {
            Log.d(TAG, "Login success");
            callback.onSuccess(response);
        }

        @Override
        public void onFailure(String responseBody, Throwable error) {
            Log.d(TAG, "Login failed");
            callback.onFailure(responseBody);
        }
    });
}
 
Example #8
Source File: HomeContentFragment.java    From ONE-Unofficial with Apache License 2.0 6 votes vote down vote up
@Override
public void init() {

    lvSaying.addOnLikeChangeListener(this);

    Bundle bundle = getArguments();
    String date = bundle.getString(Constants.KEY_DATE);
    index = bundle.getInt(Constants.KEY_INDEX);

    curDate = TimeUtil.getPreviousDate(date, index);

    RequestParams params = new RequestParams();
    params.put("strDate", date);
    params.put("strRow", index);
    getHttpData(Api.URL_HOME, params, new HttpData("result", "hpEntity"));
}
 
Example #9
Source File: WriteClient.java    From StreamHub-Android-SDK with MIT License 6 votes vote down vote up
/**
 * @param action
 * @param contentId
 * @param collectionId The Id of the collection.
 * @param userToken    The token of the logged in user.
 * @param parameters
 * @param handler      Response handler
 * @throws MalformedURLException
 */

public static void featureMessage(String action, String contentId,
                                  String collectionId, String userToken,
                                  HashMap<String, Object> parameters, JsonHttpResponseHandler handler)
        throws MalformedURLException {
    RequestParams bodyParams = new RequestParams();
    bodyParams.put("lftoken", userToken);

    final Builder uriBuilder = new Uri.Builder().scheme(LivefyreConfig.scheme)
            .authority(LivefyreConfig.quillDomain + "." + LivefyreConfig.getConfiguredNetworkID())
            .appendPath("api").appendPath("v3.0").appendPath("collection")
            .appendPath(collectionId).appendPath(action)
            .appendPath(contentId).appendPath("")
            .appendQueryParameter("lftoken", userToken)
            .appendQueryParameter("collection_id", collectionId);

    Log.d("SDK", "" + uriBuilder);
    HttpClient.client.post(uriBuilder.toString(), bodyParams, handler);
}
 
Example #10
Source File: HttpUtilsAsync.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Upload files with {@link com.loopj.android.http.SyncHttpClient}
 *
 * @param url
 * @param paramsList
 * @param fileParams
 * @param files
 * @param responseHandler
 */
public static void uploadFiles(String url, List<NameValuePair> paramsList, String fileParams, List<File> files, AsyncHttpResponseHandler responseHandler) throws Exception {
    SyncHttpClient syncHttpClient = new SyncHttpClient();
    RequestParams params = new RequestParams();

    if (BasicUtils.judgeNotNull(paramsList)) {
        for (NameValuePair nameValuePair : paramsList) {
            params.put(nameValuePair.getName(), nameValuePair.getValue());
        }
    }
    if (BasicUtils.judgeNotNull(files))
        params.put(fileParams, files);

    syncHttpClient.setTimeout(timeout);
    syncHttpClient.post(url, params, responseHandler);
}
 
Example #11
Source File: AsyncHttpUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 上传文件
 *
 * @return
 */
public static void upLoadFile(String url, File file, AsyncHttpResponseHandler handler) throws FileNotFoundException {
    RequestParams params = new RequestParams();
    params.put("username", "张鸿洋");
    params.put("password", "123");
    params.put("mFile", file);
    AsyncHttpClient client = getHttpClient();
    client.addHeader("Content-disposition", "mFile=\"" + file.getName() + "\"");
    client.addHeader("APP-Key", "APP-Secret222");
    client.addHeader("APP-Secret", "APP-Secret111");
    client.post(url, params, handler);
}
 
Example #12
Source File: PhoneFragment.java    From school_shop with MIT License 5 votes vote down vote up
@Click
void codeBtn(){
    loadingProgressDialog.show();
    RequestParams params = new RequestParams();
    phone = phoneNum.getText().toString();
    params.put("userPhone", phone);
    postNetwork(URLs.CHECK_PHONE, params, URLs.CHECK_PHONE);
}
 
Example #13
Source File: NavigationDrawerFragment.java    From school_shop with MIT License 5 votes vote down vote up
private void setAvatar(){
	RequestParams params = new RequestParams();
	params.add("userId", MyApplication.userInfo[1]);
	params.add("authCode", MyApplication.userInfo[0]);
	networkHelper.getNetJson(URLs.USERINFO, params, new AsyncHttpResponseHandler(){
		
		@Override
		public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
			Gson gson = new Gson();
			DataJson dataJson = gson.fromJson(new String(responseBody), DataJson.class);
			if (dataJson.isSuccess()) {
				if(dataJson.getData()!=null){
					UserEntity userEntity = gson.fromJson(gson.toJson(dataJson.getData()), UserEntity.class);
					if(userEntity.getAvatarUrl()!=null){
						Picasso picasso = Picasso.with(avatar.getContext());
						picasso.load(userEntity.getAvatarUrl()).placeholder(R.drawable.ic_avatar).into(avatar);
					}
				}else {
					showButtomToast(getStringByRId(R.string.getUserInfo_fail));
				}
			}else {
				showButtomToast("用户信息有误");
			}
		}
		
		@Override
		public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
			loadingProgressDialog.dismiss();
		}
	});
}
 
Example #14
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void sendLocation(LoginData logindata, UserLocationData userlocationdata, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = BraceletHttpClient.getSysRp(logindata);
    String s;
    try
    {
        requestparams.put("location", (new StringBuilder()).append("").append(URLEncoder.encode(userlocationdata.toString(), "utf-8")).toString());
    }
    catch (UnsupportedEncodingException unsupportedencodingexception)
    {
        unsupportedencodingexception.printStackTrace();
    }
    s = BraceletHttpClient.getUrl("huami.health.backup.json");
    BraceletHttpClient.client.post(s, requestparams, asynchttpresponsehandler);
}
 
Example #15
Source File: ArticleContentFragment.java    From ONE-Unofficial with Apache License 2.0 5 votes vote down vote up
@Override
public void onLikeChanged() {
    RequestParams requestParams = new RequestParams();
    requestParams.put("strPraiseItemId", curArticle.strContentId);
    requestParams.put("strDeviceId", "");
    requestParams.put("strAppName", "ONE");
    requestParams.put("strPraiseItem", "CONTENT");
    getHttpData(Api.URL_LIKE_OR_CANCLELIKE, requestParams, new HttpData("result", "entPraise"));
}
 
Example #16
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void getGameRegisterInfo(AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = BraceletHttpClient.getSysRp(Keeper.readLoginData());
    String s = BraceletHttpClient.getUrl("huami.health.detectuserwhetherjoinhuodong.json");
    Debug.i(TAG, (new StringBuilder()).append("game register url =").append(s).toString());
    BraceletHttpClient.syncClient.post(s, requestparams, asynchttpresponsehandler);
}
 
Example #17
Source File: ThingContentFragment.java    From ONE-Unofficial with Apache License 2.0 5 votes vote down vote up
@Override
public void init() {

    Bundle bundle = getArguments();
    String date = bundle.getString(Constants.KEY_DATE);
    index = bundle.getInt(Constants.KEY_INDEX);

    curDate = TimeUtil.getPreviousDate(date, index);

    RequestParams params = new RequestParams();
    params.put("strDate", date);
    params.put("strRow", index);
    getHttpData(Api.URL_THING, params, new HttpData("rs", "entTg"));
}
 
Example #18
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void statisticBracelet(LoginData logindata, String s, String s1, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = BraceletHttpClient.getSysRp(logindata);
    requestparams.put("deviceid", s);
    requestparams.put("statistic_bracelet", s1);
    String s2 = BraceletHttpClient.getUrl("huami.health.uploadcollectdata.json");
    BraceletHttpClient.client.post(s2, requestparams, asynchttpresponsehandler);
}
 
Example #19
Source File: AskingFragmentActivity.java    From WeCenterMobile-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	// TODO Auto-generated method stub
	switch (item.getItemId()) {
	case android.R.id.home:
		finish();
		break;
	case R.id.publish:
		try {
			String quesdetil = ((DetailFragment) text2).getTextString()
					.getText().toString();
			String question = ((AskingFragment) text1).getTextString().getText()
					.toString();
			String questag = ((TagFragment) text3).getTextString().getText()
					.toString();
			RequestParams params = new RequestParams();
			params.put("question_content", question);
			params.put("question_detail", quesdetil);
			params.put("attach_access_key", attach_access_key);
			
			params.put("topics", questag);
			quespost(params);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			Toast.makeText(this, "请完善内�?", Toast.LENGTH_LONG).show();
			;
		}

		break;
	default:
		break;
	}
	return super.onOptionsItemSelected(item);
}
 
Example #20
Source File: HttpUtils.java    From foodie-app with Apache License 2.0 5 votes vote down vote up
public static void postWithAuth(Context context,String url, RequestParams params,AsyncHttpResponseHandler responseHandler) {
    String JSESSIONID=PrefUtils.get("user","session",context);
    Log.i("session","提交"+JSESSIONID);
    //client.setBasicAuth("18813073333","123456");
    client.addHeader("Cookie", "JSESSIONID="+JSESSIONID);
    client.post(getAbsoluteUrl(url), params, responseHandler);
}
 
Example #21
Source File: StatueApi.java    From monolog-android with MIT License 5 votes vote down vote up
public static void postCreateStatue(String text, String img_path, String lng, String lat, TextHttpResponseHandler responseHandler) {
    String token = AppContext.getInstance().getToken();
    String url = BaseClient.URL_POST_CREATE_STATUE;
    RequestParams params = new RequestParams();
    params.put("token", token);
    params.put("text", text);
    params.put("img_path", img_path);
    params.put("lng", lng);
    params.put("lat", lat);
    BaseClient.post(url, params, responseHandler);
}
 
Example #22
Source File: HomeContentFragment.java    From ONE-Unofficial with Apache License 2.0 5 votes vote down vote up
@Override
public void onLikeChanged() {
    RequestParams requestParams = new RequestParams();
    requestParams.put("strPraiseItemId", curSaying.strHpId);
    requestParams.put("strDeviceId", "");
    requestParams.put("strAppName", "ONE");
    requestParams.put("strPraiseItem", "HP");
    getHttpData(Api.URL_LIKE_OR_CANCLELIKE, requestParams, new HttpData("result", "entPraise"));
}
 
Example #23
Source File: BaseClient.java    From monolog-android with MIT License 5 votes vote down vote up
public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
    if (!AppContext.getInstance().isConnected()) {
        ToastUtils.show(AppContext.getInstance(), AppContext.getInstance().getString(R.string.error_no_network));
        return;
    }
    client.post(getAbsoluteUrl(url), params, responseHandler);
}
 
Example #24
Source File: BaseClient.java    From monolog-android with MIT License 5 votes vote down vote up
public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
    if (!AppContext.getInstance().isConnected()) {
        ToastUtils.show(AppContext.getInstance(), AppContext.getInstance().getString(R.string.error_no_network));
        return;
    }
    client.get(getAbsoluteUrl(url), params, responseHandler);
}
 
Example #25
Source File: StatueApi.java    From monolog-android with MIT License 5 votes vote down vote up
public static void getMyStatues(String page, TextHttpResponseHandler responseHandler) {
    String token = AppContext.getInstance().getToken();
    String url = BaseClient.URL_GET_MY_STATUES + page;
    RequestParams params = new RequestParams();
    params.put("token", token);
    BaseClient.get(url, params, responseHandler);
}
 
Example #26
Source File: StatueApi.java    From monolog-android with MIT License 5 votes vote down vote up
public static void getUserStatues(String id,String page, TextHttpResponseHandler responseHandler) {
    String token = AppContext.getInstance().getToken();
    String url = BaseClient.URL_GET_USER_STATUES + page;
    RequestParams params = new RequestParams();
    params.put("token", token);
    params.put("user_id",id);
    BaseClient.get(url, params, responseHandler);
}
 
Example #27
Source File: StatueApi.java    From monolog-android with MIT License 5 votes vote down vote up
public static void getMyGuess(String type, String page, TextHttpResponseHandler responseHandler) {
    String token = AppContext.getInstance().getToken();
    String url = BaseClient.URL_GET_MY_GUESS + type + "/" + page;
    RequestParams params = new RequestParams();
    params.put("token", token);
    BaseClient.get(url, params, responseHandler);
}
 
Example #28
Source File: StatueApi.java    From monolog-android with MIT License 5 votes vote down vote up
public static void getOssToken(TextHttpResponseHandler responseHandler) {
    String token = AppContext.getInstance().getToken();
    String url = BaseClient.URL_GET_OSS;
    RequestParams params = new RequestParams();
    params.put("token", token);
    BaseClient.get(url, params, responseHandler);
}
 
Example #29
Source File: StatueApi.java    From monolog-android with MIT License 5 votes vote down vote up
public static void postDeleteStatue(String id, TextHttpResponseHandler responseHandler) {
    String token = AppContext.getInstance().getToken();
    String url = BaseClient.URL_POST_DELETE_STATUE;
    RequestParams params = new RequestParams();
    params.put("token", token);
    params.put("id", id);
    BaseClient.post(url, params, responseHandler);
}
 
Example #30
Source File: BuidUrl.java    From Mobike with Apache License 2.0 5 votes vote down vote up
/**
 * 红包问题
 * @param p
 * @param t
 * @return
 */
public static String getRedPacketProblem(int p, int t)//getUrl
{
    RequestParams requestParms = new RequestParams();
    requestParms.put("p", p);
    requestParms.put("t", t);
    return getHelp("/redPacketProblem.html", requestParms);
}