demo 例子优化
This commit is contained in:
@@ -50,7 +50,7 @@ public class CheckDEntityUtil implements ICheckEntityUtil {
|
|||||||
@Override
|
@Override
|
||||||
public boolean checkEntity() {
|
public boolean checkEntity() {
|
||||||
if (mWrapper.getErrorEvent() != null) {
|
if (mWrapper.getErrorEvent() != null) {
|
||||||
ALog.e(TAG, String.format("下载失败,%s", mWrapper.getErrorEvent().errorMsg));
|
ALog.e(TAG, String.format("任务操作失败,%s", mWrapper.getErrorEvent().errorMsg));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class CheckDGEntityUtil implements ICheckEntityUtil {
|
|||||||
@Override
|
@Override
|
||||||
public boolean checkEntity() {
|
public boolean checkEntity() {
|
||||||
if (mWrapper.getErrorEvent() != null) {
|
if (mWrapper.getErrorEvent() != null) {
|
||||||
ALog.e(TAG, String.format("操作失败,%s", mWrapper.getErrorEvent().errorMsg));
|
ALog.e(TAG, String.format("任务操作失败,%s", mWrapper.getErrorEvent().errorMsg));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class CheckFtpDirEntityUtil implements ICheckEntityUtil {
|
|||||||
@Override
|
@Override
|
||||||
public boolean checkEntity() {
|
public boolean checkEntity() {
|
||||||
if (mWrapper.getErrorEvent() != null) {
|
if (mWrapper.getErrorEvent() != null) {
|
||||||
ALog.e(TAG, String.format("下载失败,%s", mWrapper.getErrorEvent().errorMsg));
|
ALog.e(TAG, String.format("任务操作失败,%s", mWrapper.getErrorEvent().errorMsg));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class CheckUEntityUtil implements ICheckEntityUtil {
|
|||||||
@Override
|
@Override
|
||||||
public boolean checkEntity() {
|
public boolean checkEntity() {
|
||||||
if (mWrapper.getErrorEvent() != null) {
|
if (mWrapper.getErrorEvent() != null) {
|
||||||
ALog.e(TAG, String.format("上传失败,%s", mWrapper.getErrorEvent().errorMsg));
|
ALog.e(TAG, String.format("任务操作失败,%s", mWrapper.getErrorEvent().errorMsg));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,10 +60,6 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
|||||||
HttpURLConnection conn = null;
|
HttpURLConnection conn = null;
|
||||||
BufferedInputStream is = null;
|
BufferedInputStream is = null;
|
||||||
BufferedRandomAccessFile file = null;
|
BufferedRandomAccessFile file = null;
|
||||||
if (getThreadRecord().threadId == 1){
|
|
||||||
fail(null, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
URL url = ConnectionHelp.handleUrl(getThreadConfig().url, mTaskOption);
|
URL url = ConnectionHelp.handleUrl(getThreadConfig().url, mTaskOption);
|
||||||
conn = ConnectionHelp.handleConnection(url, mTaskOption);
|
conn = ConnectionHelp.handleConnection(url, mTaskOption);
|
||||||
|
|||||||
@@ -18,34 +18,29 @@ package com.arialyy.simple.core.download;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
import com.arialyy.annotations.Download;
|
import com.arialyy.annotations.Download;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
import com.arialyy.aria.core.common.FtpConnectionMode;
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.common.FtpOption;
|
import com.arialyy.aria.core.common.FtpOption;
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
|
||||||
import com.arialyy.aria.core.task.DownloadTask;
|
import com.arialyy.aria.core.task.DownloadTask;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import com.arialyy.frame.util.show.L;
|
|
||||||
import com.arialyy.frame.util.show.T;
|
|
||||||
import com.arialyy.simple.R;
|
import com.arialyy.simple.R;
|
||||||
import com.arialyy.simple.base.BaseActivity;
|
import com.arialyy.simple.base.BaseActivity;
|
||||||
import com.arialyy.simple.common.DirChooseDialog;
|
import com.arialyy.simple.databinding.ActivitySingleBinding;
|
||||||
import com.arialyy.simple.common.ModifyUrlDialog;
|
import com.arialyy.simple.widget.ProgressLayout;
|
||||||
import com.arialyy.simple.databinding.ActivityFtpDownloadBinding;
|
|
||||||
import com.arialyy.simple.util.AppUtil;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by lyy on 2017/7/25.
|
* Created by lyy on 2017/7/25.
|
||||||
* Ftp下载
|
* Ftp下载
|
||||||
*/
|
*/
|
||||||
public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding> {
|
public class FtpDownloadActivity extends BaseActivity<ActivitySingleBinding> {
|
||||||
private String mUrl, mFilePath;
|
private String mUrl, mFilePath;
|
||||||
private FtpDownloadModule mModule;
|
private FtpDownloadModule mModule;
|
||||||
private long mTaskId;
|
private long mTaskId;
|
||||||
@@ -64,62 +59,36 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mTaskId = entity.getId();
|
mTaskId = entity.getId();
|
||||||
if (entity.getState() == IEntity.STATE_STOP) {
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
} else if (entity.getState() == IEntity.STATE_RUNNING) {
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.getFileSize() != 0) {
|
|
||||||
getBinding().setFileSize(CommonUtil.formatFileSize(entity.getFileSize()));
|
|
||||||
getBinding().setProgress(entity.isComplete() ? 100
|
|
||||||
: (int) (entity.getCurrentProgress() * 100 / entity.getFileSize()));
|
|
||||||
}
|
|
||||||
getBinding().setUrl(entity.getUrl());
|
|
||||||
getBinding().setFilePath(entity.getFilePath());
|
|
||||||
mUrl = entity.getUrl();
|
mUrl = entity.getUrl();
|
||||||
mFilePath = entity.getFilePath();
|
mFilePath = entity.getFilePath();
|
||||||
|
getBinding().pl.setInfo(entity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
getBinding().setViewModel(this);
|
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
|
||||||
//try {
|
@Override public void create(View v, AbsEntity entity) {
|
||||||
// getBinding().codeView.setSource(AppUtil.getHelpCode(this, "FtpDownload.java"));
|
mTaskId = Aria.download(this).loadFtp(mUrl)
|
||||||
//} catch (IOException e) {
|
.setFilePath(mFilePath)
|
||||||
// e.printStackTrace();
|
.ignoreFilePathOccupy()
|
||||||
//}
|
.option(getFtpOption())
|
||||||
}
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
@Override public void stop(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).loadFtp(mTaskId).stop();
|
||||||
|
}
|
||||||
|
|
||||||
switch (view.getId()) {
|
@Override public void resume(View v, AbsEntity entity) {
|
||||||
case R.id.start:
|
Aria.download(this)
|
||||||
|
.loadFtp(mTaskId)
|
||||||
|
.option(getFtpOption())
|
||||||
|
.resume();
|
||||||
|
}
|
||||||
|
|
||||||
if (mTaskId == -1) {
|
@Override public void cancel(View v, AbsEntity entity) {
|
||||||
mTaskId = Aria.download(this).loadFtp(mUrl)
|
|
||||||
.setFilePath(mFilePath, true)
|
|
||||||
.option(getFtpOption())
|
|
||||||
.create();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (Aria.download(this).load(mTaskId).isRunning()) {
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
Aria.download(this).loadFtp(mTaskId).stop();
|
|
||||||
} else {
|
|
||||||
Aria.download(this)
|
|
||||||
.loadFtp(mTaskId)
|
|
||||||
.option(getFtpOption())
|
|
||||||
.resume();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.cancel:
|
|
||||||
Aria.download(this).loadFtp(mTaskId).cancel();
|
Aria.download(this).loadFtp(mTaskId).cancel();
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
mTaskId = -1;
|
mTaskId = -1;
|
||||||
break;
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private FtpOption getFtpOption() {
|
private FtpOption getFtpOption() {
|
||||||
@@ -130,75 +99,83 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
|
|||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chooseUrl() {
|
@Download.onWait
|
||||||
ModifyUrlDialog dialog =
|
void onWait(DownloadTask task) {
|
||||||
new ModifyUrlDialog(this, getString(R.string.modify_url_dialog_title), mUrl);
|
if (task.getKey().equals(mUrl)) {
|
||||||
dialog.show(getSupportFragmentManager(), "ModifyUrlDialog");
|
Log.d(TAG, "wait ==> " + task.getDownloadEntity().getFileName());
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chooseFilePath() {
|
@Download.onPre
|
||||||
DirChooseDialog dirChooseDialog = new DirChooseDialog(this);
|
protected void onPre(DownloadTask task) {
|
||||||
dirChooseDialog.show(getSupportFragmentManager(), "DirChooseDialog");
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onPre() protected void onPre(DownloadTask task) {
|
@Download.onTaskStart
|
||||||
L.d(TAG, "ftp pre");
|
void taskStart(DownloadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
ALog.d(TAG, "isComplete = " + task.isComplete() + ", state = " + task.getState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskPre() protected void onTaskPre(DownloadTask task) {
|
@Download.onTaskRunning
|
||||||
L.d(TAG, "ftp task pre, fileSize = " + task.getConvertFileSize());
|
protected void running(DownloadTask task) {
|
||||||
getBinding().setFileSize(task.getConvertFileSize());
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
ALog.d(TAG, "isRunning" + "; state = " + task.getEntity().getState());
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskStart() void taskStart(DownloadTask task) {
|
@Download.onTaskResume
|
||||||
L.d(TAG, "ftp task create");
|
void taskResume(DownloadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
ALog.d(TAG, "resume");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskRunning() protected void running(DownloadTask task) {
|
@Download.onTaskStop
|
||||||
ALog.d(TAG, "running, p = " + task.getPercent() + ", speed = " + task.getConvertSpeed());
|
void taskStop(DownloadTask task) {
|
||||||
getBinding().setProgress(task.getPercent());
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setSpeed(task.getConvertSpeed());
|
ALog.d(TAG, "stop");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskResume() void taskResume(DownloadTask task) {
|
@Download.onTaskCancel
|
||||||
L.d(TAG, "ftp task resume");
|
void taskCancel(DownloadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
mTaskId = -1;
|
||||||
|
Log.d(TAG, "cancel");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskStop() void taskStop(DownloadTask task) {
|
@Download.onTaskFail
|
||||||
L.d(TAG, "ftp task stop");
|
void taskFail(DownloadTask task, Exception e) {
|
||||||
getBinding().setSpeed("");
|
ALog.d(TAG, "下载失败");
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
Toast.makeText(this, getString(R.string.download_fail), Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
|
if (task != null && task.getKey().equals(mUrl)) {
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskCancel() void taskCancel(DownloadTask task) {
|
@Download.onTaskComplete
|
||||||
getBinding().setSpeed("");
|
void taskComplete(DownloadTask task) {
|
||||||
getBinding().setProgress(0);
|
if (task.getKey().equals(mUrl)) {
|
||||||
}
|
Toast.makeText(this, getString(R.string.download_success),
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
@Download.onTaskFail() void taskFail(DownloadTask task) {
|
ALog.d(TAG, "md5: " + CommonUtil.getFileMD5(new File(task.getFilePath())));
|
||||||
L.d(TAG, "ftp task fail");
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setSpeed("");
|
}
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Download.onTaskComplete() void taskComplete(DownloadTask task) {
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
getBinding().setProgress(100);
|
|
||||||
getBinding().setStateStr(getString(R.string.re_start));
|
|
||||||
Log.d(TAG, "md5 ==> " + CommonUtil.getFileMD5(new File(task.getFilePath())));
|
|
||||||
T.showShort(this, "文件:" + task.getEntity().getFileName() + ",下载完成");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected int setLayoutId() {
|
@Override protected int setLayoutId() {
|
||||||
return R.layout.activity_ftp_download;
|
return R.layout.activity_single;
|
||||||
}
|
|
||||||
|
|
||||||
@Override protected void dataCallback(int result, Object data) {
|
|
||||||
super.dataCallback(result, data);
|
|
||||||
if (result == ModifyUrlDialog.MODIFY_URL_DIALOG_RESULT) {
|
|
||||||
mModule.uploadUrl(this, String.valueOf(data));
|
|
||||||
} else if (result == DirChooseDialog.DIR_CHOOSE_DIALOG_RESULT) {
|
|
||||||
mModule.updateFilePath(this, String.valueOf(data));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,25 +18,25 @@ package com.arialyy.simple.core.download;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
import com.arialyy.annotations.Download;
|
import com.arialyy.annotations.Download;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.common.SFtpOption;
|
import com.arialyy.aria.core.common.SFtpOption;
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
|
||||||
import com.arialyy.aria.core.task.DownloadTask;
|
import com.arialyy.aria.core.task.DownloadTask;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import com.arialyy.aria.util.FileUtil;
|
import com.arialyy.aria.util.FileUtil;
|
||||||
import com.arialyy.frame.util.show.L;
|
|
||||||
import com.arialyy.frame.util.show.T;
|
|
||||||
import com.arialyy.simple.R;
|
import com.arialyy.simple.R;
|
||||||
import com.arialyy.simple.base.BaseActivity;
|
import com.arialyy.simple.base.BaseActivity;
|
||||||
import com.arialyy.simple.common.DirChooseDialog;
|
import com.arialyy.simple.common.DirChooseDialog;
|
||||||
import com.arialyy.simple.common.ModifyUrlDialog;
|
import com.arialyy.simple.common.ModifyUrlDialog;
|
||||||
import com.arialyy.simple.databinding.ActivitySftpDownloadBinding;
|
import com.arialyy.simple.databinding.ActivitySingleBinding;
|
||||||
|
import com.arialyy.simple.widget.ProgressLayout;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ import java.io.IOException;
|
|||||||
* Created by lyy on 2017/7/25.
|
* Created by lyy on 2017/7/25.
|
||||||
* Ftp下载
|
* Ftp下载
|
||||||
*/
|
*/
|
||||||
public class SFtpDownloadActivity extends BaseActivity<ActivitySftpDownloadBinding> {
|
public class SFtpDownloadActivity extends BaseActivity<ActivitySingleBinding> {
|
||||||
private String mUrl, mFilePath;
|
private String mUrl, mFilePath;
|
||||||
private FtpDownloadModule mModule;
|
private FtpDownloadModule mModule;
|
||||||
private long mTaskId;
|
private long mTaskId;
|
||||||
@@ -67,29 +67,36 @@ public class SFtpDownloadActivity extends BaseActivity<ActivitySftpDownloadBindi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mTaskId = entity.getId();
|
mTaskId = entity.getId();
|
||||||
if (entity.getState() == IEntity.STATE_STOP) {
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
} else if (entity.getState() == IEntity.STATE_RUNNING) {
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.getFileSize() != 0) {
|
|
||||||
getBinding().setFileSize(CommonUtil.formatFileSize(entity.getFileSize()));
|
|
||||||
getBinding().setProgress(entity.isComplete() ? 100
|
|
||||||
: (int) (entity.getCurrentProgress() * 100 / entity.getFileSize()));
|
|
||||||
}
|
|
||||||
getBinding().setUrl(entity.getUrl());
|
|
||||||
getBinding().setFilePath(entity.getFilePath());
|
|
||||||
mUrl = entity.getUrl();
|
mUrl = entity.getUrl();
|
||||||
mFilePath = entity.getFilePath();
|
mFilePath = entity.getFilePath();
|
||||||
|
getBinding().pl.setInfo(entity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
|
||||||
|
@Override public void create(View v, AbsEntity entity) {
|
||||||
|
mTaskId = Aria.download(this).loadFtp(mUrl)
|
||||||
|
.setFilePath(mFilePath)
|
||||||
|
.ignoreFilePathOccupy()
|
||||||
|
.sftpOption(getFtpOption())
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void stop(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).loadFtp(mTaskId).stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void resume(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this)
|
||||||
|
.loadFtp(mTaskId)
|
||||||
|
.sftpOption(getFtpOption())
|
||||||
|
.resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void cancel(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).loadFtp(mTaskId).cancel(true);
|
||||||
|
mTaskId = -1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
getBinding().setViewModel(this);
|
|
||||||
//try {
|
|
||||||
// getBinding().codeView.setSource(AppUtil.getHelpCode(this, "FtpDownload.java"));
|
|
||||||
//} catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyKey() {
|
private void copyKey() {
|
||||||
@@ -110,39 +117,6 @@ public class SFtpDownloadActivity extends BaseActivity<ActivitySftpDownloadBindi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
|
||||||
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.start:
|
|
||||||
|
|
||||||
if (mTaskId == -1) {
|
|
||||||
mTaskId = Aria.download(this).loadFtp(mUrl)
|
|
||||||
.setFilePath(mFilePath, true)
|
|
||||||
.sftpOption(getFtpOption())
|
|
||||||
.create();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (Aria.download(this).load(mTaskId).isRunning()) {
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
Aria.download(this).loadFtp(mTaskId).stop();
|
|
||||||
} else {
|
|
||||||
Aria.download(this)
|
|
||||||
.loadFtp(mTaskId)
|
|
||||||
.sftpOption(getFtpOption())
|
|
||||||
.resume();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.cancel:
|
|
||||||
Aria.download(this).loadFtp(mTaskId).cancel(true);
|
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
mTaskId = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private SFtpOption getFtpOption() {
|
private SFtpOption getFtpOption() {
|
||||||
SFtpOption option = new SFtpOption();
|
SFtpOption option = new SFtpOption();
|
||||||
option.login(user, passw); // 账号密码登录
|
option.login(user, passw); // 账号密码登录
|
||||||
@@ -168,56 +142,84 @@ public class SFtpDownloadActivity extends BaseActivity<ActivitySftpDownloadBindi
|
|||||||
dirChooseDialog.show(getSupportFragmentManager(), "DirChooseDialog");
|
dirChooseDialog.show(getSupportFragmentManager(), "DirChooseDialog");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onPre() protected void onPre(DownloadTask task) {
|
@Download.onWait
|
||||||
L.d(TAG, "ftp pre");
|
void onWait(DownloadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
Log.d(TAG, "wait ==> " + task.getDownloadEntity().getFileName());
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskPre() protected void onTaskPre(DownloadTask task) {
|
@Download.onPre
|
||||||
L.d(TAG, "ftp task pre, fileSize = " + task.getConvertFileSize());
|
protected void onPre(DownloadTask task) {
|
||||||
getBinding().setFileSize(task.getConvertFileSize());
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskStart() void taskStart(DownloadTask task) {
|
@Download.onTaskStart
|
||||||
L.d(TAG, "ftp task create");
|
void taskStart(DownloadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
ALog.d(TAG, "isComplete = " + task.isComplete() + ", state = " + task.getState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskRunning() protected void running(DownloadTask task) {
|
@Download.onTaskRunning
|
||||||
ALog.d(TAG, "running, p = " + task.getPercent() + ", speed = " + task.getConvertSpeed());
|
protected void running(DownloadTask task) {
|
||||||
getBinding().setProgress(task.getPercent());
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setSpeed(task.getConvertSpeed());
|
ALog.d(TAG, "isRunning" + "; state = " + task.getEntity().getState());
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskResume() void taskResume(DownloadTask task) {
|
@Download.onTaskResume
|
||||||
L.d(TAG, "ftp task resume");
|
void taskResume(DownloadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
ALog.d(TAG, "resume");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskStop() void taskStop(DownloadTask task) {
|
@Download.onTaskStop
|
||||||
L.d(TAG, "ftp task stop");
|
void taskStop(DownloadTask task) {
|
||||||
getBinding().setSpeed("");
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
ALog.d(TAG, "stop");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskCancel() void taskCancel(DownloadTask task) {
|
@Download.onTaskCancel
|
||||||
getBinding().setSpeed("");
|
void taskCancel(DownloadTask task) {
|
||||||
getBinding().setProgress(0);
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
mTaskId = -1;
|
||||||
|
Log.d(TAG, "cancel");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskFail() void taskFail(DownloadTask task) {
|
@Download.onTaskFail
|
||||||
L.d(TAG, "ftp task fail");
|
void taskFail(DownloadTask task, Exception e) {
|
||||||
getBinding().setSpeed("");
|
ALog.d(TAG, "下载失败");
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
Toast.makeText(this, getString(R.string.download_fail), Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
|
if (task != null && task.getKey().equals(mUrl)) {
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskComplete() void taskComplete(DownloadTask task) {
|
@Download.onTaskComplete
|
||||||
getBinding().setSpeed("");
|
void taskComplete(DownloadTask task) {
|
||||||
getBinding().setProgress(100);
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.re_start));
|
Toast.makeText(this, getString(R.string.download_success),
|
||||||
Log.d(TAG, "md5 ==> " + CommonUtil.getFileMD5(new File(task.getFilePath())));
|
Toast.LENGTH_SHORT).show();
|
||||||
T.showShort(this, "文件:" + task.getEntity().getFileName() + ",下载完成");
|
ALog.d(TAG, "md5: " + CommonUtil.getFileMD5(new File(task.getFilePath())));
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected int setLayoutId() {
|
@Override protected int setLayoutId() {
|
||||||
return R.layout.activity_sftp_download;
|
return R.layout.activity_single;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void dataCallback(int result, Object data) {
|
@Override protected void dataCallback(int result, Object data) {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.StatFs;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -32,6 +31,7 @@ import androidx.lifecycle.Observer;
|
|||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
import com.arialyy.annotations.Download;
|
import com.arialyy.annotations.Download;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.common.HttpOption;
|
import com.arialyy.aria.core.common.HttpOption;
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
import com.arialyy.aria.core.inf.IEntity;
|
||||||
@@ -43,9 +43,8 @@ import com.arialyy.aria.util.CommonUtil;
|
|||||||
import com.arialyy.frame.util.show.T;
|
import com.arialyy.frame.util.show.T;
|
||||||
import com.arialyy.simple.R;
|
import com.arialyy.simple.R;
|
||||||
import com.arialyy.simple.base.BaseActivity;
|
import com.arialyy.simple.base.BaseActivity;
|
||||||
import com.arialyy.simple.common.ModifyPathDialog;
|
|
||||||
import com.arialyy.simple.common.ModifyUrlDialog;
|
|
||||||
import com.arialyy.simple.databinding.ActivitySingleBinding;
|
import com.arialyy.simple.databinding.ActivitySingleBinding;
|
||||||
|
import com.arialyy.simple.widget.ProgressLayout;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -96,36 +95,32 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mTaskId = entity.getId();
|
mTaskId = entity.getId();
|
||||||
if (entity.getState() == IEntity.STATE_STOP) {
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
} else if (entity.getState() == IEntity.STATE_RUNNING) {
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.getFileSize() != 0) {
|
|
||||||
getBinding().setFileSize(CommonUtil.formatFileSize(entity.getFileSize()));
|
|
||||||
getBinding().setProgress(entity.isComplete() ? 100
|
|
||||||
: (int) (entity.getCurrentProgress() * 100 / entity.getFileSize()));
|
|
||||||
}
|
|
||||||
getBinding().setUrl(entity.getUrl());
|
|
||||||
getBinding().setFilePath(entity.getFilePath());
|
|
||||||
mUrl = entity.getUrl();
|
mUrl = entity.getUrl();
|
||||||
mFilePath = entity.getFilePath();
|
mFilePath = entity.getFilePath();
|
||||||
|
getBinding().pl.setInfo(entity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
getBinding().setViewModel(this);
|
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
|
||||||
}
|
@Override public void create(View v, AbsEntity entity) {
|
||||||
|
startD();
|
||||||
|
}
|
||||||
|
|
||||||
public void chooseUrl() {
|
@Override public void stop(View v, AbsEntity entity) {
|
||||||
ModifyUrlDialog dialog =
|
Aria.download(this)
|
||||||
new ModifyUrlDialog(this, getString(R.string.modify_url_dialog_title), mUrl);
|
.load(mTaskId)
|
||||||
dialog.show(getSupportFragmentManager(), "ModifyUrlDialog");
|
.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chooseFilePath() {
|
@Override public void resume(View v, AbsEntity entity) {
|
||||||
ModifyPathDialog dialog =
|
Aria.download(this).load(mTaskId)
|
||||||
new ModifyPathDialog(this, getString(R.string.modify_file_path), mFilePath);
|
//.updateUrl(mUrl)
|
||||||
dialog.show(getSupportFragmentManager(), "ModifyPathDialog");
|
.resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void cancel(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).load(mTaskId).cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -174,20 +169,21 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
void onWait(DownloadTask task) {
|
void onWait(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
Log.d(TAG, "wait ==> " + task.getDownloadEntity().getFileName());
|
Log.d(TAG, "wait ==> " + task.getDownloadEntity().getFileName());
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onPre
|
@Download.onPre
|
||||||
protected void onPre(DownloadTask task) {
|
protected void onPre(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskStart
|
@Download.onTaskStart
|
||||||
void taskStart(DownloadTask task) {
|
void taskStart(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setFileSize(task.getConvertFileSize());
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
ALog.d(TAG, "isComplete = " + task.isComplete() + ", state = " + task.getState());
|
ALog.d(TAG, "isComplete = " + task.isComplete() + ", state = " + task.getState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,32 +191,24 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
@Download.onTaskRunning
|
@Download.onTaskRunning
|
||||||
protected void running(DownloadTask task) {
|
protected void running(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
ALog.d(TAG, "isRunning");
|
ALog.d(TAG, "isRunning" + "; state = " + task.getEntity().getState());
|
||||||
//Log.d(TAG, task.getKey());
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
long len = task.getFileSize();
|
|
||||||
if (len == 0) {
|
|
||||||
getBinding().setProgress(0);
|
|
||||||
} else {
|
|
||||||
getBinding().setProgress(task.getPercent());
|
|
||||||
}
|
|
||||||
getBinding().setSpeed(task.getConvertSpeed());
|
|
||||||
getBinding().setTimeLeft(task.getConvertTimeLeft());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskResume
|
@Download.onTaskResume
|
||||||
void taskResume(DownloadTask task) {
|
void taskResume(DownloadTask task) {
|
||||||
ALog.d(TAG, "resume");
|
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
ALog.d(TAG, "resume");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskStop
|
@Download.onTaskStop
|
||||||
void taskStop(DownloadTask task) {
|
void taskStop(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
ALog.d(TAG, "stop");
|
||||||
getBinding().setSpeed("");
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,10 +216,8 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
void taskCancel(DownloadTask task) {
|
void taskCancel(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
mTaskId = -1;
|
mTaskId = -1;
|
||||||
getBinding().setProgress(0);
|
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
Log.d(TAG, "cancel");
|
Log.d(TAG, "cancel");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,19 +227,17 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
Toast.makeText(SingleTaskActivity.this, getString(R.string.download_fail), Toast.LENGTH_SHORT)
|
Toast.makeText(SingleTaskActivity.this, getString(R.string.download_fail), Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
if (task != null && task.getKey().equals(mUrl)) {
|
if (task != null && task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskComplete
|
@Download.onTaskComplete
|
||||||
void taskComplete(DownloadTask task) {
|
void taskComplete(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setProgress(100);
|
|
||||||
Toast.makeText(SingleTaskActivity.this, getString(R.string.download_success),
|
Toast.makeText(SingleTaskActivity.this, getString(R.string.download_success),
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
getBinding().setStateStr(getString(R.string.re_start));
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
ALog.d(TAG, "md5: " + CommonUtil.getFileMD5(new File(task.getFilePath())));
|
ALog.d(TAG, "md5: " + CommonUtil.getFileMD5(new File(task.getFilePath())));
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,29 +246,6 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
return R.layout.activity_single;
|
return R.layout.activity_single;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.start:
|
|
||||||
if (mTaskId == -1) {
|
|
||||||
startD();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (Aria.download(this).load(mTaskId).isRunning()) {
|
|
||||||
Aria.download(this)
|
|
||||||
.load(mTaskId)
|
|
||||||
.stop();
|
|
||||||
} else {
|
|
||||||
Aria.download(this).load(mTaskId)
|
|
||||||
//.updateUrl(mUrl)
|
|
||||||
.resume();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.cancel:
|
|
||||||
Aria.download(this).load(mTaskId).cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startD() {
|
private void startD() {
|
||||||
HttpOption option = new HttpOption();
|
HttpOption option = new HttpOption();
|
||||||
option.addHeader("1", "@")
|
option.addHeader("1", "@")
|
||||||
@@ -309,15 +270,6 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
return super.dispatchTouchEvent(ev);
|
return super.dispatchTouchEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void dataCallback(int result, Object data) {
|
|
||||||
super.dataCallback(result, data);
|
|
||||||
if (result == ModifyUrlDialog.MODIFY_URL_DIALOG_RESULT) {
|
|
||||||
mModule.uploadUrl(this, String.valueOf(data));
|
|
||||||
} else if (result == ModifyPathDialog.MODIFY_PATH_RESULT) {
|
|
||||||
mModule.updateFilePath(this, String.valueOf(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class FileLenAdapter implements IHttpFileLenAdapter {
|
static class FileLenAdapter implements IHttpFileLenAdapter {
|
||||||
@Override public long handleFileLen(Map<String, List<String>> headers) {
|
@Override public long handleFileLen(Map<String, List<String>> headers) {
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
import com.arialyy.annotations.Download;
|
import com.arialyy.annotations.Download;
|
||||||
|
import com.arialyy.annotations.M3U8;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.download.m3u8.M3U8LiveOption;
|
import com.arialyy.aria.core.download.m3u8.M3U8LiveOption;
|
||||||
import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
|
import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
|
||||||
@@ -40,7 +42,7 @@ import com.arialyy.simple.base.BaseActivity;
|
|||||||
import com.arialyy.simple.common.ModifyPathDialog;
|
import com.arialyy.simple.common.ModifyPathDialog;
|
||||||
import com.arialyy.simple.common.ModifyUrlDialog;
|
import com.arialyy.simple.common.ModifyUrlDialog;
|
||||||
import com.arialyy.simple.databinding.ActivityM3u8LiveBinding;
|
import com.arialyy.simple.databinding.ActivityM3u8LiveBinding;
|
||||||
import com.arialyy.simple.util.AppUtil;
|
import com.arialyy.simple.widget.ProgressLayout;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding> {
|
public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding> {
|
||||||
@@ -48,7 +50,6 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
|
|||||||
private String mUrl;
|
private String mUrl;
|
||||||
private String mFilePath;
|
private String mFilePath;
|
||||||
private M3U8LiveModule mModule;
|
private M3U8LiveModule mModule;
|
||||||
private DownloadEntity mEntity;
|
|
||||||
private long mTaskId;
|
private long mTaskId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -63,28 +64,30 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
|
|||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mEntity = entity;
|
mTaskId = entity.getId();
|
||||||
mTaskId = mEntity.getId();
|
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
getBinding().setUrl(entity.getUrl());
|
|
||||||
getBinding().setFilePath(entity.getFilePath());
|
|
||||||
mUrl = entity.getUrl();
|
mUrl = entity.getUrl();
|
||||||
mFilePath = entity.getFilePath();
|
mFilePath = entity.getFilePath();
|
||||||
|
getBinding().pl.setInfo(entity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
getBinding().setViewModel(this);
|
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
|
||||||
}
|
@Override public void create(View v, AbsEntity entity) {
|
||||||
|
startD();
|
||||||
|
}
|
||||||
|
|
||||||
public void chooseUrl() {
|
@Override public void stop(View v, AbsEntity entity) {
|
||||||
ModifyUrlDialog dialog =
|
Aria.download(this).load(mTaskId).stop();
|
||||||
new ModifyUrlDialog(this, getString(R.string.modify_url_dialog_title), mUrl);
|
}
|
||||||
dialog.show(getSupportFragmentManager(), "ModifyUrlDialog");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void chooseFilePath() {
|
@Override public void resume(View v, AbsEntity entity) {
|
||||||
ModifyPathDialog dialog =
|
ALog.d(TAG, "m3u8 live 不支持恢复");
|
||||||
new ModifyPathDialog(this, getString(R.string.modify_file_path), mFilePath);
|
}
|
||||||
dialog.show(getSupportFragmentManager(), "ModifyPathDialog");
|
|
||||||
|
@Override public void cancel(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).load(mTaskId).cancel(true);
|
||||||
|
mTaskId = -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -129,6 +132,22 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@M3U8.onPeerStart
|
||||||
|
void onPeerStart(String m3u8Url, String peerPath, int peerIndex) {
|
||||||
|
//ALog.d(TAG, "peer create, path: " + peerPath + ", index: " + peerIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@M3U8.onPeerComplete
|
||||||
|
void onPeerComplete(String m3u8Url, String peerPath, int peerIndex) {
|
||||||
|
//ALog.d(TAG, "peer complete, path: " + peerPath + ", index: " + peerIndex);
|
||||||
|
//mVideoFragment.addPlayer(peerIndex, peerPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@M3U8.onPeerFail
|
||||||
|
void onPeerFail(String m3u8Url, String peerPath, int peerIndex) {
|
||||||
|
//ALog.d(TAG, "peer fail, path: " + peerPath + ", index: " + peerIndex);
|
||||||
|
}
|
||||||
|
|
||||||
@Download.onWait
|
@Download.onWait
|
||||||
void onWait(DownloadTask task) {
|
void onWait(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
@@ -139,71 +158,70 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
|
|||||||
@Download.onPre
|
@Download.onPre
|
||||||
protected void onPre(DownloadTask task) {
|
protected void onPre(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
ALog.d(TAG, "pre");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskStart
|
@Download.onTaskStart
|
||||||
void taskStart(DownloadTask task) {
|
void taskStart(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setFileSize(task.getConvertFileSize());
|
|
||||||
ALog.d(TAG, "isComplete = " + task.isComplete() + ", state = " + task.getState());
|
ALog.d(TAG, "isComplete = " + task.isComplete() + ", state = " + task.getState());
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskRunning
|
@Download.onTaskRunning
|
||||||
protected void running(DownloadTask task) {
|
protected void running(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
ALog.d(TAG, "isRunning");
|
ALog.d(TAG,
|
||||||
getBinding().setProgress(task.getPercent());
|
"m3u8 void running, p = " + task.getPercent() + ", speed = " + task.getConvertSpeed());
|
||||||
getBinding().setSpeed(task.getConvertSpeed());
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskResume
|
@Download.onTaskResume
|
||||||
void taskResume(DownloadTask task) {
|
void taskResume(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
ALog.d(TAG, "m3u8 vod resume");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskStop
|
@Download.onTaskStop
|
||||||
void taskStop(DownloadTask task) {
|
void taskStop(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
ALog.d(TAG, "stop");
|
||||||
getBinding().setSpeed("");
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskCancel
|
@Download.onTaskCancel
|
||||||
void taskCancel(DownloadTask task) {
|
void taskCancel(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setProgress(0);
|
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
Log.d(TAG, "cancel");
|
Log.d(TAG, "cancel");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskFail
|
@Download.onTaskFail
|
||||||
void taskFail(DownloadTask task, Exception e) {
|
void taskFail(DownloadTask task, Exception e) {
|
||||||
if (task != null && task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
Toast.makeText(M3U8LiveDLoadActivity.this, getString(R.string.download_fail),
|
Toast.makeText(this, getString(R.string.download_fail),
|
||||||
Toast.LENGTH_SHORT)
|
Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
Log.d(TAG, "fail");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskComplete
|
@Download.onTaskComplete
|
||||||
void taskComplete(DownloadTask task) {
|
void taskComplete(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setProgress(100);
|
Toast.makeText(this, getString(R.string.download_success),
|
||||||
Toast.makeText(M3U8LiveDLoadActivity.this, getString(R.string.download_success),
|
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
getBinding().setStateStr(getString(R.string.re_start));
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
ALog.d(TAG, "md5: " + CommonUtil.getFileMD5(new File(task.getFilePath())));
|
ALog.d(TAG, "md5: " + CommonUtil.getFileMD5(new File(task.getFilePath())));
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,28 +230,11 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
|
|||||||
return R.layout.activity_m3u8_live;
|
return R.layout.activity_m3u8_live;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.start:
|
|
||||||
if (Aria.download(this).load(mTaskId).isRunning()) {
|
|
||||||
Aria.download(this).load(mTaskId).stop();
|
|
||||||
} else {
|
|
||||||
startD();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.cancel:
|
|
||||||
if (mTaskId != -1){
|
|
||||||
Aria.download(this).load(mTaskId).cancel(true);
|
|
||||||
mTaskId = -1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startD() {
|
private void startD() {
|
||||||
mTaskId = Aria.download(M3U8LiveDLoadActivity.this)
|
mTaskId = Aria.download(M3U8LiveDLoadActivity.this)
|
||||||
.load(mUrl)
|
.load(mUrl)
|
||||||
.setFilePath(mFilePath, true)
|
.setFilePath(mFilePath)
|
||||||
|
.ignoreFilePathOccupy()
|
||||||
.m3u8LiveOption(getLiveoption())
|
.m3u8LiveOption(getLiveoption())
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,15 @@ import android.view.View;
|
|||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
import com.arialyy.annotations.Download;
|
import com.arialyy.annotations.Download;
|
||||||
import com.arialyy.annotations.M3U8;
|
import com.arialyy.annotations.M3U8;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
import com.arialyy.aria.core.common.controller.BuilderController;
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.download.M3U8Entity;
|
import com.arialyy.aria.core.download.M3U8Entity;
|
||||||
import com.arialyy.aria.core.download.m3u8.M3U8VodOption;
|
import com.arialyy.aria.core.download.m3u8.M3U8VodOption;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
|
||||||
import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
|
import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
|
||||||
import com.arialyy.aria.core.processor.IKeyUrlConverter;
|
import com.arialyy.aria.core.processor.IKeyUrlConverter;
|
||||||
import com.arialyy.aria.core.processor.ITsMergeHandler;
|
import com.arialyy.aria.core.processor.ITsMergeHandler;
|
||||||
@@ -50,6 +48,7 @@ import com.arialyy.simple.common.ModifyPathDialog;
|
|||||||
import com.arialyy.simple.common.ModifyUrlDialog;
|
import com.arialyy.simple.common.ModifyUrlDialog;
|
||||||
import com.arialyy.simple.databinding.ActivityM3u8VodBinding;
|
import com.arialyy.simple.databinding.ActivityM3u8VodBinding;
|
||||||
import com.arialyy.simple.to.PeerIndex;
|
import com.arialyy.simple.to.PeerIndex;
|
||||||
|
import com.arialyy.simple.widget.ProgressLayout;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -77,32 +76,20 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
|
|||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (entity.getM3U8Entity() != null){
|
if (entity.getM3U8Entity() != null) {
|
||||||
getBinding().pb.setMax(entity.getM3U8Entity().getPeerNum());
|
getBinding().seekBar.setMax(entity.getM3U8Entity().getPeerNum());
|
||||||
}
|
}
|
||||||
mTaskId = entity.getId();
|
mTaskId = entity.getId();
|
||||||
if (entity.getState() == IEntity.STATE_STOP) {
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
} else if (entity.getState() == IEntity.STATE_RUNNING) {
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.getFileSize() != 0) {
|
|
||||||
getBinding().setFileSize(CommonUtil.formatFileSize(entity.getFileSize()));
|
|
||||||
}
|
|
||||||
getBinding().setProgress(entity.getPercent());
|
|
||||||
getBinding().setUrl(entity.getUrl());
|
|
||||||
getBinding().setFilePath(entity.getFilePath());
|
|
||||||
mUrl = entity.getUrl();
|
mUrl = entity.getUrl();
|
||||||
mFilePath = entity.getFilePath();
|
mFilePath = entity.getFilePath();
|
||||||
|
getBinding().pl.setInfo(entity);
|
||||||
//mVideoFragment = new VideoPlayerFragment(0, entity);
|
//mVideoFragment = new VideoPlayerFragment(0, entity);
|
||||||
//FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
//FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
//ft.add(R.id.video_content, mVideoFragment);
|
//ft.add(R.id.video_content, mVideoFragment);
|
||||||
//ft.commit();
|
//ft.commit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
getBinding().setViewModel(this);
|
getBinding().seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
getBinding().pb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
|
||||||
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -115,6 +102,27 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
|
|||||||
Aria.download(this).load(mTaskId).m3u8VodOption().jumPeerIndex(seekBar.getProgress());
|
Aria.download(this).load(mTaskId).m3u8VodOption().jumPeerIndex(seekBar.getProgress());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
|
||||||
|
@Override public void create(View v, AbsEntity entity) {
|
||||||
|
startD();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void stop(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).load(mTaskId).stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void resume(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this)
|
||||||
|
.load(mTaskId)
|
||||||
|
.m3u8VodOption(getM3U8Option())
|
||||||
|
.resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void cancel(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).load(mTaskId).cancel();
|
||||||
|
mTaskId = -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chooseUrl() {
|
public void chooseUrl() {
|
||||||
@@ -212,50 +220,50 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
|
|||||||
@Download.onPre
|
@Download.onPre
|
||||||
protected void onPre(DownloadTask task) {
|
protected void onPre(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
ALog.d(TAG, "pre");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskStart
|
@Download.onTaskStart
|
||||||
void taskStart(DownloadTask task) {
|
void taskStart(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().pb.setMax(task.getEntity().getM3U8Entity().getPeerNum());
|
|
||||||
ALog.d(TAG, "isComplete = " + task.isComplete() + ", state = " + task.getState());
|
ALog.d(TAG, "isComplete = " + task.isComplete() + ", state = " + task.getState());
|
||||||
|
getBinding().seekBar.setMax(task.getEntity().getM3U8Entity().getPeerNum());
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskRunning
|
@Download.onTaskRunning
|
||||||
protected void running(DownloadTask task) {
|
protected void running(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
ALog.d(TAG, "m3u8 void running, p = " + task.getPercent() + ", speed = " + task.getConvertSpeed());
|
ALog.d(TAG,
|
||||||
getBinding().setProgress(task.getPercent());
|
"m3u8 void running, p = " + task.getPercent() + ", speed = " + task.getConvertSpeed());
|
||||||
getBinding().setSpeed(task.getConvertSpeed());
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskResume
|
@Download.onTaskResume
|
||||||
void taskResume(DownloadTask task) {
|
void taskResume(DownloadTask task) {
|
||||||
ALog.d(TAG, "m3u8 vod resume");
|
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
ALog.d(TAG, "m3u8 vod resume");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskStop
|
@Download.onTaskStop
|
||||||
void taskStop(DownloadTask task) {
|
void taskStop(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
ALog.d(TAG, "stop");
|
||||||
getBinding().setSpeed("");
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskCancel
|
@Download.onTaskCancel
|
||||||
void taskCancel(DownloadTask task) {
|
void taskCancel(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setProgress(0);
|
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
Log.d(TAG, "cancel");
|
Log.d(TAG, "cancel");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,21 +273,18 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
|
|||||||
Toast.makeText(M3U8VodDLoadActivity.this, getString(R.string.download_fail),
|
Toast.makeText(M3U8VodDLoadActivity.this, getString(R.string.download_fail),
|
||||||
Toast.LENGTH_SHORT)
|
Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
Log.d(TAG, "fail");
|
Log.d(TAG, "fail");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskComplete
|
@Download.onTaskComplete
|
||||||
void taskComplete(DownloadTask task) {
|
void taskComplete(DownloadTask task) {
|
||||||
if (task.getKey().equals(mUrl)) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
getBinding().setProgress(100);
|
|
||||||
Toast.makeText(M3U8VodDLoadActivity.this, getString(R.string.download_success),
|
Toast.makeText(M3U8VodDLoadActivity.this, getString(R.string.download_success),
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
getBinding().setStateStr(getString(R.string.re_start));
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
ALog.d(TAG, "md5: " + CommonUtil.getFileMD5(new File(task.getFilePath())));
|
ALog.d(TAG, "md5: " + CommonUtil.getFileMD5(new File(task.getFilePath())));
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,33 +293,11 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
|
|||||||
return R.layout.activity_m3u8_vod;
|
return R.layout.activity_m3u8_vod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.start:
|
|
||||||
if (mTaskId == -1) {
|
|
||||||
startD();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (Aria.download(this).load(mTaskId).isRunning()) {
|
|
||||||
Aria.download(this).load(mTaskId).stop();
|
|
||||||
} else {
|
|
||||||
Aria.download(this)
|
|
||||||
.load(mTaskId)
|
|
||||||
.m3u8VodOption(getM3U8Option())
|
|
||||||
.resume();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.cancel:
|
|
||||||
Aria.download(this).load(mTaskId).cancel();
|
|
||||||
mTaskId = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startD() {
|
private void startD() {
|
||||||
mTaskId = Aria.download(M3U8VodDLoadActivity.this)
|
mTaskId = Aria.download(M3U8VodDLoadActivity.this)
|
||||||
.load(mUrl)
|
.load(mUrl)
|
||||||
.setFilePath(mFilePath, true)
|
.setFilePath(mFilePath)
|
||||||
|
.ignoreFilePathOccupy()
|
||||||
.m3u8VodOption(getM3U8Option())
|
.m3u8VodOption(getM3U8Option())
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
@@ -326,7 +309,7 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
|
|||||||
//.generateIndexFile()
|
//.generateIndexFile()
|
||||||
//.merge(true)
|
//.merge(true)
|
||||||
.setVodTsUrlConvert(new VodTsUrlConverter());
|
.setVodTsUrlConvert(new VodTsUrlConverter());
|
||||||
//.setMergeHandler(new TsMergeHandler());
|
//.setMergeHandler(new TsMergeHandler());
|
||||||
option.setKeyUrlConverter(new KeyUrlConverter());
|
option.setKeyUrlConverter(new KeyUrlConverter());
|
||||||
//option.setBandWidthUrlConverter(new BandWidthUrlConverter(mUrl));
|
//option.setBandWidthUrlConverter(new BandWidthUrlConverter(mUrl));
|
||||||
return option;
|
return option;
|
||||||
@@ -379,7 +362,7 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class KeyUrlConverter implements IKeyUrlConverter{
|
static class KeyUrlConverter implements IKeyUrlConverter {
|
||||||
|
|
||||||
@Override public String convert(String m3u8Url, String keyUrl) {
|
@Override public String convert(String m3u8Url, String keyUrl) {
|
||||||
ALog.d("TAG", "convertUrl....");
|
ALog.d("TAG", "convertUrl....");
|
||||||
|
|||||||
@@ -15,41 +15,36 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.simple.core.upload;
|
package com.arialyy.simple.core.upload;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
import com.arialyy.annotations.Upload;
|
import com.arialyy.annotations.Upload;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.common.FtpOption;
|
import com.arialyy.aria.core.common.FtpOption;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
|
||||||
import com.arialyy.aria.core.processor.FtpInterceptHandler;
|
import com.arialyy.aria.core.processor.FtpInterceptHandler;
|
||||||
import com.arialyy.aria.core.processor.IFtpUploadInterceptor;
|
import com.arialyy.aria.core.processor.IFtpUploadInterceptor;
|
||||||
import com.arialyy.aria.core.task.UploadTask;
|
import com.arialyy.aria.core.task.UploadTask;
|
||||||
import com.arialyy.aria.core.upload.UploadEntity;
|
import com.arialyy.aria.core.upload.UploadEntity;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import com.arialyy.frame.util.FileUtil;
|
|
||||||
import com.arialyy.frame.util.show.T;
|
|
||||||
import com.arialyy.simple.R;
|
import com.arialyy.simple.R;
|
||||||
import com.arialyy.simple.base.BaseActivity;
|
import com.arialyy.simple.base.BaseActivity;
|
||||||
import com.arialyy.simple.common.ModifyUrlDialog;
|
import com.arialyy.simple.databinding.ActivitySingleBinding;
|
||||||
import com.arialyy.simple.databinding.ActivityFtpUploadBinding;
|
import com.arialyy.simple.widget.ProgressLayout;
|
||||||
import com.arialyy.simple.util.AppUtil;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by lyy on 2017/7/28. Ftp 文件上传demo
|
* Created by lyy on 2017/7/28. Ftp 文件上传demo
|
||||||
*/
|
*/
|
||||||
public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
|
public class FtpUploadActivity extends BaseActivity<ActivitySingleBinding> {
|
||||||
private final int OPEN_FILE_MANAGER_CODE = 0xB1;
|
private final int OPEN_FILE_MANAGER_CODE = 0xB1;
|
||||||
private String mFilePath;
|
private String mFilePath;
|
||||||
private String mUrl;
|
private String mUrl;
|
||||||
@@ -62,7 +57,6 @@ public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
|
|||||||
super.init(savedInstanceState);
|
super.init(savedInstanceState);
|
||||||
Aria.upload(this).register();
|
Aria.upload(this).register();
|
||||||
|
|
||||||
getBinding().setViewModel(this);
|
|
||||||
setUI();
|
setUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,79 +65,43 @@ public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
|
|||||||
mModule.getFtpInfo(this).observe(this, new Observer<UploadEntity>() {
|
mModule.getFtpInfo(this).observe(this, new Observer<UploadEntity>() {
|
||||||
@Override public void onChanged(@Nullable UploadEntity entity) {
|
@Override public void onChanged(@Nullable UploadEntity entity) {
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
mTaskId = entity.getId();
|
|
||||||
if (entity.getFileSize() != 0) {
|
|
||||||
getBinding().setFileSize(CommonUtil.formatFileSize(entity.getFileSize()));
|
|
||||||
getBinding().setProgress(entity.isComplete() ? 100
|
|
||||||
: (int) (entity.getCurrentProgress() * 100 / entity.getFileSize()));
|
|
||||||
}
|
|
||||||
getBinding().setUrl(entity.getUrl());
|
|
||||||
getBinding().setFilePath(entity.getFilePath());
|
|
||||||
mUrl = entity.getUrl();
|
|
||||||
mFilePath = entity.getFilePath();
|
mFilePath = entity.getFilePath();
|
||||||
getBinding().setStateStr(getString(
|
mUrl = entity.getUrl();
|
||||||
entity.getState() == IEntity.STATE_RUNNING ? R.string.stop : R.string.start));
|
mTaskId = entity.getId();
|
||||||
} else {
|
getBinding().pl.setInfo(entity);
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setHelpCode();
|
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
|
||||||
}
|
@Override public void create(View v, AbsEntity entity) {
|
||||||
|
mTaskId = Aria.upload(this)
|
||||||
|
.loadFtp(mFilePath)
|
||||||
|
.setUploadUrl(mUrl)
|
||||||
|
.option(getOption())
|
||||||
|
.ignoreFilePathOccupy()
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
private void setHelpCode() {
|
@Override public void stop(View v, AbsEntity entity) {
|
||||||
//try {
|
Aria.upload(this).loadFtp(mTaskId).stop();
|
||||||
// getBinding().codeView.setSource(AppUtil.getHelpCode(this, "FtpUpload.java"));
|
}
|
||||||
//} catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
@Override public void resume(View v, AbsEntity entity) {
|
||||||
//}
|
Aria.upload(this)
|
||||||
|
.loadFtp(mTaskId)
|
||||||
|
.option(getOption())
|
||||||
|
.resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void cancel(View v, AbsEntity entity) {
|
||||||
|
Aria.upload(this).loadFtp(mTaskId).cancel(false);
|
||||||
|
mTaskId = -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected int setLayoutId() {
|
@Override protected int setLayoutId() {
|
||||||
return R.layout.activity_ftp_upload;
|
return R.layout.activity_single;
|
||||||
}
|
|
||||||
|
|
||||||
public void chooseUrl() {
|
|
||||||
ModifyUrlDialog dialog =
|
|
||||||
new ModifyUrlDialog(this, getString(R.string.modify_url_dialog_title), mUrl);
|
|
||||||
dialog.show(getSupportFragmentManager(), "ModifyUrlDialog");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void chooseFilePath() {
|
|
||||||
AppUtil.chooseFile(this, new File(mFilePath), null, OPEN_FILE_MANAGER_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.start:
|
|
||||||
if (mTaskId == -1) {
|
|
||||||
mTaskId = Aria.upload(this)
|
|
||||||
.loadFtp(mFilePath)
|
|
||||||
.setUploadUrl(mUrl)
|
|
||||||
.option(getOption())
|
|
||||||
.forceUpload()
|
|
||||||
.create();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (Aria.upload(this).loadFtp(mTaskId).isRunning()) {
|
|
||||||
Aria.upload(this).loadFtp(mTaskId).stop();
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
} else {
|
|
||||||
Aria.upload(this)
|
|
||||||
.loadFtp(mTaskId)
|
|
||||||
.option(getOption())
|
|
||||||
.resume();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
}
|
|
||||||
//upload();
|
|
||||||
break;
|
|
||||||
case R.id.cancel:
|
|
||||||
Aria.upload(this).loadFtp(mTaskId).cancel(false);
|
|
||||||
mTaskId = -1;
|
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void upload() {
|
private void upload() {
|
||||||
@@ -175,69 +133,79 @@ public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
|
|||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Upload.onWait void onWait(UploadTask task) {
|
@Upload.onWait
|
||||||
Log.d(TAG, task.getTaskName() + "_wait");
|
void onWait(UploadTask task) {
|
||||||
}
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
Log.d(TAG, "wait ==> " + task.getEntity().getFileName());
|
||||||
@Upload.onPre public void onPre(UploadTask task) {
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setFileSize(task.getConvertFileSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskStart public void taskStart(UploadTask task) {
|
|
||||||
Log.d(TAG, "开始上传,md5:" + FileUtil.getFileMD5(new File(task.getEntity().getFilePath())));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskResume public void taskResume(UploadTask task) {
|
|
||||||
Log.d(TAG, "恢复上传");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskStop public void taskStop(UploadTask task) {
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
Log.d(TAG, "停止上传");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskCancel public void taskCancel(UploadTask task) {
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
getBinding().setFileSize("");
|
|
||||||
getBinding().setProgress(0);
|
|
||||||
Log.d(TAG, "删除任务");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskFail public void taskFail(UploadTask task) {
|
|
||||||
Log.d(TAG, "上传失败");
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskRunning public void taskRunning(UploadTask task) {
|
|
||||||
Log.d(TAG, "PP = " + task.getPercent());
|
|
||||||
getBinding().setProgress(task.getPercent());
|
|
||||||
getBinding().setSpeed(task.getConvertSpeed());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskComplete public void taskComplete(UploadTask task) {
|
|
||||||
getBinding().setProgress(100);
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
T.showShort(this, "文件:" + task.getEntity().getFileName() + ",上传完成");
|
|
||||||
getBinding().setStateStr(getString(R.string.re_start));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override protected void dataCallback(int result, Object data) {
|
|
||||||
super.dataCallback(result, data);
|
|
||||||
if (result == ModifyUrlDialog.MODIFY_URL_DIALOG_RESULT) {
|
|
||||||
mModule.updateFtpUrl(this, String.valueOf(data));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
@Upload.onPre
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
protected void onPre(UploadTask task) {
|
||||||
if (requestCode == OPEN_FILE_MANAGER_CODE && resultCode == RESULT_OK) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
Uri uri = data.getData();
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
if (uri != null) {
|
}
|
||||||
mModule.updateFtpFilePath(this, uri.getPath());
|
}
|
||||||
ALog.d(TAG, String.format("选择的文件路径:%s", uri.getPath()));
|
|
||||||
} else {
|
@Upload.onTaskStart
|
||||||
ALog.d(TAG, "没有选择文件");
|
void taskStart(UploadTask task) {
|
||||||
}
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
ALog.d(TAG, "isComplete = " + task.isComplete() + ", state = " + task.getState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskRunning
|
||||||
|
protected void running(UploadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
ALog.d(TAG, "isRunning" + "; state = " + task.getEntity().getState());
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskResume
|
||||||
|
void taskResume(UploadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
ALog.d(TAG, "resume");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskStop
|
||||||
|
void taskStop(UploadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
ALog.d(TAG, "stop");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskCancel
|
||||||
|
void taskCancel(UploadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
mTaskId = -1;
|
||||||
|
Log.d(TAG, "cancel");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskFail
|
||||||
|
void taskFail(UploadTask task, Exception e) {
|
||||||
|
ALog.d(TAG, "fail");
|
||||||
|
Toast.makeText(this, getString(R.string.download_fail), Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
|
if (task != null && task.getKey().equals(mUrl)) {
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskComplete
|
||||||
|
void taskComplete(UploadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
Toast.makeText(this, getString(R.string.download_success),
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
ALog.d(TAG, "md5: " + CommonUtil.getFileMD5(new File(task.getEntity().getFilePath())));
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,29 +17,28 @@
|
|||||||
package com.arialyy.simple.core.upload;
|
package com.arialyy.simple.core.upload;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import com.arialyy.annotations.Upload;
|
import com.arialyy.annotations.Upload;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.common.HttpOption;
|
import com.arialyy.aria.core.common.HttpOption;
|
||||||
import com.arialyy.aria.core.common.RequestEnum;
|
import com.arialyy.aria.core.common.RequestEnum;
|
||||||
import com.arialyy.aria.core.task.UploadTask;
|
import com.arialyy.aria.core.task.UploadTask;
|
||||||
import com.arialyy.aria.core.upload.UploadEntity;
|
import com.arialyy.aria.core.upload.UploadEntity;
|
||||||
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.frame.util.FileUtil;
|
import com.arialyy.frame.util.FileUtil;
|
||||||
import com.arialyy.frame.util.show.L;
|
|
||||||
import com.arialyy.simple.R;
|
import com.arialyy.simple.R;
|
||||||
import com.arialyy.simple.base.BaseActivity;
|
import com.arialyy.simple.base.BaseActivity;
|
||||||
import com.arialyy.simple.databinding.ActivityUploadBinding;
|
import com.arialyy.simple.databinding.ActivitySingleBinding;
|
||||||
import com.arialyy.simple.util.AppUtil;
|
import com.arialyy.simple.util.AppUtil;
|
||||||
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber;
|
import com.arialyy.simple.widget.ProgressLayout;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by lyy on 2017/2/9.
|
* Created by lyy on 2017/2/9.
|
||||||
*/
|
*/
|
||||||
public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> {
|
public class HttpUploadActivity extends BaseActivity<ActivitySingleBinding> {
|
||||||
private static final String TAG = "HttpUploadActivity";
|
private static final String TAG = "HttpUploadActivity";
|
||||||
HorizontalProgressBarWithNumber mPb;
|
|
||||||
|
|
||||||
private final String FILE_PATH = "/mnt/sdcard/QQMusic-import-1.2.1.zip";
|
private final String FILE_PATH = "/mnt/sdcard/QQMusic-import-1.2.1.zip";
|
||||||
//private final String FILE_PATH =
|
//private final String FILE_PATH =
|
||||||
@@ -47,7 +46,7 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> {
|
|||||||
private UploadEntity mEntity;
|
private UploadEntity mEntity;
|
||||||
|
|
||||||
@Override protected int setLayoutId() {
|
@Override protected int setLayoutId() {
|
||||||
return R.layout.activity_upload;
|
return R.layout.activity_single;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void init(Bundle savedInstanceState) {
|
@Override protected void init(Bundle savedInstanceState) {
|
||||||
@@ -56,24 +55,26 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> {
|
|||||||
Aria.upload(this).getTaskList();
|
Aria.upload(this).getTaskList();
|
||||||
|
|
||||||
mEntity = Aria.upload(this).getFirstUploadEntity(FILE_PATH);
|
mEntity = Aria.upload(this).getFirstUploadEntity(FILE_PATH);
|
||||||
|
getBinding().pl.setInfo(mEntity);
|
||||||
Aria.upload(this).register();
|
Aria.upload(this).register();
|
||||||
getBinding().upload.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override public void onClick(View v) {
|
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
|
||||||
|
@Override public void create(View v, AbsEntity entity) {
|
||||||
upload();
|
upload();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
getBinding().stop.setOnClickListener(new View.OnClickListener() {
|
@Override public void stop(View v, AbsEntity entity) {
|
||||||
@Override public void onClick(View v) {
|
HttpUploadActivity.this.stop();
|
||||||
stop();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
getBinding().remove.setOnClickListener(new View.OnClickListener() {
|
@Override public void resume(View v, AbsEntity entity) {
|
||||||
@Override public void onClick(View v) {
|
upload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void cancel(View v, AbsEntity entity) {
|
||||||
remove();
|
remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mPb = getBinding().pb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void upload() {
|
void upload() {
|
||||||
@@ -107,32 +108,29 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Upload.onTaskStart public void taskStart(UploadTask task) {
|
@Upload.onTaskStart public void taskStart(UploadTask task) {
|
||||||
L.d(TAG, "upload create,md5:" + FileUtil.getFileMD5(new File(task.getEntity().getFilePath())));
|
ALog.d(TAG,
|
||||||
getBinding().setFileSize(task.getConvertFileSize());
|
"upload create,md5:" + FileUtil.getFileMD5(new File(task.getEntity().getFilePath())));
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Upload.onTaskStop public void taskStop(UploadTask task) {
|
@Upload.onTaskStop public void taskStop(UploadTask task) {
|
||||||
L.d(TAG, "upload stop");
|
ALog.d(TAG, "upload stop");
|
||||||
getBinding().setSpeed("");
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setProgress(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Upload.onTaskCancel public void taskCancel(UploadTask task) {
|
@Upload.onTaskCancel public void taskCancel(UploadTask task) {
|
||||||
L.d(TAG, "upload cancel");
|
ALog.d(TAG, "upload cancel");
|
||||||
getBinding().setSpeed("");
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setProgress(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Upload.onTaskRunning public void taskRunning(UploadTask task) {
|
@Upload.onTaskRunning public void taskRunning(UploadTask task) {
|
||||||
getBinding().setSpeed(task.getConvertSpeed());
|
ALog.d(TAG, "running, P = " + task.getPercent());
|
||||||
getBinding().setProgress(task.getPercent());
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
L.d(TAG, "running, P = " + task.getPercent());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Upload.onTaskComplete public void taskComplete(UploadTask task) {
|
@Upload.onTaskComplete public void taskComplete(UploadTask task) {
|
||||||
L.d(TAG, "上传完成");
|
ALog.d(TAG, "上传完成");
|
||||||
L.d(TAG, "上传成功服务端返回数据(如果有的话):" + task.getEntity().getResponseStr());
|
ALog.d(TAG, "上传成功服务端返回数据(如果有的话):" + task.getEntity().getResponseStr());
|
||||||
getBinding().setSpeed("");
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setProgress(100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,38 +15,31 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.simple.core.upload;
|
package com.arialyy.simple.core.upload;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
import com.arialyy.annotations.Upload;
|
import com.arialyy.annotations.Upload;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.common.SFtpOption;
|
import com.arialyy.aria.core.common.SFtpOption;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
|
||||||
import com.arialyy.aria.core.task.UploadTask;
|
import com.arialyy.aria.core.task.UploadTask;
|
||||||
import com.arialyy.aria.core.upload.UploadEntity;
|
import com.arialyy.aria.core.upload.UploadEntity;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import com.arialyy.frame.util.FileUtil;
|
|
||||||
import com.arialyy.frame.util.show.T;
|
|
||||||
import com.arialyy.simple.R;
|
import com.arialyy.simple.R;
|
||||||
import com.arialyy.simple.base.BaseActivity;
|
import com.arialyy.simple.base.BaseActivity;
|
||||||
import com.arialyy.simple.common.ModifyUrlDialog;
|
import com.arialyy.simple.databinding.ActivitySingleBinding;
|
||||||
import com.arialyy.simple.databinding.ActivitySftpUploadBinding;
|
import com.arialyy.simple.widget.ProgressLayout;
|
||||||
import com.arialyy.simple.util.AppUtil;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by lyy on 2017/7/28. Ftp 文件上传demo
|
* Created by lyy on 2017/7/28. Ftp 文件上传demo
|
||||||
*/
|
*/
|
||||||
public class SFtpUploadActivity extends BaseActivity<ActivitySftpUploadBinding> {
|
public class SFtpUploadActivity extends BaseActivity<ActivitySingleBinding> {
|
||||||
private final int OPEN_FILE_MANAGER_CODE = 0xB1;
|
private final int OPEN_FILE_MANAGER_CODE = 0xB1;
|
||||||
private String mFilePath;
|
private String mFilePath;
|
||||||
private String mUrl;
|
private String mUrl;
|
||||||
@@ -59,7 +52,6 @@ public class SFtpUploadActivity extends BaseActivity<ActivitySftpUploadBinding>
|
|||||||
super.init(savedInstanceState);
|
super.init(savedInstanceState);
|
||||||
Aria.upload(this).register();
|
Aria.upload(this).register();
|
||||||
|
|
||||||
getBinding().setViewModel(this);
|
|
||||||
setUI();
|
setUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,100 +61,42 @@ public class SFtpUploadActivity extends BaseActivity<ActivitySftpUploadBinding>
|
|||||||
@Override public void onChanged(@Nullable UploadEntity entity) {
|
@Override public void onChanged(@Nullable UploadEntity entity) {
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
mTaskId = entity.getId();
|
mTaskId = entity.getId();
|
||||||
if (entity.getFileSize() != 0) {
|
|
||||||
getBinding().setFileSize(CommonUtil.formatFileSize(entity.getFileSize()));
|
|
||||||
getBinding().setProgress(entity.isComplete() ? 100
|
|
||||||
: (int) (entity.getCurrentProgress() * 100 / entity.getFileSize()));
|
|
||||||
}
|
|
||||||
getBinding().setUrl(entity.getUrl());
|
|
||||||
getBinding().setFilePath(entity.getFilePath());
|
|
||||||
mUrl = entity.getUrl();
|
mUrl = entity.getUrl();
|
||||||
mFilePath = entity.getFilePath();
|
mFilePath = entity.getFilePath();
|
||||||
getBinding().setStateStr(getString(
|
getBinding().pl.setInfo(entity);
|
||||||
entity.getState() == IEntity.STATE_RUNNING ? R.string.stop : R.string.start));
|
|
||||||
} else {
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setHelpCode();
|
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
|
||||||
}
|
@Override public void create(View v, AbsEntity entity) {
|
||||||
|
mTaskId = Aria.upload(this)
|
||||||
|
.loadFtp(mFilePath)
|
||||||
|
.setUploadUrl(mUrl)
|
||||||
|
.sftpOption(getOption())
|
||||||
|
.ignoreFilePathOccupy()
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
private void setHelpCode() {
|
@Override public void stop(View v, AbsEntity entity) {
|
||||||
//try {
|
Aria.upload(this).loadFtp(mTaskId).stop();
|
||||||
// getBinding().codeView.setSource(AppUtil.getHelpCode(this, "FtpUpload.java"));
|
}
|
||||||
//} catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
@Override public void resume(View v, AbsEntity entity) {
|
||||||
//}
|
Aria.upload(this)
|
||||||
|
.loadFtp(mTaskId)
|
||||||
|
.sftpOption(getOption())
|
||||||
|
.resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void cancel(View v, AbsEntity entity) {
|
||||||
|
Aria.upload(this).loadFtp(mTaskId).cancel(false);
|
||||||
|
mTaskId = -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected int setLayoutId() {
|
@Override protected int setLayoutId() {
|
||||||
return R.layout.activity_sftp_upload;
|
return R.layout.activity_single;
|
||||||
}
|
|
||||||
|
|
||||||
public void chooseUrl() {
|
|
||||||
ModifyUrlDialog dialog =
|
|
||||||
new ModifyUrlDialog(this, getString(R.string.modify_url_dialog_title), mUrl);
|
|
||||||
dialog.show(getSupportFragmentManager(), "ModifyUrlDialog");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void chooseFilePath() {
|
|
||||||
AppUtil.chooseFile(this, new File(mFilePath), null, OPEN_FILE_MANAGER_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.start:
|
|
||||||
if (mTaskId == -1) {
|
|
||||||
mTaskId = Aria.upload(this)
|
|
||||||
.loadFtp(mFilePath)
|
|
||||||
.setUploadUrl(mUrl)
|
|
||||||
.sftpOption(getOption())
|
|
||||||
.ignoreFilePathOccupy()
|
|
||||||
.create();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (Aria.upload(this).loadFtp(mTaskId).isRunning()) {
|
|
||||||
Aria.upload(this).loadFtp(mTaskId).stop();
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
} else {
|
|
||||||
Aria.upload(this)
|
|
||||||
.loadFtp(mTaskId)
|
|
||||||
.sftpOption(getOption())
|
|
||||||
.resume();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
}
|
|
||||||
//upload();
|
|
||||||
break;
|
|
||||||
case R.id.cancel:
|
|
||||||
Aria.upload(this).loadFtp(mTaskId).cancel(false);
|
|
||||||
mTaskId = -1;
|
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void upload() {
|
|
||||||
List<String> paths = new ArrayList<>();
|
|
||||||
paths.add(Environment.getExternalStorageDirectory().getPath() + "/Download/img/img/1.jpg");
|
|
||||||
paths.add(Environment.getExternalStorageDirectory().getPath() + "/Download/img/img/2.jpg");
|
|
||||||
paths.add(Environment.getExternalStorageDirectory().getPath() + "/Download/img/img/3.jpg");
|
|
||||||
paths.add(Environment.getExternalStorageDirectory().getPath() + "/Download/img/img/4.jpg");
|
|
||||||
paths.add(Environment.getExternalStorageDirectory().getPath() + "/Download/img/img/5.jpg");
|
|
||||||
paths.add(Environment.getExternalStorageDirectory().getPath() + "/Download/img/img/6.jpg");
|
|
||||||
paths.add(Environment.getExternalStorageDirectory().getPath() + "/Download/img/img/7.jpg");
|
|
||||||
paths.add(Environment.getExternalStorageDirectory().getPath() + "/Download/img/img/8.jpg");
|
|
||||||
paths.add(Environment.getExternalStorageDirectory().getPath() + "/Download/img/img/9.jpg");
|
|
||||||
paths.add(Environment.getExternalStorageDirectory().getPath() + "/Download/img/img/10.jpg");
|
|
||||||
for (String path : paths) {
|
|
||||||
Aria.upload(this)
|
|
||||||
.loadFtp(path)
|
|
||||||
.setUploadUrl(mUrl)
|
|
||||||
.sftpOption(getOption())
|
|
||||||
.ignoreFilePathOccupy()
|
|
||||||
.create();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SFtpOption getOption() {
|
private SFtpOption getOption() {
|
||||||
@@ -171,69 +105,79 @@ public class SFtpUploadActivity extends BaseActivity<ActivitySftpUploadBinding>
|
|||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Upload.onWait void onWait(UploadTask task) {
|
@Upload.onWait
|
||||||
Log.d(TAG, task.getTaskName() + "_wait");
|
void onWait(UploadTask task) {
|
||||||
}
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
Log.d(TAG, "wait ==> " + task.getEntity().getFileName());
|
||||||
@Upload.onPre public void onPre(UploadTask task) {
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setFileSize(task.getConvertFileSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskStart public void taskStart(UploadTask task) {
|
|
||||||
Log.d(TAG, "开始上传,md5:" + FileUtil.getFileMD5(new File(task.getEntity().getFilePath())));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskResume public void taskResume(UploadTask task) {
|
|
||||||
Log.d(TAG, "恢复上传");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskStop public void taskStop(UploadTask task) {
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
Log.d(TAG, "停止上传");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskCancel public void taskCancel(UploadTask task) {
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
getBinding().setFileSize("");
|
|
||||||
getBinding().setProgress(0);
|
|
||||||
Log.d(TAG, "删除任务");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskFail public void taskFail(UploadTask task) {
|
|
||||||
Log.d(TAG, "上传失败");
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskRunning public void taskRunning(UploadTask task) {
|
|
||||||
Log.d(TAG, "PP = " + task.getPercent());
|
|
||||||
getBinding().setProgress(task.getPercent());
|
|
||||||
getBinding().setSpeed(task.getConvertSpeed());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Upload.onTaskComplete public void taskComplete(UploadTask task) {
|
|
||||||
getBinding().setProgress(100);
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
T.showShort(this, "文件:" + task.getEntity().getFileName() + ",上传完成");
|
|
||||||
getBinding().setStateStr(getString(R.string.re_start));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override protected void dataCallback(int result, Object data) {
|
|
||||||
super.dataCallback(result, data);
|
|
||||||
if (result == ModifyUrlDialog.MODIFY_URL_DIALOG_RESULT) {
|
|
||||||
mModule.updateFtpUrl(this, String.valueOf(data));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
@Upload.onPre
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
protected void onPre(UploadTask task) {
|
||||||
if (requestCode == OPEN_FILE_MANAGER_CODE && resultCode == RESULT_OK) {
|
if (task.getKey().equals(mUrl)) {
|
||||||
Uri uri = data.getData();
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
if (uri != null) {
|
}
|
||||||
mModule.updateFtpFilePath(this, uri.getPath());
|
}
|
||||||
ALog.d(TAG, String.format("选择的文件路径:%s", uri.getPath()));
|
|
||||||
} else {
|
@Upload.onTaskStart
|
||||||
ALog.d(TAG, "没有选择文件");
|
void taskStart(UploadTask task) {
|
||||||
}
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
ALog.d(TAG, "isComplete = " + task.isComplete() + ", state = " + task.getState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskRunning
|
||||||
|
protected void running(UploadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
ALog.d(TAG, "isRunning" + "; state = " + task.getEntity().getState());
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskResume
|
||||||
|
void taskResume(UploadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
ALog.d(TAG, "resume");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskStop
|
||||||
|
void taskStop(UploadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
ALog.d(TAG, "stop");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskCancel
|
||||||
|
void taskCancel(UploadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
mTaskId = -1;
|
||||||
|
Log.d(TAG, "cancel");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskFail
|
||||||
|
void taskFail(UploadTask task, Exception e) {
|
||||||
|
ALog.d(TAG, "fail");
|
||||||
|
Toast.makeText(this, getString(R.string.download_fail), Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
|
if (task != null && task.getKey().equals(mUrl)) {
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Upload.onTaskComplete
|
||||||
|
void taskComplete(UploadTask task) {
|
||||||
|
if (task.getKey().equals(mUrl)) {
|
||||||
|
Toast.makeText(this, getString(R.string.download_success),
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
ALog.d(TAG, "md5: " + CommonUtil.getFileMD5(new File(task.getEntity().getFilePath())));
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
267
app/src/main/java/com/arialyy/simple/widget/ProgressLayout.java
Normal file
267
app/src/main/java/com/arialyy/simple/widget/ProgressLayout.java
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.arialyy.simple.widget;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.appcompat.widget.AppCompatImageButton;
|
||||||
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
|
import com.arialyy.aria.core.common.AbsGroupEntity;
|
||||||
|
import com.arialyy.aria.core.common.AbsNormalEntity;
|
||||||
|
import com.arialyy.aria.core.inf.IEntity;
|
||||||
|
import com.arialyy.aria.util.ALog;
|
||||||
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
|
import com.arialyy.simple.R;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一的进度布局
|
||||||
|
*/
|
||||||
|
public class ProgressLayout extends RelativeLayout implements View.OnClickListener {
|
||||||
|
private final String TAG = "ProgressLayout";
|
||||||
|
private TextView speedOrState, fileName, leftTime, fileSize;
|
||||||
|
private HorizontalProgressBarWithNumber pb;
|
||||||
|
private AppCompatImageButton delBt;
|
||||||
|
private Button handleBt;
|
||||||
|
private OnProgressLayoutBtListener listener;
|
||||||
|
private AbsEntity entity;
|
||||||
|
private int currentState;
|
||||||
|
|
||||||
|
public interface OnProgressLayoutBtListener {
|
||||||
|
/**
|
||||||
|
* 处理创建操作
|
||||||
|
*/
|
||||||
|
void create(View v, AbsEntity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理任务暂停的操作
|
||||||
|
*/
|
||||||
|
void stop(View v, AbsEntity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理恢复任务的操作
|
||||||
|
*/
|
||||||
|
void resume(View v, AbsEntity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理任务删除的操作
|
||||||
|
*/
|
||||||
|
void cancel(View v, AbsEntity entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProgressLayout(Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProgressLayout(Context context, AttributeSet attrs) {
|
||||||
|
this(context, attrs, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProgressLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
init(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(Context context, AttributeSet attrs) {
|
||||||
|
LayoutInflater.from(context).inflate(R.layout.layout_progress_content, this, true);
|
||||||
|
speedOrState = findViewById(R.id.speed_or_state);
|
||||||
|
fileName = findViewById(R.id.file_name);
|
||||||
|
leftTime = findViewById(R.id.left_time);
|
||||||
|
fileSize = findViewById(R.id.file_size);
|
||||||
|
pb = findViewById(R.id.pb);
|
||||||
|
delBt = findViewById(R.id.del_bt);
|
||||||
|
handleBt = findViewById(R.id.handle_bt);
|
||||||
|
delBt.setOnClickListener(this);
|
||||||
|
handleBt.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBtListener(OnProgressLayoutBtListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void onClick(View v) {
|
||||||
|
if (listener == null) {
|
||||||
|
ALog.d(TAG, "没有设置OnProgressLayoutBtListener");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (entity == null) {
|
||||||
|
ALog.d(TAG, "entity 为空,请设置信息");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.del_bt:
|
||||||
|
listener.cancel(v, entity);
|
||||||
|
initState();
|
||||||
|
break;
|
||||||
|
case R.id.handle_bt:
|
||||||
|
handleTask(v);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initState() {
|
||||||
|
fileName.setText("-");
|
||||||
|
leftTime.setText("");
|
||||||
|
speedOrState.setText("");
|
||||||
|
fileSize.setText("-/-");
|
||||||
|
pb.setProgress(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleTask(View v) {
|
||||||
|
switch (entity.getState()) {
|
||||||
|
case IEntity.STATE_OTHER:
|
||||||
|
case IEntity.STATE_FAIL:
|
||||||
|
case IEntity.STATE_STOP:
|
||||||
|
listener.resume(v, entity);
|
||||||
|
break;
|
||||||
|
case IEntity.STATE_COMPLETE:
|
||||||
|
case IEntity.STATE_WAIT:
|
||||||
|
if (entity.getId() != -1) {
|
||||||
|
listener.resume(v, entity);
|
||||||
|
} else {
|
||||||
|
listener.create(v, entity);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IEntity.STATE_PRE:
|
||||||
|
case IEntity.STATE_POST_PRE:
|
||||||
|
case IEntity.STATE_RUNNING:
|
||||||
|
listener.stop(v, entity);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
listener.create(v, entity);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInfo(AbsEntity entity) {
|
||||||
|
this.entity = entity;
|
||||||
|
this.currentState = entity.getState();
|
||||||
|
if (entity instanceof AbsNormalEntity) {
|
||||||
|
AbsNormalEntity normalEntity = (AbsNormalEntity) entity;
|
||||||
|
ALog.d(TAG, "fileName = " + ((AbsNormalEntity) entity).getFileName());
|
||||||
|
fileName.setText(normalEntity.getFileName());
|
||||||
|
} else if (entity instanceof AbsGroupEntity) {
|
||||||
|
AbsGroupEntity groupEntity = (AbsGroupEntity) entity;
|
||||||
|
fileName.setText(
|
||||||
|
groupEntity.getAlias() == null ? groupEntity.getKey() : groupEntity.getAlias());
|
||||||
|
}
|
||||||
|
|
||||||
|
String str =
|
||||||
|
formatFileSize(entity.getCurrentProgress()) + "/" + formatFileSize(entity.getFileSize());
|
||||||
|
fileSize.setText(str);
|
||||||
|
leftTime.setText(CommonUtil.formatTime(entity.getTimeLeft()));
|
||||||
|
String btStr = getResources().getString(R.string.start);
|
||||||
|
String stateStr = "";
|
||||||
|
switch (entity.getState()) {
|
||||||
|
case IEntity.STATE_WAIT:
|
||||||
|
btStr = getResources().getString(R.string.start);
|
||||||
|
stateStr = getResources().getString(R.string.waiting);
|
||||||
|
break;
|
||||||
|
case IEntity.STATE_OTHER:
|
||||||
|
case IEntity.STATE_FAIL:
|
||||||
|
btStr = getResources().getString(R.string.start);
|
||||||
|
stateStr = getResources().getString(R.string.state_error);
|
||||||
|
break;
|
||||||
|
case IEntity.STATE_STOP:
|
||||||
|
btStr = getResources().getString(R.string.resume);
|
||||||
|
stateStr = getResources().getString(R.string.stopped);
|
||||||
|
break;
|
||||||
|
case IEntity.STATE_PRE:
|
||||||
|
case IEntity.STATE_POST_PRE:
|
||||||
|
case IEntity.STATE_RUNNING:
|
||||||
|
btStr = getResources().getString(R.string.stop);
|
||||||
|
stateStr = entity.getConvertSpeed();
|
||||||
|
leftTime.setText(CommonUtil.formatTime(entity.getTimeLeft()));
|
||||||
|
break;
|
||||||
|
case IEntity.STATE_COMPLETE:
|
||||||
|
btStr = getResources().getString(R.string.re_start);
|
||||||
|
stateStr = getResources().getString(R.string.completed);
|
||||||
|
break;
|
||||||
|
case IEntity.STATE_CANCEL:
|
||||||
|
initState();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
btStr = getResources().getString(R.string.start);
|
||||||
|
stateStr = "";
|
||||||
|
leftTime.setText("");
|
||||||
|
}
|
||||||
|
this.handleBt.setText(btStr);
|
||||||
|
this.speedOrState.setText(stateStr);
|
||||||
|
if (entity.getState() != IEntity.STATE_CANCEL){
|
||||||
|
this.pb.setProgress(entity.getPercent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileName(Character fileName) {
|
||||||
|
this.fileName.setText(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeftTime(Character leftTime) {
|
||||||
|
this.leftTime.setText(leftTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileSize(Character fileSize) {
|
||||||
|
this.fileSize.setText(fileSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProgress(int progress) {
|
||||||
|
this.pb.setProgress(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpeed(Character speed) {
|
||||||
|
this.speedOrState.setText(speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(Character state) {
|
||||||
|
this.speedOrState.setText(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formatFileSize(double size) {
|
||||||
|
if (size < 0) {
|
||||||
|
return "0k";
|
||||||
|
}
|
||||||
|
double kiloByte = size / 1024;
|
||||||
|
if (kiloByte < 1) {
|
||||||
|
return size + "b";
|
||||||
|
}
|
||||||
|
|
||||||
|
double megaByte = kiloByte / 1024;
|
||||||
|
if (megaByte < 1) {
|
||||||
|
BigDecimal result1 = new BigDecimal(Double.toString(kiloByte));
|
||||||
|
return result1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "k";
|
||||||
|
}
|
||||||
|
|
||||||
|
double gigaByte = megaByte / 1024;
|
||||||
|
if (gigaByte < 1) {
|
||||||
|
BigDecimal result2 = new BigDecimal(Double.toString(megaByte));
|
||||||
|
return result2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "m";
|
||||||
|
}
|
||||||
|
|
||||||
|
double teraBytes = gigaByte / 1024;
|
||||||
|
if (teraBytes < 1) {
|
||||||
|
BigDecimal result3 = new BigDecimal(Double.toString(gigaByte));
|
||||||
|
return result3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "g";
|
||||||
|
}
|
||||||
|
BigDecimal result4 = new BigDecimal(teraBytes);
|
||||||
|
return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "t";
|
||||||
|
}
|
||||||
|
}
|
||||||
9
app/src/main/res/drawable/ic_close.xml
Normal file
9
app/src/main/res/drawable/ic_close.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="1024"
|
||||||
|
android:viewportHeight="1024">
|
||||||
|
<path
|
||||||
|
android:pathData="M521.69,449.3L111.41,39.01a51.2,51.2 0,1 0,-72.43 72.36l410.28,410.32 -410.28,410.32a51.2,51.2 0,1 0,72.4 72.4l410.32,-410.28 410.32,410.28a51.2,51.2 0,1 0,72.4 -72.36l-410.28,-410.35 410.28,-410.28a51.2,51.2 0,1 0,-72.4 -72.4l-410.28,410.28z"
|
||||||
|
android:fillColor="#515151"/>
|
||||||
|
</vector>
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:bind="http://schemas.android.com/apk/res-auto"
|
|
||||||
>
|
|
||||||
|
|
||||||
<data>
|
|
||||||
<variable
|
|
||||||
name="fileSize"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="speed"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="progress"
|
|
||||||
type="int"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="stateStr"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<variable
|
|
||||||
name="url"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="filePath"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="viewModel"
|
|
||||||
type="com.arialyy.simple.core.download.FtpDownloadActivity"
|
|
||||||
/>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:orientation="vertical"
|
|
||||||
tools:context=".core.download.SingleTaskActivity"
|
|
||||||
>
|
|
||||||
|
|
||||||
<include layout="@layout/layout_bar"/>
|
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseUrl()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_modify"
|
|
||||||
bind:text="@{@string/url(url)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseFilePath()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_choose_file"
|
|
||||||
bind:text="@{@string/file_path(filePath)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/layout_content_single"
|
|
||||||
bind:fileSize="@{fileSize}"
|
|
||||||
bind:progress="@{progress}"
|
|
||||||
bind:speed="@{speed}"
|
|
||||||
bind:stateStr="@{stateStr}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- <com.arialyy.simple.widget.CodeView-->
|
|
||||||
<!-- android:id="@+id/code_view"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="match_parent"-->
|
|
||||||
<!-- />-->
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</layout>
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:bind="http://schemas.android.com/apk/res-auto"
|
|
||||||
>
|
|
||||||
<data>
|
|
||||||
<variable
|
|
||||||
name="fileSize"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="speed"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="progress"
|
|
||||||
type="int"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="url"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="filePath"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="viewModel"
|
|
||||||
type="com.arialyy.simple.core.upload.FtpUploadActivity"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="stateStr"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
>
|
|
||||||
|
|
||||||
<include layout="@layout/layout_bar"/>
|
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseUrl()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_modify"
|
|
||||||
bind:text="@{@string/url(url)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseFilePath()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_choose_file"
|
|
||||||
bind:text="@{@string/file_path(filePath)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/layout_content_single"
|
|
||||||
bind:fileSize="@{fileSize}"
|
|
||||||
bind:progress="@{progress}"
|
|
||||||
bind:speed="@{speed}"
|
|
||||||
bind:stateStr="@{stateStr}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <com.arialyy.simple.widget.CodeView-->
|
|
||||||
<!-- android:id="@+id/code_view"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="match_parent"-->
|
|
||||||
<!-- />-->
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</layout>
|
|
||||||
@@ -1,46 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
xmlns:bind="http://schemas.android.com/apk/res-auto"
|
|
||||||
>
|
|
||||||
|
|
||||||
<data>
|
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
|
||||||
<variable
|
|
||||||
name="fileSize"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="speed"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="progress"
|
|
||||||
type="int"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="stateStr"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<variable
|
|
||||||
name="url"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="filePath"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="hint"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="viewModel"
|
|
||||||
type="com.arialyy.simple.core.download.m3u8.M3U8LiveDLoadActivity"
|
|
||||||
/>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
@@ -48,75 +9,14 @@
|
|||||||
tools:context=".core.download.SingleTaskActivity"
|
tools:context=".core.download.SingleTaskActivity"
|
||||||
>
|
>
|
||||||
|
|
||||||
<include layout="@layout/layout_bar"/>
|
<include layout="@layout/layout_bar" />
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
<com.arialyy.simple.widget.ProgressLayout
|
||||||
|
android:id="@+id/pl"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_margin="16dp"
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseUrl()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_modify"
|
|
||||||
bind:text="@{@string/url(url)}"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseFilePath()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_choose_file"
|
|
||||||
bind:text="@{@string/file_path(filePath)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/hint"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@{hint}"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
>
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/speed"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@{speed}"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/start"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:onClick="onClick"
|
|
||||||
android:text="@{stateStr ?? @string/start}"
|
|
||||||
style="?buttonBarButtonStyle"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/cancel"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:onClick="onClick"
|
|
||||||
android:text="@string/cancel"
|
|
||||||
style="?buttonBarButtonStyle"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -1,40 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:bind="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
>
|
>
|
||||||
|
|
||||||
<data>
|
|
||||||
<variable
|
|
||||||
name="fileSize"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="speed"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="progress"
|
|
||||||
type="int"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="stateStr"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<variable
|
|
||||||
name="url"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="filePath"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="viewModel"
|
|
||||||
type="com.arialyy.simple.core.download.m3u8.M3U8VodDLoadActivity"
|
|
||||||
/>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -46,38 +14,15 @@
|
|||||||
|
|
||||||
<include layout="@layout/layout_bar" />
|
<include layout="@layout/layout_bar" />
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
<com.arialyy.simple.widget.ProgressLayout
|
||||||
|
android:id="@+id/pl"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_margin="16dp"
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseUrl()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_modify"
|
|
||||||
bind:text="@{@string/url(url)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseFilePath()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_choose_file"
|
|
||||||
bind:text="@{@string/file_path(filePath)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/layout_content_single"
|
|
||||||
bind:fileSize="@{fileSize}"
|
|
||||||
bind:progress="@{progress}"
|
|
||||||
bind:speed="@{speed}"
|
|
||||||
bind:stateStr="@{stateStr}"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatSeekBar
|
<androidx.appcompat.widget.AppCompatSeekBar
|
||||||
android:id="@+id/pb"
|
android:id="@+id/seek_bar"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:bind="http://schemas.android.com/apk/res-auto"
|
|
||||||
>
|
|
||||||
|
|
||||||
<data>
|
|
||||||
<variable
|
|
||||||
name="fileSize"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="speed"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="progress"
|
|
||||||
type="int"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="stateStr"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<variable
|
|
||||||
name="url"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="filePath"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="viewModel"
|
|
||||||
type="com.arialyy.simple.core.download.SFtpDownloadActivity"
|
|
||||||
/>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:orientation="vertical"
|
|
||||||
tools:context=".core.download.SingleTaskActivity"
|
|
||||||
>
|
|
||||||
|
|
||||||
<include layout="@layout/layout_bar"/>
|
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseUrl()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_modify"
|
|
||||||
bind:text="@{@string/url(url)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseFilePath()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_choose_file"
|
|
||||||
bind:text="@{@string/file_path(filePath)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/layout_content_single"
|
|
||||||
bind:fileSize="@{fileSize}"
|
|
||||||
bind:progress="@{progress}"
|
|
||||||
bind:speed="@{speed}"
|
|
||||||
bind:stateStr="@{stateStr}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- <com.arialyy.simple.widget.CodeView-->
|
|
||||||
<!-- android:id="@+id/code_view"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="match_parent"-->
|
|
||||||
<!-- />-->
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</layout>
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:bind="http://schemas.android.com/apk/res-auto"
|
|
||||||
>
|
|
||||||
<data>
|
|
||||||
<variable
|
|
||||||
name="fileSize"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="speed"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="progress"
|
|
||||||
type="int"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="url"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="filePath"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="viewModel"
|
|
||||||
type="com.arialyy.simple.core.upload.SFtpUploadActivity"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="stateStr"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
>
|
|
||||||
|
|
||||||
<include layout="@layout/layout_bar"/>
|
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseUrl()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_modify"
|
|
||||||
bind:text="@{@string/url(url)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseFilePath()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_choose_file"
|
|
||||||
bind:text="@{@string/file_path(filePath)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/layout_content_single"
|
|
||||||
bind:fileSize="@{fileSize}"
|
|
||||||
bind:progress="@{progress}"
|
|
||||||
bind:speed="@{speed}"
|
|
||||||
bind:stateStr="@{stateStr}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <com.arialyy.simple.widget.CodeView-->
|
|
||||||
<!-- android:id="@+id/code_view"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="match_parent"-->
|
|
||||||
<!-- />-->
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</layout>
|
|
||||||
@@ -1,46 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
xmlns:bind="http://schemas.android.com/apk/res-auto"
|
|
||||||
>
|
|
||||||
|
|
||||||
<data>
|
|
||||||
<variable
|
|
||||||
name="fileSize"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="speed"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="progress"
|
|
||||||
type="int"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="stateStr"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<variable
|
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
|
||||||
name="url"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="filePath"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="viewModel"
|
|
||||||
type="com.arialyy.simple.core.download.SingleTaskActivity"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="timeLeft"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
@@ -48,37 +10,13 @@
|
|||||||
tools:context=".core.download.SingleTaskActivity"
|
tools:context=".core.download.SingleTaskActivity"
|
||||||
>
|
>
|
||||||
|
|
||||||
<include layout="@layout/layout_bar"/>
|
<include layout="@layout/layout_bar" />
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
<com.arialyy.simple.widget.ProgressLayout
|
||||||
|
android:id="@+id/pl"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_margin="16dp"
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseUrl()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_modify"
|
|
||||||
bind:text="@{@string/url(url)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SvgTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
bind:iconClickListener="@{() -> viewModel.chooseFilePath()}"
|
|
||||||
bind:svg_text_view_icon="@drawable/ic_choose_file"
|
|
||||||
bind:text="@{@string/file_path(filePath)}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/layout_content_single"
|
|
||||||
bind:fileSize="@{fileSize}"
|
|
||||||
bind:progress="@{progress}"
|
|
||||||
bind:speed="@{speed}"
|
|
||||||
bind:stateStr="@{stateStr}"
|
|
||||||
bind:timeLeft="@{timeLeft}"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -1,103 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<data>
|
|
||||||
<variable
|
|
||||||
name="fileSize"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="speed"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<variable
|
|
||||||
name="progress"
|
|
||||||
type="int"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
>
|
|
||||||
<include layout="@layout/layout_bar"/>
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/top_bar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/toolbar"
|
|
||||||
>
|
|
||||||
|
|
||||||
<com.arialyy.simple.widget.HorizontalProgressBarWithNumber
|
|
||||||
android:id="@+id/pb"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="20dp"
|
|
||||||
android:layout_margin="16dp"
|
|
||||||
android:layout_toLeftOf="@+id/size"
|
|
||||||
android:max="100"
|
|
||||||
android:progress="@{progress}"
|
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/size"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:text="@{fileSize}"
|
|
||||||
/>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/speed"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:text="@{speed}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/upload"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="上传"
|
|
||||||
style="?buttonBarButtonStyle"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/stop"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="停止"
|
|
||||||
style="?buttonBarButtonStyle"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/remove"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="删除"
|
|
||||||
style="?buttonBarButtonStyle"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</layout>
|
|
||||||
101
app/src/main/res/layout/layout_progress_content.xml
Normal file
101
app/src/main/res/layout/layout_progress_content.xml
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/file_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="@dimen/text_size_normal"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/file_name"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:layout_toLeftOf="@+id/del_bt"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/speed_or_state"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/text_grey"
|
||||||
|
android:textSize="@dimen/text_size_smallest"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/left_time"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignTop="@+id/speed_or_state"
|
||||||
|
android:layout_marginStart="4dp"
|
||||||
|
android:layout_marginLeft="4dp"
|
||||||
|
android:layout_toEndOf="@+id/speed_or_state"
|
||||||
|
android:layout_toRightOf="@+id/speed_or_state"
|
||||||
|
android:textColor="@color/text_grey"
|
||||||
|
android:textSize="@dimen/text_size_smallest"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/file_size"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignTop="@+id/speed_or_state"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:textSize="@dimen/text_size_smallest"
|
||||||
|
tools:ignore="RelativeOverlap"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.arialyy.simple.widget.HorizontalProgressBarWithNumber
|
||||||
|
android:id="@+id/pb"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_below="@+id/speed_or_state"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:max="100"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
|
android:id="@+id/del_bt"
|
||||||
|
style="?buttonBarButtonStyle"
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:layout_toLeftOf="@+id/handle_bt"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
app:srcCompat="@drawable/ic_close"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/handle_bt"
|
||||||
|
style="?buttonBarButtonStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:text="@string/start"
|
||||||
|
android:textSize="@dimen/text_size_normal"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
@@ -6,7 +6,9 @@
|
|||||||
<color name="icon_color">#FF4081</color>
|
<color name="icon_color">#FF4081</color>
|
||||||
<color name="black">#2B2B2B</color>
|
<color name="black">#2B2B2B</color>
|
||||||
<color name="text_black">#2B2B2B</color>
|
<color name="text_black">#2B2B2B</color>
|
||||||
|
<color name="text_grey">#55544F</color>
|
||||||
<color name="icon_black">#2B2B2B</color>
|
<color name="icon_black">#2B2B2B</color>
|
||||||
<color name="bg_grey">#efefef</color>
|
<color name="bg_grey">#efefef</color>
|
||||||
<color name="bg_line">#597F96</color>
|
<color name="bg_line">#597F96</color>
|
||||||
|
<color name="transparent">#00000000</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -9,10 +9,14 @@
|
|||||||
<string name="cancel">取消</string>
|
<string name="cancel">取消</string>
|
||||||
<string name="modify_url_dialog_title">修改URL</string>
|
<string name="modify_url_dialog_title">修改URL</string>
|
||||||
<string name="stop">停止</string>
|
<string name="stop">停止</string>
|
||||||
|
<string name="stopped">已停止</string>
|
||||||
<string name="start">开始</string>
|
<string name="start">开始</string>
|
||||||
|
<string name="waiting">等待中</string>
|
||||||
|
<string name="state_error">任务已失败</string>
|
||||||
<string name="resume">恢复</string>
|
<string name="resume">恢复</string>
|
||||||
<string name="delete">删除</string>
|
<string name="delete">删除</string>
|
||||||
<string name="complete">完成</string>
|
<string name="complete">完成</string>
|
||||||
|
<string name="completed">已完成</string>
|
||||||
<string name="code_simple">代码示例:</string>
|
<string name="code_simple">代码示例:</string>
|
||||||
<string name="download_success">下载完成</string>
|
<string name="download_success">下载完成</string>
|
||||||
<string name="download_fail">下载失败</string>
|
<string name="download_fail">下载失败</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user