|
@@ -4,10 +4,13 @@ import android.annotation.SuppressLint;
|
|
|
import android.content.Context;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
+import android.text.Editable;
|
|
|
+import android.text.TextWatcher;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.ArrayAdapter;
|
|
|
+import android.widget.Button;
|
|
|
import android.widget.CheckBox;
|
|
|
import android.widget.EditText;
|
|
|
import android.widget.ImageView;
|
|
@@ -71,6 +74,8 @@ public class BaseListAdapter extends ArrayAdapter<BaseModel> {
|
|
|
view = LayoutInflater.from(getContext()).inflate(R.layout.item_checkbox, null);
|
|
|
} else if (model.cellType == Constant.CellType.REFRESH) {
|
|
|
view = LayoutInflater.from(getContext()).inflate(R.layout.item_refresh, null);
|
|
|
+ } else if (model.cellType == Constant.CellType.CANCEL_SURE) {
|
|
|
+ view = LayoutInflater.from(getContext()).inflate(R.layout.item_cancel_sure, null);
|
|
|
}
|
|
|
|
|
|
assert view != null;
|
|
@@ -80,9 +85,11 @@ public class BaseListAdapter extends ArrayAdapter<BaseModel> {
|
|
|
ImageView itembackground = view.findViewById(R.id.item_background);
|
|
|
ImageView itemIcon = view.findViewById(R.id.item_icon);
|
|
|
ImageView itemArrow = view.findViewById(R.id.item_arrow);
|
|
|
- Switch itemSwitch = view.findViewById(R.id.item_switch);
|
|
|
- CheckBox itemCheckbox = view.findViewById(R.id.item_checkbox);
|
|
|
IconProgressView iconProgressView = view.findViewById(R.id.item_icon_progress);
|
|
|
+ Switch switchButton = view.findViewById(R.id.item_switch);
|
|
|
+ CheckBox checkboxButton = view.findViewById(R.id.item_checkbox);
|
|
|
+ Button cancelButton = view.findViewById(R.id.button_cancel);
|
|
|
+ Button sureButton = view.findViewById(R.id.button_sure);
|
|
|
|
|
|
|
|
|
if (itemTitle != null) {
|
|
@@ -100,9 +107,9 @@ public class BaseListAdapter extends ArrayAdapter<BaseModel> {
|
|
|
if (itemArrow != null) {
|
|
|
itemArrow.setVisibility(model.isShowArrow ? View.VISIBLE : View.GONE);
|
|
|
}
|
|
|
- if (itemSwitch != null) {
|
|
|
- itemSwitch.setChecked(model.isOn);
|
|
|
- itemSwitch.setOnCheckedChangeListener((compoundButton, b) -> {
|
|
|
+ if (switchButton != null) {
|
|
|
+ switchButton.setChecked(model.isOn);
|
|
|
+ switchButton.setOnCheckedChangeListener((compoundButton, b) -> {
|
|
|
if (mHandler == null)
|
|
|
return;
|
|
|
Message message = new Message();
|
|
@@ -113,11 +120,11 @@ public class BaseListAdapter extends ArrayAdapter<BaseModel> {
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
- if (itemCheckbox != null) {
|
|
|
- itemCheckbox.setChecked(model.isOn);
|
|
|
- itemCheckbox.setEnabled(false);
|
|
|
- itemCheckbox.setFocusable(false);
|
|
|
- itemCheckbox.setOnCheckedChangeListener((compoundButton, b) -> {
|
|
|
+ if (checkboxButton != null) {
|
|
|
+ checkboxButton.setChecked(model.isOn);
|
|
|
+ checkboxButton.setEnabled(false);
|
|
|
+ checkboxButton.setFocusable(false);
|
|
|
+ checkboxButton.setOnCheckedChangeListener((compoundButton, b) -> {
|
|
|
if (mHandler == null)
|
|
|
return;
|
|
|
Message message = new Message();
|
|
@@ -132,6 +139,55 @@ public class BaseListAdapter extends ArrayAdapter<BaseModel> {
|
|
|
//iconProgressView.setProgressColor(((IconProgressModel)model).progressColor);
|
|
|
iconProgressView.setProgress100(((IconProgressModel)model).progress);
|
|
|
}
|
|
|
+ if (cancelButton != null) {
|
|
|
+ cancelButton.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (mHandler == null)
|
|
|
+ return;
|
|
|
+ Message message = new Message();
|
|
|
+ message.what = Constant.MSG_CANCEL_CLICK;
|
|
|
+ mHandler.sendMessage(message);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (sureButton != null) {
|
|
|
+ sureButton.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (mHandler == null)
|
|
|
+ return;
|
|
|
+ Message message = new Message();
|
|
|
+ message.what = Constant.MSG_SURE_CLICK;
|
|
|
+ mHandler.sendMessage(message);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (itemEdit != null) {
|
|
|
+ TextWatcher watcher = new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
+
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
+
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+ if (mHandler == null)
|
|
|
+ return;
|
|
|
+ Message message = new Message();
|
|
|
+ message.what = Constant.MSG_TEXTEDIT_FINISH;
|
|
|
+ message.arg1 = position;
|
|
|
+ message.obj = s.toString();
|
|
|
+ mHandler.sendMessage(message);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ itemEdit.addTextChangedListener(watcher);
|
|
|
+ }
|
|
|
+
|
|
|
return view;
|
|
|
}
|
|
|
|