Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MiYaFastCashier
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangjiantao
MiYaFastCashier
Commits
0ac0f500
Commit
0ac0f500
authored
Mar 01, 2023
by
赵鹏翔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
退款界面数字键盘重写,并处理成kotlin
parent
13aef8bd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
159 additions
and
164 deletions
+159
-164
NumberManualDialog.kt
...om/fastcashier/lib_common/ui/dialog/NumberManualDialog.kt
+37
-35
NumKeyboard.java
...ava/com/fastcashier/lib_common/ui/widget/NumKeyboard.java
+0
-129
NumKeyboard.kt
.../java/com/fastcashier/lib_common/ui/widget/NumKeyboard.kt
+122
-0
No files found.
lib_common/src/main/java/com/fastcashier/lib_common/ui/dialog/NumberManualDialog.kt
View file @
0ac0f500
...
...
@@ -46,48 +46,50 @@ class NumberManualDialog(context: Context) : Dialog(context) {
numKeyboard
=
findViewById
(
R
.
id
.
numKeyboard
)
numInputFinish
=
numKeyboard
.
okButton
numKeyboard
.
setKeyboardClickListener
{
when
(
it
)
{
NumKeyboard
.
DELETE
->
{
if
(
TextUtils
.
isEmpty
(
etNumber
.
text
.
toString
()))
{
return
@setKeyboardClickListener
numKeyboard
.
setKeyNumKeyboardClickListener
(
object
:
NumKeyboard
.
KeyboardClickListener
{
override
fun
onNumClick
(
it
:
Int
)
{
when
(
it
)
{
NumKeyboard
.
DELETE
->
{
if
(
TextUtils
.
isEmpty
(
etNumber
.
text
.
toString
()))
{
return
}
var
currentCode
:
String
=
etNumber
.
text
.
toString
()
currentCode
=
if
(
currentCode
.
length
<=
1
)
{
""
}
else
{
currentCode
.
substring
(
0
,
currentCode
.
length
-
1
)
}
etNumber
.
setText
(
currentCode
)
numInputFinish
.
isEnabled
=
!
TextUtils
.
isEmpty
(
currentCode
)
}
var
currentCode
:
String
=
etNumber
.
text
.
toString
()
currentCode
=
if
(
currentCode
.
length
<=
1
)
{
""
}
else
{
currentCode
.
substring
(
0
,
currentCode
.
length
-
1
)
NumKeyboard
.
SURE
->
{
val
currentCode
:
String
=
etNumber
.
text
.
toString
()
if
(!
TextUtils
.
isEmpty
(
currentCode
))
{
dismiss
()
tvErrInfo
.
visibility
=
View
.
GONE
etNumber
.
setText
(
currentCode
)
numberInputListener
.
numberInput
(
currentCode
)
}
else
{
tvErrInfo
.
visibility
=
View
.
VISIBLE
tvErrInfo
.
text
=
"内容为空"
}
}
etNumber
.
setText
(
currentCode
)
numInputFinish
.
isEnabled
=
!
TextUtils
.
isEmpty
(
currentCode
)
}
NumKeyboard
.
SURE
->
{
val
currentCode
:
String
=
etNumber
.
text
.
toString
()
if
(!
TextUtils
.
isEmpty
(
currentCode
))
{
dismiss
()
else
->
{
tvErrInfo
.
visibility
=
View
.
GONE
etNumber
.
setText
(
currentCode
)
numberInputListener
.
numberInput
(
currentCode
)
}
else
{
tvErrInfo
.
visibility
=
View
.
VISIBLE
tvErrInfo
.
text
=
"内容为空"
var
currentCode
:
String
=
etNumber
.
text
.
toString
()
if
(
TextUtils
.
isEmpty
(
currentCode
))
{
etNumber
.
setText
(
it
.
toString
())
}
else
{
currentCode
+=
it
etNumber
.
setText
(
currentCode
)
}
numInputFinish
.
isEnabled
=
!
TextUtils
.
isEmpty
(
currentCode
)
}
}
else
->
{
tvErrInfo
.
visibility
=
View
.
GONE
var
currentCode
:
String
=
etNumber
.
text
.
toString
()
if
(
TextUtils
.
isEmpty
(
currentCode
))
{
etNumber
.
setText
(
it
.
toString
())
}
else
{
currentCode
+=
it
etNumber
.
setText
(
currentCode
)
}
numInputFinish
.
isEnabled
=
!
TextUtils
.
isEmpty
(
currentCode
)
}
}
}
}
})
}
fun
setNumberInputListener
(
numberInputListener
:
NumberInputListener
)
{
this
.
numberInputListener
=
numberInputListener
...
...
lib_common/src/main/java/com/fastcashier/lib_common/ui/widget/NumKeyboard.java
deleted
100644 → 0
View file @
13aef8bd
package
com
.
fastcashier
.
lib_common
.
ui
.
widget
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.LinearLayout
;
import
com.fastcashier.lib_common.R
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
NumKeyboard
extends
LinearLayout
{
public
static
final
int
DELETE
=
-
2
;
public
static
final
int
SURE
=
-
3
;
private
View
btn_7
,
btn_8
,
btn_9
,
btn_6
,
btn_5
,
btn_4
,
btn_3
,
btn_2
,
btn_1
,
btn_0
;
private
View
delete
;
private
Button
btn_sure
;
private
List
<
View
>
buttons
;
private
KeyboardClickListener
keyboardClickListener
;
public
NumKeyboard
(
Context
context
)
{
this
(
context
,
null
);
}
public
NumKeyboard
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
View
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
app_layout_keyboard_number
,
this
,
true
);
buttons
=
new
ArrayList
<>(
12
);
ClickListener
clickListener
=
new
ClickListener
();
btn_7
=
view
.
findViewById
(
R
.
id
.
btn_7
);
btn_8
=
view
.
findViewById
(
R
.
id
.
btn_8
);
btn_9
=
view
.
findViewById
(
R
.
id
.
btn_9
);
btn_6
=
view
.
findViewById
(
R
.
id
.
btn_6
);
btn_5
=
view
.
findViewById
(
R
.
id
.
btn_5
);
btn_4
=
view
.
findViewById
(
R
.
id
.
btn_4
);
btn_3
=
view
.
findViewById
(
R
.
id
.
btn_3
);
btn_2
=
view
.
findViewById
(
R
.
id
.
btn_2
);
btn_1
=
view
.
findViewById
(
R
.
id
.
btn_1
);
btn_0
=
view
.
findViewById
(
R
.
id
.
btn_0
);
delete
=
view
.
findViewById
(
R
.
id
.
btn_delete
);
btn_sure
=
view
.
findViewById
(
R
.
id
.
btn_sure
);
buttons
.
add
(
btn_7
);
buttons
.
add
(
btn_8
);
buttons
.
add
(
btn_9
);
buttons
.
add
(
btn_6
);
buttons
.
add
(
btn_5
);
buttons
.
add
(
btn_4
);
buttons
.
add
(
btn_3
);
buttons
.
add
(
btn_2
);
buttons
.
add
(
btn_1
);
buttons
.
add
(
btn_0
);
buttons
.
add
(
delete
);
buttons
.
add
(
btn_sure
);
for
(
View
btn
:
buttons
)
{
btn
.
setOnClickListener
(
clickListener
);
}
}
class
ClickListener
implements
OnClickListener
{
@Override
public
void
onClick
(
View
v
)
{
if
(
keyboardClickListener
==
null
)
{
return
;
}
int
i
=
v
.
getId
();
if
(
i
==
R
.
id
.
btn_7
)
{
keyboardClickListener
.
onNumClick
(
7
);
}
if
(
i
==
R
.
id
.
btn_8
)
{
keyboardClickListener
.
onNumClick
(
8
);
}
if
(
i
==
R
.
id
.
btn_9
)
{
keyboardClickListener
.
onNumClick
(
9
);
}
if
(
i
==
R
.
id
.
btn_6
)
{
keyboardClickListener
.
onNumClick
(
6
);
}
if
(
i
==
R
.
id
.
btn_5
)
{
keyboardClickListener
.
onNumClick
(
5
);
}
if
(
i
==
R
.
id
.
btn_4
)
{
keyboardClickListener
.
onNumClick
(
4
);
}
if
(
i
==
R
.
id
.
btn_3
)
{
keyboardClickListener
.
onNumClick
(
3
);
}
if
(
i
==
R
.
id
.
btn_2
)
{
keyboardClickListener
.
onNumClick
(
2
);
}
if
(
i
==
R
.
id
.
btn_1
)
{
keyboardClickListener
.
onNumClick
(
1
);
}
if
(
i
==
R
.
id
.
btn_0
)
{
keyboardClickListener
.
onNumClick
(
0
);
}
if
(
i
==
R
.
id
.
btn_delete
)
{
keyboardClickListener
.
onNumClick
(
DELETE
);
}
if
(
i
==
R
.
id
.
btn_sure
)
{
keyboardClickListener
.
onNumClick
(
SURE
);
}
}
}
public
Button
getOkButton
(){
return
btn_sure
;
}
public
KeyboardClickListener
getKeyboardClickListener
()
{
return
keyboardClickListener
;
}
public
void
setKeyboardClickListener
(
KeyboardClickListener
keyboardClickListener
)
{
this
.
keyboardClickListener
=
keyboardClickListener
;
}
public
interface
KeyboardClickListener
{
void
onNumClick
(
int
num
);
}
}
lib_common/src/main/java/com/fastcashier/lib_common/ui/widget/NumKeyboard.kt
0 → 100644
View file @
0ac0f500
package
com.fastcashier.lib_common.ui.widget
import
android.content.Context
import
android.util.AttributeSet
import
kotlin.jvm.JvmOverloads
import
android.widget.LinearLayout
import
com.fastcashier.lib_common.R
import
com.fastcashier.lib_common.ui.widget.NumKeyboard
import
android.view.LayoutInflater
import
android.view.View
import
android.widget.Button
import
java.util.ArrayList
class
NumKeyboard
@JvmOverloads
constructor
(
context
:
Context
?,
attrs
:
AttributeSet
?
=
null
)
:
LinearLayout
(
context
,
attrs
)
{
private
val
btn_7
:
View
private
val
btn_8
:
View
private
val
btn_9
:
View
private
val
btn_6
:
View
private
val
btn_5
:
View
private
val
btn_4
:
View
private
val
btn_3
:
View
private
val
btn_2
:
View
private
val
btn_1
:
View
private
val
btn_0
:
View
private
val
delete
:
View
val
okButton
:
Button
private
val
buttons
:
MutableList
<
View
>
var
keyboardClickListener
:
KeyboardClickListener
?
=
null
internal
inner
class
ClickListener
:
OnClickListener
{
override
fun
onClick
(
v
:
View
)
{
if
(
keyboardClickListener
==
null
)
{
return
}
val
i
=
v
.
id
if
(
i
==
R
.
id
.
btn_7
)
{
keyboardClickListener
!!
.
onNumClick
(
7
)
}
if
(
i
==
R
.
id
.
btn_8
)
{
keyboardClickListener
!!
.
onNumClick
(
8
)
}
if
(
i
==
R
.
id
.
btn_9
)
{
keyboardClickListener
!!
.
onNumClick
(
9
)
}
if
(
i
==
R
.
id
.
btn_6
)
{
keyboardClickListener
!!
.
onNumClick
(
6
)
}
if
(
i
==
R
.
id
.
btn_5
)
{
keyboardClickListener
!!
.
onNumClick
(
5
)
}
if
(
i
==
R
.
id
.
btn_4
)
{
keyboardClickListener
!!
.
onNumClick
(
4
)
}
if
(
i
==
R
.
id
.
btn_3
)
{
keyboardClickListener
!!
.
onNumClick
(
3
)
}
if
(
i
==
R
.
id
.
btn_2
)
{
keyboardClickListener
!!
.
onNumClick
(
2
)
}
if
(
i
==
R
.
id
.
btn_1
)
{
keyboardClickListener
!!
.
onNumClick
(
1
)
}
if
(
i
==
R
.
id
.
btn_0
)
{
keyboardClickListener
!!
.
onNumClick
(
0
)
}
if
(
i
==
R
.
id
.
btn_delete
)
{
keyboardClickListener
!!
.
onNumClick
(
DELETE
)
}
if
(
i
==
R
.
id
.
btn_sure
)
{
keyboardClickListener
!!
.
onNumClick
(
SURE
)
}
}
}
interface
KeyboardClickListener
{
fun
onNumClick
(
num
:
Int
)
}
companion
object
{
const
val
DELETE
=
-
2
const
val
SURE
=
-
3
}
init
{
val
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
app_layout_keyboard_number
,
this
,
true
)
buttons
=
ArrayList
(
12
)
val
clickListener
:
ClickListener
=
ClickListener
()
btn_7
=
view
.
findViewById
(
R
.
id
.
btn_7
)
btn_8
=
view
.
findViewById
(
R
.
id
.
btn_8
)
btn_9
=
view
.
findViewById
(
R
.
id
.
btn_9
)
btn_6
=
view
.
findViewById
(
R
.
id
.
btn_6
)
btn_5
=
view
.
findViewById
(
R
.
id
.
btn_5
)
btn_4
=
view
.
findViewById
(
R
.
id
.
btn_4
)
btn_3
=
view
.
findViewById
(
R
.
id
.
btn_3
)
btn_2
=
view
.
findViewById
(
R
.
id
.
btn_2
)
btn_1
=
view
.
findViewById
(
R
.
id
.
btn_1
)
btn_0
=
view
.
findViewById
(
R
.
id
.
btn_0
)
delete
=
view
.
findViewById
(
R
.
id
.
btn_delete
)
okButton
=
view
.
findViewById
(
R
.
id
.
btn_sure
)
buttons
.
add
(
btn_7
)
buttons
.
add
(
btn_8
)
buttons
.
add
(
btn_9
)
buttons
.
add
(
btn_6
)
buttons
.
add
(
btn_5
)
buttons
.
add
(
btn_4
)
buttons
.
add
(
btn_3
)
buttons
.
add
(
btn_2
)
buttons
.
add
(
btn_1
)
buttons
.
add
(
btn_0
)
buttons
.
add
(
delete
)
buttons
.
add
(
okButton
)
for
(
btn
in
buttons
)
{
btn
.
setOnClickListener
(
clickListener
)
}
}
fun
setKeyNumKeyboardClickListener
(
keyboardClickListener
:
KeyboardClickListener
){
this
.
keyboardClickListener
=
keyboardClickListener
}
}
\ No newline at end of file
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