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
8c32f10e
Commit
8c32f10e
authored
Aug 28, 2023
by
chenyuling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
1b2f9938
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
172 additions
and
108 deletions
+172
-108
LeaveAdapter.java
...ain/java/com/srthinker/statinfo/adapter/LeaveAdapter.java
+4
-0
ConfigEntity.java
.../com/srthinker/statinfo/database/entity/ConfigEntity.java
+15
-0
ApiManager.java
...ain/java/com/srthinker/statinfo/presenter/ApiManager.java
+12
-3
ApiQuest.java
.../main/java/com/srthinker/statinfo/presenter/ApiQuest.java
+59
-40
PersonEntityComparator.java
.../srthinker/statinfo/presenter/PersonEntityComparator.java
+11
-3
MainActivity.java
...rc/main/java/com/srthinker/statinfo/uis/MainActivity.java
+10
-58
ConfigDlgFragment.java
...om/srthinker/statinfo/uis/fragment/ConfigDlgFragment.java
+17
-4
DateUtil.java
...ain/java/com/srthinker/statinfo/util/common/DateUtil.java
+12
-0
EditView.java
...src/main/java/com/srthinker/statinfo/wedget/EditView.java
+7
-0
custom_edit.xml
app/src/main/res/layout/custom_edit.xml
+9
-0
EqualTest.java
app/src/test/java/com/srthinker/statinfo/EqualTest.java
+16
-0
No files found.
app/src/main/java/com/srthinker/statinfo/adapter/LeaveAdapter.java
View file @
8c32f10e
...
@@ -60,4 +60,8 @@ public class LeaveAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
...
@@ -60,4 +60,8 @@ public class LeaveAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
//Log.i(TAG, "setDataList: size="+this.peopleBeans.size());
//Log.i(TAG, "setDataList: size="+this.peopleBeans.size());
this
.
notifyDataSetChanged
();
this
.
notifyDataSetChanged
();
}
}
public
List
<
PersonEntity
>
getDataList
(){
return
this
.
peopleBeans
;
}
}
}
app/src/main/java/com/srthinker/statinfo/database/entity/ConfigEntity.java
View file @
8c32f10e
...
@@ -6,6 +6,8 @@ import com.raizlabs.android.dbflow.annotation.Table;
...
@@ -6,6 +6,8 @@ import com.raizlabs.android.dbflow.annotation.Table;
import
com.raizlabs.android.dbflow.structure.BaseModel
;
import
com.raizlabs.android.dbflow.structure.BaseModel
;
import
com.srthinker.statinfo.database.AppDB
;
import
com.srthinker.statinfo.database.AppDB
;
import
java.util.Objects
;
@Table
(
database
=
AppDB
.
class
)
@Table
(
database
=
AppDB
.
class
)
public
class
ConfigEntity
extends
BaseModel
{
public
class
ConfigEntity
extends
BaseModel
{
@PrimaryKey
(
autoincrement
=
true
)
@PrimaryKey
(
autoincrement
=
true
)
...
@@ -69,4 +71,17 @@ public class ConfigEntity extends BaseModel {
...
@@ -69,4 +71,17 @@ public class ConfigEntity extends BaseModel {
public
void
setType
(
int
type
)
{
public
void
setType
(
int
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
ConfigEntity
config
=
(
ConfigEntity
)
o
;
return
id
==
config
.
id
&&
isConnect
==
config
.
isConnect
&&
type
==
config
.
type
&&
Objects
.
equals
(
username
,
config
.
username
)
&&
Objects
.
equals
(
password
,
config
.
password
)
&&
Objects
.
equals
(
serverIp
,
config
.
serverIp
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
id
,
username
,
password
,
serverIp
,
isConnect
,
type
);
}
}
}
app/src/main/java/com/srthinker/statinfo/presenter/ApiManager.java
View file @
8c32f10e
...
@@ -29,6 +29,7 @@ import java.util.concurrent.ScheduledExecutorService;
...
@@ -29,6 +29,7 @@ import java.util.concurrent.ScheduledExecutorService;
public
class
ApiManager
{
public
class
ApiManager
{
private
static
final
String
TAG
=
"ApiManager"
;
private
static
final
String
TAG
=
"ApiManager"
;
private
static
final
long
GET_PASS_TIME
=
60000
;
private
final
String
username
;
private
final
String
username
;
private
final
String
password
;
private
final
String
password
;
private
final
String
serverIp
;
private
final
String
serverIp
;
...
@@ -42,6 +43,7 @@ public class ApiManager {
...
@@ -42,6 +43,7 @@ public class ApiManager {
private
PassApiImpl
passApi
;
private
PassApiImpl
passApi
;
private
boolean
isRunning
=
false
;
// 标记任务是否正在执行
private
boolean
isRunning
=
false
;
// 标记任务是否正在执行
private
boolean
isFirstStatus
=
false
;
private
boolean
isFirstStatus
=
false
;
private
int
lastPassTotal
;
private
AuthApi
authApi
;
private
AuthApi
authApi
;
private
PersonApiImpl
personApi
;
private
PersonApiImpl
personApi
;
private
boolean
lastConnect
=
false
;
private
boolean
lastConnect
=
false
;
...
@@ -76,6 +78,7 @@ public class ApiManager {
...
@@ -76,6 +78,7 @@ public class ApiManager {
isRunning
=
true
;
isRunning
=
true
;
isFirstStatus
=
true
;
isFirstStatus
=
true
;
lastConnect
=
false
;
lastConnect
=
false
;
lastPassTotal
=
0
;
handler
.
post
(
authThreadRunnable
);
handler
.
post
(
authThreadRunnable
);
//ThreadPool.getInstance().getThreadPoolExecutor().execute(passRecordRunnable);
//ThreadPool.getInstance().getThreadPoolExecutor().execute(passRecordRunnable);
handler
.
post
(
passThreadRunnable
);
handler
.
post
(
passThreadRunnable
);
...
@@ -103,6 +106,7 @@ public class ApiManager {
...
@@ -103,6 +106,7 @@ public class ApiManager {
//只要连接成功都传避免出现意外,因为鉴权成功后也只访问一次
//只要连接成功都传避免出现意外,因为鉴权成功后也只访问一次
if
(
callback
!=
null
)
{
if
(
callback
!=
null
)
{
lastConnect
=
true
;
lastConnect
=
true
;
isFirstStatus
=
false
;
callback
.
onConnectStatus
(
true
,
type
);
callback
.
onConnectStatus
(
true
,
type
);
}
}
//updateLastConnect(true);
//updateLastConnect(true);
...
@@ -164,9 +168,14 @@ public class ApiManager {
...
@@ -164,9 +168,14 @@ public class ApiManager {
totalPassLists
=
new
ArrayList
<>();
totalPassLists
=
new
ArrayList
<>();
pass_offset
=
0
;
pass_offset
=
0
;
queryPass
();
queryPass
();
//Log.i(TAG, "run: totalPassLists.size()="+totalPassLists.size());
//Log.i(TAG, "run: lastPassTotal="+lastPassTotal);
if
(
totalPassLists
.
size
()!=
0
&&
totalPassLists
.
size
()!=
lastPassTotal
){
if
(
callback
!=
null
)
{
if
(
callback
!=
null
)
{
callback
.
getPassInfo
(
totalPassLists
,
type
);
callback
.
getPassInfo
(
totalPassLists
,
type
);
}
}
}
lastPassTotal
=
totalPassLists
.
size
();
/*handler.postDelayed(this,60000);*/
/*handler.postDelayed(this,60000);*/
}
}
};
};
...
@@ -179,7 +188,7 @@ public class ApiManager {
...
@@ -179,7 +188,7 @@ public class ApiManager {
return
;
return
;
}
}
ThreadPool
.
getInstance
().
getThreadPoolExecutor
().
execute
(
passRecordRunnable
);
ThreadPool
.
getInstance
().
getThreadPoolExecutor
().
execute
(
passRecordRunnable
);
handler
.
postDelayed
(
this
,
60000
);
handler
.
postDelayed
(
this
,
GET_PASS_TIME
);
}
}
};
};
...
...
app/src/main/java/com/srthinker/statinfo/presenter/ApiQuest.java
View file @
8c32f10e
...
@@ -14,6 +14,7 @@ import com.srthinker.statinfo.listener.upper.UpperDevicesCallback;
...
@@ -14,6 +14,7 @@ import com.srthinker.statinfo.listener.upper.UpperDevicesCallback;
import
com.srthinker.statinfo.util.common.ThreadPool
;
import
com.srthinker.statinfo.util.common.ThreadPool
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.List
;
...
@@ -47,10 +48,22 @@ public class ApiQuest {
...
@@ -47,10 +48,22 @@ public class ApiQuest {
this
.
upperDevicesCallback
=
upperDevicesCallback
;
this
.
upperDevicesCallback
=
upperDevicesCallback
;
}
}
private
void
initData
(
int
type
){
if
(
type
==
ENTER_TYPE
){
isEnterAllConnect
=
false
;
allEnterPass
=
new
ArrayList
<>();
}
else
if
(
type
==
LEAVE_TYPE
){
isLeaveAllConnect
=
false
;
allLeavePass
=
new
ArrayList
<>();
}
}
public
void
startApi
(
List
<
ConfigEntity
>
configList
,
int
type
){
public
void
startApi
(
List
<
ConfigEntity
>
configList
,
int
type
){
if
(
configList
!=
null
)
{
if
(
configList
!=
null
)
{
synchronized
(
this
){
//把之前的所有的停掉
//把之前的所有的停掉
stopApiByType
(
type
);
stopApiByType
(
type
);
initData
(
type
);
for
(
int
i
=
0
;
i
<
configList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
configList
.
size
();
i
++)
{
ConfigEntity
config
=
configList
.
get
(
i
);
ConfigEntity
config
=
configList
.
get
(
i
);
String
username
=
config
.
getUsername
();
String
username
=
config
.
getUsername
();
...
@@ -67,7 +80,7 @@ public class ApiQuest {
...
@@ -67,7 +80,7 @@ public class ApiQuest {
}
}
}
}
}
}
}
private
void
startEnterIp
(
String
username
,
String
password
,
String
ip
)
{
private
void
startEnterIp
(
String
username
,
String
password
,
String
ip
)
{
...
@@ -86,20 +99,22 @@ public class ApiQuest {
...
@@ -86,20 +99,22 @@ public class ApiQuest {
enterMgr
.
setOnDeviceCallback
(
new
DeviceCallback
()
{
enterMgr
.
setOnDeviceCallback
(
new
DeviceCallback
()
{
@Override
@Override
public
void
getPassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
)
{
public
void
getPassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
)
{
synchronized
(
allEnterPass
){
allEnterPass
.
addAll
(
passEntities
);
allEnterPass
.
addAll
(
passEntities
);
for
(
PersonEntity
enterPass
:
allEnterPass
)
{
/*
for (PersonEntity enterPass : allEnterPass) {
Log.i(TAG, "去重前getPassInfo: enterPass.time="+enterPass.getTimestamp()+",name="+enterPass.getPerson_name());
Log.i(TAG, "去重前getPassInfo: enterPass.time="+enterPass.getTimestamp()+",name="+enterPass.getPerson_name());
}
}*/
PersonEntityComparator
comparator
=
new
PersonEntityComparator
();
Collections
.
sort
(
allEnterPass
,
comparator
);
LinkedHashSet
<
PersonEntity
>
mergeList
=
new
LinkedHashSet
<>(
allEnterPass
);
LinkedHashSet
<
PersonEntity
>
mergeList
=
new
LinkedHashSet
<>(
allEnterPass
);
allEnterPass
=
new
ArrayList
<>(
mergeList
);
allEnterPass
=
new
ArrayList
<>(
mergeList
);
for
(
PersonEntity
enterPass
:
allEnterPass
)
{
Log
.
i
(
TAG
,
"去重后getPassInfo: enterPass.time="
+
enterPass
.
getTimestamp
()+
",name="
+
enterPass
.
getPerson_name
());
}
/*for (PersonEntity enterPass : allEnterPass) {
/*for (PersonEntity enterPass : allEnterPass) {
Log.i(TAG, "getPassInfo:
name="+enterPass.getPerson_name());
Log.i(TAG, "去重后getPassInfo: enterPass.time="+enterPass.getTimestamp()+",
name="+enterPass.getPerson_name());
}*/
}*/
ArrayList
<
PersonEntity
>
allPassList
=
new
ArrayList
<>(
allEnterPass
);
if
(
upperDevicesCallback
!=
null
)
{
if
(
upperDevicesCallback
!=
null
)
{
upperDevicesCallback
.
getAllPassInfo
(
allEnterPass
,
type
);
upperDevicesCallback
.
getAllPassInfo
(
allPassList
,
type
);
}
}
}
}
}
...
@@ -153,14 +168,16 @@ public class ApiQuest {
...
@@ -153,14 +168,16 @@ public class ApiQuest {
leaveMgr
.
setOnDeviceCallback
(
new
DeviceCallback
()
{
leaveMgr
.
setOnDeviceCallback
(
new
DeviceCallback
()
{
@Override
@Override
public
void
getPassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
)
{
public
void
getPassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
)
{
synchronized
(
allLeavePass
){
allLeavePass
.
addAll
(
passEntities
);
allLeavePass
.
addAll
(
passEntities
);
PersonEntityComparator
comparator
=
new
PersonEntityComparator
();
Collections
.
sort
(
allLeavePass
,
comparator
);
LinkedHashSet
<
PersonEntity
>
mergeList
=
new
LinkedHashSet
<>(
allLeavePass
);
LinkedHashSet
<
PersonEntity
>
mergeList
=
new
LinkedHashSet
<>(
allLeavePass
);
allLeavePass
=
new
ArrayList
<>(
mergeList
);
allLeavePass
=
new
ArrayList
<>(
mergeList
);
/*for (PersonEntity leavePass : allLeavePass) {
ArrayList
<
PersonEntity
>
allPassList
=
new
ArrayList
<>(
allLeavePass
);
Log.i(TAG, "getPassInfo: name="+leavePass.getPerson_name());
}*/
if
(
upperDevicesCallback
!=
null
)
{
if
(
upperDevicesCallback
!=
null
)
{
upperDevicesCallback
.
getAllPassInfo
(
allLeavePass
,
type
);
upperDevicesCallback
.
getAllPassInfo
(
allPassList
,
type
);
}
}
}
}
}
...
@@ -221,8 +238,10 @@ public class ApiQuest {
...
@@ -221,8 +238,10 @@ public class ApiQuest {
public
void
queryPersons
(
QueryPersonCallback
callback
){
public
void
queryPersons
(
QueryPersonCallback
callback
){
if
(
enterMgrHashMap
.
size
()>
0
){
if
(
enterMgrHashMap
.
size
()>
0
){
ApiManager
oneEnterMgr
=
enterMgrHashMap
.
get
(
oneEnterIp
);
ApiManager
oneEnterMgr
=
enterMgrHashMap
.
get
(
oneEnterIp
);
if
(
oneEnterMgr
!=
null
)
{
oneEnterMgr
.
queryPersons
();
oneEnterMgr
.
queryPersons
();
oneEnterMgr
.
setOnQueryPersonsCallback
(
callback
);
oneEnterMgr
.
setOnQueryPersonsCallback
(
callback
);
}
}
}
}
}
}
}
app/src/main/java/com/srthinker/statinfo/presenter/PersonEntityComparator.java
View file @
8c32f10e
package
com
.
srthinker
.
statinfo
.
presenter
;
package
com
.
srthinker
.
statinfo
.
presenter
;
import
com.srthinker.statinfo.database.entity.PersonEntity
;
import
com.srthinker.statinfo.database.entity.PersonEntity
;
import
com.srthinker.statinfo.util.common.DateUtil
;
import
java.util.Comparator
;
import
java.util.Comparator
;
public
class
PersonEntityComparator
implements
Comparator
<
PersonEntity
>
{
public
class
PersonEntityComparator
implements
Comparator
<
PersonEntity
>
{
@Override
@Override
public
int
compare
(
PersonEntity
p1
,
PersonEntity
p2
)
{
public
int
compare
(
PersonEntity
p1
,
PersonEntity
p2
)
{
long
time1
=
DateUtil
.
getTime
(
p1
.
getTimestamp
(),
"HH:mm"
);
//return time2.compareTo(time1);
long
time2
=
DateUtil
.
getTime
(
p2
.
getTimestamp
(),
"HH:mm"
);
//从大到小排列
if
(
time1
>
time2
){
return
-
1
;
}
else
if
(
time1
<
time2
){
return
1
;
}
else
{
return
0
;
return
0
;
}
}
}
}
}
app/src/main/java/com/srthinker/statinfo/uis/MainActivity.java
View file @
8c32f10e
...
@@ -362,14 +362,14 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -362,14 +362,14 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
private
void
updatePassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
)
{
private
void
updatePassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
)
{
Log
.
i
(
TAG
,
"updatePassInfo: 获取的总数="
+
passEntities
.
size
());
Log
.
i
(
TAG
,
"updatePassInfo: 获取的总数="
+
passEntities
.
size
());
for
(
PersonEntity
passEntity
:
passEntities
)
{
/*
for (PersonEntity passEntity : passEntities) {
Log.i(TAG, "updatePassInfo: 获取到的name="+passEntity.getPerson_name());
Log.i(TAG, "updatePassInfo: 获取到的name="+passEntity.getPerson_name());
}
}
*/
if
(
type
==
ENTER_TYPE
){
if
(
type
==
ENTER_TYPE
){
if
(
passEntities
!=
null
)
{
if
(
passEntities
!=
null
)
{
if
(
enterAdapter
!=
null
)
{
if
(
enterAdapter
!=
null
)
{
int
size
=
passEntities
.
size
();
int
size
=
passEntities
.
size
();
if
(
size
!=
lastEnterSize
){
if
(
enterBeans
!=
null
&&
size
!=
enterBeans
.
size
()
){
//更新进出情况
//更新进出情况
//enterBeans = passEntities; 全局变量直接赋值会出现问题
//enterBeans = passEntities; 全局变量直接赋值会出现问题
enterBeans
.
clear
();
enterBeans
.
clear
();
...
@@ -390,6 +390,8 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -390,6 +390,8 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
groupEnterHashMap
=
getGroupSizeHashMap
(
passEntities
);
groupEnterHashMap
=
getGroupSizeHashMap
(
passEntities
);
updatePresentSize
(
groupEnterHashMap
,
groupLeaveHashMap
);
updatePresentSize
(
groupEnterHashMap
,
groupLeaveHashMap
);
}
}
/* Log.i(TAG, "updatePassInfo: enterBeans.size="+enterBeans.size());
Log.i(TAG, "updatePassInfo: adapter.size="+enterAdapter.getDataList().size());*/
}
}
}
}
...
@@ -399,7 +401,7 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -399,7 +401,7 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
if
(
leaveAdapter
!=
null
)
{
if
(
leaveAdapter
!=
null
)
{
int
size
=
passEntities
.
size
();
int
size
=
passEntities
.
size
();
//进出有变化时才更新
//进出有变化时才更新
if
(
size
!=
lastLeaveSize
){
if
(
leaveBeans
!=
null
&&
size
!=
leaveBeans
.
size
()
){
leaveBeans
.
clear
();
leaveBeans
.
clear
();
leaveBeans
.
addAll
(
passEntities
);
leaveBeans
.
addAll
(
passEntities
);
//更新进出情况
//更新进出情况
...
@@ -419,6 +421,8 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -419,6 +421,8 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
groupLeaveHashMap
=
getGroupSizeHashMap
(
passEntities
);
groupLeaveHashMap
=
getGroupSizeHashMap
(
passEntities
);
updatePresentSize
(
groupEnterHashMap
,
groupLeaveHashMap
);
updatePresentSize
(
groupEnterHashMap
,
groupLeaveHashMap
);
}
}
/*Log.i(TAG, "updatePassInfo: leaveBeans.size="+leaveBeans.size());
Log.i(TAG, "updatePassInfo: adapter.size="+leaveAdapter.getDataList().size());*/
}
}
}
}
...
@@ -548,22 +552,6 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -548,22 +552,6 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
ApiQuest.startEnterApi(enterConfigList,this);
ApiQuest.startEnterApi(enterConfigList,this);
List<ConfigBean> leaveConfigList = SharedUtil.getInstance(this).readSharedList(LEAVE_TYPE, ConfigBean.class, "");
List<ConfigBean> leaveConfigList = SharedUtil.getInstance(this).readSharedList(LEAVE_TYPE, ConfigBean.class, "");
ApiQuest.startLeaveApi(leaveConfigList,this);*/
ApiQuest.startLeaveApi(leaveConfigList,this);*/
/*runOnUiThread(() -> {
List<ConfigEntity> enterConfigList = ConfigHelper.getInstance().queryByType(ENTER_TYPE);
ApiQuest.getInstance().startApi(enterConfigList,ENTER_TYPE);
ApiQuest.getInstance().setOnUpperDevicesCallback(this);
List<ConfigEntity> leaveConfigList = ConfigHelper.getInstance().queryByType(LEAVE_TYPE);
ApiQuest.getInstance().startApi(leaveConfigList,LEAVE_TYPE);
ApiQuest.getInstance().setOnUpperDevicesCallback(this);
});*/
/*ThreadPool.getInstance().getThreadPoolExecutor().execute(() -> {
List<ConfigEntity> enterConfigList = ConfigHelper.getInstance().queryByType(ENTER_TYPE);
ApiQuest.getInstance().startApi(enterConfigList,ENTER_TYPE);
ApiQuest.getInstance().setOnUpperDevicesCallback(this);
List<ConfigEntity> leaveConfigList = ConfigHelper.getInstance().queryByType(LEAVE_TYPE);
ApiQuest.getInstance().startApi(leaveConfigList,LEAVE_TYPE);
ApiQuest.getInstance().setOnUpperDevicesCallback(this);
});*/
List
<
ConfigEntity
>
enterConfigList
=
ConfigHelper
.
getInstance
().
queryByType
(
ENTER_TYPE
);
List
<
ConfigEntity
>
enterConfigList
=
ConfigHelper
.
getInstance
().
queryByType
(
ENTER_TYPE
);
ApiQuest
.
getInstance
().
startApi
(
enterConfigList
,
ENTER_TYPE
);
ApiQuest
.
getInstance
().
startApi
(
enterConfigList
,
ENTER_TYPE
);
ApiQuest
.
getInstance
().
setOnUpperDevicesCallback
(
this
);
ApiQuest
.
getInstance
().
setOnUpperDevicesCallback
(
this
);
...
@@ -586,18 +574,10 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -586,18 +574,10 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
}else if (type == LEAVE_TYPE){
}else if (type == LEAVE_TYPE){
ApiQuest.getInstance().startLeaveApi(configList);
ApiQuest.getInstance().startLeaveApi(configList);
}*/
}*/
for
(
ConfigEntity
config
:
configList
)
{
/*
for (ConfigEntity config : configList) {
Log.i(TAG, "onUpdateConfig: pass="+config.getPassword());
Log.i(TAG, "onUpdateConfig: pass="+config.getPassword());
Log.i(TAG, "onUpdateConfig: ip="+config.getServerIp());
Log.i(TAG, "onUpdateConfig: ip="+config.getServerIp());
}
}*/
/*runOnUiThread(()->{
ApiQuest.getInstance().startApi(configList,type);
ApiQuest.getInstance().setOnUpperDevicesCallback(this);
});*/
/*ThreadPool.getInstance().getThreadPoolExecutor().execute(()->{
ApiQuest.getInstance().startApi(configList,type);
ApiQuest.getInstance().setOnUpperDevicesCallback(this);
});*/
ApiQuest
.
getInstance
().
startApi
(
configList
,
type
);
ApiQuest
.
getInstance
().
startApi
(
configList
,
type
);
ApiQuest
.
getInstance
().
setOnUpperDevicesCallback
(
this
);
ApiQuest
.
getInstance
().
setOnUpperDevicesCallback
(
this
);
}
}
...
@@ -629,32 +609,4 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
...
@@ -629,32 +609,4 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
}
}
});
});
}
}
/*@Override
public void getPassInfo(List<PersonEntity> passEntities, int type) {
runOnUiThread(()->{
updatePassInfo(passEntities, type);
});
}
@Override
public void onConnectStatus(boolean isConnect, int type) {
runOnUiThread(()->{
if (type==ENTER_TYPE){
if (!isConnect) {
mBinding.tvEnterError.setVisibility(View.VISIBLE);
}else{
mBinding.tvEnterError.setVisibility(View.GONE);
}
}else if (type == LEAVE_TYPE){
if (!isConnect) {
mBinding.tvLeaveError.setVisibility(View.VISIBLE);
}else{
mBinding.tvLeaveError.setVisibility(View.GONE);
}
}
});
}*/
}
}
\ No newline at end of file
app/src/main/java/com/srthinker/statinfo/uis/fragment/ConfigDlgFragment.java
View file @
8c32f10e
...
@@ -9,6 +9,7 @@ import android.graphics.drawable.ColorDrawable;
...
@@ -9,6 +9,7 @@ import android.graphics.drawable.ColorDrawable;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.text.InputType
;
import
android.text.InputType
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
...
@@ -34,6 +35,7 @@ import java.util.stream.Collectors;
...
@@ -34,6 +35,7 @@ import java.util.stream.Collectors;
public
class
ConfigDlgFragment
extends
DialogFragment
{
public
class
ConfigDlgFragment
extends
DialogFragment
{
private
static
final
String
TAG
=
"ConfigDlgFragment"
;
private
Context
context
;
private
Context
context
;
private
int
type
;
private
int
type
;
private
com
.
srthinker
.
statinfo
.
databinding
.
DialogConfigBinding
mBinding
;
private
com
.
srthinker
.
statinfo
.
databinding
.
DialogConfigBinding
mBinding
;
...
@@ -98,12 +100,15 @@ public class ConfigDlgFragment extends DialogFragment {
...
@@ -98,12 +100,15 @@ public class ConfigDlgFragment extends DialogFragment {
ConfigEntity
config
=
mLastConfig
.
get
(
i
);
ConfigEntity
config
=
mLastConfig
.
get
(
i
);
if
(
config
!=
null
)
{
if
(
config
!=
null
)
{
String
serverIp
=
config
.
getServerIp
();
String
serverIp
=
config
.
getServerIp
();
boolean
connect
=
config
.
isConnect
();
if
(
i
==
0
){
if
(
i
==
0
){
mBinding
.
evServerip
.
setContent
(
serverIp
);
mBinding
.
evServerip
.
setContent
(
serverIp
);
mBinding
.
evServerip
.
setStatus
(
connect
);
}
else
{
}
else
{
addDeviceIpView
();
addDeviceIpView
();
EditView
editView
=
devicesIpList
.
get
(
i
);
EditView
editView
=
devicesIpList
.
get
(
i
);
editView
.
setContent
(
serverIp
);
editView
.
setContent
(
serverIp
);
editView
.
setStatus
(
connect
);
}
}
}
}
}
}
...
@@ -156,21 +161,29 @@ public class ConfigDlgFragment extends DialogFragment {
...
@@ -156,21 +161,29 @@ public class ConfigDlgFragment extends DialogFragment {
config
.
setPassword
(
password
);
config
.
setPassword
(
password
);
config
.
setServerIp
(
ip
);
config
.
setServerIp
(
ip
);
config
.
setType
(
type
);
config
.
setType
(
type
);
configEntities
.
add
(
config
);
if
(
mLastConfig
!=
null
&&
mLastConfig
.
size
()>
i
)
{
if
(
mLastConfig
!=
null
&&
mLastConfig
.
size
()>
i
)
{
ConfigEntity
mLastEntity
=
mLastConfig
.
get
(
i
);
ConfigEntity
mLastEntity
=
mLastConfig
.
get
(
i
);
try
{
if
(
TextUtils
.
equals
(
mLastEntity
.
getServerIp
(),
ip
)){
config
.
setId
(
mLastEntity
.
getId
());
config
.
setConnect
(
mLastEntity
.
isConnect
());
}
/*try {
String newConfigString = GsonUtil.toJsonString(config);
String newConfigString = GsonUtil.toJsonString(config);
String lastConfigString = GsonUtil.toJsonString(mLastEntity);
String lastConfigString = GsonUtil.toJsonString(mLastEntity);
Log.i(TAG, "updateConfig: newConfigString="+newConfigString);
Log.i(TAG, "updateConfig: lastConfigString="+lastConfigString);
if (!TextUtils.equals(newConfigString,lastConfigString)){
if (!TextUtils.equals(newConfigString,lastConfigString)){
isUpdate = true;
isUpdate = true;
}
}
} catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
}*/
}
}
configEntities
.
add
(
config
);
}
}
}
Log
.
i
(
TAG
,
"updateConfig: mLastConfig="
+
GsonUtil
.
ListToJson
(
mLastConfig
));
if
(
isUpdate
||
mLastConfig
!=
null
&&
allDeviceIps
.
size
()!=
mLastConfig
.
size
()){
Log
.
i
(
TAG
,
"updateConfig: configEntity="
+
GsonUtil
.
ListToJson
(
configEntities
));
if
(
mLastConfig
!=
null
&&!
mLastConfig
.
equals
(
configEntities
)){
/*if (callback != null) {
/*if (callback != null) {
SharedUtil.getInstance(context).writeShared(type,configBeanList);
SharedUtil.getInstance(context).writeShared(type,configBeanList);
callback.onUpdateConfig(configBeanList,type);
callback.onUpdateConfig(configBeanList,type);
...
...
app/src/main/java/com/srthinker/statinfo/util/common/DateUtil.java
View file @
8c32f10e
...
@@ -108,6 +108,7 @@ public class DateUtil {
...
@@ -108,6 +108,7 @@ public class DateUtil {
return
sdf
.
format
(
d_date
);
return
sdf
.
format
(
d_date
);
}
}
public
static
String
getAddDate
(
String
str
,
long
day_num
)
{
public
static
String
getAddDate
(
String
str
,
long
day_num
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
Date
old_date
;
Date
old_date
;
...
@@ -137,6 +138,17 @@ public class DateUtil {
...
@@ -137,6 +138,17 @@ public class DateUtil {
}
}
}
}
public
static
long
getTime
(
String
str
,
String
formatStr
){
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
formatStr
);
try
{
Date
date
=
sdf
.
parse
(
str
);
return
date
.
getTime
();
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
return
0
;
}
}
//计算某天是星期几
//计算某天是星期几
public
static
int
getWeekIndex
(
String
s_date
)
{
public
static
int
getWeekIndex
(
String
s_date
)
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
...
...
app/src/main/java/com/srthinker/statinfo/wedget/EditView.java
View file @
8c32f10e
...
@@ -61,4 +61,11 @@ public class EditView extends LinearLayout {
...
@@ -61,4 +61,11 @@ public class EditView extends LinearLayout {
mBinding
.
etContent
.
setInputType
(
type
);
mBinding
.
etContent
.
setInputType
(
type
);
}
}
public
void
setStatus
(
boolean
status
){
if
(
status
){
mBinding
.
tvStatus
.
setVisibility
(
INVISIBLE
);
}
else
{
mBinding
.
tvStatus
.
setVisibility
(
VISIBLE
);
}
}
}
}
app/src/main/res/layout/custom_edit.xml
View file @
8c32f10e
...
@@ -26,7 +26,16 @@
...
@@ -26,7 +26,16 @@
android:textSize=
"@dimen/text_12_5"
android:textSize=
"@dimen/text_12_5"
android:layout_gravity=
"center_vertical"
android:layout_gravity=
"center_vertical"
android:gravity=
"center|right"
android:gravity=
"center|right"
android:text=
""
android:singleLine=
"true"
android:singleLine=
"true"
android:background=
"@null"
android:background=
"@null"
android:outlineProvider=
"none"
/>
android:outlineProvider=
"none"
/>
<TextView
android:id=
"@+id/tv_status"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/color_0287F9"
android:text=
"!"
android:paddingLeft=
"5dp"
android:visibility=
"invisible"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
app/src/test/java/com/srthinker/statinfo/EqualTest.java
View file @
8c32f10e
package
com
.
srthinker
.
statinfo
;
package
com
.
srthinker
.
statinfo
;
import
com.srthinker.statinfo.bean.ConfigBean
;
import
com.srthinker.statinfo.bean.ConfigBean
;
import
com.srthinker.statinfo.database.entity.ConfigEntity
;
import
com.srthinker.statinfo.database.entity.PersonEntity
;
import
com.srthinker.statinfo.database.entity.PersonEntity
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -55,4 +56,19 @@ public class EqualTest {
...
@@ -55,4 +56,19 @@ public class EqualTest {
System
.
out
.
println
(
"遍历bean的:name="
+
bean
.
getUsername
());
System
.
out
.
println
(
"遍历bean的:name="
+
bean
.
getUsername
());
}
}
}
}
@Test
public
void
configTest1
(){
List
<
ConfigEntity
>
configList1
=
new
ArrayList
<>();
List
<
ConfigEntity
>
configList2
=
new
ArrayList
<>();
ConfigEntity
configBean
=
new
ConfigEntity
();
configBean
.
setUsername
(
"admin"
);
configBean
.
setServerIp
(
"111"
);
ConfigEntity
configBean1
=
new
ConfigEntity
();
configBean1
.
setUsername
(
"admin"
);
configBean1
.
setServerIp
(
"111"
);
configList1
.
add
(
configBean
);
configList2
.
add
(
configBean1
);
System
.
out
.
println
(
"是否相等="
+
configList1
.
equals
(
configList2
));
}
}
}
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