|
|
@ -25,6 +25,7 @@ import android.view.View; |
|
|
|
import android.widget.Button; |
|
|
|
import android.widget.Button; |
|
|
|
import android.widget.TextView; |
|
|
|
import android.widget.TextView; |
|
|
|
import butterknife.Bind; |
|
|
|
import butterknife.Bind; |
|
|
|
|
|
|
|
import com.arialyy.annotations.Download; |
|
|
|
import com.arialyy.aria.core.Aria; |
|
|
|
import com.arialyy.aria.core.Aria; |
|
|
|
import com.arialyy.aria.core.download.DownloadEntity; |
|
|
|
import com.arialyy.aria.core.download.DownloadEntity; |
|
|
|
import com.arialyy.aria.core.download.DownloadTarget; |
|
|
|
import com.arialyy.aria.core.download.DownloadTarget; |
|
|
@ -71,6 +72,7 @@ public class HighestPriorityActivity extends BaseActivity<ActivityHighestPriorit |
|
|
|
setTitle("最高优先级任务"); |
|
|
|
setTitle("最高优先级任务"); |
|
|
|
getBinding().setTaskName("任务名:" + mTaskName + " (最高优先级任务)"); |
|
|
|
getBinding().setTaskName("任务名:" + mTaskName + " (最高优先级任务)"); |
|
|
|
initWidget(); |
|
|
|
initWidget(); |
|
|
|
|
|
|
|
Aria.download(this).register(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initWidget() { |
|
|
|
private void initWidget() { |
|
|
@ -97,11 +99,6 @@ public class HighestPriorityActivity extends BaseActivity<ActivityHighestPriorit |
|
|
|
mList.setAdapter(mAdapter); |
|
|
|
mList.setAdapter(mAdapter); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override protected void onResume() { |
|
|
|
|
|
|
|
super.onResume(); |
|
|
|
|
|
|
|
Aria.download(this).addSchedulerListener(new MySchedulerListener()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override public boolean onCreateOptionsMenu(Menu menu) { |
|
|
|
@Override public boolean onCreateOptionsMenu(Menu menu) { |
|
|
|
getMenuInflater().inflate(R.menu.menu_highest_priority, menu); |
|
|
|
getMenuInflater().inflate(R.menu.menu_highest_priority, menu); |
|
|
|
return super.onCreateOptionsMenu(menu); |
|
|
|
return super.onCreateOptionsMenu(menu); |
|
|
@ -169,36 +166,32 @@ public class HighestPriorityActivity extends BaseActivity<ActivityHighestPriorit |
|
|
|
mStop.setEnabled(!state); |
|
|
|
mStop.setEnabled(!state); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class MySchedulerListener extends Aria.DownloadSchedulerListener { |
|
|
|
@Download.onPre public void onPre(DownloadTask task) { |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onPre(DownloadTask task) { |
|
|
|
|
|
|
|
super.onPre(task); |
|
|
|
|
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onTaskPre(DownloadTask task) { |
|
|
|
@Download.onTaskPre public void onTaskPre(DownloadTask task) { |
|
|
|
super.onTaskPre(task); |
|
|
|
|
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
mSize.setText(task.getConvertFileSize()); |
|
|
|
mSize.setText(task.getConvertFileSize()); |
|
|
|
} |
|
|
|
} |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onTaskStart(DownloadTask task) { |
|
|
|
@Download.onTaskStart public void onTaskStart(DownloadTask task) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
setBtState(false); |
|
|
|
setBtState(false); |
|
|
|
} |
|
|
|
} |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onTaskResume(DownloadTask task) { |
|
|
|
@Download.onTaskResume public void onTaskResume(DownloadTask task) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
setBtState(false); |
|
|
|
setBtState(false); |
|
|
|
} |
|
|
|
} |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onTaskStop(DownloadTask task) { |
|
|
|
@Download.onTaskStop public void onTaskStop(DownloadTask task) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
setBtState(true); |
|
|
|
setBtState(true); |
|
|
|
mStart.setText("恢复"); |
|
|
|
mStart.setText("恢复"); |
|
|
@ -207,7 +200,7 @@ public class HighestPriorityActivity extends BaseActivity<ActivityHighestPriorit |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onTaskCancel(DownloadTask task) { |
|
|
|
@Download.onTaskCancel public void onTaskCancel(DownloadTask task) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
setBtState(true); |
|
|
|
setBtState(true); |
|
|
|
mStart.setText("开始"); |
|
|
|
mStart.setText("开始"); |
|
|
@ -216,7 +209,7 @@ public class HighestPriorityActivity extends BaseActivity<ActivityHighestPriorit |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onTaskFail(DownloadTask task) { |
|
|
|
@Download.onTaskFail public void onTaskFail(DownloadTask task) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
setBtState(true); |
|
|
|
setBtState(true); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -224,7 +217,7 @@ public class HighestPriorityActivity extends BaseActivity<ActivityHighestPriorit |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onTaskComplete(DownloadTask task) { |
|
|
|
@Download.onTaskComplete public void onTaskComplete(DownloadTask task) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
setBtState(true); |
|
|
|
setBtState(true); |
|
|
|
mStart.setText("重新开始"); |
|
|
|
mStart.setText("重新开始"); |
|
|
@ -234,12 +227,11 @@ public class HighestPriorityActivity extends BaseActivity<ActivityHighestPriorit |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
mAdapter.updateState(task.getDownloadEntity()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override public void onTaskRunning(DownloadTask task) { |
|
|
|
@Download.onTaskRunning public void onTaskRunning(DownloadTask task) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
mPb.setProgress(task.getPercent()); |
|
|
|
mPb.setProgress(task.getPercent()); |
|
|
|
mSpeed.setText(task.getConvertSpeed()); |
|
|
|
mSpeed.setText(task.getConvertSpeed()); |
|
|
|
} |
|
|
|
} |
|
|
|
mAdapter.setProgress(task.getDownloadEntity()); |
|
|
|
mAdapter.setProgress(task.getDownloadEntity()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|