以前用async-http

275 篇文章 4 订阅
53 篇文章 0 订阅

		Set<Entry<Integer, PhotoInfo>> entrySet = photoMap.entrySet();
		ArrayList<String> al = new ArrayList<String>();
		Iterator<Entry<Integer, PhotoInfo>> iterator = entrySet.iterator();
		while (iterator.hasNext()) {
			PhotoInfo pi = iterator.next().getValue();
			al.add(pi.getPath_absolute());
		}
		pd.show();
		pd.setMax(al.size());
		int id = 0;
		SharedPreferences sp = getSharedPreferences(CommonUtils.SP_NAME, 0);
		id = sp.getInt("id", 0);
		if (id == 0) {
			return;
		}
		int folder = 0;
		folder = sp.getInt("photos", 0);
		if (folder == 0) {
			return;
		}
		String url = CommonUtils.getHost(getApplicationContext()) + "upload";
		AsyncHttpClient httpClient = new AsyncHttpClient();
		RequestParams p = new RequestParams();
		for (int i = 0; i < al.size(); i++) { 
			String path = al.get(i);
			try {
				p.put("file", new File(path));
				p.put("cloud",cloud_type);
				p.put("account", id);
				p.put("folder", folder);
				httpClient.post(url, p, new AsyncHttpResponseHandler() {
					@Override
					public void onStart() {
						super.onStart();
					}

					@Override
					public void onFailure(int arg0, Header[] arg1, byte[] arg2,
							Throwable arg3) {
						// TODO Auto-generated method stub
					}

					@Override
					public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
						uploadNum++;
						pd.setProgress(uploadNum);

						if (uploadNum == pd.getMax())// 达到百分百
						{
							pd.dismiss();
							pd.setProgress(0);
							finish();
						}

					}
				});

			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}

	

mark

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值