From bd94e7dd272ea3f895d8ff90db81f614ad4193d3 Mon Sep 17 00:00:00 2001 From: lyy <511455842@qq.com> Date: Mon, 14 Nov 2016 16:56:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E4=BB=BB=E5=8A=A1=E6=95=B0?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simple/activity/MultiTaskActivity.java | 15 ++++ .../simple/adapter/DownloadAdapter.java | 4 + .../com/arialyy/simple/base/BaseDialog.java | 18 ++++ .../simple/dialog/DownloadNumDialog.java | 46 ++++++++++ app/src/main/res/layout/activity_multi.xml | 17 +++- .../main/res/layout/dialog_download_num.xml | 85 +++++++++++++++++++ .../core/queue/DownloadTaskQueue.java | 2 +- .../core/queue/pool/ExecutePool.java | 2 +- 8 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/arialyy/simple/base/BaseDialog.java create mode 100644 app/src/main/java/com/arialyy/simple/dialog/DownloadNumDialog.java create mode 100644 app/src/main/res/layout/dialog_download_num.xml diff --git a/app/src/main/java/com/arialyy/simple/activity/MultiTaskActivity.java b/app/src/main/java/com/arialyy/simple/activity/MultiTaskActivity.java index c3b5284b..9773036f 100644 --- a/app/src/main/java/com/arialyy/simple/activity/MultiTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/activity/MultiTaskActivity.java @@ -7,6 +7,8 @@ import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; +import android.view.View; +import android.widget.Button; import butterknife.Bind; import com.arialyy.downloadutil.core.DownloadEntity; import com.arialyy.downloadutil.core.DownloadManager; @@ -15,6 +17,7 @@ import com.arialyy.simple.R; import com.arialyy.simple.adapter.DownloadAdapter; import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.databinding.ActivityMultiBinding; +import com.arialyy.simple.dialog.DownloadNumDialog; import com.arialyy.simple.module.DownloadModule; /** @@ -86,6 +89,11 @@ public class MultiTaskActivity extends BaseActivity { } }; + public void onClick(View view){ + DownloadNumDialog dialog = new DownloadNumDialog(); + dialog.show(getSupportFragmentManager(), "download_num"); + } + @Override protected void onResume() { super.onResume(); registerReceiver(mReceiver, getModule(DownloadModule.class).getDownloadFilter()); @@ -95,4 +103,11 @@ public class MultiTaskActivity extends BaseActivity { super.onDestroy(); unregisterReceiver(mReceiver); } + + @Override protected void dataCallback(int result, Object data) { + super.dataCallback(result, data); + if (result == DownloadNumDialog.RESULT_CODE){ + mAdapter.setDownloadNum(Integer.parseInt(data + "")); + } + } } diff --git a/app/src/main/java/com/arialyy/simple/adapter/DownloadAdapter.java b/app/src/main/java/com/arialyy/simple/adapter/DownloadAdapter.java index 5ef1bf35..87108708 100644 --- a/app/src/main/java/com/arialyy/simple/adapter/DownloadAdapter.java +++ b/app/src/main/java/com/arialyy/simple/adapter/DownloadAdapter.java @@ -133,6 +133,10 @@ public class DownloadAdapter extends AbsRVAdapter extends AbsDialogFragment{ + @Override protected void init(Bundle savedInstanceState) { + + } + + @Override protected void dataCallback(int result, Object data) { + + } +} diff --git a/app/src/main/java/com/arialyy/simple/dialog/DownloadNumDialog.java b/app/src/main/java/com/arialyy/simple/dialog/DownloadNumDialog.java new file mode 100644 index 00000000..90933a7c --- /dev/null +++ b/app/src/main/java/com/arialyy/simple/dialog/DownloadNumDialog.java @@ -0,0 +1,46 @@ +package com.arialyy.simple.dialog; + +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.RadioButton; +import android.widget.RadioGroup; +import butterknife.Bind; +import com.arialyy.simple.R; +import com.arialyy.simple.base.BaseDialog; +import com.arialyy.simple.databinding.DialogDownloadNumBinding; + +/** + * Created by “AriaLyy@outlook.com” on 2016/11/14. + * 设置下载数量对话框 + */ +public class DownloadNumDialog extends BaseDialog implements RadioGroup.OnCheckedChangeListener{ + public static final int RESULT_CODE = 1001; + @Bind(R.id.cancel) Button mCancel; + @Bind(R.id.rg) RadioGroup mRg; + + @Override protected int setLayoutId() { + return R.layout.dialog_download_num; + } + + @Override protected void init(Bundle savedInstanceState) { + super.init(savedInstanceState); + mCancel.setOnClickListener(new View.OnClickListener() { + @Override public void onClick(View v) { + dismiss(); + } + }); + for (int i = 0, count = mRg.getChildCount(); i < count; i++) { + RadioButton rb = (RadioButton) mRg.getChildAt(i); + rb.setId(i); + } + mRg.setOnCheckedChangeListener(this); + } + + @Override public void onCheckedChanged(RadioGroup group, int checkedId) { + RadioButton rb = (RadioButton) group.getChildAt(checkedId); + if (rb.isChecked()) { + getSimplerModule().onDialog(RESULT_CODE, rb.getTag()); + } + } +} diff --git a/app/src/main/res/layout/activity_multi.xml b/app/src/main/res/layout/activity_multi.xml index 557259fb..ef85f1b1 100644 --- a/app/src/main/res/layout/activity_multi.xml +++ b/app/src/main/res/layout/activity_multi.xml @@ -1,9 +1,10 @@ - - +