From af215378a8ee2aec071ce690b642de19e6a8c7bb Mon Sep 17 00:00:00 2001 From: Ztiany Date: Tue, 17 Dec 2019 20:41:35 +0800 Subject: [PATCH] optimize code --- .../android/base/permission/AutoPermissionRequester.java | 4 +++- .../main/java/com/android/base/utils/common/Strings.kt | 8 ++++++++ lib_media_selector/src/main/res/values-zh/strings.xml | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 lib_media_selector/src/main/res/values-zh/strings.xml diff --git a/lib_base/src/main/java/com/android/base/permission/AutoPermissionRequester.java b/lib_base/src/main/java/com/android/base/permission/AutoPermissionRequester.java index d48dbd2..4d5661f 100644 --- a/lib_base/src/main/java/com/android/base/permission/AutoPermissionRequester.java +++ b/lib_base/src/main/java/com/android/base/permission/AutoPermissionRequester.java @@ -68,7 +68,9 @@ public class AutoPermissionRequester { mOnAllPermissionGrantedListener = null; mOnPermissionDeniedListener = null; mPermissionUIProvider = null; - mPermissionCallback.setDestroyed(); + if (mPermissionCallback != null) { + mPermissionCallback.setDestroyed(); + } } }; diff --git a/lib_base/src/main/java/com/android/base/utils/common/Strings.kt b/lib_base/src/main/java/com/android/base/utils/common/Strings.kt index f5492a5..3416979 100644 --- a/lib_base/src/main/java/com/android/base/utils/common/Strings.kt +++ b/lib_base/src/main/java/com/android/base/utils/common/Strings.kt @@ -19,6 +19,14 @@ private const val CONTAINS_LOWERCASE_LETTERS_REG = "^.*[a-z]+.*$" private const val CONTAINS_UPPERCASE_LETTERS_REG = "^.*[A-Z]+.*$" private const val CHINESE_HAN_NATIONALITY_NAME_REG = "^[\\u4E00-\\u9FA5]{2,4}\$" private const val CHINESE_NAME_REG = "^[\\u4E00-\\u9FA5]+(·[\\u4E00-\\u9FA5]+)*\$" +private const val PASSPORT_REG = "^([a-zA-z]|[0-9]){5,17}\$" + +/** + * 验证护照号 + */ +fun isPassport(mobile: String?): Boolean { + return !isEmpty(mobile) && Pattern.matches(PASSPORT_REG, mobile) +} /** * 验证中国的手机号 diff --git a/lib_media_selector/src/main/res/values-zh/strings.xml b/lib_media_selector/src/main/res/values-zh/strings.xml new file mode 100644 index 0000000..1d8a1f9 --- /dev/null +++ b/lib_media_selector/src/main/res/values-zh/strings.xml @@ -0,0 +1,8 @@ + + + + 旋转 + 缩放 + 裁剪 + + \ No newline at end of file