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


Java HttpUtils类代码示例

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


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

示例1: loadData

import com.lidroid.xutils.HttpUtils; //导入依赖的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

示例2: loadData

import com.lidroid.xutils.HttpUtils; //导入依赖的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: onCreate

import com.lidroid.xutils.HttpUtils; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i("info", "fragmentwefef");
    setContentView(R.layout.activity_info1_listview);
    topView= (LinearLayout) getLayoutInflater()
            .inflate(R.layout.activity_info1_headview, null);
    handler=new Handler();
    listView= (ListView) findViewById(R.id.info1_listView);
    listView.addHeaderView(topView);
    apps=new ArrayList<Data.App_Share_List>();
    bitmapUtils=new BitmapUtils(this);
    adapter=new Info1_ListViewAdapter(apps,this,bitmapUtils);
    listView.setAdapter(adapter);
    memberShareTagId=getIntent().getIntExtra("memberShareTagId", 0);
    path=String.format(method,memberShareTagId);
    httpUtils=new HttpUtils();

    //initHeadView(topView,mem);
    loadData();
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:22,代码来源:Info1Activity.java

示例4: loadData

import com.lidroid.xutils.HttpUtils; //导入依赖的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: download

import com.lidroid.xutils.HttpUtils; //导入依赖的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

示例6: doDonate

import com.lidroid.xutils.HttpUtils; //导入依赖的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

示例7: getDetails

import com.lidroid.xutils.HttpUtils; //导入依赖的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

示例8: uploadApply

import com.lidroid.xutils.HttpUtils; //导入依赖的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

示例9: getDataFromServer

import com.lidroid.xutils.HttpUtils; //导入依赖的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

示例10: checkForUpdate

import com.lidroid.xutils.HttpUtils; //导入依赖的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

示例11: downAPK

import com.lidroid.xutils.HttpUtils; //导入依赖的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

示例12: getDataFromServer

import com.lidroid.xutils.HttpUtils; //导入依赖的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

示例13: getNewsDateFromServer

import com.lidroid.xutils.HttpUtils; //导入依赖的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

示例14: getDataFromServer

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

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

                String result = responseInfo.result;

                PrefUtils.putString(SplashActivity.this, Constants.SPLASH_URL, result);
            }

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

                Toast.makeText(SplashActivity.this, "发生错误", Toast.LENGTH_SHORT).show();

                Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(mainIntent);
                finish();
                overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
            }
        });
    }
 
开发者ID:AlarmZeng,项目名称:zhishi,代码行数:25,代码来源:SplashActivity.java

示例15: readString

import com.lidroid.xutils.HttpUtils; //导入依赖的package包/类
public String readString() throws IOException {
    if (_directResult != null) return _directResult;
    if (baseStream == null) return null;
    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(baseStream, charset));
        StringBuilder sb = new StringBuilder();
        String line = "";
        while ((line = reader.readLine()) != null) {
            sb.append(line);
        }
        _directResult = sb.toString();
        if (requestUrl != null && HttpUtils.sHttpCache.isEnabled(requestMethod)) {
            HttpUtils.sHttpCache.put(requestUrl, _directResult, expiry);
        }
        return _directResult;
    } finally {
        IOUtils.closeQuietly(baseStream);
    }
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:20,代码来源:ResponseStream.java


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