当前位置: 首页>>代码示例>>Java>>正文


Java RequestCallBack类代码示例

本文整理汇总了Java中com.lidroid.xutils.http.callback.RequestCallBack的典型用法代码示例。如果您正苦于以下问题:Java RequestCallBack类的具体用法?Java RequestCallBack怎么用?Java RequestCallBack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RequestCallBack类属于com.lidroid.xutils.http.callback包,在下文中一共展示了RequestCallBack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: login

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
@OnClick(R.id.login_button_myFragment)
public void login(View v){
    String phone = telephoneNum.getText().toString();
    String password = passWord.getText().toString();
    if(phone!=null&&password!=null){
        httpUtils.send(HttpRequest.HttpMethod.GET, UrlsConfig.LOGIN, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {

            }

            @Override
            public void onFailure(HttpException e, String s) {

            }
        });
    }else{
        Toast.makeText(getActivity(), "信息不完整", Toast.LENGTH_SHORT);
    }
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:21,代码来源:MyFragment.java

示例2: loadData

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
private void loadData(String url) {
    httpUtils = new HttpUtils();
    httpUtils.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {

        @Override
        public void onSuccess(ResponseInfo<String> responseInfo) {
            String json = responseInfo.result;
            homeBean = JSON.parseObject(json, HomeBean.class);
            List<HomeBean.DataEntity.App_index_recommandEntity> list1 = homeBean.getData().getApp_index_recommand();
            if (homeBean != null) {
                View headView = getHeadView(inflater);
                ptrlistview.getRefreshableView().addHeaderView(headView);
            }
            list.addAll(list1);
            adapter.notifyDataSetChanged();
        }

        @Override
        public void onFailure(HttpException e, String s) {
            Toast.makeText(getActivity(), "加载数据失败", Toast.LENGTH_SHORT).show();
            View view = ViewStub.inflate(getActivity(),R.layout.faild_layout,null);
        }
    });
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:25,代码来源:HomeFragment.java

示例3: loadData

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
private void loadData() {
    HttpUtils httpUtils = new HttpUtils();
    httpUtils.send(HttpRequest.HttpMethod.POST, UrlsConfig.HUODONG_DETAIL_URL, new RequestCallBack<String>() {
        @Override
        public void onSuccess(ResponseInfo<String> responseInfo) {
            String json = responseInfo.result;
             huoDongBean = JSON.parseObject(json, HuoDongBean.class);
            HuoDongBean.DataEntity.Index_activity_itemEntity  itemEntivity = huoDongBean.getData().getIndex_activity_item();
            bitmapUtils.display(huodong_headview_img,itemEntivity.getImage_url());
            huodong_upimg_name.setText(itemEntivity.getName());
            huodong_people_time.setText(itemEntivity.getActivity_time_tip() + "  " + itemEntivity.getMember_count() + "人参加");
            huodong_huodong_detail_textview.setText(itemEntivity.getDesc());
            List<HuoDongBean.DataEntity.Activity_share_itemEntity> list1 = huoDongBean.getData().getActivity_share_item();
            list.addAll(list1);
            adapter.notifyDataSetChanged();
        }

        @Override
        public void onFailure(HttpException e, String s) {
            Toast.makeText(getApplicationContext(), "数据加载失败", Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:24,代码来源:HDdetailActivity.java

示例4: loadData

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
private void loadData(String URL) {
    HttpUtils httpUtils = new HttpUtils();
    httpUtils.send(HttpRequest.HttpMethod.GET, URL, new RequestCallBack<String>() {
        @Override
        public void onSuccess(ResponseInfo<String> responseInfo) {
            String str = responseInfo.result;
            SearchGrid searchGrid = JSONObject.parseObject(str, SearchGrid.class);
            List<SearchGrid.DataEntity.App_share_dish_list_by_propertyEntity> list = searchGrid.getData().getApp_share_dish_list_by_property();
            if (list != null && list.size() > 0) {
                datas.addAll(list);
                adapter.notifyDataSetChanged();
            }
        }

        @Override
        public void onFailure(HttpException e, String s) {

        }
    });
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:21,代码来源:GirdViewActivity.java

示例5: get

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
/**
 * get请求 
 * @param url 请求路径
 * @param requestCallBackListener 请求回调
 */
public static void get(String url , final RequestCallBackListener requestCallBackListener){
	http.configTimeout(1000*10);
	http.send(HttpMethod.GET, url, new RequestCallBack<String>() {

		@Override
		public void onSuccess(ResponseInfo<String> response) {
			requestCallBackListener.onSuccess(response.result);
		}
		
		@Override
		public void onFailure(HttpException error, String msg) {
			requestCallBackListener.onFailure(msg);
		}
	});
}
 
开发者ID:Catslovetoplaygames,项目名称:MVP,代码行数:21,代码来源:HttpRequest.java

示例6: post

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
/**
 * post请求
 * @param url	请求地址
 * @param params	请求参数
 * @param requestCallBackListener	请求回调
 */
public static void post(String url ,RequestParams params , final RequestCallBackListener requestCallBackListener){
	http.configTimeout(1000*10);
	http.send(HttpMethod.POST, url, params, new RequestCallBack<String>() {

		@Override
		public void onSuccess(ResponseInfo<String> response) {
			requestCallBackListener.onSuccess(response.result);
		}
		
		@Override
		public void onFailure(HttpException error, String msg) {
			requestCallBackListener.onFailure(msg);
		}
	});
}
 
开发者ID:Catslovetoplaygames,项目名称:MVP,代码行数:22,代码来源:HttpRequest.java

示例7: download

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
public static void download(String url, String path,
		final IOAuthCallBack iOAuthCallBack) {
	HttpUtils http = new HttpUtils();
	HttpHandler<File> handler = http.download(url, path, false, // 如果目标文件存在,接着未完成的部分继续下载。服务器不支持RANGE时将从新下载。
			false, // 如果从请求返回信息中获取到文件名,下载完成后自动重命名。
			new RequestCallBack<File>() {

				@Override
				public void onSuccess(ResponseInfo<File> arg0) {
					if (d)
						Log.d("-----downfile-----", "success");
					iOAuthCallBack.getIOAuthCallBack(arg0.result.getName(),
							0);
				}

                   @Override
                   public void onFailure(com.lidroid.xutils.exception.HttpException e, String s) {
                       if (d)
                           Log.d("-----downfile-----", "fail");
                       iOAuthCallBack.getIOAuthCallBack(e.toString(), 1);
                   }
               });
}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:24,代码来源:Tools.java

示例8: doDonate

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
void doDonate(int love_id, String money){
    RequestParams params = new RequestParams();
    params.addHeader("authorization", loginData.getToken());
    params.addBodyParameter("love_id", love_id + "");
    params.addBodyParameter("money", money);

    HttpUtils httpUtils = new HttpUtils();
    httpUtils.configCurrentHttpCacheExpiry(1000);
    httpUtils.send(HttpRequest.HttpMethod.POST, ApiStores.donate, params, new RequestCallBack<String>() {
        @Override
        public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
            Toast.makeText(context, "捐赠成功", Toast.LENGTH_SHORT).show();
            et_donate.setText("");
            getDetails(donation.id);
            CenterFragment.instance.getMyInfo();
        }

        @Override
        public void onFailure(HttpException e, String s) {
            Toast.makeText(context, "请求失败" + s, Toast.LENGTH_SHORT).show();
            Log.e("aaa", e.getMessage());
            Log.e("aaa", s);
        }
    });
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:26,代码来源:DonateDetailActivity.java

示例9: getDetails

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
void getDetails(int donationId){
    RequestParams params = new RequestParams();
    params.addHeader("authorization", loginData.getToken());
    params.addQueryStringParameter("love_id", donationId + "");

    HttpUtils httpUtils = new HttpUtils();
    httpUtils.configCurrentHttpCacheExpiry(1000);
    httpUtils.send(HttpRequest.HttpMethod.GET, ApiStores.getDonationDetail, params, new RequestCallBack<String>() {
        @Override
        public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
            donation = new Gson().fromJson(responseInfo.result, RequestDonation.class).data;
            initViews();
        }

        @Override
        public void onFailure(HttpException e, String s) {
            Toast.makeText(context, "请求失败", Toast.LENGTH_SHORT).show();
            Log.e("aaa", e.getMessage());
            Log.e("aaa", s);
        }
    });
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:23,代码来源:DonateDetailActivity.java

示例10: uploadApply

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
public void uploadApply(final String certificate, final String name, final String position, final String introduction, final String investorsProjects){
    RequestParams params = new RequestParams();
    params.addHeader("authorization", loginData.getToken());
    params.addBodyParameter("certificate", certificate);
    params.addBodyParameter("name", name);
    params.addBodyParameter("position", position);
    params.addBodyParameter("introduction", introduction);
    params.addBodyParameter("investorsProjects", investorsProjects);

    HttpUtils httpUtils = new HttpUtils();
    httpUtils.send(HttpMethod.POST, "http://116.62.228.37:8000/mine/investors", params, new RequestCallBack<String>() {
        @Override
        public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
            Toast.makeText(delegate.getActivity(), "已提交申请", Toast.LENGTH_SHORT).show();
            delegate.setStatus(3);
        }

        @Override
        public void onFailure(HttpException e, String s) {
            ToastUtil.showToast("uploadFiles failed", delegate.getActivity());
            Log.e("aaa", e.getMessage());
            Log.e("aaa", s);
        }
    });
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:26,代码来源:InvestorsPresenter.java

示例11: getDataFromServer

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
private void getDataFromServer() {
	HttpUtils httpUtils = new HttpUtils();
	httpUtils.send(HttpMethod.GET, mUrl, new RequestCallBack<String>() {

		@Override
		public void onSuccess(ResponseInfo<String> responseInfo) {
			String result = responseInfo.result;
			processData(result);
			
			//���û���
			CacheUtils.setCache(mUrl, result, mActivity);
		}

		@Override
		public void onFailure(HttpException error, String msg) {
			error.printStackTrace();
			Toast.makeText(mActivity, msg, Toast.LENGTH_SHORT).show();
		}
	});
	
}
 
开发者ID:unique5954,项目名称:zhbj74,代码行数:22,代码来源:TabDetailPager.java

示例12: checkForUpdate

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
/**
 * 连接服务器检查更新
 * 
 * @author: cl
 * @param context
 * @date: 2016-2-19-下午2:45:34
 */
public static void checkForUpdate(Context context) {
	UpdateUtil.context = context;
	// 连接服务器获取json
	// 请求结果会进入缓存,持续时间大概30s,1min内
	// 缓存存在期间,请求该链接会直接调用回调函数RequestCallBack,使用缓存中的返回结果
	HttpUtils http = new HttpUtils();
	http.send(HttpMethod.GET, UpdateUtil.URL_JSON,
			new RequestCallBack<String>() {

				@Override
				public void onFailure(HttpException httpexception, String s) {
					Toast.makeText(
							UpdateUtil.context,
							"无法连接到服务器(" + httpexception.getExceptionCode()
									+ ")", Toast.LENGTH_SHORT).show();

				}

				@Override
				public void onSuccess(ResponseInfo<String> responseinfo) {
					alertUpdate(responseinfo.result);
				}
			});

}
 
开发者ID:Cheng-Long,项目名称:WuYouHelper,代码行数:33,代码来源:UpdateUtil.java

示例13: downAPK

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
/**
 * 下载APK的方法
 * @param url 要下载文件的路径
 * @param targetFile 下载文件的本地路径
 * @param myCallBack 一个接口对象用于监听文件下载的状态
 */

public void downAPK(String url, String targetFile, final MyCallBack myCallBack) {
    //创建HttpUtils对象
    HttpUtils httpUtils = new HttpUtils();
    //调用HttpUtils的下载方法下载指定文件
    httpUtils.download(url, targetFile, new RequestCallBack<File>() {
        @Override
        public void onSuccess(ResponseInfo<File> responseInfo) {
            myCallBack.onSuccess(responseInfo);
        }

        @Override
        public void onFailure(HttpException e, String s) {
            myCallBack.onFailure(e,s);
        }

        @Override
        public void onLoading(long total, long current, boolean isUploading) {
            super.onLoading(total, current, isUploading);
            myCallBack.onLoading(total,current,isUploading);
        }
    });
}
 
开发者ID:sh2zqp,项目名称:MobilePhoneSafeProtector,代码行数:30,代码来源:DownLoadUtils.java

示例14: getDataFromServer

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
private void getDataFromServer() {

        HttpUtils utils = new HttpUtils();
        utils.send(HttpRequest.HttpMethod.GET, Constants.TOP_STORIES_URL, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {

                String result = responseInfo.result;

                processResult(result);

                PrefUtils.putString(mActivity, Constants.TOP_STORIES_URL, result);
            }

            @Override
            public void onFailure(HttpException e, String s) {

            }
        });
    }
 
开发者ID:AlarmZeng,项目名称:zhishi,代码行数:21,代码来源:MainNewsFragment.java

示例15: getNewsDateFromServer

import com.lidroid.xutils.http.callback.RequestCallBack; //导入依赖的package包/类
private void getNewsDateFromServer(String itemId) {

        final String url = Constants.MENU_NEWS_URL + itemId;

        HttpUtils utils = new HttpUtils();
        utils.send(HttpRequest.HttpMethod.GET, url, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                String result = responseInfo.result;
                PrefUtils.putString(mActivity, url, result);
                processResult(result);
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Toast.makeText(mActivity, "网络发生错误", Toast.LENGTH_SHORT).show();
            }
        });
    }
 
开发者ID:AlarmZeng,项目名称:zhishi,代码行数:20,代码来源:NewsFragment.java


注:本文中的com.lidroid.xutils.http.callback.RequestCallBack类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。