本文整理汇总了Java中com.android.volley.toolbox.JsonArrayRequest.setTag方法的典型用法代码示例。如果您正苦于以下问题:Java JsonArrayRequest.setTag方法的具体用法?Java JsonArrayRequest.setTag怎么用?Java JsonArrayRequest.setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.volley.toolbox.JsonArrayRequest
的用法示例。
在下文中一共展示了JsonArrayRequest.setTag方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RequestJsonArrayGet
import com.android.volley.toolbox.JsonArrayRequest; //导入方法依赖的package包/类
public static void RequestJsonArrayGet(Context context,String url ,String tag,VolleyIntfcArray intface)
{
arrarRequest=new JsonArrayRequest(url,intface.iListenerArrary(),intface.iErrListener());
arrarRequest.setTag(tag);
SelfApplication.getHttpQueues().add(arrarRequest);
SelfApplication.getHttpQueues().start();
}
示例2: onBackgrounds
import com.android.volley.toolbox.JsonArrayRequest; //导入方法依赖的package包/类
@Override
public void onBackgrounds() {
// 请求获取首页资金 titleId=2811600
final String url = MyAPI.getBaseUrl() + "/api/Funds/FundAccount/GetAccountNameFundBalance?titleId=" + userInfoSp.getInt(AppDelegate.TITLE_ID, -1);
JsonArrayRequest getAccountNameFundBalance = new JsonArrayRequest(Request.Method.GET, url, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
LogUtils.d("我的资金URL-" + url + "\n我的资金-RESPONSE:" + response.toString());
// [{ "currency": "RMB","amount": 5823771.94,"fundAccountName": 1}]
if (response.toString().equals("[]")) {
mTotalFundBalance.setText("0.00");
} else {
List<T_AccountFundBalanceEntity> entity = JSON.parseArray(response.toString(), T_AccountFundBalanceEntity.class);
if (entity.size() != 0) {
GeneralAccount = entity.get(0).getAmount();
}
if (entity.size() > 2) {
FinancingAccount = entity.get(2).getAmount();
}
TotalFundBalance = GeneralAccount + FinancingAccount;
mTotalFundBalance.setText(StringUtil.numberFormat(TotalFundBalance));
}
hideProgressbar();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
LogUtils.e("请求错误:" + error.toString());
mTotalFundBalance.setText("0.00");
hideProgressbar();
}
}
) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> map = new HashMap<>();
map.put(AppDelegate.QS_LOGIN, userInfoSp.getString(AppDelegate.LOGIN_NAME, ""));
return map;
}
};
getAccountNameFundBalance.setTag(this);
mRequestQueue.add(getAccountNameFundBalance);
}
示例3: onBackgrounds
import com.android.volley.toolbox.JsonArrayRequest; //导入方法依赖的package包/类
@Background
public void onBackgrounds() {
// 发票信息 详情页-商品详情 http://101.200.194.102:10104/api/Funds/VatRegister/FindVatInvoiceDetails?ownerId=2962926
T_InvoiceInformationEntity.RowsEntity rowsEntity = (T_InvoiceInformationEntity.RowsEntity) getIntent().getSerializableExtra("rowsEntity");
if (rowsEntity != null) {
final String url = MyAPI.getBaseUrl() + "/api/Funds/VatRegister/FindVatInvoiceDetails?owerId=" + rowsEntity.getId();
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, url, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
LogUtils.d("\n发票信息-商品详情-URL:" + url + "\n发票信息-商品详情-RESPONSE:" + response.toString());
List<T_InvoiceInformationProductsEntity> invoiceInformationProductsEntities =
JSON.parseArray(response.toString(), T_InvoiceInformationProductsEntity.class);
if (invoiceInformationProductsEntities.size() == 0) {
showView(tv_no_data);
} else {
hideView(tv_no_data);
}
if (invoiceInformationProductsEntities != null) {
mAdapter = new MyInvoiceInformationProductsAdapter(invoiceInformationProductsEntities);
mRecyclerView.setAdapter(mAdapter);
}
if (!isFirstLoading)
createRefreshCompleteSnackbar(mRecyclerView);
mSwipeRefreshLayout.setRefreshing(false);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
LogUtils.e("请求错误:" + error.toString());
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> map = new HashMap<>();
map.put(AppDelegate.QS_LOGIN, MyApplication_.getInstance().getUserInfoSp().getString(AppDelegate.LOGIN_NAME, ""));
return map;
}
};
jsonArrayRequest.setTag(this);
mRequestQueue.add(jsonArrayRequest);
}
}
示例4: requestYLR
import com.android.volley.toolbox.JsonArrayRequest; //导入方法依赖的package包/类
/**
* 进仓管理-经营单位:请求查看预录入单
*/
@Background
void requestYLR() {
final String url = MyAPI.getBaseUrl() + "/api/Orders/Storage/ResolvePreCustomsDeclaration?blNo=" + blNo;
JsonArrayRequest ylrRequest = new JsonArrayRequest(Request.Method.POST, url, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
String res = response.toString();
LogUtils.d("\n预录入单-URL:" + url + "\n预录入单-RESPONSE:" + res);
// [ {"blNo": "NGBNYC028386","customsDeclarationNo": "310420160549945415","queryUrl": "http://lh.nbytg.com/WebApp/AgentManage/biz/YTGEntryPage.aspx?t1=310420160549945415&t2=lh.nbytg.com"}]
if (res.equals("[]")) {
mProgressDialog.dismiss();
ToastUtil.showToast(CB_ManageDetailsActivity.this, "提单编号 [" + blNo + "] 查询的预录入单不存在");
} else {
mProgressDialog.dismiss();
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(JSON.parseArray(res).get(0).toString());
String customsDeclarationNo = jsonObject.getString("customsDeclarationNo");
String queryUrl = jsonObject.getString("queryUrl");
CB_WebActivity_.intent(CB_ManageDetailsActivity.this).extra(AppDelegate.URL, queryUrl).extra(AppDelegate.TOOLBAR_TITLE, "海关编号-" + customsDeclarationNo).start();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
LogUtils.e("预录入单:" + error.toString());
mProgressDialog.dismiss();
ToastUtil.showToast(CB_ManageDetailsActivity.this, "查询请求超时,请稍后再试");
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> map = new HashMap<>();
map.put("Content-Type", "application/x-www-form-urlencoded");
return map;
}
};
ylrRequest.setTag(this);
mRequestQueue.add(ylrRequest);
}
示例5: getAuthProviders
import com.android.volley.toolbox.JsonArrayRequest; //导入方法依赖的package包/类
/**
* Gets all available auth providers for the current app.
*
* @return A task containing {@link AvailableAuthProviders} that can be resolved on completion
* of the request.
*/
public Task<AvailableAuthProviders> getAuthProviders() {
final TaskCompletionSource<AvailableAuthProviders> future = new TaskCompletionSource<>();
final String url = getResourcePath(routes.AUTH_PROVIDERS);
final JsonArrayRequest request = new JsonArrayRequest(
Request.Method.GET,
url,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(final JSONArray response) {
final AvailableAuthProviders.Builder builder = new AvailableAuthProviders.Builder();
for (int i = 0; i < response.length(); i++) {
try {
JSONObject info = response.getJSONObject(i);
switch (info.getString("type")) {
case FacebookAuthProviderInfo.FQ_NAME:
final FacebookAuthProviderInfo fbInfo =
_objMapper.readValue(info.toString(), FacebookAuthProviderInfo.class);
builder.withFacebook(fbInfo);
break;
case GoogleAuthProviderInfo.FQ_NAME:
final GoogleAuthProviderInfo googleInfo =
_objMapper.readValue(info.toString(), GoogleAuthProviderInfo.class);
builder.withGoogle(googleInfo);
break;
case AnonymousAuthProviderInfo.FQ_NAME:
final AnonymousAuthProviderInfo anonInfo =
_objMapper.readValue(info.toString(), AnonymousAuthProviderInfo.class);
builder.withAnonymous(anonInfo);
break;
case EmailPasswordAuthProviderInfo.FQ_NAME:
final EmailPasswordAuthProviderInfo emailPassInfo =
_objMapper.readValue(info.toString(), EmailPasswordAuthProviderInfo.class);
builder.withEmailPass(emailPassInfo);
break;
case CustomAuthProviderInfo.FQ_NAME:
final CustomAuthProviderInfo customAuthProviderInfo =
_objMapper.readValue(info.toString(), CustomAuthProviderInfo.class);
builder.withCustomAuth(customAuthProviderInfo);
}
} catch (JSONException | IOException e) {
Log.e(
TAG,
"Error while getting auth provider info",
e);
future.setException(e);
return;
}
}
future.setResult(builder.build());
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(final VolleyError error) {
Log.e(TAG, "Error while getting auth provider info", error);
future.setException(parseRequestError(error));
}
});
request.setTag(this);
_queue.add(request);
return future.getTask();
}
示例6: downloadMovieReviews
import com.android.volley.toolbox.JsonArrayRequest; //导入方法依赖的package包/类
private void downloadMovieReviews() {
if (adapter == null) {
adapter = new ReviewAdapter(new ArrayList<Review>(), this);
reviewList.setAdapter(adapter);
}
JsonArrayRequest request = new JsonArrayRequest(
Request.Method.GET, ApiHelper.getMovieReviewsLink(movieId, pageToDownload), null,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray array) {
try {
for (int i = 0; i < array.length(); i++) {
JSONObject review = array.getJSONObject(i);
String id = review.getString("id");
String comment = review.getString("comment");
boolean hasSpoiler = review.getBoolean("spoiler");
// Get date and format it
String inputTime = review.getString("created_at").substring(0, 10);
DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = inputFormat.parse(inputTime);
DateFormat outputFormat = new SimpleDateFormat("dd MMM yyyy");
String createdAt = outputFormat.format(date);
// Get user name
JSONObject user = review.getJSONObject("user");
String userName = user.getString("username");
if (!user.getBoolean("private")) {
String name = user.getString("name");
if (!TextUtil.isNullOrEmpty(name)) {
userName = name;
}
}
adapter.reviewList.add(new Review(id, userName, comment, createdAt, hasSpoiler));
}
onDownloadSuccessful();
} catch (Exception ex) {
// Parsing error
onDownloadFailed();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
if (volleyError.networkResponse.statusCode == 404 || volleyError.networkResponse.statusCode == 405) {
// No such movie exists
onDownloadSuccessful();
} else {
// Network error, failed to load
onDownloadFailed();
}
}
}) {
// Add Request Headers
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("Content-type", "application/json");
params.put("trakt-api-key", ApiHelper.getTraktKey(getContext()));
params.put("trakt-api-version", "2");
return params;
}
// Get Response Headers
@Override
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
pageToDownload = Integer.parseInt(response.headers.get("X-Pagination-Page")) + 1;
totalPages = Integer.parseInt(response.headers.get("X-Pagination-Page-Count"));
return super.parseNetworkResponse(response);
}
};
isLoading = true;
request.setTag(getClass().getName());
VolleySingleton.getInstance().requestQueue.add(request);
}