本文整理汇总了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);
}
});
}
}