AriaManager 逻辑重写,api接口优化
This commit is contained in:
@ -18,7 +18,6 @@
|
||||
package com.arialyy.simple.base;
|
||||
|
||||
import android.app.Application;
|
||||
import com.arialyy.aria.core.DownloadManager;
|
||||
import com.arialyy.frame.core.AbsFrame;
|
||||
|
||||
/**
|
||||
@ -28,6 +27,5 @@ public class BaseApplication extends Application {
|
||||
@Override public void onCreate() {
|
||||
super.onCreate();
|
||||
AbsFrame.init(this);
|
||||
//DownloadManager.init(this);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
import com.arialyy.aria.core.AMTarget;
|
||||
import com.arialyy.aria.core.DownloadTarget;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.DownloadEntity;
|
||||
import com.arialyy.aria.core.task.Task;
|
||||
@ -40,13 +40,13 @@ public class DownloadDialog extends AbsDialog {
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (Aria.get(this).taskExists(DOWNLOAD_URL)) {
|
||||
AMTarget target = Aria.download(this).load(DOWNLOAD_URL);
|
||||
if (Aria.download(this).taskExists(DOWNLOAD_URL)) {
|
||||
DownloadTarget target = Aria.download(this).load(DOWNLOAD_URL);
|
||||
int p = (int) (target.getCurrentProgress() * 100 / target.getFileSize());
|
||||
mPb.setProgress(p);
|
||||
}
|
||||
Aria.download(this).addSchedulerListener(new MyDialogDownloadCallback());
|
||||
DownloadEntity entity = Aria.get(this).getDownloadEntity(DOWNLOAD_URL);
|
||||
DownloadEntity entity = Aria.download(this).getDownloadEntity(DOWNLOAD_URL);
|
||||
if (entity != null) {
|
||||
mSize.setText(CommonUtil.formatFileSize(entity.getFileSize()));
|
||||
int state = entity.getState();
|
||||
|
@ -7,7 +7,7 @@ import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
import com.arialyy.aria.core.AMTarget;
|
||||
import com.arialyy.aria.core.DownloadTarget;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.DownloadEntity;
|
||||
import com.arialyy.aria.core.task.Task;
|
||||
@ -32,12 +32,12 @@ public class DownloadFragment extends AbsFragment<FragmentDownloadBinding> {
|
||||
"http://static.gaoshouyou.com/d/3a/93/573ae1db9493a801c24bf66128b11e39.apk";
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
if (Aria.get(this).taskExists(DOWNLOAD_URL)) {
|
||||
AMTarget target = Aria.download(this).load(DOWNLOAD_URL);
|
||||
if (Aria.download(this).taskExists(DOWNLOAD_URL)) {
|
||||
DownloadTarget target = Aria.download(this).load(DOWNLOAD_URL);
|
||||
int p = (int) (target.getCurrentProgress() * 100 / target.getFileSize());
|
||||
mPb.setProgress(p);
|
||||
}
|
||||
DownloadEntity entity = Aria.get(this).getDownloadEntity(DOWNLOAD_URL);
|
||||
DownloadEntity entity = Aria.download(this).getDownloadEntity(DOWNLOAD_URL);
|
||||
if (entity != null) {
|
||||
mSize.setText(CommonUtil.formatFileSize(entity.getFileSize()));
|
||||
int state = entity.getState();
|
||||
|
@ -86,7 +86,7 @@ public class DownloadModule extends BaseModule {
|
||||
String[] urls = getContext().getResources().getStringArray(R.array.test_apk_download_url);
|
||||
List<DownloadEntity> list = new ArrayList<>();
|
||||
for (String url : urls) {
|
||||
DownloadEntity entity = Aria.get(getContext()).getDownloadEntity(url);
|
||||
DownloadEntity entity = Aria.download(getContext()).getDownloadEntity(url);
|
||||
if (entity == null) {
|
||||
entity = createDownloadEntity(url);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class DownloadActivity extends BaseActivity<ActivityDownloadBinding> {
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
super.init(savedInstanceState);
|
||||
mAdapter = new DownloadAdapter(this, Aria.get(this).getDownloadList());
|
||||
mAdapter = new DownloadAdapter(this, Aria.download(this).getDownloadList());
|
||||
mList.setLayoutManager(new LinearLayoutManager(this));
|
||||
mList.setAdapter(mAdapter);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
|
||||
dialog.show(getSupportFragmentManager(), "download_num");
|
||||
break;
|
||||
case R.id.stop_all:
|
||||
Aria.get(this).stopAllTask();
|
||||
Aria.download(this).stopAllTask();
|
||||
break;
|
||||
case R.id.turn:
|
||||
startActivity(new Intent(this, DownloadActivity.class));
|
||||
|
@ -9,7 +9,7 @@ import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
import com.arialyy.aria.core.AMTarget;
|
||||
import com.arialyy.aria.core.DownloadTarget;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.DownloadEntity;
|
||||
import com.arialyy.aria.core.task.Task;
|
||||
@ -42,13 +42,13 @@ public class DownloadPopupWindow extends AbsPopupWindow {
|
||||
}
|
||||
|
||||
private void initWidget() {
|
||||
if (Aria.get(this).taskExists(DOWNLOAD_URL)) {
|
||||
AMTarget target = Aria.download(this).load(DOWNLOAD_URL);
|
||||
if (Aria.download(this).taskExists(DOWNLOAD_URL)) {
|
||||
DownloadTarget target = Aria.download(this).load(DOWNLOAD_URL);
|
||||
int p = (int) (target.getCurrentProgress() * 100 / target.getFileSize());
|
||||
mPb.setProgress(p);
|
||||
}
|
||||
Aria.download(this).addSchedulerListener(new MyDialogDownloadCallback());
|
||||
DownloadEntity entity = Aria.get(this).getDownloadEntity(DOWNLOAD_URL);
|
||||
DownloadEntity entity = Aria.download(this).getDownloadEntity(DOWNLOAD_URL);
|
||||
if (entity != null) {
|
||||
mSize.setText(CommonUtil.formatFileSize(entity.getFileSize()));
|
||||
int state = entity.getState();
|
||||
|
@ -30,7 +30,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import butterknife.Bind;
|
||||
import com.arialyy.aria.core.AMTarget;
|
||||
import com.arialyy.aria.core.DownloadTarget;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.DownloadEntity;
|
||||
import com.arialyy.aria.core.task.Task;
|
||||
@ -161,8 +161,8 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (Aria.get(this).taskExists(DOWNLOAD_URL)) {
|
||||
AMTarget target = Aria.download(this).load(DOWNLOAD_URL);
|
||||
if (Aria.download(this).taskExists(DOWNLOAD_URL)) {
|
||||
DownloadTarget target = Aria.download(this).load(DOWNLOAD_URL);
|
||||
int p = (int) (target.getCurrentProgress() * 100 / target.getFileSize());
|
||||
mPb.setProgress(p);
|
||||
}
|
||||
|
Reference in New Issue
Block a user