修复快速切换,暂停、恢复功能时,概率性出现的重新下载问题,添加onPre()回调,onPre()用于请求地址之前执行界面UI更新操作
This commit is contained in:
@ -44,7 +44,7 @@ public class DownloadDialog extends AbsDialog {
|
||||
@Bind(R.id.speed) TextView mSpeed;
|
||||
|
||||
private static final String DOWNLOAD_URL =
|
||||
"http://clashroyalecdn.static.kunlun.com/Clash_Royale-1.2.6-kunlun_landing_page-release.apk.apk";
|
||||
"http://static.gaoshouyou.com/d/4b/d7/e04b308d9cd7f0ad4cac18d1a514544c.apk";
|
||||
|
||||
public DownloadDialog(Context context) {
|
||||
super(context);
|
||||
@ -77,7 +77,7 @@ public class DownloadDialog extends AbsDialog {
|
||||
case R.id.start:
|
||||
Aria.download(this)
|
||||
.load(DOWNLOAD_URL)
|
||||
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/daialog.apk")
|
||||
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/飞机大战.apk")
|
||||
.start();
|
||||
break;
|
||||
case R.id.stop:
|
||||
@ -122,14 +122,10 @@ public class DownloadDialog extends AbsDialog {
|
||||
|
||||
@Override public void onTaskRunning(DownloadTask task) {
|
||||
super.onTaskRunning(task);
|
||||
long current = task.getCurrentProgress();
|
||||
long len = task.getFileSize();
|
||||
if (len == 0) {
|
||||
mPb.setProgress(0);
|
||||
} else {
|
||||
mPb.setProgress((int) ((current * 100) / len));
|
||||
if (task.getKey().equals(DOWNLOAD_URL)) {
|
||||
mPb.setProgress(task.getPercent());
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
}
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public class DownloadModule extends BaseModule {
|
||||
case Aria.ACTION_POST_PRE:
|
||||
DownloadEntity entity = intent.getParcelableExtra(Aria.DOWNLOAD_ENTITY);
|
||||
len = entity.getFileSize();
|
||||
L.d(TAG, "download pre");
|
||||
L.d(TAG, "download onPre");
|
||||
handler.obtainMessage(SingleTaskActivity.DOWNLOAD_PRE, len).sendToTarget();
|
||||
break;
|
||||
case Aria.ACTION_START:
|
||||
|
@ -46,7 +46,7 @@ public class DownloadPopupWindow extends AbsPopupWindow {
|
||||
@Bind(R.id.speed) TextView mSpeed;
|
||||
|
||||
private static final String DOWNLOAD_URL =
|
||||
"http://static.gaoshouyou.com/d/3a/93/573ae1db9493a801c24bf66128b11e39.apk";
|
||||
"http://static.gaoshouyou.com/d/25/57/2e25bd9d4557ba31e9beebacfaf9e804.apk";
|
||||
|
||||
public DownloadPopupWindow(Context context) {
|
||||
super(context, new ColorDrawable(Color.WHITE));
|
||||
@ -79,7 +79,7 @@ public class DownloadPopupWindow extends AbsPopupWindow {
|
||||
case R.id.start:
|
||||
Aria.download(this)
|
||||
.load(DOWNLOAD_URL)
|
||||
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/daialog.apk")
|
||||
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/消消乐.apk")
|
||||
.start();
|
||||
break;
|
||||
case R.id.stop:
|
||||
|
@ -30,7 +30,7 @@ import com.arialyy.simple.R;
|
||||
|
||||
public class SimpleNotification {
|
||||
private static final String DOWNLOAD_URL =
|
||||
"http://static.gaoshouyou.com/d/6e/e5/ff6ecaaf45e532e6d07747af82357472.apk";
|
||||
"http://static.gaoshouyou.com/d/cb/38/f0cb1b2c57388fe14342eecd64bbae65.apk";
|
||||
|
||||
private NotificationManager mManager;
|
||||
private Context mContext;
|
||||
@ -58,7 +58,7 @@ public class SimpleNotification {
|
||||
.load(DOWNLOAD_URL)
|
||||
.setDownloadName("notification_test.apk")
|
||||
.setDownloadPath(
|
||||
Environment.getExternalStorageDirectory() + "/Download/notification_test.apk")
|
||||
Environment.getExternalStorageDirectory() + "/Download/消灭星星.apk")
|
||||
.start();
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.RadioGroup;
|
||||
@ -243,6 +244,11 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
|
||||
private class MySchedulerListener extends Aria.DownloadSchedulerListener {
|
||||
|
||||
@Override public void onPre(String url) {
|
||||
super.onPre(url);
|
||||
Log.d(TAG, "url ==> " + url);
|
||||
}
|
||||
|
||||
@Override public void onNoSupportBreakPoint(DownloadTask task) {
|
||||
super.onNoSupportBreakPoint(task);
|
||||
T.showShort(SingleTaskActivity.this, "该下载链接不支持断点");
|
||||
|
@ -45,7 +45,7 @@ public class DownloadFragment extends AbsFragment<FragmentDownloadBinding> {
|
||||
@Bind(R.id.speed) TextView mSpeed;
|
||||
|
||||
private static final String DOWNLOAD_URL =
|
||||
"http://rs.0.gaoshouyou.com/d/90/d7/7490c6fd6cd733bef336e766778507c5.apk";
|
||||
"http://static.ilongyuan.cn/rayark/RayarkFZ_2.0.7.apk";
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
if (Aria.download(this).taskExists(DOWNLOAD_URL)) {
|
||||
@ -73,7 +73,7 @@ public class DownloadFragment extends AbsFragment<FragmentDownloadBinding> {
|
||||
case R.id.start:
|
||||
Aria.download(this)
|
||||
.load(DOWNLOAD_URL)
|
||||
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/daialog.apk")
|
||||
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/兰空VOEZ.apk")
|
||||
.start();
|
||||
break;
|
||||
case R.id.stop:
|
||||
|
@ -70,7 +70,7 @@ final class DownloadAdapter extends AbsRVAdapter<DownloadEntity, DownloadAdapter
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
int position = indexItem(entity.getDownloadUrl());
|
||||
if (position == -1) {
|
||||
if (position == -1 || position >= mData.size()) {
|
||||
return;
|
||||
}
|
||||
mData.set(position, entity);
|
||||
@ -81,7 +81,7 @@ final class DownloadAdapter extends AbsRVAdapter<DownloadEntity, DownloadAdapter
|
||||
public synchronized void setProgress(DownloadEntity entity) {
|
||||
String url = entity.getDownloadUrl();
|
||||
int position = indexItem(url);
|
||||
if (position == -1) {
|
||||
if (position == -1 || position >= mData.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -169,6 +169,7 @@ final class DownloadAdapter extends AbsRVAdapter<DownloadEntity, DownloadAdapter
|
||||
case DownloadEntity.STATE_FAIL:
|
||||
case DownloadEntity.STATE_STOP:
|
||||
case DownloadEntity.STATE_COMPLETE:
|
||||
case DownloadEntity.STATE_POST_PRE:
|
||||
start(entity);
|
||||
break;
|
||||
case DownloadEntity.STATE_RUNNING:
|
||||
|
@ -61,7 +61,7 @@ public class MultiDownloadActivity extends BaseActivity<ActivityMultiDownloadBin
|
||||
private class MySchedulerListener extends Aria.DownloadSchedulerListener {
|
||||
@Override public void onTaskPre(DownloadTask task) {
|
||||
super.onTaskPre(task);
|
||||
L.d(TAG, "download pre");
|
||||
L.d(TAG, "download onPre");
|
||||
mAdapter.updateState(task.getDownloadEntity());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user