Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
ShenghuoquanBusiness
Commits
5fa0259e
Commit
5fa0259e
authored
Jul 16, 2021
by
shiyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化验收相关的UI效果
parent
6bddf689
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
269 additions
and
22 deletions
+269
-22
ValidationUtils.kt
.../src/main/java/com/yidian/common/utils/ValidationUtils.kt
+234
-0
ChooseStoreApter.kt
...dian/shenghuoquan/newscontent/adapter/ChooseStoreApter.kt
+20
-5
EditStoreActivity.kt
...an/shenghuoquan/newscontent/ui/store/EditStoreActivity.kt
+5
-7
SelectAddressActivity.kt
...henghuoquan/newscontent/ui/store/SelectAddressActivity.kt
+0
-1
activity_store_edit.xml
...s/newscontent/src/main/res/layout/activity_store_edit.xml
+6
-5
layout_choose_store_list_item.xml
...ent/src/main/res/layout/layout_choose_store_list_item.xml
+4
-4
No files found.
CommonLib/Common/src/main/java/com/yidian/common/utils/ValidationUtils.kt
0 → 100644
View file @
5fa0259e
package
com.yidian.common.utils
import
android.text.Editable
import
android.text.InputFilter
import
android.text.TextUtils
import
android.text.TextWatcher
import
android.widget.EditText
import
java.io.Serializable
import
java.util.regex.Pattern
/**
* 检查工具类
*/
abstract
class
ValidationUtils
:
Serializable
{
/**
* 检查输入是否超出规定长度
*
* @param length
* @param value
* @return
*/
fun
checkLength
(
value
:
String
?,
length
:
Int
):
Boolean
{
return
(
if
(
value
==
null
||
""
==
value
.
trim
{
it
<=
' '
})
0
else
value
.
length
)
<=
length
}
/**
* 检查是否为整数
*
* @param value
* @return
*/
fun
checkInteger
(
value
:
String
?):
Boolean
{
val
p
=
Pattern
.
compile
(
"^\\d*$"
)
val
m
=
p
.
matcher
(
value
)
return
m
.
matches
()
}
companion
object
{
private
const
val
serialVersionUID
=
-
7712299555022613697L
/**
* 匹配正则表达式
*
* @param reg 正则表达式
* @param content 匹配内容
* @return
*/
fun
pattern
(
reg
:
String
?,
content
:
String
?):
Boolean
{
val
pattern
=
Pattern
.
compile
(
reg
)
val
matcher
=
pattern
.
matcher
(
content
)
return
matcher
.
matches
()
}
/**
* 是否为null/字符串""
*
* @param str
* @return
*/
fun
isNull
(
str
:
String
?):
Boolean
{
return
str
==
null
||
str
==
""
||
str
==
"0"
}
/**
* 价格输入控制
* 小数点后两位
*
* @param editText
*/
fun
setPricePoint
(
editText
:
EditText
)
{
editText
.
addTextChangedListener
(
object
:
TextWatcher
{
override
fun
onTextChanged
(
s
:
CharSequence
,
start
:
Int
,
before
:
Int
,
count
:
Int
)
{
var
s
=
s
if
(
s
.
toString
().
contains
(
"."
))
{
if
(
s
.
length
-
1
-
s
.
toString
().
indexOf
(
"."
)
>
2
)
{
s
=
s
.
toString
().
subSequence
(
0
,
s
.
toString
().
indexOf
(
"."
)
+
3
)
editText
.
setText
(
s
)
editText
.
setSelection
(
editText
.
text
.
length
)
}
}
if
(
s
.
toString
().
trim
{
it
<=
' '
}.
substring
(
0
)
==
"."
)
{
s
=
"0$s"
editText
.
setText
(
s
)
editText
.
setSelection
(
2
)
}
if
(
s
.
toString
().
startsWith
(
"0"
)
&&
s
.
toString
().
trim
{
it
<=
' '
}.
length
>
1
)
{
if
(
s
.
toString
().
substring
(
1
,
2
)
!=
"."
)
{
editText
.
setText
(
s
.
subSequence
(
0
,
1
))
editText
.
setSelection
(
1
)
return
}
}
}
override
fun
beforeTextChanged
(
s
:
CharSequence
,
start
:
Int
,
count
:
Int
,
after
:
Int
)
{
}
override
fun
afterTextChanged
(
s
:
Editable
)
{}
})
}
/**
* 手机号码匹配 *
* rg\iuyt qwertyuio[po0`124`569hqw23
*
* @param mobiles
* @return
*/
fun
isMobile
(
mobiles
:
String
?):
Boolean
{
val
p
=
Pattern
.
compile
(
"^1[3,4,5,7,8]\\d{9}$"
)
val
m
=
p
.
matcher
(
mobiles
)
return
m
.
matches
()
}
/**
* 银行卡号匹配 *
* rg\iuyt qwertyuio[po0`124`569hqw23
*
* @param mobiles
* @return
*/
fun
isBankCard
(
mobiles
:
String
?):
Boolean
{
val
p
=
Pattern
.
compile
(
"^\\d{16}|\\d{17}|\\d{18}|\\d{19}$"
)
val
m
=
p
.
matcher
(
mobiles
)
return
m
.
matches
()
}
/**
* 验证邮箱地址是否正确
*
* @param email
* @return
*/
fun
isEmail
(
email
:
String
?):
Boolean
{
var
flag
=
false
flag
=
try
{
val
check
=
"^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$"
val
regex
=
Pattern
.
compile
(
check
)
val
matcher
=
regex
.
matcher
(
email
)
matcher
.
matches
()
}
catch
(
e
:
Exception
)
{
false
}
return
flag
}
fun
length
(
str
:
String
):
Int
{
var
str
=
str
str
=
str
.
replace
(
"[^\\x00-\\xff]"
.
toRegex
(),
"**"
)
return
str
.
length
}
fun
equlse
(
v
:
String
?,
v1
:
String
?):
Boolean
{
if
(
v
==
null
||
v1
==
null
)
{
return
false
}
return
v
==
v1
}
/**
* 只要有一个 引用相等 都返回True
*
* @param value
* @param v
* @return
* @Title: orEqulse
* @return: boolean
*/
fun
orEqulse
(
value
:
String
?,
vararg
v
:
String
?):
Boolean
{
if
(
value
==
null
)
{
return
false
}
if
(
v
.
size
>
0
)
{
for
(
i
in
v
)
{
if
(
equlse
(
value
,
i
))
{
return
true
}
}
}
return
false
}
/**
* 字符串函数 模仿数据库 REGIHT()
*
* @param value
* @param count
* @return
*/
fun
right
(
value
:
String
,
count
:
Int
):
String
{
return
value
.
substring
(
value
.
length
-
count
)
}
/**
* 字符串函数 模仿数据库 LEFT()
*
* @param value
* @param count
* @return
*/
fun
left
(
value
:
String
,
count
:
Int
):
String
{
return
if
(
value
.
length
>=
count
)
{
value
.
substring
(
0
,
count
)
+
"..."
}
else
{
value
}
}
/**
* 检查身份证号码
*/
fun
isIDCardNum
(
num
:
String
?):
Boolean
{
if
(
TextUtils
.
isEmpty
(
num
))
{
return
false
}
val
regex
=
"(\\d{14}[0-9a-zA-Z])|(\\d{17}[0-9a-zA-Z])"
val
pattern
=
Pattern
.
compile
(
regex
)
return
pattern
.
matcher
(
num
).
matches
()
}
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/adapter/ChooseStoreApter.kt
View file @
5fa0259e
...
...
@@ -19,18 +19,25 @@ class ChooseStoreApter : BaseQuickAdapter<GetShopListBean, BaseViewHolder>(R.lay
override
fun
convert
(
holder
:
BaseViewHolder
,
item
:
GetShopListBean
)
{
val
position
=
holder
.
layoutPosition
holder
.
getView
<
TextView
>(
R
.
id
.
tv_store_name
).
text
=
item
.
shop_name
holder
.
getView
<
TextView
>(
R
.
id
.
tv_store_address
).
text
=
item
.
address
val
tvStoreName
=
holder
.
getView
<
TextView
>(
R
.
id
.
tv_store_name
)
val
tvStoreAddress
=
holder
.
getView
<
TextView
>(
R
.
id
.
tv_store_address
)
tvStoreName
.
text
=
item
.
shop_name
tvStoreAddress
.
text
=
item
.
address
val
ivStoreSelect
=
holder
.
getView
<
ImageView
>(
R
.
id
.
iv_store_select
)
if
(
item
.
isSelected
)
{
ivStoreSelect
.
background
=
ContextCompat
.
getDrawable
(
context
,
R
.
drawable
.
icon_protocol_checked
)
}
else
{
ivStoreSelect
.
background
=
ContextCompat
.
getDrawable
(
context
,
R
.
drawable
.
icon_protocol_unchecked
)
}
// 选择门店
// 选择门店
(增大选择触控区域,故增加点击事件)
ivStoreSelect
.
clickAntiShake
{
item
.
isSelected
=
!
item
.
isSelected
notifyItemChanged
(
position
)
updateSelected
(
item
,
position
)
}
tvStoreName
.
clickAntiShake
{
updateSelected
(
item
,
position
)
}
tvStoreAddress
.
clickAntiShake
{
updateSelected
(
item
,
position
)
}
// 点击编辑
holder
.
getView
<
ImageView
>(
R
.
id
.
iv_store_edit
).
clickAntiShake
{
...
...
@@ -46,4 +53,12 @@ class ChooseStoreApter : BaseQuickAdapter<GetShopListBean, BaseViewHolder>(R.lay
context
.
startActivity
(
intent
)
}
}
/**
* 更新选中
*/
private
fun
updateSelected
(
item
:
GetShopListBean
,
position
:
Int
)
{
item
.
isSelected
=
!
item
.
isSelected
notifyItemChanged
(
position
)
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/store/EditStoreActivity.kt
View file @
5fa0259e
...
...
@@ -7,13 +7,14 @@ import android.widget.Toast
import
com.tbruyelle.rxpermissions3.Permission
import
com.tbruyelle.rxpermissions3.RxPermissions
import
com.yidian.common.base.BaseActivity
import
com.yidian.common.extensions.hideKeyBoard
import
com.yidian.common.utils.EditTextUtils
import
com.yidian.common.utils.ToastUtils
import
com.yidian.common.utils.ValidationUtils
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityStoreEditBinding
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.utils.StorageUtil
import
com.yidian.shenghuoquan.newscontent.widget.CommonTopBarView
import
io.reactivex.rxjava3.functions.Consumer
/**
* 新增/编辑门店
...
...
@@ -90,6 +91,7 @@ class EditStoreActivity : BaseActivity<ActivityStoreEditBinding>(), CommonTopBar
* 保存(新建和编辑)
*/
override
fun
onDoAction
()
{
hideKeyBoard
()
if
(
isAddStore
)
{
toAddStore
()
}
else
{
...
...
@@ -110,7 +112,7 @@ class EditStoreActivity : BaseActivity<ActivityStoreEditBinding>(), CommonTopBar
requestParams
[
"address"
]
=
store
.
title
ApiService
.
addStore
(
requestParams
)
{
if
(
it
)
{
Toast
.
makeText
(
this
@EditStoreActivity
,
"保存成功"
,
Toast
.
LENGTH_SHORT
).
show
(
)
Toast
Utils
.
showLongSafe
(
"保存成功,门店经纬度:${store.longitude}, ${store.latitude}"
)
finish
()
}
}
...
...
@@ -131,7 +133,7 @@ class EditStoreActivity : BaseActivity<ActivityStoreEditBinding>(), CommonTopBar
requestParams
[
"address"
]
=
store
.
title
ApiService
.
updateStore
(
requestParams
)
{
if
(
it
)
{
Toast
.
makeText
(
this
@EditStoreActivity
,
"保存成功"
,
Toast
.
LENGTH_SHORT
).
show
(
)
Toast
Utils
.
showLongSafe
(
"保存成功,门店经纬度:${store.longitude}, ${store.latitude}"
)
finish
()
}
}
...
...
@@ -152,10 +154,6 @@ class EditStoreActivity : BaseActivity<ActivityStoreEditBinding>(), CommonTopBar
ToastUtils
.
showShortSafe
(
"请输入联系电话"
)
return
false
}
if
(
storePhoneNum
.
length
!=
11
)
{
ToastUtils
.
showShortSafe
(
"请输入11位手机号"
)
return
false
}
return
true
}
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/store/SelectAddressActivity.kt
View file @
5fa0259e
...
...
@@ -50,7 +50,6 @@ class SelectAddressActivity : BaseActivity<ActivitySelectAddressBinding>(), OnMy
override
fun
init
(
savedInstanceState
:
Bundle
?)
{
super
.
init
(
savedInstanceState
)
initTitleBar
(
viewBind
.
include
.
toolbar
,
viewBind
.
include
.
tvTitle
,
"选择门店地址"
)
initAmap
(
savedInstanceState
)
initList
()
initClick
()
...
...
Components/newscontent/src/main/res/layout/activity_store_edit.xml
View file @
5fa0259e
...
...
@@ -24,8 +24,9 @@
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"
60dp
"
android:layout_height=
"
wrap_content
"
android:gravity=
"center_vertical"
android:minHeight=
"@dimen/dp60"
android:orientation=
"horizontal"
>
<TextView
...
...
@@ -38,8 +39,8 @@
<EditText
android:id=
"@+id/store_name"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_height=
"24dp"
android:background=
"@null"
android:hint=
"请输入店名"
android:maxLength=
"20"
...
...
@@ -122,13 +123,13 @@
<EditText
android:id=
"@+id/store_phone_num"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"24dp"
android:layout_gravity=
"center_vertical|start"
android:layout_weight=
"1"
android:background=
"@null"
android:digits=
"0123456789-"
android:hint=
"请输入联系电话"
android:inputType=
"number"
android:maxLength=
"11"
android:maxLength=
"12"
android:textColor=
"#333333"
android:textSize=
"16sp"
/>
...
...
Components/newscontent/src/main/res/layout/layout_choose_store_list_item.xml
View file @
5fa0259e
...
...
@@ -10,8 +10,8 @@
<ImageView
android:id=
"@+id/iv_store_select"
android:layout_width=
"@dimen/dp
2
4"
android:layout_height=
"@dimen/dp
2
4"
android:layout_width=
"@dimen/dp
3
4"
android:layout_height=
"@dimen/dp
3
4"
android:background=
"@drawable/icon_protocol_unchecked"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
@@ -50,8 +50,8 @@
<ImageView
android:id=
"@+id/iv_store_edit"
android:layout_width=
"@dimen/dp
24
"
android:layout_height=
"@dimen/dp
24
"
android:layout_width=
"@dimen/dp
30
"
android:layout_height=
"@dimen/dp
30
"
android:background=
"@drawable/icon_edit"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment