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
497b78a2
Commit
497b78a2
authored
Mar 02, 2023
by
赵鹏翔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils covert
parent
0ac0f500
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
174 additions
and
184 deletions
+174
-184
MiyaApplication.kt
app/src/main/java/com/miya/fastcashier/MiyaApplication.kt
+9
-7
PayDatabase.kt
app/src/main/java/com/miya/fastcashier/dao/PayDatabase.kt
+1
-1
LoginActivity.kt
app/src/main/java/com/miya/fastcashier/ui/LoginActivity.kt
+0
-2
CenterToasty.java
...src/main/java/com/miya/fastcashier/util/CenterToasty.java
+0
-140
CenterToasty.kt
app/src/main/java/com/miya/fastcashier/util/CenterToasty.kt
+127
-0
ContextUtils.java
...src/main/java/com/miya/fastcashier/util/ContextUtils.java
+0
-34
ContextUtils.kt
app/src/main/java/com/miya/fastcashier/util/ContextUtils.kt
+37
-0
No files found.
app/src/main/java/com/miya/fastcashier/MiyaApplication.kt
View file @
497b78a2
...
...
@@ -98,7 +98,7 @@ class MiyaApplication : BaseApplication() {
loggingInterceptor
=
MiyaHttpLoggingInterceptor
{
message
->
if
(!
LogFileUtils
.
isProhibitWrite
)
{
LogFileUtils
.
writeLog
(
ContextUtils
.
getContext
(),
ContextUtils
.
getContext
()
!!
,
DateUtils
.
getDateStringByTimeStamp
(
System
.
currentTimeMillis
())
.
toString
()
+
" $message"
+
"\n"
)
...
...
@@ -112,7 +112,7 @@ class MiyaApplication : BaseApplication() {
ex
.
printStackTrace
()
if
(!
LogFileUtils
.
isProhibitWrite
)
{
LogFileUtils
.
writeLog
(
ContextUtils
.
getContext
(),
ContextUtils
.
getContext
()
!!
,
DateUtils
.
getDateStringByTimeStamp
(
System
.
currentTimeMillis
())
.
toString
()
+
"异常: ${ex.message}"
+
"\n"
)
...
...
@@ -151,7 +151,7 @@ class MiyaApplication : BaseApplication() {
Runtime
.
getRuntime
().
totalMemory
()
}
\
tfreeMemory
:
$
{
Runtime
.
getRuntime
().
freeMemory
()}
"
LogFileUtils
.
writeLog
(
ContextUtils
.
getContext
(),
ContextUtils
.
getContext
()
!!
,
"\n${DateUtils.format18(Date())}########onActivitySaveInstanceState() called with:"
+
" activity = [$activity]\nmemoryStatus: $memoryStatus"
)
...
...
@@ -167,12 +167,14 @@ class MiyaApplication : BaseApplication() {
private
fun
activityLifeCycleLog
(
activity
:
Activity
,
lifeName
:
String
)
{
XLog
.
d
(
DateUtils
.
format18
(
Date
())
+
" $lifeName"
)
if
(!
LogFileUtils
.
isProhibitWrite
)
{
ContextUtils
.
getContext
()
?.
let
{
LogFileUtils
.
writeLog
(
ContextUtils
.
getContext
()
,
it
,
"\n${DateUtils.format18(Date())}########$lifeName called with: activity = [$activity]\n"
)
}
}
}
fun
resetConfig
()
{
LocalKeyDataMKManageKit
.
clearCommonData
()
...
...
app/src/main/java/com/miya/fastcashier/dao/PayDatabase.kt
View file @
497b78a2
...
...
@@ -19,7 +19,7 @@ class DatabaseKeeper {
private
val
DATABASE_NAME
=
"pay_data"
val
payDatabase
:
PayDatabase
by
lazy
(
mode
=
LazyThreadSafetyMode
.
SYNCHRONIZED
)
{
Room
.
databaseBuilder
(
ContextUtils
.
getContext
(),
PayDatabase
::
class
.
java
,
DATABASE_NAME
)
Room
.
databaseBuilder
(
ContextUtils
.
getContext
()
!!
,
PayDatabase
::
class
.
java
,
DATABASE_NAME
)
.
addMigrations
(
MIGRATION_1_2
)
.
build
()
}
...
...
app/src/main/java/com/miya/fastcashier/ui/LoginActivity.kt
View file @
497b78a2
...
...
@@ -17,8 +17,6 @@ import com.blankj.utilcode.util.ToastUtils
import
com.fastcashier.lib_common.function.account.AccountService
import
com.fastcashier.lib_common.util.clickWithTrigger
import
com.miya.fastcashier.databinding.ActivityLoginBinding
import
com.miya.fastcashier.util.CenterToasty
import
com.miya.fastcashier.util.manage.ChannelManageKit
import
com.miya.fastcashier.util.manage.LocalKeyDataMKManageKit
import
com.miya.fastcashier.viewmodel.LoginViewModel
import
com.permissionx.guolindev.PermissionX
...
...
app/src/main/java/com/miya/fastcashier/util/CenterToasty.java
deleted
100644 → 0
View file @
0ac0f500
package
com
.
miya
.
fastcashier
.
util
;
import
android.content.Context
;
import
android.view.Gravity
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.CheckResult
;
import
androidx.annotation.NonNull
;
import
es.dmoral.toasty.Toasty
;
/**
* 居中的Toasty弹窗 将图片和文字的左右排布,改为了 上下排布
* Created by fengyu on 2018/10/8.
*/
public
class
CenterToasty
{
@CheckResult
public
static
Toast
info
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
,
int
duration
,
boolean
withIcon
)
{
Toast
toast
=
Toasty
.
info
(
context
,
message
,
duration
,
withIcon
);
transformToast
(
toast
);
return
toast
;
}
@CheckResult
public
static
Toast
info
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
,
int
duration
)
{
Toast
toast
=
Toasty
.
info
(
context
,
message
,
duration
);
transformToast
(
toast
);
return
toast
;
}
@CheckResult
public
static
Toast
info
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
)
{
Toast
toast
=
Toasty
.
info
(
context
,
message
);
transformToast
(
toast
);
return
toast
;
}
@CheckResult
public
static
Toast
infox
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
,
@NonNull
int
xOffset
)
{
Toast
toast
=
Toasty
.
info
(
context
,
message
);
transformToast
(
toast
,
xOffset
,
0
);
return
toast
;
}
@CheckResult
public
static
Toast
normal
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
,
int
duration
)
{
Toast
toast
=
Toasty
.
normal
(
context
,
message
,
duration
);
transformToast
(
toast
);
return
toast
;
}
@CheckResult
public
static
Toast
warning
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
,
int
duration
)
{
Toast
toast
=
Toasty
.
warning
(
context
,
message
,
duration
);
transformToast
(
toast
);
return
toast
;
}
@CheckResult
public
static
Toast
warning
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
,
int
duration
,
boolean
withIcon
)
{
Toast
toast
=
Toasty
.
warning
(
context
,
message
,
duration
,
withIcon
);
transformToast
(
toast
);
return
toast
;
}
@CheckResult
public
static
Toast
success
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
,
int
duration
,
boolean
withIcon
)
{
Toast
toast
=
Toasty
.
success
(
context
,
message
,
duration
,
withIcon
);
transformToast
(
toast
);
return
toast
;
}
@CheckResult
public
static
Toast
success
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
,
int
duration
)
{
Toast
toast
=
Toasty
.
success
(
context
,
message
,
duration
);
transformToast
(
toast
);
return
toast
;
}
@CheckResult
public
static
Toast
error
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
,
int
duration
,
boolean
withIcon
)
{
Toast
toast
=
Toasty
.
error
(
context
,
message
,
duration
,
withIcon
);
transformToast
(
toast
);
return
toast
;
}
@CheckResult
public
static
Toast
error
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
)
{
Toast
toast
=
Toasty
.
error
(
context
,
message
);
transformToast
(
toast
);
return
toast
;
}
@CheckResult
public
static
Toast
error
(
@NonNull
Context
context
,
@NonNull
CharSequence
message
,
int
duration
)
{
Toast
toast
=
Toasty
.
error
(
context
,
message
,
duration
);
transformToast
(
toast
);
return
toast
;
}
private
static
void
transformToast
(
Toast
toast
)
{
LinearLayout
linearLayout
=
(
LinearLayout
)
toast
.
getView
();
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
linearLayout
.
setPadding
(
20
,
20
,
20
,
20
);
ImageView
icon
=
(
ImageView
)
linearLayout
.
getChildAt
(
0
);
icon
.
setLayoutParams
(
new
LinearLayout
.
LayoutParams
(
50
,
50
));
TextView
messageTextView
=
(
TextView
)
linearLayout
.
getChildAt
(
1
);
messageTextView
.
setTextSize
(
28
);
messageTextView
.
setPadding
(
0
,
30
,
0
,
30
);
messageTextView
.
setGravity
(
Gravity
.
CENTER
);
toast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
}
private
static
void
transformToast
(
Toast
toast
,
int
xOffset
,
int
yOffset
)
{
LinearLayout
linearLayout
=
(
LinearLayout
)
toast
.
getView
();
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
linearLayout
.
setPadding
(
20
,
20
,
20
,
20
);
ImageView
icon
=
(
ImageView
)
linearLayout
.
getChildAt
(
0
);
icon
.
setLayoutParams
(
new
LinearLayout
.
LayoutParams
(
50
,
50
));
TextView
messageTextView
=
(
TextView
)
linearLayout
.
getChildAt
(
1
);
messageTextView
.
setTextSize
(
28
);
messageTextView
.
setPadding
(
0
,
30
,
0
,
30
);
messageTextView
.
setGravity
(
Gravity
.
CENTER
);
toast
.
setGravity
(
Gravity
.
CENTER
,
xOffset
,
yOffset
);
}
}
app/src/main/java/com/miya/fastcashier/util/CenterToasty.kt
0 → 100644
View file @
497b78a2
package
com.miya.fastcashier.util
import
android.content.Context
import
android.widget.Toast
import
es.dmoral.toasty.Toasty
import
com.miya.fastcashier.util.CenterToasty
import
android.widget.LinearLayout
import
android.widget.TextView
import
android.view.Gravity
import
android.widget.ImageView
import
androidx.annotation.CheckResult
/**
* 居中的Toasty弹窗 将图片和文字的左右排布,改为了 上下排布
* Created by fengyu on 2018/10/8.
*/
object
CenterToasty
{
@CheckResult
fun
info
(
context
:
Context
,
message
:
CharSequence
,
duration
:
Int
,
withIcon
:
Boolean
):
Toast
{
val
toast
=
Toasty
.
info
(
context
,
message
,
duration
,
withIcon
)
transformToast
(
toast
)
return
toast
}
@CheckResult
fun
info
(
context
:
Context
,
message
:
CharSequence
,
duration
:
Int
):
Toast
{
val
toast
=
Toasty
.
info
(
context
,
message
,
duration
)
transformToast
(
toast
)
return
toast
}
@CheckResult
fun
info
(
context
:
Context
,
message
:
CharSequence
):
Toast
{
val
toast
=
Toasty
.
info
(
context
,
message
)
transformToast
(
toast
)
return
toast
}
@CheckResult
fun
infox
(
context
:
Context
,
message
:
CharSequence
,
xOffset
:
Int
):
Toast
{
val
toast
=
Toasty
.
info
(
context
,
message
)
transformToast
(
toast
,
xOffset
,
0
)
return
toast
}
@CheckResult
fun
normal
(
context
:
Context
,
message
:
CharSequence
,
duration
:
Int
):
Toast
{
val
toast
=
Toasty
.
normal
(
context
,
message
,
duration
)
transformToast
(
toast
)
return
toast
}
@CheckResult
fun
warning
(
context
:
Context
,
message
:
CharSequence
,
duration
:
Int
):
Toast
{
val
toast
=
Toasty
.
warning
(
context
,
message
,
duration
)
transformToast
(
toast
)
return
toast
}
@CheckResult
fun
warning
(
context
:
Context
,
message
:
CharSequence
,
duration
:
Int
,
withIcon
:
Boolean
):
Toast
{
val
toast
=
Toasty
.
warning
(
context
,
message
,
duration
,
withIcon
)
transformToast
(
toast
)
return
toast
}
@CheckResult
fun
success
(
context
:
Context
,
message
:
CharSequence
,
duration
:
Int
,
withIcon
:
Boolean
):
Toast
{
val
toast
=
Toasty
.
success
(
context
,
message
,
duration
,
withIcon
)
transformToast
(
toast
)
return
toast
}
@CheckResult
fun
success
(
context
:
Context
,
message
:
CharSequence
,
duration
:
Int
):
Toast
{
val
toast
=
Toasty
.
success
(
context
,
message
,
duration
)
transformToast
(
toast
)
return
toast
}
@CheckResult
fun
error
(
context
:
Context
,
message
:
CharSequence
,
duration
:
Int
,
withIcon
:
Boolean
):
Toast
{
val
toast
=
Toasty
.
error
(
context
,
message
,
duration
,
withIcon
)
transformToast
(
toast
)
return
toast
}
@CheckResult
fun
error
(
context
:
Context
,
message
:
CharSequence
):
Toast
{
val
toast
=
Toasty
.
error
(
context
,
message
)
transformToast
(
toast
)
return
toast
}
@CheckResult
fun
error
(
context
:
Context
,
message
:
CharSequence
,
duration
:
Int
):
Toast
{
val
toast
=
Toasty
.
error
(
context
,
message
,
duration
)
transformToast
(
toast
)
return
toast
}
private
fun
transformToast
(
toast
:
Toast
)
{
val
linearLayout
=
toast
.
view
as
LinearLayout
?
linearLayout
!!
.
orientation
=
LinearLayout
.
VERTICAL
linearLayout
.
setPadding
(
20
,
20
,
20
,
20
)
val
icon
=
linearLayout
.
getChildAt
(
0
)
as
ImageView
icon
.
layoutParams
=
LinearLayout
.
LayoutParams
(
50
,
50
)
val
messageTextView
=
linearLayout
.
getChildAt
(
1
)
as
TextView
messageTextView
.
textSize
=
28f
messageTextView
.
setPadding
(
0
,
30
,
0
,
30
)
messageTextView
.
gravity
=
Gravity
.
CENTER
toast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
)
}
private
fun
transformToast
(
toast
:
Toast
,
xOffset
:
Int
,
yOffset
:
Int
)
{
val
linearLayout
=
toast
.
view
as
LinearLayout
?
linearLayout
!!
.
orientation
=
LinearLayout
.
VERTICAL
linearLayout
.
setPadding
(
20
,
20
,
20
,
20
)
val
icon
=
linearLayout
.
getChildAt
(
0
)
as
ImageView
icon
.
layoutParams
=
LinearLayout
.
LayoutParams
(
50
,
50
)
val
messageTextView
=
linearLayout
.
getChildAt
(
1
)
as
TextView
messageTextView
.
textSize
=
28f
messageTextView
.
setPadding
(
0
,
30
,
0
,
30
)
messageTextView
.
gravity
=
Gravity
.
CENTER
toast
.
setGravity
(
Gravity
.
CENTER
,
xOffset
,
yOffset
)
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/util/ContextUtils.java
deleted
100644 → 0
View file @
0ac0f500
package
com
.
miya
.
fastcashier
.
util
;
import
android.content.Context
;
/**
* 描述: 上下文相关工具类
*/
public
class
ContextUtils
{
private
static
Context
context
;
private
ContextUtils
()
{
throw
new
UnsupportedOperationException
(
"u can't instantiate me..."
);
}
/**
* 初始化工具类
*
* @param context 上下文
*/
public
static
void
init
(
Context
context
)
{
ContextUtils
.
context
=
context
.
getApplicationContext
();
}
/**
* 获取ApplicationContext
*
* @return ApplicationContext
*/
public
static
Context
getContext
()
{
if
(
context
!=
null
)
return
context
;
throw
new
NullPointerException
(
"u should init first"
);
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/util/ContextUtils.kt
0 → 100644
View file @
497b78a2
package
com.miya.fastcashier.util
import
android.content.Context
import
java.lang.NullPointerException
import
java.lang.UnsupportedOperationException
/**
* 描述: 上下文相关工具类
*/
class
ContextUtils
private
constructor
()
{
companion
object
{
private
var
context
:
Context
?
=
null
/**
* 初始化工具类
*
* @param context 上下文
*/
fun
init
(
context
:
Context
)
{
Companion
.
context
=
context
.
applicationContext
}
/**
* 获取ApplicationContext
*
* @return ApplicationContext
*/
fun
getContext
():
Context
?
{
if
(
context
!=
null
)
return
context
throw
NullPointerException
(
"u should init first"
)
}
}
init
{
throw
UnsupportedOperationException
(
"u can't instantiate me..."
)
}
}
\ 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