Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StatInfo
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
chenyuling
StatInfo
Commits
211ebcd5
Commit
211ebcd5
authored
Aug 04, 2023
by
chenyuling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
密码不可见,默认账号admin
parent
42be5cff
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
141 additions
and
11 deletions
+141
-11
MainActivity.java
...rc/main/java/com/srthinker/statinfo/uis/MainActivity.java
+31
-10
ConfigDlgFragment.java
...om/srthinker/statinfo/uis/fragment/ConfigDlgFragment.java
+11
-0
Utils.java
...c/main/java/com/srthinker/statinfo/util/common/Utils.java
+65
-1
EditView.java
...src/main/java/com/srthinker/statinfo/wedget/EditView.java
+1
-0
UtilTest.java
app/src/test/java/com/srthinker/statinfo/UtilTest.java
+33
-0
No files found.
app/src/main/java/com/srthinker/statinfo/uis/MainActivity.java
View file @
211ebcd5
...
@@ -98,6 +98,7 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -98,6 +98,7 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
private
HashMap
<
Integer
,
Integer
>
groupLeaveHashMap
=
null
;
private
HashMap
<
Integer
,
Integer
>
groupLeaveHashMap
=
null
;
private
HashMap
<
Integer
,
Integer
>
groupPresentHashMap
=
null
;
private
HashMap
<
Integer
,
Integer
>
groupPresentHashMap
=
null
;
private
boolean
isPermission
;
private
boolean
isPermission
;
public
static
boolean
NEED_NO_REPET
=
true
;
//是否需要去重,false:不需要,true:需要
@Override
@Override
...
@@ -159,6 +160,7 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -159,6 +160,7 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
private
void
showConfigDialog
(
int
type
)
{
private
void
showConfigDialog
(
int
type
)
{
ConfigDlgFragment
configDlgFragment
=
ConfigDlgFragment
.
getInstance
(
type
);
ConfigDlgFragment
configDlgFragment
=
ConfigDlgFragment
.
getInstance
(
type
);
configDlgFragment
.
setUsername
(
"admin"
);
configDlgFragment
.
setConfigCallback
(
this
);
configDlgFragment
.
setConfigCallback
(
this
);
if
(
configDlgFragment
.
isResumed
()){
if
(
configDlgFragment
.
isResumed
()){
return
;
return
;
...
@@ -364,13 +366,18 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -364,13 +366,18 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
if
(
size
!=
lastEnterSize
){
if
(
size
!=
lastEnterSize
){
//更新进出情况
//更新进出情况
enterAdapter
.
setDateList
(
enterBeans
);
enterAdapter
.
setDateList
(
enterBeans
);
//更新人员情况
//更新人员情况(是否要根据id去重)
lastEnterSize
=
size
;
if
(
NEED_NO_REPET
)
{
List
<
PersonEntity
>
enterListNo
=
Utils
.
removeDuplicates
(
enterBeans
,
"id"
);
lastEnterSize
=
enterListNo
.
size
();
}
else
{
lastEnterSize
=
size
;
}
lastPresentSize
=
lastEnterSize
-
lastLeaveSize
;
lastPresentSize
=
lastEnterSize
-
lastLeaveSize
;
mBinding
.
nvEnter
.
setNumber
(
lastEnterSize
);
mBinding
.
nvEnter
.
setNumber
(
lastEnterSize
);
mBinding
.
nvLeave
.
setNumber
(
lastLeaveSize
);
mBinding
.
nvLeave
.
setNumber
(
lastLeaveSize
);
mBinding
.
nvPresent
.
setNumber
(
lastPresentSize
);
mBinding
.
nvPresent
.
setNumber
(
lastPresentSize
);
//更新分组情况
//更新分组情况
(是否要根据id去重)
groupEnterHashMap
=
getGroupSizeHashMap
(
enterBeans
);
groupEnterHashMap
=
getGroupSizeHashMap
(
enterBeans
);
updatePresentSize
(
groupEnterHashMap
,
groupLeaveHashMap
);
updatePresentSize
(
groupEnterHashMap
,
groupLeaveHashMap
);
}
}
...
@@ -386,13 +393,18 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -386,13 +393,18 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
if
(
size
!=
lastLeaveSize
){
if
(
size
!=
lastLeaveSize
){
//更新进出情况
//更新进出情况
leaveAdapter
.
setDateList
(
leaveBeans
);
leaveAdapter
.
setDateList
(
leaveBeans
);
//更新人员情况
//更新人员情况(是否要根据id去重)
lastLeaveSize
=
size
;
if
(
NEED_NO_REPET
)
{
List
<
PersonEntity
>
leaveListNo
=
Utils
.
removeDuplicates
(
leaveBeans
,
"id"
);
lastLeaveSize
=
leaveListNo
.
size
();
}
else
{
lastLeaveSize
=
size
;
}
lastPresentSize
=
lastEnterSize
-
lastLeaveSize
;
lastPresentSize
=
lastEnterSize
-
lastLeaveSize
;
mBinding
.
nvEnter
.
setNumber
(
lastEnterSize
);
mBinding
.
nvEnter
.
setNumber
(
lastEnterSize
);
mBinding
.
nvLeave
.
setNumber
(
lastLeaveSize
);
mBinding
.
nvLeave
.
setNumber
(
lastLeaveSize
);
mBinding
.
nvPresent
.
setNumber
(
lastPresentSize
);
mBinding
.
nvPresent
.
setNumber
(
lastPresentSize
);
//更新分组情况
//更新分组情况
(是否要根据id去重)
groupLeaveHashMap
=
getGroupSizeHashMap
(
leaveBeans
);
groupLeaveHashMap
=
getGroupSizeHashMap
(
leaveBeans
);
updatePresentSize
(
groupEnterHashMap
,
groupLeaveHashMap
);
updatePresentSize
(
groupEnterHashMap
,
groupLeaveHashMap
);
}
}
...
@@ -405,9 +417,13 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -405,9 +417,13 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
}
}
@NonNull
@NonNull
private
HashMap
<
Integer
,
Integer
>
getGroupSizeHashMap
(
List
<
PersonEntity
>
personEntityList
)
{
private
HashMap
<
Integer
,
Integer
>
getGroupSizeHashMap
(
List
<
PersonEntity
>
personEntityList
)
{
HashMap
<
Integer
,
Integer
>
groupSizeHashMap
=
new
HashMap
<>();
HashMap
<
Integer
,
Integer
>
groupSizeHashMap
=
new
HashMap
<>();
if
(
NEED_NO_REPET
)
{
personEntityList
=
Utils
.
removeDuplicates
(
personEntityList
,
"id"
);
}
if
(
mQueryPersonList
!=
null
)
{
if
(
mQueryPersonList
!=
null
)
{
for
(
PersonEntity
entity
:
mQueryPersonList
)
{
for
(
PersonEntity
entity
:
mQueryPersonList
)
{
int
group
=
entity
.
getGroup
();
int
group
=
entity
.
getGroup
();
...
@@ -455,7 +471,11 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -455,7 +471,11 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
groupPresentHashMap
.
put
(
group
,
groupPresentHashMap
.
get
(
group
)-
leaveSize
);
groupPresentHashMap
.
put
(
group
,
groupPresentHashMap
.
get
(
group
)-
leaveSize
);
}
}
}
}
//如果只有一个人,从一个组换到另一个组,之前的数据没有清空,需要先进行清空,置空为0
SharedUtil
.
getInstance
(
this
).
writeShared
(
WATERPROOF
,
0
);
SharedUtil
.
getInstance
(
this
).
writeShared
(
OUTRIGGER
,
0
);
SharedUtil
.
getInstance
(
this
).
writeShared
(
BUILD
,
0
);
SharedUtil
.
getInstance
(
this
).
writeShared
(
SUPERVISOR
,
0
);
for
(
Map
.
Entry
<
Integer
,
Integer
>
presentEntry
:
groupPresentHashMap
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
Integer
>
presentEntry
:
groupPresentHashMap
.
entrySet
())
{
int
group
=
presentEntry
.
getKey
();
int
group
=
presentEntry
.
getKey
();
int
presentSize
=
presentEntry
.
getValue
();
int
presentSize
=
presentEntry
.
getValue
();
...
@@ -519,12 +539,13 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -519,12 +539,13 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
}*/
}*/
Log
.
i
(
TAG
,
"getTotalPerson: 已获取总数:personEntities.size="
+
personEntities
.
size
());
Log
.
i
(
TAG
,
"getTotalPerson: 已获取总数:personEntities.size="
+
personEntities
.
size
());
PersonMgr
.
getInstance
().
updatePersonThread
(
personEntities
,
()
->
{
PersonMgr
.
getInstance
().
updatePersonThread
(
personEntities
,
()
->
{
runOnUiThread
(()->{
ClickUtil
.
enableClick
(
mBinding
.
btnGroupDetail
);
});
Intent
intent
=
new
Intent
(
MainActivity
.
this
,
GroupActivity
.
class
);
Intent
intent
=
new
Intent
(
MainActivity
.
this
,
GroupActivity
.
class
);
startActivity
(
intent
);
startActivity
(
intent
);
});
});
runOnUiThread
(()->{
ClickUtil
.
enableClick
(
mBinding
.
btnGroupDetail
);
});
}
}
...
...
app/src/main/java/com/srthinker/statinfo/uis/fragment/ConfigDlgFragment.java
View file @
211ebcd5
...
@@ -7,6 +7,7 @@ import android.content.Context;
...
@@ -7,6 +7,7 @@ import android.content.Context;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.graphics.drawable.ColorDrawable
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.text.InputType
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.view.Gravity
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
...
@@ -34,6 +35,7 @@ public class ConfigDlgFragment extends DialogFragment {
...
@@ -34,6 +35,7 @@ public class ConfigDlgFragment extends DialogFragment {
private
String
mLastAccount
;
private
String
mLastAccount
;
private
String
mLastPassword
;
private
String
mLastPassword
;
private
String
mLastServerIp
;
private
String
mLastServerIp
;
private
String
username
;
public
static
ConfigDlgFragment
getInstance
(
int
type
){
public
static
ConfigDlgFragment
getInstance
(
int
type
){
ConfigDlgFragment
configDlgFragment
=
new
ConfigDlgFragment
();
ConfigDlgFragment
configDlgFragment
=
new
ConfigDlgFragment
();
...
@@ -59,6 +61,7 @@ public class ConfigDlgFragment extends DialogFragment {
...
@@ -59,6 +61,7 @@ public class ConfigDlgFragment extends DialogFragment {
mBinding
.
evAccount
.
initItem
(
"设备账号:"
,
"输入设备账号"
);
mBinding
.
evAccount
.
initItem
(
"设备账号:"
,
"输入设备账号"
);
mBinding
.
evPassword
.
initItem
(
"设备密码:"
,
"输入设备密码"
);
mBinding
.
evPassword
.
initItem
(
"设备密码:"
,
"输入设备密码"
);
mBinding
.
evServerip
.
initItem
(
"设备IP:"
,
"输入设备IP"
);
mBinding
.
evServerip
.
initItem
(
"设备IP:"
,
"输入设备IP"
);
mBinding
.
evPassword
.
setInputType
(
InputType
.
TYPE_CLASS_TEXT
|
InputType
.
TYPE_TEXT_VARIATION_PASSWORD
);
if
(
type
==
ENTER_TYPE
){
if
(
type
==
ENTER_TYPE
){
mBinding
.
tvTitle
.
setText
(
"进去设备的配置信息"
);
mBinding
.
tvTitle
.
setText
(
"进去设备的配置信息"
);
}
else
if
(
type
==
LEAVE_TYPE
){
}
else
if
(
type
==
LEAVE_TYPE
){
...
@@ -66,6 +69,10 @@ public class ConfigDlgFragment extends DialogFragment {
...
@@ -66,6 +69,10 @@ public class ConfigDlgFragment extends DialogFragment {
}
}
if
(!
TextUtils
.
isEmpty
(
mLastAccount
)){
if
(!
TextUtils
.
isEmpty
(
mLastAccount
)){
mBinding
.
evAccount
.
setContent
(
mLastAccount
);
mBinding
.
evAccount
.
setContent
(
mLastAccount
);
}
else
{
if
(!
TextUtils
.
isEmpty
(
username
)){
mBinding
.
evAccount
.
setContent
(
username
);
}
}
}
if
(!
TextUtils
.
isEmpty
(
mLastPassword
)){
if
(!
TextUtils
.
isEmpty
(
mLastPassword
)){
mBinding
.
evPassword
.
setContent
(
mLastPassword
);
mBinding
.
evPassword
.
setContent
(
mLastPassword
);
...
@@ -116,6 +123,10 @@ public class ConfigDlgFragment extends DialogFragment {
...
@@ -116,6 +123,10 @@ public class ConfigDlgFragment extends DialogFragment {
}
}
}
}
public
void
setUsername
(
String
username
){
this
.
username
=
username
;
}
@Override
@Override
public
void
onResume
()
{
public
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
...
...
app/src/main/java/com/srthinker/statinfo/util/common/Utils.java
View file @
211ebcd5
...
@@ -9,9 +9,11 @@ import android.content.res.Configuration;
...
@@ -9,9 +9,11 @@ import android.content.res.Configuration;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Build
;
import
android.provider.Settings
;
import
android.provider.Settings
;
import
android.text.InputType
;
import
android.util.DisplayMetrics
;
import
android.util.DisplayMetrics
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
import
android.widget.EditText
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
androidx.core.content.FileProvider
;
import
androidx.core.content.FileProvider
;
...
@@ -21,11 +23,17 @@ import java.io.DataOutputStream;
...
@@ -21,11 +23,17 @@ import java.io.DataOutputStream;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.lang.reflect.Field
;
import
java.net.MalformedURLException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
me.jessyan.autosize.AutoSizeConfig
;
import
me.jessyan.autosize.AutoSizeConfig
;
import
me.jessyan.autosize.onAdaptListener
;
import
me.jessyan.autosize.onAdaptListener
;
...
@@ -203,7 +211,6 @@ public class Utils {
...
@@ -203,7 +211,6 @@ public class Utils {
}
}
//获取自己应用内部的版本名
//获取自己应用内部的版本名
public
static
String
getVersionName
(
Context
context
)
{
public
static
String
getVersionName
(
Context
context
)
{
PackageManager
manager
=
context
.
getPackageManager
();
PackageManager
manager
=
context
.
getPackageManager
();
String
name
=
null
;
String
name
=
null
;
...
@@ -222,6 +229,17 @@ public class Utils {
...
@@ -222,6 +229,17 @@ public class Utils {
return
Integer
.
parseInt
(
replace
);
return
Integer
.
parseInt
(
replace
);
}
}
/*控制输入内容的可见*/
public
static
void
setEditTextVisible
(
EditText
editText
)
{
editText
.
setInputType
(
InputType
.
TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
);
}
/*控制输入内容的不可见*/
public
static
void
setEditTextInvisible
(
EditText
editText
)
{
editText
.
setInputType
(
InputType
.
TYPE_CLASS_TEXT
|
InputType
.
TYPE_TEXT_VARIATION_PASSWORD
);
}
/** 判断字符串中是否包含数字 **/
/** 判断字符串中是否包含数字 **/
public
static
boolean
isContainsNum
(
String
input
)
{
public
static
boolean
isContainsNum
(
String
input
)
{
int
len
=
input
.
length
();
int
len
=
input
.
length
();
...
@@ -233,6 +251,52 @@ public class Utils {
...
@@ -233,6 +251,52 @@ public class Utils {
return
false
;
return
false
;
}
}
/**
* 通过对象的某个字段判断,如果有item的该字段重复则去重
* @param originalList 对象的列表
* @param fieldName 对象的某个字段
* @param <T> 某对象
* @return
*/
public
static
<
T
>
List
<
T
>
removeDuplicates
(
List
<
T
>
originalList
,
String
fieldName
)
{
Set
<
Object
>
set
=
new
LinkedHashSet
<>();
List
<
T
>
distinctList
=
new
ArrayList
<>();
for
(
T
item
:
originalList
)
{
Object
fieldValue
=
getFieldValue
(
item
,
fieldName
);
if
(!
set
.
contains
(
fieldValue
))
{
set
.
add
(
fieldValue
);
distinctList
.
add
(
item
);
}
}
return
distinctList
;
}
private
static
Object
getFieldValue
(
Object
obj
,
String
fieldName
)
{
try
{
Field
field
=
obj
.
getClass
().
getDeclaredField
(
fieldName
);
//允许访问私有字段
field
.
setAccessible
(
true
);
return
field
.
get
(
obj
);
}
catch
(
NoSuchFieldException
|
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 将某个List列表倒序排序
* @param originalList
* @param <T>
* @return
*/
public
static
<
T
>
List
<
T
>
reverseList
(
List
<
T
>
originalList
)
{
List
<
T
>
reversedList
=
new
ArrayList
<>(
originalList
);
Collections
.
reverse
(
reversedList
);
return
reversedList
;
}
//返回true表示用限制使用
//返回true表示用限制使用
public
static
boolean
isRootPermissionRestricted
()
{
public
static
boolean
isRootPermissionRestricted
()
{
...
...
app/src/main/java/com/srthinker/statinfo/wedget/EditView.java
View file @
211ebcd5
...
@@ -58,4 +58,5 @@ public class EditView extends LinearLayout {
...
@@ -58,4 +58,5 @@ public class EditView extends LinearLayout {
public
void
setInputType
(
int
type
){
public
void
setInputType
(
int
type
){
mBinding
.
etContent
.
setInputType
(
type
);
mBinding
.
etContent
.
setInputType
(
type
);
}
}
}
}
app/src/test/java/com/srthinker/statinfo/UtilTest.java
0 → 100644
View file @
211ebcd5
package
com
.
srthinker
.
statinfo
;
import
com.srthinker.statinfo.database.entity.PersonEntity
;
import
com.srthinker.statinfo.util.common.Utils
;
import
org.junit.Test
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
UtilTest
{
@Test
public
void
noRepet
(){
List
<
PersonEntity
>
personEntities
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
PersonEntity
person
=
new
PersonEntity
();
person
.
setId
(
"1"
);
person
.
setPerson_name
(
"王大崔"
);
person
.
setTimestamp
(
"11:0"
+
i
);
personEntities
.
add
(
person
);
}
for
(
PersonEntity
personEntity
:
personEntities
)
{
System
.
out
.
println
(
"去重前:id="
+
personEntity
.
getId
()+
" name="
+
personEntity
.
getPerson_name
()+
" time="
+
personEntity
.
getTimestamp
());
}
List
<
PersonEntity
>
personEntities2
=
Utils
.
reverseList
(
personEntities
);
List
<
PersonEntity
>
personEntities1
=
Utils
.
removeDuplicates
(
personEntities2
,
"id"
);
for
(
PersonEntity
personEntity
:
personEntities1
)
{
System
.
out
.
println
(
"去重后:id="
+
personEntity
.
getId
()+
" name="
+
personEntity
.
getPerson_name
()+
" time="
+
personEntity
.
getTimestamp
());
}
}
}
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