排程浇水历史记录
This commit is contained in:
@@ -20,6 +20,7 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.InputFilter;
|
||||
import android.text.InputType;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -100,6 +101,11 @@ public abstract class BaseActivity<T extends ViewBinding, P extends IPresenter>
|
||||
public static final int REQUEST_EVENT_CODE_10001 = 10001;
|
||||
public static final int REQUEST_EVENT_CODE_10002 = 10002;
|
||||
public static final int REQUEST_EVENT_CODE_10003 = 10003;
|
||||
public static final int INPUT_TYPE_NORMAL = 0; // 默认
|
||||
public static final int INPUT_TYPE_NUMBER = 1; // 数字
|
||||
public static final int INPUT_TYPE_LETTER = 2; // 英文字母
|
||||
public static final int INPUT_TYPE_CHINESE = 3; // 中文
|
||||
public static final int INPUT_TYPE_NUMBER_LETTER = 4;//数字+字母
|
||||
public InputFilter mInputFilter;
|
||||
private static final AtomicBoolean isDialogShown = new AtomicBoolean(false); // 使用 AtomicBoolean 保证线程安全
|
||||
private ObjectAnimator rotateAnimator;
|
||||
@@ -484,15 +490,29 @@ public abstract class BaseActivity<T extends ViewBinding, P extends IPresenter>
|
||||
* @param confirmText 确定 文案
|
||||
* @param click
|
||||
*/
|
||||
public void showEditDialog(String title, String hint,String content, boolean touchOutsideCancel, String cancelText, String confirmText,
|
||||
public void showEditDialog(String title,
|
||||
String hint,
|
||||
String content,
|
||||
boolean touchOutsideCancel,
|
||||
String cancelText,
|
||||
String confirmText,
|
||||
int inputType,
|
||||
final OnDialogClick click) {
|
||||
View view = getLayoutInflater().inflate(R.layout.public_dialog_input_text, null);
|
||||
EditText editText = view.findViewById(R.id.et_input);
|
||||
// EditText自动获取焦点
|
||||
editText.requestFocus();
|
||||
//设置输入类型
|
||||
setEditInputType(editText,inputType);
|
||||
|
||||
if(TextUtils.isEmpty(content)){
|
||||
editText.setHint(hint);
|
||||
}else{
|
||||
editText.setText(content);
|
||||
}
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
editText.setSelection(editText.getText().length());
|
||||
}
|
||||
setTextView(R.id.tv_title, title, view);
|
||||
if (!TextUtils.isEmpty(confirmText) && !TextUtils.isEmpty(cancelText)) {
|
||||
((TextView) view.findViewById(R.id.btnLeft)).setText(cancelText);
|
||||
@@ -1128,4 +1148,72 @@ public abstract class BaseActivity<T extends ViewBinding, P extends IPresenter>
|
||||
// 方法2:通过Application检查(如果有记录当前Activity)
|
||||
return MyApplication.getCurrentActivity() == this;
|
||||
}
|
||||
|
||||
private void setEditInputType(EditText editText,int type){
|
||||
|
||||
switch (type){
|
||||
|
||||
case INPUT_TYPE_NUMBER:
|
||||
//纯数字键盘
|
||||
editText.setInputType(
|
||||
InputType.TYPE_CLASS_NUMBER
|
||||
);
|
||||
break;
|
||||
|
||||
case INPUT_TYPE_LETTER:
|
||||
|
||||
//只能输入字母
|
||||
editText.setFilters(
|
||||
new InputFilter[]{
|
||||
(source,start,end,dest,dstart,dend)->{
|
||||
|
||||
if(source.toString()
|
||||
.matches("[a-zA-Z]+")){
|
||||
return source;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case INPUT_TYPE_CHINESE:
|
||||
|
||||
//只能输入中文
|
||||
editText.setFilters(
|
||||
new InputFilter[]{
|
||||
(source,start,end,dest,dstart,dend)->{
|
||||
|
||||
if(source.toString()
|
||||
.matches("[\\u4e00-\\u9fa5]+")){
|
||||
return source;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case INPUT_TYPE_NUMBER_LETTER:
|
||||
|
||||
//数字+字母
|
||||
editText.setFilters(
|
||||
new InputFilter[]{
|
||||
(source,start,end,dest,dstart,dend)->{
|
||||
|
||||
if(source.toString()
|
||||
.matches("[a-zA-Z0-9]+")){
|
||||
return source;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
editText.setInputType(
|
||||
InputType.TYPE_CLASS_TEXT
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user