parent
493810d0b0
commit
bd94e7dd27
@ -0,0 +1,18 @@ |
||||
package com.arialyy.simple.base; |
||||
|
||||
import android.databinding.ViewDataBinding; |
||||
import android.os.Bundle; |
||||
import com.arialyy.frame.core.AbsDialogFragment; |
||||
|
||||
/** |
||||
* Created by “AriaLyy@outlook.com” on 2016/11/14. |
||||
*/ |
||||
public abstract class BaseDialog<VB extends ViewDataBinding> extends AbsDialogFragment<VB>{ |
||||
@Override protected void init(Bundle savedInstanceState) { |
||||
|
||||
} |
||||
|
||||
@Override protected void dataCallback(int result, Object data) { |
||||
|
||||
} |
||||
} |
@ -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<DialogDownloadNumBinding> 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()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,85 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:orientation="vertical" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
> |
||||
|
||||
<TextView |
||||
android:textColor="@color/colorPrimary" |
||||
android:textSize="16sp" |
||||
android:layout_gravity="center_horizontal" |
||||
android:padding="10dp" |
||||
android:text="设置下载数" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
/> |
||||
|
||||
<View |
||||
android:background="@color/black" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="1dp"/> |
||||
|
||||
<RadioGroup |
||||
android:id="@+id/rg" |
||||
android:padding="16dp" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
> |
||||
|
||||
<RadioButton |
||||
android:tag="2" |
||||
android:text="下载线程数:2" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layoutDirection="rtl" |
||||
android:textAlignment="textStart" |
||||
android:layout_gravity="start" |
||||
/> |
||||
|
||||
<RadioButton |
||||
android:tag="3" |
||||
android:text="下载线程数:3" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layoutDirection="rtl" |
||||
android:textAlignment="textStart" |
||||
android:layout_gravity="start" |
||||
/> |
||||
|
||||
<RadioButton |
||||
android:tag="4" |
||||
android:text="下载线程数:4" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layoutDirection="rtl" |
||||
android:textAlignment="textStart" |
||||
android:layout_gravity="start" |
||||
/> |
||||
|
||||
</RadioGroup> |
||||
|
||||
|
||||
<View |
||||
android:background="@color/black" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="1dp"/> |
||||
|
||||
|
||||
<Button |
||||
android:id="@+id/cancel" |
||||
android:text="取消" |
||||
style="?buttonBarButtonStyle" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
/> |
||||
|
||||
</LinearLayout> |
||||
|
||||
</layout> |
Loading…
Reference in new issue