List of usage examples for com.squareup.okhttp FormEncodingBuilder FormEncodingBuilder
FormEncodingBuilder
From source file:com.gqp.duoduo.ui.activity.SearchMarketVoiceActivity.java
private void getMarketList(String input) { if (TextUtils.isEmpty(input)) { return;//from w ww .ja va 2s.com } String loc = SpCache.getString(SharedPreferencesKey.CURRENT_LOC, ""); String lat = ""; String lng = ""; if (!TextUtils.isEmpty(loc)) { lat = loc.split(",")[0]; lng = loc.split(",")[1]; } Request request = new Request.Builder().url(HttpUrl.MARKET_LIST) .post(new FormEncodingBuilder().add("page", "0").add("size", "10").add("marketname", input) .add("lons", String.valueOf(lng)).add("dims", String.valueOf(lat)).add("flg", "1") .add("raidus", "5000").build()) .addHeader("accept", "application/json").addHeader("dodomobile", String.valueOf(UUID.randomUUID())) .tag(System.currentTimeMillis()).build(); compositeSubscription .add(HttpRequest.modelRequest(request, MarketList.class).subscribe(new Subscriber<MarketList>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { // showToast(""); if (e instanceof ErrorMessageException) { if (App.getNetState()) { reLogin(); } else { showToast("??"); } } showToast(e.getMessage()); } @Override public void onNext(MarketList marketList) { int size = marketList.getMessage().getSuperMarketContent().size(); mList.clear(); mList.addAll(marketList.getMessage().getSuperMarketContent()); adapter.notifyDataSetChanged(); // MarketList.MessageEntity.SuperMarketContentEntity rowsEntity = marketList.getMessage().getSuperMarketContent().get(i); } })); }
From source file:com.gqp.duoduo.ui.activity.SearchMoveGoodActivity.java
private void getGoodsList(String input) { if (TextUtils.isEmpty(input)) { return;//from www . jav a2 s . c o m } Request request = new Request.Builder().url(HttpUrl.QUERY_MOVE_GOODS) .post(new FormEncodingBuilder().add("warehousecode", warehousecode).add("goodsname", input) .add("offsetApp", "1").add("limitApp", "100").build()) .addHeader("accept", "application/json").addHeader("dodomobile", String.valueOf(UUID.randomUUID())) .tag(System.currentTimeMillis()).build(); compositeSubscription.add( HttpRequest.modelRequest(request, InventoryList.class).subscribe(new Subscriber<InventoryList>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { showToast(e.getMessage()); if (e instanceof ErrorMessageException) { if (App.getNetState()) { reLogin(); } else { showToast("??"); } } showToast(e.getMessage()); } @Override public void onNext(InventoryList inventoryList) { mList.clear(); int size = inventoryList.getMessage().size(); search_result_listview.removeAllViews(); mList.addAll(inventoryList.getMessage()); if (mList != null && mList.size() > 0) { LayoutInflater inflater = LayoutInflater.from(SearchMoveGoodActivity.this); int index = 0; for (GoodsMoveDetail.NormalGoodsEntity entity : mList) { View view = inflater.inflate(R.layout.search_goods_move_detail_item, null); SearchGoodsViewItemHolder holder = new SearchGoodsViewItemHolder(view); holder.bind(entity, index); search_result_listview.addView(view); View divider = new View(SearchMoveGoodActivity.this); divider.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 2)); divider.setBackgroundColor(Color.parseColor("#dddddd")); search_result_listview.addView(divider); index++; } } } })); }
From source file:com.gqp.duoduo.ui.activity.SearchProductActivity.java
private void getGoodsList(String input) { if (TextUtils.isEmpty(input)) { return;/*from www. j a va 2 s.c o m*/ } FormEncodingBuilder builder = new FormEncodingBuilder().add("customerid", id).add("page", "0").add("size", "65535"); if (!TextUtils.isEmpty(isBarcode)) { builder.add("barcode", input); builder.add("goodsname", ""); } else { builder.add("goodsname", input); } Request request = new Request.Builder().url(HttpUrl.QUERY_GOODS).post(builder.build()) .addHeader("accept", "application/json").addHeader("dodomobile", String.valueOf(UUID.randomUUID())) .tag(System.currentTimeMillis()).build(); compositeSubscription .add(HttpRequest.modelRequest(request, GoodsList.class).subscribe(new Subscriber<GoodsList>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { // showToast(""); if (e instanceof ErrorMessageException) { if (App.getNetState()) { reLogin(); } else { showToast("??"); } } showToast(e.getMessage()); } @Override public void onNext(GoodsList inventoryList) { mList.clear(); mList.addAll(inventoryList.getRows()); listView.removeAllViews(); if (mList != null && mList.size() > 0) { LayoutInflater inflater = LayoutInflater.from(SearchProductActivity.this); int index = 0; for (Goods entity : mList) { View view = inflater.inflate(R.layout.search_goods_view_item, null); SearchGoodsViewItemHolder holder = new SearchGoodsViewItemHolder(view); holder.bind(entity, index); listView.addView(view); View divider = new View(SearchProductActivity.this); divider.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 2)); divider.setBackgroundColor(Color.parseColor("#dddddd")); listView.addView(divider); index++; } } } })); }
From source file:com.gqp.duoduo.ui.activity.SearchProductForDeliverActivity.java
private void getGoodsList(String input) { if (TextUtils.isEmpty(input)) { return;/*www.j a v a 2 s. c om*/ } Request request = new Request.Builder().url(HttpUrl.QUERY_GOODS) .post(new FormEncodingBuilder().add("customerid", id).add("goodsname", input).add("page", "0") .add("size", "65535").build()) .addHeader("accept", "application/json").addHeader("dodomobile", String.valueOf(UUID.randomUUID())) .tag(System.currentTimeMillis()).build(); compositeSubscription .add(HttpRequest.modelRequest(request, GoodsList.class).subscribe(new Subscriber<GoodsList>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { // showToast(""); if (e instanceof ErrorMessageException) { if (App.getNetState()) { reLogin(); } else { showToast("??"); } } showToast(e.getMessage()); } @Override public void onNext(GoodsList inventoryList) { mList.clear(); mList.addAll(inventoryList.getRows()); listView.removeAllViews(); if (mList != null && mList.size() > 0) { LayoutInflater inflater = LayoutInflater.from(SearchProductForDeliverActivity.this); int index = 0; for (Goods entity : mList) { View view = inflater.inflate(R.layout.search_goods_view_item, null); SearchGoodsViewItemHolder holder = new SearchGoodsViewItemHolder(view); holder.bind(entity, index); listView.addView(view); View divider = new View(SearchProductForDeliverActivity.this); divider.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 2)); divider.setBackgroundColor(Color.parseColor("#dddddd")); listView.addView(divider); index++; } } } })); }
From source file:com.gqp.duoduo.ui.activity.SearchProductForOrderActivity.java
private void getGoodsList(String input) { if (TextUtils.isEmpty(input)) { return;/*from w w w .j a v a 2 s.c o m*/ } FormEncodingBuilder builder = new FormEncodingBuilder().add("customerid", id).add("page", "0").add("size", "65535"); if (!TextUtils.isEmpty(isBarcode)) { builder.add("barcode", input); builder.add("goodsname", ""); } else { builder.add("goodsname", input); } Request request = new Request.Builder().url(HttpUrl.QUERY_GOODS).post(builder.build()) .addHeader("accept", "application/json").addHeader("dodomobile", String.valueOf(UUID.randomUUID())) .tag(System.currentTimeMillis()).build(); compositeSubscription .add(HttpRequest.modelRequest(request, GoodsList.class).subscribe(new Subscriber<GoodsList>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { // showToast(""); if (e instanceof ErrorMessageException) { if (App.getNetState()) { reLogin(); } else { showToast("??"); } } showToast(e.getMessage()); } @Override public void onNext(GoodsList inventoryList) { mList.clear(); mList.addAll(inventoryList.getRows()); listView.removeAllViews(); if (mList != null && mList.size() > 0) { LayoutInflater inflater = LayoutInflater.from(SearchProductForOrderActivity.this); int index = 0; for (Goods entity : mList) { View view = inflater.inflate(R.layout.search_goods_view_item, null); SearchGoodsViewItemHolder holder = new SearchGoodsViewItemHolder(view); holder.bind(entity, index); listView.addView(view); View divider = new View(SearchProductForOrderActivity.this); divider.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 2)); divider.setBackgroundColor(Color.parseColor("#dddddd")); listView.addView(divider); index++; } } } })); }
From source file:com.gqp.duoduo.ui.activity.SearchProductForOrderDeliverActivity.java
private void getGoodsList(String input) { if (TextUtils.isEmpty(input)) { return;// w ww. j a v a 2s. com } Request request = new Request.Builder().url(HttpUrl.QUERY_GOODS) .post(new FormEncodingBuilder().add("customerid", id).add("goodsname", input).add("page", "0") .add("size", "65535").build()) .addHeader("accept", "application/json").addHeader("dodomobile", String.valueOf(UUID.randomUUID())) .tag(System.currentTimeMillis()).build(); compositeSubscription .add(HttpRequest.modelRequest(request, GoodsList.class).subscribe(new Subscriber<GoodsList>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { // showToast(""); if (e instanceof ErrorMessageException) { if (App.getNetState()) { reLogin(); } else { showToast("??"); } } showToast(e.getMessage()); } @Override public void onNext(GoodsList inventoryList) { mList.clear(); mList.addAll(inventoryList.getRows()); listView.removeAllViews(); if (mList != null && mList.size() > 0) { LayoutInflater inflater = LayoutInflater .from(SearchProductForOrderDeliverActivity.this); int index = 0; for (Goods entity : mList) { View view = inflater.inflate(R.layout.search_goods_view_item, null); SearchGoodsViewItemHolder holder = new SearchGoodsViewItemHolder(view); holder.bind(entity, index); listView.addView(view); View divider = new View(SearchProductForOrderDeliverActivity.this); divider.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 2)); divider.setBackgroundColor(Color.parseColor("#dddddd")); listView.addView(divider); index++; } } } })); }
From source file:com.gqp.duoduo.ui.activity.SearchProductForPrestoreActivity.java
private void getGoodsList(String input) { if (TextUtils.isEmpty(input)) { return;//from ww w. j a v a 2 s. c om } Request request = new Request.Builder().url(HttpUrl.QUERY_GOODS) .post(new FormEncodingBuilder().add("customerid", id).add("goodsname", input).add("page", "0") .add("size", "65535").build()) .addHeader("accept", "application/json").addHeader("dodomobile", String.valueOf(UUID.randomUUID())) .tag(System.currentTimeMillis()).build(); compositeSubscription .add(HttpRequest.modelRequest(request, GoodsList.class).subscribe(new Subscriber<GoodsList>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { // showToast(""); if (e instanceof ErrorMessageException) { if (App.getNetState()) { reLogin(); } else { showToast("??"); } } showToast(e.getMessage()); } @Override public void onNext(GoodsList inventoryList) { mList.clear(); mList.addAll(inventoryList.getRows()); listView.removeAllViews(); if (mList != null && mList.size() > 0) { LayoutInflater inflater = LayoutInflater.from(SearchProductForPrestoreActivity.this); int index = 0; for (Goods entity : mList) { View view = inflater.inflate(R.layout.search_goods_for_prestore_view_item, null); SearchGoodsViewItemHolder holder = new SearchGoodsViewItemHolder(view); holder.bind(entity, index); listView.addView(view); View divider = new View(SearchProductForPrestoreActivity.this); divider.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 2)); divider.setBackgroundColor(Color.parseColor("#dddddd")); listView.addView(divider); index++; } } } })); }
From source file:com.he5ed.lib.cloudprovider.apis.BoxApi.java
License:Apache License
/** * Build form body to be passed to access token * * @param authCode code from authorization process * @return RequestBody//from w w w.java2s .co m */ public static RequestBody getAccessTokenBody(String authCode) { return new FormEncodingBuilder().addEncoded("grant_type", "authorization_code").addEncoded("code", authCode) .addEncoded("client_id", CLIENT_ID).addEncoded("client_secret", CLIENT_SECRET) .addEncoded("redirect_uri", REDIRECT_URL).build(); }
From source file:com.he5ed.lib.cloudprovider.apis.BoxApi.java
License:Apache License
/** * Build form body to be passed to access token * * @param refreshToken code from authorization process * @return RequestBody//from w w w .j a v a2s . co m */ public static RequestBody getRefreshTokenBody(String refreshToken) { return new FormEncodingBuilder().addEncoded("grant_type", "refresh_token") .addEncoded("refresh_token", refreshToken).addEncoded("client_id", CLIENT_ID) .addEncoded("client_secret", CLIENT_SECRET).addEncoded("redirect_uri", REDIRECT_URL).build(); }
From source file:com.he5ed.lib.cloudprovider.apis.BoxApi.java
License:Apache License
@Override public synchronized void logout(@NonNull Callback callback) { RequestBody body = new FormEncodingBuilder().add("client_id", CLIENT_ID).add("client_secret", CLIENT_SECRET) .add("token", mAccessToken).build(); Request request = new Request.Builder().url(REVOKE_URL).post(body).build(); mHttpClient.newCall(request).enqueue(callback); }