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
Show 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,
private
HashMap
<
Integer
,
Integer
>
groupLeaveHashMap
=
null
;
private
HashMap
<
Integer
,
Integer
>
groupPresentHashMap
=
null
;
private
boolean
isPermission
;
public
static
boolean
NEED_NO_REPET
=
true
;
//是否需要去重,false:不需要,true:需要
@Override
...
...
@@ -159,6 +160,7 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
private
void
showConfigDialog
(
int
type
)
{
ConfigDlgFragment
configDlgFragment
=
ConfigDlgFragment
.
getInstance
(
type
);
configDlgFragment
.
setUsername
(
"admin"
);
configDlgFragment
.
setConfigCallback
(
this
);
if
(
configDlgFragment
.
isResumed
()){
return
;
...
...
@@ -364,13 +366,18 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
if
(
size
!=
lastEnterSize
){
//更新进出情况
enterAdapter
.
setDateList
(
enterBeans
);
//更新人员情况
//更新人员情况(是否要根据id去重)
if
(
NEED_NO_REPET
)
{
List
<
PersonEntity
>
enterListNo
=
Utils
.
removeDuplicates
(
enterBeans
,
"id"
);
lastEnterSize
=
enterListNo
.
size
();
}
else
{
lastEnterSize
=
size
;
}
lastPresentSize
=
lastEnterSize
-
lastLeaveSize
;
mBinding
.
nvEnter
.
setNumber
(
lastEnterSize
);
mBinding
.
nvLeave
.
setNumber
(
lastLeaveSize
);
mBinding
.
nvPresent
.
setNumber
(
lastPresentSize
);
//更新分组情况
//更新分组情况
(是否要根据id去重)
groupEnterHashMap
=
getGroupSizeHashMap
(
enterBeans
);
updatePresentSize
(
groupEnterHashMap
,
groupLeaveHashMap
);
}
...
...
@@ -386,13 +393,18 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
if
(
size
!=
lastLeaveSize
){
//更新进出情况
leaveAdapter
.
setDateList
(
leaveBeans
);
//更新人员情况
//更新人员情况(是否要根据id去重)
if
(
NEED_NO_REPET
)
{
List
<
PersonEntity
>
leaveListNo
=
Utils
.
removeDuplicates
(
leaveBeans
,
"id"
);
lastLeaveSize
=
leaveListNo
.
size
();
}
else
{
lastLeaveSize
=
size
;
}
lastPresentSize
=
lastEnterSize
-
lastLeaveSize
;
mBinding
.
nvEnter
.
setNumber
(
lastEnterSize
);
mBinding
.
nvLeave
.
setNumber
(
lastLeaveSize
);
mBinding
.
nvPresent
.
setNumber
(
lastPresentSize
);
//更新分组情况
//更新分组情况
(是否要根据id去重)
groupLeaveHashMap
=
getGroupSizeHashMap
(
leaveBeans
);
updatePresentSize
(
groupEnterHashMap
,
groupLeaveHashMap
);
}
...
...
@@ -405,9 +417,13 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
}
@NonNull
private
HashMap
<
Integer
,
Integer
>
getGroupSizeHashMap
(
List
<
PersonEntity
>
personEntityList
)
{
HashMap
<
Integer
,
Integer
>
groupSizeHashMap
=
new
HashMap
<>();
if
(
NEED_NO_REPET
)
{
personEntityList
=
Utils
.
removeDuplicates
(
personEntityList
,
"id"
);
}
if
(
mQueryPersonList
!=
null
)
{
for
(
PersonEntity
entity
:
mQueryPersonList
)
{
int
group
=
entity
.
getGroup
();
...
...
@@ -455,7 +471,11 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
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
())
{
int
group
=
presentEntry
.
getKey
();
int
presentSize
=
presentEntry
.
getValue
();
...
...
@@ -519,12 +539,13 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
}*/
Log
.
i
(
TAG
,
"getTotalPerson: 已获取总数:personEntities.size="
+
personEntities
.
size
());
PersonMgr
.
getInstance
().
updatePersonThread
(
personEntities
,
()
->
{
Intent
intent
=
new
Intent
(
MainActivity
.
this
,
GroupActivity
.
class
);
startActivity
(
intent
);
});
runOnUiThread
(()->{
ClickUtil
.
enableClick
(
mBinding
.
btnGroupDetail
);
});
Intent
intent
=
new
Intent
(
MainActivity
.
this
,
GroupActivity
.
class
);
startActivity
(
intent
);
});
}
...
...
app/src/main/java/com/srthinker/statinfo/uis/fragment/ConfigDlgFragment.java
View file @
211ebcd5
...
...
@@ -7,6 +7,7 @@ import android.content.Context;
import
android.graphics.Color
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Bundle
;
import
android.text.InputType
;
import
android.text.TextUtils
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
...
...
@@ -34,6 +35,7 @@ public class ConfigDlgFragment extends DialogFragment {
private
String
mLastAccount
;
private
String
mLastPassword
;
private
String
mLastServerIp
;
private
String
username
;
public
static
ConfigDlgFragment
getInstance
(
int
type
){
ConfigDlgFragment
configDlgFragment
=
new
ConfigDlgFragment
();
...
...
@@ -59,6 +61,7 @@ public class ConfigDlgFragment extends DialogFragment {
mBinding
.
evAccount
.
initItem
(
"设备账号:"
,
"输入设备账号"
);
mBinding
.
evPassword
.
initItem
(
"设备密码:"
,
"输入设备密码"
);
mBinding
.
evServerip
.
initItem
(
"设备IP:"
,
"输入设备IP"
);
mBinding
.
evPassword
.
setInputType
(
InputType
.
TYPE_CLASS_TEXT
|
InputType
.
TYPE_TEXT_VARIATION_PASSWORD
);
if
(
type
==
ENTER_TYPE
){
mBinding
.
tvTitle
.
setText
(
"进去设备的配置信息"
);
}
else
if
(
type
==
LEAVE_TYPE
){
...
...
@@ -66,6 +69,10 @@ public class ConfigDlgFragment extends DialogFragment {
}
if
(!
TextUtils
.
isEmpty
(
mLastAccount
)){
mBinding
.
evAccount
.
setContent
(
mLastAccount
);
}
else
{
if
(!
TextUtils
.
isEmpty
(
username
)){
mBinding
.
evAccount
.
setContent
(
username
);
}
}
if
(!
TextUtils
.
isEmpty
(
mLastPassword
)){
mBinding
.
evPassword
.
setContent
(
mLastPassword
);
...
...
@@ -116,6 +123,10 @@ public class ConfigDlgFragment extends DialogFragment {
}
}
public
void
setUsername
(
String
username
){
this
.
username
=
username
;
}
@Override
public
void
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;
import
android.net.Uri
;
import
android.os.Build
;
import
android.provider.Settings
;
import
android.text.InputType
;
import
android.util.DisplayMetrics
;
import
android.util.Log
;
import
android.view.WindowManager
;
import
android.widget.EditText
;
import
android.widget.Toast
;
import
androidx.core.content.FileProvider
;
...
...
@@ -21,11 +23,17 @@ import java.io.DataOutputStream;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.lang.reflect.Field
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
me.jessyan.autosize.AutoSizeConfig
;
import
me.jessyan.autosize.onAdaptListener
;
...
...
@@ -203,7 +211,6 @@ public class Utils {
}
//获取自己应用内部的版本名
public
static
String
getVersionName
(
Context
context
)
{
PackageManager
manager
=
context
.
getPackageManager
();
String
name
=
null
;
...
...
@@ -222,6 +229,17 @@ public class Utils {
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
)
{
int
len
=
input
.
length
();
...
...
@@ -233,6 +251,52 @@ public class Utils {
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表示用限制使用
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 {
public
void
setInputType
(
int
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