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 @@ - - +