本文整理汇总了Java中org.xutils.http.RequestParams类的典型用法代码示例。如果您正苦于以下问题:Java RequestParams类的具体用法?Java RequestParams怎么用?Java RequestParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestParams类属于org.xutils.http包,在下文中一共展示了RequestParams类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildParams
import org.xutils.http.RequestParams; //导入依赖的package包/类
@Override
public void buildParams(RequestParams params) {
// 添加公共参数
params.addParameter("common_a", "xxxx");
params.addParameter("common_b", "xxxx");
// 将post请求的body参数以json形式提交
params.setAsJsonContent(true);
// 或者query参数和body参数都json形式
/*String json = params.toJSONString();
params.clearParams();// 清空参数
if (params.getMethod() == HttpMethod.GET) {
params.addQueryStringParameter("xxx", json);
} else {
params.setBodyContent(json);
}*/
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:JsonDemoParamsBuilder.java
示例2: loadImgList
import org.xutils.http.RequestParams; //导入依赖的package包/类
private void loadImgList(String url) {
x.http().get(new RequestParams(url), new Callback.CommonCallback<String>() {
@Override
public void onSuccess(String result) {
imageListAdapter.addSrc(getImgSrcList(result));
imageListAdapter.notifyDataSetChanged();//通知listview更新数据
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
}
@Override
public void onCancelled(CancelledException cex) {
}
@Override
public void onFinished() {
}
});
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:ImageFragment.java
示例3: buildCacheKey
import org.xutils.http.RequestParams; //导入依赖的package包/类
/**
* 根据注解的cacheKeys构建缓存的自定义key,
* 如果返回null, 默认使用 url 和整个 query string 组成.
*
* @param params
* @param cacheKeys
* @return
*/
@Override
public String buildCacheKey(RequestParams params, String[] cacheKeys) {
String cacheKey = null;
if (cacheKeys != null && cacheKeys.length > 0) {
cacheKey = params.getUri() + "?";
// 添加cacheKeys对应的参数
for (String key : cacheKeys) {
String value = params.getStringParameter(key);
if (value != null) {
cacheKey += key + "=" + value + "&";
}
}
}
return cacheKey;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:DefaultParamsBuilder.java
示例4: createRequestParams
import org.xutils.http.RequestParams; //导入依赖的package包/类
private static RequestParams createRequestParams(String url, ImageOptions options) {
RequestParams params = new RequestParams(url);
params.setCacheDirName(DISK_CACHE_DIR_NAME);
params.setConnectTimeout(1000 * 8);
params.setPriority(Priority.BG_LOW);
params.setExecutor(EXECUTOR);
params.setCancelFast(true);
params.setUseCookie(false);
if (options != null) {
ImageOptions.ParamsBuilder paramsBuilder = options.getParamsBuilder();
if (paramsBuilder != null) {
params = paramsBuilder.buildParams(params, options);
}
}
return params;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:ImageLoader.java
示例5: querySubject
import org.xutils.http.RequestParams; //导入依赖的package包/类
public static void querySubject(int pageNum, final SuccessFailCallback<List<SubjectInfo>> callback) {
RequestParams params = new RequestParams(AppConstants.MOBILE_API.APP_ORIGIN + "app/subject" + pageNum);
x.http().get(params, new SuccessFailCallback<String>() {
@Override
public void onSuccess(String result) {
List<SubjectInfo> subjectInfos = JSON.parseArray(result, SubjectInfo.class);
for(SubjectInfo info : subjectInfos) {
info.setUrl(AppConstants.MOBILE_API.APP_ORIGIN + info.getUrl());
}
callback.onSuccess(subjectInfos);
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
callback.onError(ex, isOnCallback);
}
});
}
开发者ID:ting4937,项目名称:AndroidUtils,代码行数:20,代码来源:SubjectEngine.java
示例6: getCategories
import org.xutils.http.RequestParams; //导入依赖的package包/类
public static void getCategories(final SuccessFailCallback<List<NewsMenuData>> callback) {
RequestParams params = new RequestParams(AppConstants.MOBILE_API.CATEGORIES);
x.http().get(params, new Callback.CommonCallback<String>() {
@Override
public void onSuccess(String result) {
JSONObject jsonObject = JSON.parseObject(result);
List<NewsMenuData> menuDatas = JSON.parseArray(jsonObject.getString("data"), NewsMenuData.class);
callback.onSuccess(menuDatas);
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
callback.onError(ex, isOnCallback);
}
@Override
public void onCancelled(CancelledException cex) {
}
@Override
public void onFinished() {
}
});
}
开发者ID:ting4937,项目名称:AndroidUtils,代码行数:27,代码来源:NewsEngine.java
示例7: getDetail
import org.xutils.http.RequestParams; //导入依赖的package包/类
public static void getDetail(String url, final SuccessFailCallback<NewsDetail> callback) {
RequestParams params = new RequestParams(AppConstants.MOBILE_API.Z_ORIGIN + url);
x.http().get(params, new Callback.CommonCallback<String>() {
@Override
public void onSuccess(String result) {
JSONObject jsonObject = JSON.parseObject(result);
NewsDetail newsDetail = JSON.parseObject(jsonObject.getString("data"), NewsDetail.class);
callback.onSuccess(newsDetail);
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
callback.onError(ex, isOnCallback);
}
@Override
public void onCancelled(CancelledException cex) {
}
@Override
public void onFinished() {
}
});
}
开发者ID:ting4937,项目名称:AndroidUtils,代码行数:27,代码来源:NewsEngine.java
示例8: checkUpgrade
import org.xutils.http.RequestParams; //导入依赖的package包/类
public static void checkUpgrade(final Activity context) {
RequestParams requestParams = new RequestParams(UPGRADE_INFO);
x.http().get(requestParams, new SuccessCallback<String>() {
@Override
public void onSuccess(String result) {
final UpgradeInfo upgradeInfo = JSON.parseObject(result, UpgradeInfo.class);
if (upgradeInfo.getVersion() > DeviceInfoUtils.getVersionCode()) {
DialogUtils.showConfirmDialog(context, "升级app", "更新内容:" + upgradeInfo.getDesc(),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
downloadAppWithProgressbar(context, upgradeInfo.getUrl());
}
}, null);
} else {
LogUtil.d("不升级");
}
}
});
}
开发者ID:ting4937,项目名称:AndroidUtils,代码行数:21,代码来源:UpgradeEngine.java
示例9: getUriRequest
import org.xutils.http.RequestParams; //导入依赖的package包/类
public static UriRequest getUriRequest(RequestParams params, Type loadType) throws Throwable {
// get scheme
String scheme = null;
String uri = params.getUri();
int index = uri.indexOf(":");
if (index > 0) {
scheme = uri.substring(0, index);
} else if (uri.startsWith("/")) {
scheme = "file";
}
// get UriRequest
if (!TextUtils.isEmpty(scheme)) {
Class<? extends UriRequest> cls = SCHEME_CLS_MAP.get(scheme);
if (cls != null) {
Constructor<? extends UriRequest> constructor
= cls.getConstructor(RequestParams.class, Class.class);
return constructor.newInstance(params, loadType);
} else {
if (scheme.startsWith("http")) {
return new HttpRequest(params, loadType);
} else if (scheme.equals("assets")) {
return new AssetsRequest(params, loadType);
} else if (scheme.equals("file")) {
return new LocalFileRequest(params, loadType);
} else {
throw new IllegalArgumentException("The url not be support: " + uri);
}
}
} else {
throw new IllegalArgumentException("The url not be support: " + uri);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:UriRequestFactory.java
示例10: buildQueryUrl
import org.xutils.http.RequestParams; //导入依赖的package包/类
@Override
protected String buildQueryUrl(RequestParams params) {
String uri = params.getUri();
StringBuilder queryBuilder = new StringBuilder(uri);
if (!uri.contains("?")) {
queryBuilder.append("?");
} else if (!uri.endsWith("?")) {
queryBuilder.append("&");
}
List<KeyValue> queryParams = params.getQueryStringParams();
if (queryParams != null) {
for (KeyValue kv : queryParams) {
String name = kv.key;
String value = kv.getValueStr();
if (!TextUtils.isEmpty(name) && value != null) {
queryBuilder.append(
Uri.encode(name, params.getCharset()))
.append("=")
.append(Uri.encode(value, params.getCharset()))
.append("&");
}
}
}
if (queryBuilder.charAt(queryBuilder.length() - 1) == '&') {
queryBuilder.deleteCharAt(queryBuilder.length() - 1);
}
if (queryBuilder.charAt(queryBuilder.length() - 1) == '?') {
queryBuilder.deleteCharAt(queryBuilder.length() - 1);
}
return queryBuilder.toString();
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:HttpRequest.java
示例11: setParams
import org.xutils.http.RequestParams; //导入依赖的package包/类
@Override
public void setParams(final RequestParams params) {
if (params != null) {
String charset = params.getCharset();
if (!TextUtils.isEmpty(charset)) {
this.charset = charset;
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:JSONArrayLoader.java
示例12: setParams
import org.xutils.http.RequestParams; //导入依赖的package包/类
@Override
public void setParams(final RequestParams params) {
if (params != null) {
this.params = params;
isAutoResume = params.isAutoResume();
isAutoRename = params.isAutoRename();
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:FileLoader.java
示例13: getLoader
import org.xutils.http.RequestParams; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static Loader<?> getLoader(Type type, RequestParams params) {
Loader<?> result = converterHashMap.get(type);
if (result == null) {
result = new ObjectLoader(type);
} else {
result = result.newInstance();
}
result.setParams(params);
return result;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:LoaderFactory.java
示例14: doLoadFile
import org.xutils.http.RequestParams; //导入依赖的package包/类
/**
* load from Network or DiskCache, invoke in any thread.
*
* @param url
* @param options
* @param callback
*/
/*package*/
static Cancelable doLoadFile(final String url,
final ImageOptions options,
final Callback.CacheCallback<File> callback) {
if (TextUtils.isEmpty(url)) {
postArgsException(null, options, "url is null", callback);
return null;
}
RequestParams params = createRequestParams(url, options);
return x.http().get(params, callback);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ImageLoader.java
示例15: doLoad
import org.xutils.http.RequestParams; //导入依赖的package包/类
/**
* load from Network or DiskCache
*
* @param view
* @param url
* @param options
* @param callback
*/
private Cancelable doLoad(ImageView view,
String url,
ImageOptions options,
Callback.CommonCallback<Drawable> callback) {
this.viewRef = new WeakReference<ImageView>(view);
this.options = options;
this.key = new MemCacheKey(url, options);
this.callback = callback;
if (callback instanceof Callback.ProgressCallback) {
this.progressCallback = (Callback.ProgressCallback<Drawable>) callback;
}
if (callback instanceof Callback.PrepareCallback) {
this.prepareCallback = (Callback.PrepareCallback<File, Drawable>) callback;
}
if (callback instanceof Callback.CacheCallback) {
this.cacheCallback = (Callback.CacheCallback<Drawable>) callback;
}
// set loadingDrawable
Drawable loadingDrawable = null;
if (options.isForceLoadingDrawable()) {
loadingDrawable = options.getLoadingDrawable(view);
view.setScaleType(options.getPlaceholderScaleType());
view.setImageDrawable(new AsyncDrawable(this, loadingDrawable));
} else {
loadingDrawable = view.getDrawable();
view.setImageDrawable(new AsyncDrawable(this, loadingDrawable));
}
// request
RequestParams params = createRequestParams(url, options);
if (view instanceof FakeImageView) {
synchronized (FAKE_IMG_MAP) {
FAKE_IMG_MAP.put(url, (FakeImageView) view);
}
}
return cancelable = x.http().get(params, this);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:48,代码来源:ImageLoader.java
示例16: get
import org.xutils.http.RequestParams; //导入依赖的package包/类
/**
* 异步get请求
*
* @param url
* @param maps
* @param callBack
*/
public void get(String url, Map<String, String> maps, final XCallBack callBack) {
RequestParams params = new RequestParams(url);
if (maps != null && !maps.isEmpty()) {
for (Map.Entry<String, String> entry : maps.entrySet()) {
params.addQueryStringParameter(entry.getKey(), entry.getValue());
}
}
Log.e("url",params.toString());
x.http().get(params, new Callback.CommonCallback<String>() {
@Override
public void onSuccess(String result) {
onSuccessResponse(result, callBack);
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
ex.printStackTrace();
onFailResponse(ex.toString(), callBack);
}
@Override
public void onCancelled(CancelledException cex) {
}
@Override
public void onFinished() {
}
});
}
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:44,代码来源:XUtilHttpRequest.java
示例17: post
import org.xutils.http.RequestParams; //导入依赖的package包/类
/**
* 异步post请求
*
* @param url
* @param maps
* @param callback
*/
public void post(String url, Map<String, String> maps, final XCallBack callback) {
RequestParams params =new RequestParams(url);
//LinkHelper.getparams(url);
if (maps != null && !maps.isEmpty()) {
for (Map.Entry<String, String> entry : maps.entrySet()) {
params.addBodyParameter(entry.getKey(), entry.getValue());
}
Log.e(url,params.toString());
}
Log.e("url",params.toString());
x.http().post(params, new Callback.CommonCallback<String>() {
@Override
public void onSuccess(String result) {
onSuccessResponse(result, callback);
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
}
@Override
public void onCancelled(CancelledException cex) {
}
@Override
public void onFinished() {
}
});
}
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:41,代码来源:XUtilHttpRequest.java
示例18: httpSearchLike
import org.xutils.http.RequestParams; //导入依赖的package包/类
private void httpSearchLike() {
RequestParams params=new RequestParams("http://101.69.181.251/api/v1/app_drugreminds/all_drugs_name");
params.addBodyParameter("name",medName.getText().toString().trim());
x.http().get(params, new Callback.CommonCallback<String>() {
@Override
public void onSuccess(String result) {
try {
JSONArray medNameJO= (new JSONObject(result)).getJSONArray("drug_names");
if(medNameJO.length()==0) ToastUtils.showShortToast("没有相关"+medName.getText().toString().trim()+"的药品");
for (int i = 0; i <medNameJO.length() ; i++) {
JSONObject o=medNameJO.getJSONObject(i);
medNameList.add(o.optString("name"));
}
commonAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
}
@Override
public void onCancelled(CancelledException cex) {
}
@Override
public void onFinished() {
}
});
}
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:38,代码来源:AssociativeSearchActivity.java
示例19: onCreate
import org.xutils.http.RequestParams; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setToolBarTitle(AppConstants.ToolBarTitle.Contacts);
initMenu();
RequestParams params=new RequestParams(AppConstants.BASE_ACTION+AppConstants.ALL_CONTACTS);
params.addBodyParameter("token","426426426");
Log.e("params",params.toString());
x.http().get(params, new Callback.CommonCallback<String>() {
@Override
public void onSuccess(String result) {
Log.e("ALL_CONTACTS","onSuccess");
contactResponseBean=new Gson().fromJson(result.toString(),ContactResponseBean.class);
contactAdapter = new ContactAdapter(ContactActivity.this,contactResponseBean);
lvContact.setAdapter(contactAdapter);
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
Log.e("ALL_CONTACTS",ex.toString());
}
@Override
public void onCancelled(CancelledException cex) {
}
@Override
public void onFinished() {
}
});
}
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:39,代码来源:ContactActivity.java
示例20: onCreate
import org.xutils.http.RequestParams; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setToolBarTitle(AppConstants.ToolBarTitle.nationalDrugstore);
RequestParams requestParams=new RequestParams(AppConstants.BASE_ACTION+AppConstants.HOSPTIALS);
x.http().get(requestParams, new Callback.CommonCallback<String>() {
@Override
public void onSuccess(String result) {
nationalDrugstoreResponseBean=new Gson().fromJson(result,NationalDrugstoreResponseBean.class);
natDrugstoreAdapter=new NatDrugstoreAdapter(NationalDrugstoreWebActivity.this,nationalDrugstoreResponseBean);
nationalDrugstoreListView.setAdapter(natDrugstoreAdapter);
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
}
@Override
public void onCancelled(CancelledException cex) {
}
@Override
public void onFinished() {
}
});
}
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:32,代码来源:NationalDrugstoreWebActivity.java
注:本文中的org.xutils.http.RequestParams类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论