任务组bug 修复
This commit is contained in:
@@ -69,7 +69,9 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
||||
case R.id.start:
|
||||
Aria.download(this)
|
||||
.load(mUrls)
|
||||
.setDownloadDirPath(Environment.getExternalStorageDirectory().getPath() + "/group_test")
|
||||
.setDownloadDirPath(Environment.getExternalStorageDirectory().getPath() + "/Download/group_test_3")
|
||||
.setGroupAlias("任务组测试")
|
||||
.setSubTaskFileName(getModule(GroupModule.class).getSubName())
|
||||
.start();
|
||||
break;
|
||||
case R.id.stop:
|
||||
|
||||
@@ -32,12 +32,18 @@ public class GroupModule extends BaseModule {
|
||||
|
||||
List<String> getUrls() {
|
||||
List<String> urls = new ArrayList<>();
|
||||
String[] str = getContext().getResources().getStringArray(R.array.download_url);
|
||||
//String[] str = getContext().getResources().getStringArray(R.array.group_urls);
|
||||
String[] str = getContext().getResources().getStringArray(R.array.group_urls);
|
||||
Collections.addAll(urls, str);
|
||||
return urls;
|
||||
}
|
||||
|
||||
List<String> getSubName(){
|
||||
List<String> names = new ArrayList<>();
|
||||
String[] str = getContext().getResources().getStringArray(R.array.group_names);
|
||||
Collections.addAll(names, str);
|
||||
return names;
|
||||
}
|
||||
|
||||
//NormalList<String> convertPath(NormalList<String> urls){
|
||||
// NormalList<String> paths = new ArrayList<>();
|
||||
//
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import butterknife.Bind;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
@@ -111,6 +112,9 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新进度
|
||||
*/
|
||||
public synchronized void setProgress(AbsEntity entity) {
|
||||
String url = entity.getKey();
|
||||
int position = indexItem(url);
|
||||
@@ -119,7 +123,7 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
|
||||
}
|
||||
|
||||
mData.set(position, entity);
|
||||
notifyItemChanged(position);
|
||||
notifyItemChanged(position, entity);
|
||||
}
|
||||
|
||||
private synchronized int indexItem(String url) {
|
||||
@@ -136,6 +140,24 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
|
||||
handleProgress(holder, item);
|
||||
}
|
||||
|
||||
@Override protected void bindData(SimpleHolder holder, int position, AbsEntity item,
|
||||
List<Object> payloads) {
|
||||
AbsEntity entity = (AbsEntity) payloads.get(0);
|
||||
updateSpeed(holder, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 只更新速度
|
||||
*/
|
||||
private void updateSpeed(SimpleHolder holder, final AbsEntity entity) {
|
||||
long size = entity.getFileSize();
|
||||
long progress = entity.getCurrentProgress();
|
||||
int current = size == 0 ? 0 : (int) (progress * 100 / size);
|
||||
holder.speed.setText(entity.getConvertSpeed());
|
||||
holder.fileSize.setText(covertCurrentSize(progress) + "/" + CommonUtil.formatFileSize(size));
|
||||
holder.progress.setProgress(current);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void handleProgress(SimpleHolder holder, final AbsEntity entity) {
|
||||
String str = "";
|
||||
@@ -189,6 +211,11 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
|
||||
});
|
||||
}
|
||||
|
||||
private void handleSubChild(GroupHolder holder, final AbsEntity entity){
|
||||
if (holder.childList.getVisibility() == View.GONE) return;
|
||||
|
||||
}
|
||||
|
||||
private boolean isSimpleDownload(AbsEntity entity) {
|
||||
return entity instanceof DownloadEntity;
|
||||
}
|
||||
@@ -260,7 +287,7 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
|
||||
}
|
||||
|
||||
class GroupHolder extends SimpleHolder {
|
||||
@Bind(R.id.child_list) NoScrollListView childList;
|
||||
@Bind(R.id.child_list) LinearLayout childList;
|
||||
|
||||
GroupHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
Reference in New Issue
Block a user