Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

添加最大选择数量的控制 #91

Open
wants to merge 3 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ public View getView(final int i, View view, ViewGroup viewGroup) {
holder.fmark.setOnCheckedChangedListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(MaterialCheckbox checkbox, boolean isChecked) {
item.setMarked(isChecked);
//限制最大选择数量
if (MarkedItemList.getFileCount() < properties.max_count){
item.setMarked(isChecked);
} else {
item.setMarked(false);
holder.fmark.setChecked(false);
}
if (item.isMarked()) {
if(properties.selection_mode == DialogConfigs.MULTI_MODE) {
MarkedItemList.addSelectedItem(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public abstract class DialogConfigs {
* can be selected.
*/
public static final int FILE_AND_DIR_SELECT = 2;

/*
* Max Select Count , defalut 9
*/
public static final int MAX_COUNT = 9;

/* PARENT_DIRECTORY*/
public static final String DIRECTORY_SEPERATOR = "/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public class DialogProperties {
* See DialogConfigs for more info. Set to FILE_SELECT as default value by constructor.
*/
public int selection_type;

/**
* add property max_count
*/
public int max_count;

/** The Parent/Root Directory. List of Files are populated from here. Can be set
* to any readable directory. /sdcard is the default location.
Expand Down Expand Up @@ -78,8 +83,9 @@ public DialogProperties() {
selection_mode = DialogConfigs.SINGLE_MODE;
selection_type = DialogConfigs.FILE_SELECT;
root = new File(DialogConfigs.DEFAULT_DIR);
max_count = DialogConfigs.MAX_COUNT;
error_dir = new File(DialogConfigs.DEFAULT_DIR);
offset = new File(DialogConfigs.DEFAULT_DIR);
extensions = null;
}
}
}