本文整理匯總了Java中com.kymjs.rxvolley.client.ProgressListener類的典型用法代碼示例。如果您正苦於以下問題:Java ProgressListener類的具體用法?Java ProgressListener怎麽用?Java ProgressListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ProgressListener類屬於com.kymjs.rxvolley.client包,在下文中一共展示了ProgressListener類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initView
import com.kymjs.rxvolley.client.ProgressListener; //導入依賴的package包/類
private void initView() {
tv_size = (TextView) findViewById(R.id.tv_size);
number_progress_bar = (NumberProgressBar) findViewById(R.id.number_progress_bar);
number_progress_bar.setMax(100);
path = FileUtils.getSDCardPath() + "/" + System.currentTimeMillis() + ".apk";
//下載
url = getIntent().getStringExtra("url");
if (!TextUtils.isEmpty(url)) {
//下載
RxVolley.download(path, url, new ProgressListener() {
@Override
public void onProgress(long transferredBytes, long totalSize) {
//L.i("transferredBytes:" + transferredBytes + "totalSize:" + totalSize);
Message msg = new Message();
msg.what = HANDLER_LODING;
Bundle bundle = new Bundle();
bundle.putLong("transferredBytes", transferredBytes);
bundle.putLong("totalSize", totalSize);
msg.setData(bundle);
handler.sendMessage(msg);
}
}, new HttpCallback() {
@Override
public void onSuccess(String t) {
handler.sendEmptyMessage(HANDLER_OK);
}
@Override
public void onFailure(VolleyError error) {
handler.sendEmptyMessage(HANDLER_ON);
}
});
}
}
示例2: initView
import com.kymjs.rxvolley.client.ProgressListener; //導入依賴的package包/類
private void initView() {
mNumberProgressBar = (NumberProgressBar) findViewById(R.id.number_progress_bar);
mNumberProgressBar.setMax(100);
mTvTextSize = (TextView) findViewById(R.id.tv_size);
path = getExternalCacheDir() + "/" + System.currentTimeMillis() + ".apk";
//下載
url = getIntent().getStringExtra("url");
if (!TextUtils.isEmpty(url)) {
//下載
RxVolley.download(path, url, new ProgressListener() {
@Override
public void onProgress(long transferredBytes, long totalSize) {
Message message = new Message();
message.what = HANDLER_LOADING;
Bundle bundle = new Bundle();
bundle.putLong("transferedBytes", transferredBytes);
bundle.putLong("totalSize", totalSize);
message.setData(bundle);
mHandler.sendMessage(message);
}
}, new HttpCallback() {
@Override
public void onSuccess(String t) {
LogUtil.e("成功");
mHandler.sendEmptyMessage(HANDLER_OK);
}
@Override
public void onFailure(VolleyError error) {
LogUtil.e("失敗");
mHandler.sendEmptyMessage(HANDLER_FAIL);
}
});
}
}