Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
A
AnchorCollect
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hywang
AnchorCollect
Commits
52860942
Commit
52860942
authored
Sep 23, 2022
by
hywang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.增加多标签盘点模式;
2.蓝牙连接后自动关闭页面
parent
ca9728fd
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
491 additions
and
75 deletions
+491
-75
build.gradle
app/build.gradle
+2
-2
Configs.java
app/src/main/java/com/phlx/anchorcollect/Configs.java
+9
-1
ApiService.java
...ain/java/com/phlx/anchorcollect/data/http/ApiService.java
+2
-2
RetrofitClient.java
.../main/java/com/phlx/anchorcollect/net/RetrofitClient.java
+4
-4
BasicsCollectFragment.java
...phlx/anchorcollect/ui/fragment/BasicsCollectFragment.java
+41
-6
BreedingRecordFragment.java
...hlx/anchorcollect/ui/fragment/BreedingRecordFragment.java
+1
-1
ImmunRecordFragment.java
...m/phlx/anchorcollect/ui/fragment/ImmunRecordFragment.java
+1
-1
MedicalRecordFragment.java
...phlx/anchorcollect/ui/fragment/MedicalRecordFragment.java
+1
-1
PerformanceFragment.java
...m/phlx/anchorcollect/ui/fragment/PerformanceFragment.java
+1
-1
WeightManFragment.java
...com/phlx/anchorcollect/ui/fragment/WeightManFragment.java
+21
-1
CollectGridItem.java
.../phlx/anchorcollect/ui/fragment/list/CollectGridItem.java
+15
-14
BasicsCollectVM.java
...om/phlx/anchorcollect/ui/fragment/vm/BasicsCollectVM.java
+95
-13
WeightManVM.java
...va/com/phlx/anchorcollect/ui/fragment/vm/WeightManVM.java
+60
-14
LoginActivity.java
...n/java/com/phlx/anchorcollect/ui/login/LoginActivity.java
+8
-8
LoginVM.java
...rc/main/java/com/phlx/anchorcollect/ui/login/LoginVM.java
+7
-1
MainActivity.java
...ain/java/com/phlx/anchorcollect/ui/main/MainActivity.java
+4
-0
MainVM.java
app/src/main/java/com/phlx/anchorcollect/ui/main/MainVM.java
+43
-0
SettingVM.java
...ain/java/com/phlx/anchorcollect/ui/setting/SettingVM.java
+81
-4
ImageUtils.java
...src/main/java/com/phlx/anchorcollect/util/ImageUtils.java
+67
-0
activity_login.xml
app/src/main/res/layout/activity_login.xml
+15
-1
activity_setting.xml
app/src/main/res/layout/activity_setting.xml
+13
-0
No files found.
app/build.gradle
View file @
52860942
...
...
@@ -9,8 +9,8 @@ android {
applicationId
"com.phlx.anchorcollect"
minSdkVersion
21
targetSdkVersion
29
versionCode
1
versionName
"1.0.
0
"
versionCode
2
versionName
"1.0.
1
"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
...
...
app/src/main/java/com/phlx/anchorcollect/Configs.java
View file @
52860942
...
...
@@ -32,7 +32,7 @@ public class Configs {
/**
* 下载apk地址
*/
public
static
String
downloadApk
=
"/ap
p/download?type=APP
"
;
public
static
String
downloadApk
=
"/ap
i/download?type=iPad
"
;
/**
* 是否在线操作
...
...
@@ -86,10 +86,16 @@ public class Configs {
public
static
final
String
SP_BREEDING_RECORD_UPDATE_DATE
=
"sp_breeding_record_update_date"
;
public
static
final
String
SP_BREEDING_RECORD_DETAIL_UPDATE_DATE
=
"sp_breeding_record_detail_update_date"
;
//盘点类型
public
static
final
String
SP_INVENTORY_STATUS
=
"SP_inventory_status"
;
//0 高频,1低频
public
static
String
FREQUENCY_CONFIG
=
"1"
;
//是否是普通盘点模式,,true普通 多次,false返回最多数量标签模式 一次
public
static
boolean
inventoryStatus
;
/** 蓝牙 */
public
static
boolean
isConnected
=
false
;
// 蓝牙连接状态
public
static
final
String
DEVICEADDRESS
=
"deviceAddress"
;
...
...
@@ -125,6 +131,8 @@ public class Configs {
public
static
String
currentEvent
;
//控制接受重量数据的页面
// public static boolean ISCONNECTED;
public
static
String
packageName
(
Context
context
)
{
...
...
app/src/main/java/com/phlx/anchorcollect/data/http/ApiService.java
View file @
52860942
...
...
@@ -36,13 +36,13 @@ public interface ApiService {
/**
* 获取版本号
*/
@GET
(
"/ap
p/getAppVsesion?type=APP
"
)
@GET
(
"/ap
i/getAppVsesion?type=iPad
"
)
Observable
<
BaseResponse
<
Double
>>
versionGet
();
/**
* 下载新版本
*/
@GET
(
"/ap
p
/download"
)
@GET
(
"/ap
i
/download"
)
Observable
<
BaseResponse
>
DownloadApp
();
// @Headers({"Content-Type: application/json", "Accept: application/json"})
...
...
app/src/main/java/com/phlx/anchorcollect/net/RetrofitClient.java
View file @
52860942
...
...
@@ -50,14 +50,14 @@ public class RetrofitClient {
private
static
final
int
CACHE_TIMEOUT
=
10
*
1024
*
1024
;
//服务端根路径
public
static
String
baseUrl
=
//
"serve.xlglmnmyzspt.org.cn"//正式
"39.101.170.186"
//阿里云测试
"serve.xlglmnmyzspt.org.cn"
//正式
//
"39.101.170.186"//阿里云测试
// "192.168.8.135"//董
// "192.168.43.154"//张敏
;
public
static
String
port
=
//
""//正式
"9000"
//阿里云测试
""
//正式
//
"9000"//阿里云测试
// "9000"//董
;
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/BasicsCollectFragment.java
View file @
52860942
...
...
@@ -211,8 +211,8 @@ public class BasicsCollectFragment extends BaseFragment<FragmentBasicsCollectBin
viewModel
.
onNotifyAllEvent
.
observe
(
getActivity
(),
new
Observer
<
Boolean
>()
{
@Override
public
void
onChanged
(
Boolean
aBoolean
)
{
//
if (aBoolean)
//
viewModel.clearParamList();
if
(
aBoolean
)
viewModel
.
clearParamList
();
for
(
GenTableColumn
gtc
:
viewModel
.
uiList
)
{
gtc
.
notifyChange
();
...
...
@@ -240,13 +240,48 @@ public class BasicsCollectFragment extends BaseFragment<FragmentBasicsCollectBin
binding
.
rvCollect
.
getAdapter
().
notifyDataSetChanged
();
}
});
viewModel
.
onShowDialogEvent
.
observe
(
getActivity
(),
new
Observer
<
String
>()
{
@Override
public
void
onChanged
(
String
s
)
{
new
MaterialDialog
.
Builder
(
getActivity
()).
title
(
"系统提示"
).
content
(
s
).
positiveText
(
"确定"
).
onAny
(
new
MaterialDialog
.
SingleButtonCallback
()
{
@Override
public
void
onClick
(
@NonNull
MaterialDialog
dialog
,
@NonNull
DialogAction
which
)
{
if
(
which
==
DialogAction
.
POSITIVE
)
{
}
}
}).
show
();
}
});
viewModel
.
onShowEpcListEvent
.
observe
(
getActivity
(),
new
Observer
<
List
<
String
>>()
{
@Override
public
void
onChanged
(
List
<
String
>
stringList
)
{
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
"请选择耳标"
)
// .positiveText("确认")
// .negativeText("取消")
.
items
(
stringList
)
.
itemsCallback
(
new
MaterialDialog
.
ListCallback
()
{
@Override
public
void
onSelection
(
MaterialDialog
dialog
,
View
view
,
int
which
,
CharSequence
text
)
{
// String epcStr = text.toString().substring(text.toString().indexOf("----") + 4);
viewModel
.
initDataForRfid
(
text
.
toString
());
}
})
.
show
();
}
});
}
//选择框
private
void
showSpinnerDialog
(
GenTableColumn
uiParamEntity
)
{
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
"标题"
)
.
title
(
uiParamEntity
.
getColumnComment
()
)
// .positiveText("确认")
// .negativeText("取消")
.
items
(
DictUtils
.
getDistNameList
(
uiParamEntity
.
getDictType
()))
...
...
@@ -335,9 +370,9 @@ public class BasicsCollectFragment extends BaseFragment<FragmentBasicsCollectBin
// dialog.getInputEditText().setText(inputStr.subSequence(0, 10));
// ToastUtils.showShort("输入长度超长");
// } else {
viewModel
.
currentParamEntity
.
setShowName
(
dialog
.
getInputEditText
().
getText
().
toString
());
viewModel
.
currentParamEntity
.
setContent
(
dialog
.
getInputEditText
().
getText
().
toString
());
viewModel
.
currentParamEntity
.
notifyChange
();
viewModel
.
currentParamEntity
.
setShowName
(
dialog
.
getInputEditText
().
getText
().
toString
());
viewModel
.
currentParamEntity
.
setContent
(
dialog
.
getInputEditText
().
getText
().
toString
());
viewModel
.
currentParamEntity
.
notifyChange
();
// }
}
})
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/BreedingRecordFragment.java
View file @
52860942
...
...
@@ -184,7 +184,7 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
private
void
showSpinnerDialog
(
GenTableColumn
uiParamEntity
)
{
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
"标题"
)
.
title
(
uiParamEntity
.
getColumnComment
()
)
// .positiveText("确认")
// .negativeText("取消")
.
items
(
DictUtils
.
getDistNameList
(
uiParamEntity
.
getDictType
()))
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/ImmunRecordFragment.java
View file @
52860942
...
...
@@ -169,7 +169,7 @@ public class ImmunRecordFragment extends BaseFragment<FragmentImmunRecordBinding
private
void
showSpinnerDialog
(
GenTableColumn
uiParamEntity
)
{
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
"标题"
)
.
title
(
uiParamEntity
.
getColumnComment
()
)
// .positiveText("确认")
// .negativeText("取消")
.
items
(
DictUtils
.
getDistNameList
(
uiParamEntity
.
getDictType
()))
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/MedicalRecordFragment.java
View file @
52860942
...
...
@@ -167,7 +167,7 @@ public class MedicalRecordFragment extends BaseFragment<FragmentMedicalRecordBin
private
void
showSpinnerDialog
(
GenTableColumn
uiParamEntity
)
{
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
"标题"
)
.
title
(
uiParamEntity
.
getColumnComment
()
)
// .positiveText("确认")
// .negativeText("取消")
.
items
(
DictUtils
.
getDistNameList
(
uiParamEntity
.
getDictType
()))
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/PerformanceFragment.java
View file @
52860942
...
...
@@ -170,7 +170,7 @@ public class PerformanceFragment extends BaseFragment<FragmentPerformanceBinding
private
void
showSpinnerDialog
(
GenTableColumn
uiParamEntity
)
{
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
"标题"
)
.
title
(
uiParamEntity
.
getColumnComment
()
)
// .positiveText("确认")
// .negativeText("取消")
.
items
(
DictUtils
.
getDistNameList
(
uiParamEntity
.
getDictType
()))
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/WeightManFragment.java
View file @
52860942
...
...
@@ -272,6 +272,26 @@ public class WeightManFragment extends BaseFragment<FragmentWeightmanBinding, We
}).
show
();
}
});
viewModel
.
onShowEpcListEvent
.
observe
(
getActivity
(),
new
Observer
<
List
<
String
>>()
{
@Override
public
void
onChanged
(
List
<
String
>
stringList
)
{
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
"请选择耳标"
)
// .positiveText("确认")
// .negativeText("取消")
.
items
(
stringList
)
.
itemsCallback
(
new
MaterialDialog
.
ListCallback
()
{
@Override
public
void
onSelection
(
MaterialDialog
dialog
,
View
view
,
int
which
,
CharSequence
text
)
{
// String epcStr = text.toString().substring(text.toString().indexOf("----") + 4);
viewModel
.
initDataForRfid
(
text
.
toString
());
}
})
.
show
();
}
});
}
...
...
@@ -279,7 +299,7 @@ public class WeightManFragment extends BaseFragment<FragmentWeightmanBinding, We
private
void
showSpinnerDialog
(
GenTableColumn
uiParamEntity
)
{
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
"标题"
)
.
title
(
uiParamEntity
.
getColumnComment
()
)
// .positiveText("确认")
// .negativeText("取消")
.
items
(
DictUtils
.
getDistNameList
(
uiParamEntity
.
getDictType
()))
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/list/CollectGridItem.java
View file @
52860942
package
com
.
phlx
.
anchorcollect
.
ui
.
fragment
.
list
;
import
android.graphics.Bitmap
;
import
android.view.View
;
import
androidx.annotation.NonNull
;
...
...
@@ -26,7 +27,7 @@ public class CollectGridItem extends ItemViewModel<BaseViewModel> {
public
ObservableField
<
Integer
>
titleGrayVisiable
=
new
ObservableField
<>(
View
.
VISIBLE
);
public
ObservableField
<
Integer
>
titleBlueVisiable
=
new
ObservableField
<>(
View
.
GONE
);
private
String
fragmentType
;
private
String
fragmentType
;
public
CollectGridItem
(
@NonNull
BaseViewModel
viewModel
,
GenTableColumn
entity
,
String
fragmentType
)
{
super
(
viewModel
);
...
...
@@ -36,25 +37,25 @@ public class CollectGridItem extends ItemViewModel<BaseViewModel> {
initView
();
}
private
void
initView
(){
private
void
initView
()
{
switch
(
fragmentType
)
{
case
Configs
.
BASE_ARCHIVES
:
case
Configs
.
WEIGHTING_MANAGE
:
if
(
"1"
.
equals
(
entity
.
get
().
getIsEdit
()))
{
if
(
"1"
.
equals
(
entity
.
get
().
getIsEdit
()))
{
titleGrayVisiable
.
set
(
View
.
GONE
);
titleBlueVisiable
.
set
(
View
.
VISIBLE
);
}
else
{
}
else
{
titleGrayVisiable
.
set
(
View
.
VISIBLE
);
titleBlueVisiable
.
set
(
View
.
GONE
);
}
break
;
default
:
if
(
"1"
.
equals
(
entity
.
get
().
getIsInsert
()))
{
if
(
"1"
.
equals
(
entity
.
get
().
getIsInsert
()))
{
titleGrayVisiable
.
set
(
View
.
GONE
);
titleBlueVisiable
.
set
(
View
.
VISIBLE
);
}
else
{
}
else
{
titleGrayVisiable
.
set
(
View
.
VISIBLE
);
titleBlueVisiable
.
set
(
View
.
GONE
);
}
...
...
@@ -66,27 +67,27 @@ public class CollectGridItem extends ItemViewModel<BaseViewModel> {
@Override
public
void
call
()
{
switch
(
fragmentType
){
switch
(
fragmentType
)
{
case
Configs
.
BASE_ARCHIVES
:
((
BasicsCollectVM
)
viewModel
).
onItemClick
(
entity
.
get
());
((
BasicsCollectVM
)
viewModel
).
onItemClick
(
entity
.
get
());
break
;
case
Configs
.
SIGN_MEASURE
:
((
PerformanceVM
)
viewModel
).
onItemClick
(
entity
.
get
());
((
PerformanceVM
)
viewModel
).
onItemClick
(
entity
.
get
());
break
;
case
Configs
.
WEIGHTING_MANAGE
:
((
WeightManVM
)
viewModel
).
onItemClick
(
entity
.
get
());
((
WeightManVM
)
viewModel
).
onItemClick
(
entity
.
get
());
break
;
case
Configs
.
TREATMENT_RECORD
:
((
MedicalRecordVM
)
viewModel
).
onItemClick
(
entity
.
get
());
((
MedicalRecordVM
)
viewModel
).
onItemClick
(
entity
.
get
());
break
;
case
Configs
.
IMMUN_RECORD
:
((
ImmunRecordVM
)
viewModel
).
onItemClick
(
entity
.
get
());
((
ImmunRecordVM
)
viewModel
).
onItemClick
(
entity
.
get
());
break
;
case
Configs
.
BREEDING_RECORD
:
((
BreedingRecordVM
)
viewModel
).
onItemClick
(
entity
.
get
());
((
BreedingRecordVM
)
viewModel
).
onItemClick
(
entity
.
get
());
break
;
case
Configs
.
BREEDING_RECORD_DETAIL
:
((
BreedingRecordVM
)
viewModel
).
onItemClick
(
entity
.
get
());
((
BreedingRecordVM
)
viewModel
).
onItemClick
(
entity
.
get
());
break
;
}
}
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/vm/BasicsCollectVM.java
View file @
52860942
...
...
@@ -50,15 +50,23 @@ import java.text.ParseException;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
io.reactivex.Observable
;
import
io.reactivex.ObservableOnSubscribe
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.functions.Consumer
;
import
me.goldze.mvvmhabit.base.BaseViewModel
;
import
me.goldze.mvvmhabit.binding.command.BindingAction
;
import
me.goldze.mvvmhabit.binding.command.BindingCommand
;
import
me.goldze.mvvmhabit.bus.RxBus
;
import
me.goldze.mvvmhabit.bus.RxSubscriptions
;
import
me.goldze.mvvmhabit.bus.event.SingleLiveEvent
;
import
me.goldze.mvvmhabit.http.ResponseThrowable
;
import
me.goldze.mvvmhabit.utils.KLog
;
import
me.goldze.mvvmhabit.utils.RxUtils
;
import
me.goldze.mvvmhabit.utils.StringUtils
;
import
me.goldze.mvvmhabit.utils.ToastUtils
;
import
me.tatarka.bindingcollectionadapter2.ItemBinding
;
...
...
@@ -84,6 +92,8 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
public
SingleLiveEvent
<
Boolean
>
onCardClickEvent
=
new
SingleLiveEvent
<>();
public
SingleLiveEvent
<
Boolean
>
onTagClickEvent
=
new
SingleLiveEvent
<>();
public
SingleLiveEvent
<
Boolean
>
onNotifyAllEvent
=
new
SingleLiveEvent
<>();
//true是清空页面
public
SingleLiveEvent
<
List
<
String
>>
onShowEpcListEvent
=
new
SingleLiveEvent
<>();
//普通盘点模式下epc列表
public
SingleLiveEvent
<
String
>
onShowDialogEvent
=
new
SingleLiveEvent
<>();
//弹窗提示
public
ObservableField
<
String
>
tag
=
new
ObservableField
<>(
""
);
public
ObservableField
<
String
>
rfid
=
new
ObservableField
<>(
""
);
...
...
@@ -106,6 +116,9 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
private
String
rfidTag
=
""
;
//扫描到的标记
private
static
Map
<
String
,
Integer
>
map
;
//去重
private
ArrayList
<
String
>
epcList
;
private
Disposable
weightBus
;
private
boolean
isWeightScan
=
false
;
...
...
@@ -117,6 +130,9 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
//ImageView的占位图片,可以解决RecyclerView中图片错误问题
drawableImg
=
ContextCompat
.
getDrawable
(
getApplication
(),
R
.
drawable
.
no_image
);
map
=
new
HashMap
<>();
epcList
=
new
ArrayList
<>();
soundPool
=
new
SoundPool
(
2
,
AudioManager
.
STREAM_MUSIC
,
5
);
musicId
=
new
SparseIntArray
();
musicId
.
put
(
1
,
soundPool
.
load
(
getApplication
(),
R
.
raw
.
readcard
,
1
));
...
...
@@ -166,8 +182,8 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
public
void
initDataForTag
(
String
tag
)
{
clearTempInfo
();
clearParamList
();
onNotifyAllEvent
.
setValue
(
false
);
//
clearParamList();
//
onNotifyAllEvent.setValue(false);
this
.
tag
.
set
(
tag
);
Configs
.
tempTag
=
tag
;
if
(
StringUtils
.
isEmpty
(
tag
))
...
...
@@ -181,6 +197,7 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
public
void
initDataForRfid
(
String
rfid
)
{
// clearTempInfo();
this
.
rfid
.
set
(
rfid
);
Configs
.
tempRfid
=
rfid
;
if
(
StringUtils
.
isEmpty
(
rfid
))
...
...
@@ -195,9 +212,9 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
public
void
initDataForUnid
(
Long
unid
)
{
clearTempInfo
();
clearParamList
();
// clearParamList();
// onNotifyAllEvent.setValue(false);
Configs
.
tempUnid
=
unid
;
onNotifyAllEvent
.
setValue
(
false
);
if
(
unid
==
null
)
return
;
...
...
@@ -211,8 +228,12 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
private
void
scanRfid
()
{
if
(!
isScan
&&
isWeightScan
)
{
clearTempInfo
();
clearParamList
();
onNotifyAllEvent
.
setValue
(
false
);
// clearParamList();
// onNotifyAllEvent.setValue(false);
if
(
Configs
.
inventoryStatus
)
{
showDialog
(
"正在扫描耳标!"
);
}
App
.
getInstance
().
getLinkage
().
startInventory
(
1
,
0
);
isScan
=
true
;
...
...
@@ -298,8 +319,6 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
public
void
onItemClick
(
GenTableColumn
entity
)
{
if
(!
"1"
.
equals
(
entity
.
getIsEdit
()))
return
;
if
(
Configs
.
tempUnid
==
null
)
{
ToastUtils
.
showShort
(
"请扫描耳标或者输入耳标信息"
);
return
;
...
...
@@ -354,6 +373,8 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
@Override
public
void
call
()
{
isWeightScan
=
true
;
map
=
new
HashMap
<>();
epcList
.
clear
();
scanRfid
();
}
});
...
...
@@ -464,21 +485,73 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
App
.
getInstance
().
getLinkage
().
stopInventory
();
isScan
=
false
;
if
(
""
.
equals
(
rfidTag
))
checkEpc
(
epc
,
tid
);
if
(!
Configs
.
inventoryStatus
&&
!
""
.
equals
(
rfidTag
))
return
;
checkEpc
(
epc
,
tid
);
}
}
else
if
(
msg
.
what
==
0x222
)
{
App
.
getInstance
().
getLinkage
().
stopInventory
();
isScan
=
false
;
ToastUtils
.
showShort
(
"停止盘点"
);
dismissDialog
();
if
(
Configs
.
inventoryStatus
)
{
if
(
epcList
!=
null
&&
epcList
.
size
()
>
0
)
{
onShowEpcListEvent
.
setValue
(
epcList
);
}
else
{
onShowDialogEvent
.
setValue
(
"未扫描到标签!"
);
}
}
}
}
};
private
void
checkEpc
(
String
epc
,
String
tid
)
{
ToastUtils
.
showShort
(
"盘点到标签:"
+
epc
+
"|停止盘点"
);
rfidTag
=
epc
+
tid
;
initDataForRfid
(
epc
);
if
(
Configs
.
inventoryStatus
)
{
if
(!
map
.
containsKey
(
rfidTag
))
{
epcList
.
add
(
epc
);
map
.
put
(
rfidTag
,
epcList
.
size
()
-
1
);
//查数据库
// addSubscribe(Observable.create((ObservableOnSubscribe<CattleResumeEntity>) emitter -> {
// try {
//
// KLog.e("epc:" + epc);
// QueryBuilder<CattleResumeEntity> builder =
// DbUtil.getInstance().getQueryBuilder(CattleResumeEntity.class)
// .where(CattleResumeEntityDao.Properties.RegistrationNo.eq(epc));
// List<CattleResumeEntity> labels = DbUtil.getInstance().queryAll(CattleResumeEntity.class, builder);
//
// if (labels.size() > 0) {
// emitter.onNext(labels.get(0));
// } else {
// CattleResumeEntity entity = new CattleResumeEntity();
// entity.setRegistrationNo(epc);
// entity.setIndividualNo("");
// emitter.onNext(entity);
// }
// } catch (Exception e) {
// emitter.onError(e);
// }
//
// }).compose(RxUtils.bindToLifecycle(getLifecycleProvider()))
// .compose(RxUtils.schedulersTransformer()).compose(RxUtils.exceptionTransformer())
// .doOnSubscribe(disposable -> {
// })
// .subscribe((Consumer<CattleResumeEntity>) response -> {
// epcList.add(response.getIndividualNo() + "----" + response.getRegistrationNo());
// map.put(rfidTag, epcList.size() - 1);
// }, (Consumer<ResponseThrowable>) throwable -> {
// dismissDialog();
// ToastUtils.showShort(throwable.message);
// }));
}
}
else
{
ToastUtils
.
showShort
(
"盘点到标签:"
+
epc
+
"|停止盘点"
);
initDataForRfid
(
epc
);
}
}
@Override
...
...
@@ -498,13 +571,22 @@ public class BasicsCollectVM extends BaseViewModel<Repository> implements OnInve
RxBus
.
getDefault
().
toObservable
(
EventMsg
.
class
).
subscribe
(
eventType
->
{
if
(
eventType
.
getAction
().
equals
(
EventTag
.
EVENT_WEIGHT_DATA_BASICS
))
{
Double
weightNum
=
Double
.
parseDouble
(
eventType
.
getObj
().
toString
().
trim
());
weight
.
set
(
eventType
.
getObj
().
toString
());
if
(
weightNum
>
25
)
{
scanRfid
();
isWeightScan
=
false
;
}
else
{
String
lastWeight
=
weight
.
get
();
if
(!
StringUtils
.
isEmpty
(
lastWeight
)
&&
!
lastWeight
.
equals
(
"----"
)
&&
Double
.
parseDouble
(
lastWeight
)
>
25
)
{
lastGainWeight
.
set
(
0.0
);
adgGainWeight
.
set
(
0.0
);
totalGainWeight
.
set
(
0.0
);
clearTempInfo
();
onNotifyAllEvent
.
setValue
(
true
);
}
isWeightScan
=
true
;
}
weight
.
set
(
eventType
.
getObj
().
toString
());
}
});
RxSubscriptions
.
add
(
weightBus
);
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/vm/WeightManVM.java
View file @
52860942
...
...
@@ -53,7 +53,9 @@ import java.text.SimpleDateFormat;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
cn.hutool.core.util.IdUtil
;
import
io.reactivex.disposables.Disposable
;
...
...
@@ -89,6 +91,7 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
public
SingleLiveEvent
<
Boolean
>
onCardClickEvent
=
new
SingleLiveEvent
<>();
public
SingleLiveEvent
<
Boolean
>
onTagClickEvent
=
new
SingleLiveEvent
<>();
public
SingleLiveEvent
<
Boolean
>
onNotifyAllEvent
=
new
SingleLiveEvent
<>();
//true是清空页面
public
SingleLiveEvent
<
List
<
String
>>
onShowEpcListEvent
=
new
SingleLiveEvent
<>();
//普通盘点模式下epc列表
public
SingleLiveEvent
<
String
>
onShowDialogEvent
=
new
SingleLiveEvent
<>();
//弹窗提示
...
...
@@ -96,7 +99,7 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
public
ObservableField
<
String
>
tag
=
new
ObservableField
<>(
""
);
public
ObservableField
<
String
>
rfid
=
new
ObservableField
<>(
""
);
public
ObservableField
<
Double
>
weight
=
new
ObservableField
<>(
325.6
);
public
ObservableField
<
Double
>
weight
=
new
ObservableField
<>(
0.0
);
public
ObservableField
<
Double
>
lastGainWeight
=
new
ObservableField
<>(
0.0
);
//上次增重
public
ObservableField
<
Double
>
adgGainWeight
=
new
ObservableField
<>(
0.0
);
//日增重
...
...
@@ -127,6 +130,9 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
private
String
rfidTag
=
""
;
//扫描到的标记
private
static
Map
<
String
,
Integer
>
map
;
//去重
private
ArrayList
<
String
>
epcList
;
private
Disposable
weightBus
;
private
boolean
isWeightScan
=
false
;
...
...
@@ -138,6 +144,9 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
//ImageView的占位图片,可以解决RecyclerView中图片错误问题
drawableImg
=
ContextCompat
.
getDrawable
(
getApplication
(),
R
.
drawable
.
no_image
);
map
=
new
HashMap
<>();
epcList
=
new
ArrayList
<>();
soundPool
=
new
SoundPool
(
2
,
AudioManager
.
STREAM_MUSIC
,
5
);
musicId
=
new
SparseIntArray
();
musicId
.
put
(
1
,
soundPool
.
load
(
getApplication
(),
R
.
raw
.
readcard
,
1
));
...
...
@@ -190,8 +199,8 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
public
void
initDataForTag
(
String
tag
)
{
clearTempInfo
();
clearParamList
();
onNotifyAllEvent
.
setValue
(
false
);
//
clearParamList();
//
onNotifyAllEvent.setValue(false);
this
.
tag
.
set
(
tag
);
Configs
.
tempTag
=
tag
;
if
(
StringUtils
.
isEmpty
(
tag
))
...
...
@@ -219,9 +228,9 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
public
void
initDataForUnid
(
Long
unid
)
{
clearTempInfo
();
clearParamList
();
// clearParamList();
// onNotifyAllEvent.setValue(false);
Configs
.
tempUnid
=
unid
;
onNotifyAllEvent
.
setValue
(
false
);
if
(
unid
==
null
)
return
;
...
...
@@ -236,8 +245,12 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
if
(!
isScan
&&
isWeightScan
)
{
clearTempInfo
();
clearParamList
();
onNotifyAllEvent
.
setValue
(
false
);
// clearParamList();
// onNotifyAllEvent.setValue(false);
if
(
Configs
.
inventoryStatus
)
{
showDialog
(
"正在扫描耳标!"
);
}
App
.
getInstance
().
getLinkage
().
startInventory
(
1
,
0
);
isScan
=
true
;
...
...
@@ -369,6 +382,11 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
@Override
public
void
call
()
{
if
(
weight
.
get
()
<
25
)
{
onShowDialogEvent
.
setValue
(
"重量非法!请先称重!"
);
return
;
}
//判断必填
for
(
GenTableColumn
gtc
:
Configs
.
weightMan
)
{
if
(
"1"
.
equals
(
gtc
.
getIsRequired
())
&&
StringUtils
.
isEmpty
(
gtc
.
getContent
()))
{
...
...
@@ -406,7 +424,7 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
@Override
public
void
onSuccess
(
List
<
WeightManEntity
>
result
)
{
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
if
(
result
!=
null
&&
result
.
size
()
>
0
)
{
//本日有过称重记录
WeightManEntity
newWeightManEntity
=
result
.
get
(
0
);
...
...
@@ -449,6 +467,8 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
@Override
public
void
call
()
{
isWeightScan
=
true
;
map
=
new
HashMap
<>();
epcList
.
clear
();
scanRfid
();
}
});
...
...
@@ -563,21 +583,39 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
App
.
getInstance
().
getLinkage
().
stopInventory
();
isScan
=
false
;
if
(
""
.
equals
(
rfidTag
))
checkEpc
(
epc
,
tid
);
if
(!
Configs
.
inventoryStatus
&&
!
""
.
equals
(
rfidTag
))
return
;
checkEpc
(
epc
,
tid
);
}
}
else
if
(
msg
.
what
==
0x222
)
{
App
.
getInstance
().
getLinkage
().
stopInventory
();
isScan
=
false
;
ToastUtils
.
showShort
(
"停止盘点"
);
dismissDialog
();
if
(
Configs
.
inventoryStatus
)
{
if
(
epcList
!=
null
&&
epcList
.
size
()
>
0
)
{
onShowEpcListEvent
.
setValue
(
epcList
);
}
else
{
onShowDialogEvent
.
setValue
(
"未扫描到标签!"
);
}
}
}
}
};
private
void
checkEpc
(
String
epc
,
String
tid
)
{
ToastUtils
.
showShort
(
"盘点到标签:"
+
epc
+
"|停止盘点"
);
rfidTag
=
epc
+
tid
;
initDataForRfid
(
epc
);
if
(
Configs
.
inventoryStatus
)
{
if
(!
map
.
containsKey
(
rfidTag
))
{
epcList
.
add
(
epc
);
map
.
put
(
rfidTag
,
epcList
.
size
()
-
1
);
}
}
else
{
ToastUtils
.
showShort
(
"盘点到标签:"
+
epc
+
"|停止盘点"
);
initDataForRfid
(
epc
);
}
}
...
...
@@ -586,15 +624,23 @@ public class WeightManVM extends BaseViewModel<Repository> implements OnInventor
super
.
registerRxBus
();
weightBus
=
RxBus
.
getDefault
().
toObservable
(
EventMsg
.
class
).
subscribe
(
eventType
->
{
if
(
eventType
.
getAction
().
equals
(
EventTag
.
EVENT_WEIGHT_DATA_
BASICS
))
{
if
(
eventType
.
getAction
().
equals
(
EventTag
.
EVENT_WEIGHT_DATA_
WEIGHT
))
{
Double
weightNum
=
Double
.
parseDouble
(
eventType
.
getObj
().
toString
().
trim
());
weight
.
set
(
weightNum
);
if
(
weightNum
>
25
)
{
scanRfid
();
isWeightScan
=
false
;
}
else
{
if
(
weight
.
get
()!=
null
&&
weight
.
get
()
>
25
)
{
lastGainWeight
.
set
(
0.0
);
adgGainWeight
.
set
(
0.0
);
totalGainWeight
.
set
(
0.0
);
clearTempInfo
();
onNotifyAllEvent
.
setValue
(
true
);
}
isWeightScan
=
true
;
}
weight
.
set
(
weightNum
);
}
});
RxSubscriptions
.
add
(
weightBus
);
...
...
app/src/main/java/com/phlx/anchorcollect/ui/login/LoginActivity.java
View file @
52860942
...
...
@@ -63,14 +63,14 @@ public class LoginActivity extends BaseActivity<ActivityLoginBinding, LoginVM> {
viewModel
.
loginType
=
loginType
;
//
downloadUrl = "http://"
//
+ SPUtils.getInstance().getString(Configs.SP_APP_IP, RetrofitClient.baseUrl)
//
+ ":" +
//
SPUtils.getInstance().getString(Configs.SP_APP_PORT, RetrofitClient.port)
//
+ Configs.downloadApk;
//
path = Environment.getExternalStorageDirectory().getAbsolutePath();
//
//
viewModel.requestVersion(this);
downloadUrl
=
"http://"
+
SPUtils
.
getInstance
().
getString
(
Configs
.
SP_APP_IP
,
RetrofitClient
.
baseUrl
)
+
":"
+
SPUtils
.
getInstance
().
getString
(
Configs
.
SP_APP_PORT
,
RetrofitClient
.
port
)
+
Configs
.
downloadApk
;
path
=
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
();
viewModel
.
requestVersion
(
this
);
}
@Override
...
...
app/src/main/java/com/phlx/anchorcollect/ui/login/LoginVM.java
View file @
52860942
...
...
@@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
import
androidx.databinding.ObservableField
;
import
androidx.databinding.ObservableInt
;
import
com.azhon.appupdate.utils.ApkUtil
;
import
com.phlx.anchorcollect.Configs
;
import
com.phlx.anchorcollect.data.Repository
;
import
com.phlx.anchorcollect.data.VMFactory
;
...
...
@@ -54,6 +55,8 @@ public class LoginVM extends BaseViewModel<Repository> {
public
ObservableField
<
String
>
password
=
new
ObservableField
<>(
""
);
//用户账号EditText监听
public
ObservableInt
clearBtnVisibility
=
new
ObservableInt
();
//版本号
public
ObservableField
<
String
>
appVersion
=
new
ObservableField
<>(
""
);
//监听密码显隐
public
SingleLiveEvent
<
Boolean
>
pSwitchEvent
=
new
SingleLiveEvent
<>();
public
SingleLiveEvent
<
Boolean
>
exitEvent
=
new
SingleLiveEvent
<>();
...
...
@@ -67,11 +70,14 @@ public class LoginVM extends BaseViewModel<Repository> {
public
LoginVM
(
@NonNull
Application
application
,
Repository
model
)
{
super
(
application
,
model
);
appVersion
.
set
(
""
+
ApkUtil
.
getVersionName
(
getApplication
()));
// 从本地取得数据绑定到View层
userName
.
set
(
model
.
getUserName
());
password
.
set
(
model
.
getPassword
());
userName
.
set
(
"dzy"
);
// userName.set("dzy");
// password.set("123456");
userName
.
set
(
"ewei"
);
password
.
set
(
"123456"
);
}
...
...
app/src/main/java/com/phlx/anchorcollect/ui/main/MainActivity.java
View file @
52860942
...
...
@@ -160,6 +160,8 @@ public class MainActivity extends BaseActivity<ActivityMainBinding, MainVM> {
}
else
{
App
.
getInstance
().
getLinkage
().
stopInventory
();
}
//先看缓存的盘点模式,true普通盘点-多次,false 盘到最多数量的标签-一次
viewModel
.
setInventoryStatus
();
ToastUtils
.
showShort
(
connectManger
.
getModuleVersion
());
//设置盘点内容:Epc + Tid
...
...
@@ -170,6 +172,8 @@ public class MainActivity extends BaseActivity<ActivityMainBinding, MainVM> {
App
.
getInstance
().
getLinkage
().
Radio_SetInventoryParams
(
inventoryParams
);
}
@Override
public
void
initViewObservable
()
{
super
.
initViewObservable
();
...
...
app/src/main/java/com/phlx/anchorcollect/ui/main/MainVM.java
View file @
52860942
...
...
@@ -5,15 +5,18 @@ import android.view.View;
import
androidx.annotation.NonNull
;
import
com.phlx.anchorcollect.App
;
import
com.phlx.anchorcollect.Configs
;
import
com.phlx.anchorcollect.data.Repository
;
import
com.phlx.anchorcollect.db.DbUtil
;
import
com.phlx.anchorcollect.entity.DictEntity
;
import
com.phlx.anchorcollect.ui.base.MainBarVM
;
import
com.uhf.structures.FilterParams
;
import
me.goldze.mvvmhabit.binding.command.BindingAction
;
import
me.goldze.mvvmhabit.binding.command.BindingCommand
;
import
me.goldze.mvvmhabit.bus.event.SingleLiveEvent
;
import
me.goldze.mvvmhabit.utils.SPUtils
;
import
me.goldze.mvvmhabit.utils.StringUtils
;
import
me.goldze.mvvmhabit.utils.ToastUtils
;
...
...
@@ -39,6 +42,46 @@ public class MainVM extends MainBarVM<Repository> {
}
public
void
setInventoryStatus
(){
Configs
.
inventoryStatus
=
SPUtils
.
getInstance
().
getBoolean
(
Configs
.
SP_INVENTORY_STATUS
,
false
);
if
(!
Configs
.
inventoryStatus
){
setSpecialInventoryFilter
();
}
}
/**
* 设置为标签最多的盘点
*
* @return
*/
private
int
setSpecialInventoryFilter
()
{
int
tsh
=
10
;
int
maxRepeat
=
1
;
int
cacheTime
=
0
;
int
maxMonitorTagInRangeTimeMs
=
400
;
int
maxMonitorTagOutRangeTimeMs
=
200
;
int
filterMode
=
2
;
maxRepeat
|=
(
filterMode
<<
14
);
return
setInventoryFilter
(
tsh
,
maxRepeat
,
cacheTime
,
maxMonitorTagInRangeTimeMs
,
maxMonitorTagOutRangeTimeMs
);
}
/**
* 设置盘点过滤门限值
*
* @param threshold 过滤门限,最大值为 10
* @param maxRepeatTimes 最大上报次数
* @param maxCacheTimeMs 最大缓存时间(ms)
* @return 0--成功 非零--失败
*/
public
int
setInventoryFilter
(
int
threshold
,
int
maxRepeatTimes
,
int
maxCacheTimeMs
,
int
maxMonitorTagInRangeTimeMs
,
int
maxMonitorTagOutRangeTimeMs
)
{
FilterParams
filterParams
=
new
FilterParams
();
filterParams
.
setThreshold
(
threshold
);
filterParams
.
setFilerFlag
(
maxRepeatTimes
);
filterParams
.
setMaxCacheTimeMs
(
maxCacheTimeMs
);
filterParams
.
setMaxMonitorTagInRangeTimeMs
(
maxMonitorTagInRangeTimeMs
);
filterParams
.
setMaxMonitorTagOutRangeTimeMs
(
maxMonitorTagOutRangeTimeMs
);
return
App
.
getInstance
().
getLinkage
().
setInventoryFilter
(
filterParams
);
}
//基础信息
public
BindingCommand
OnBaseArchivesClickCommand
=
new
BindingCommand
(
new
BindingAction
()
{
...
...
app/src/main/java/com/phlx/anchorcollect/ui/setting/SettingVM.java
View file @
52860942
...
...
@@ -23,6 +23,7 @@ import androidx.databinding.ObservableList;
import
com.google.gson.Gson
;
import
com.phlx.anchorcollect.App
;
import
com.phlx.anchorcollect.BR
;
import
com.phlx.anchorcollect.Configs
;
import
com.phlx.anchorcollect.R
;
import
com.phlx.anchorcollect.ble.BluetoothEntity
;
import
com.phlx.anchorcollect.bt.BtService
;
...
...
@@ -53,6 +54,7 @@ import com.phlx.anchorcollect.rfid.InventoryManger;
import
com.phlx.anchorcollect.rfid.ModuleManager
;
import
com.phlx.anchorcollect.util.BaseImageUtils
;
import
com.phlx.anchorcollect.util.TextUtil
;
import
com.uhf.structures.FilterParams
;
import
com.uhf.structures.InventoryData
;
import
com.uhf.structures.InventoryParams
;
import
com.uhf.structures.OnInventoryListener
;
...
...
@@ -80,6 +82,7 @@ import me.goldze.mvvmhabit.bus.event.SingleLiveEvent;
import
me.goldze.mvvmhabit.http.ResponseThrowable
;
import
me.goldze.mvvmhabit.utils.KLog
;
import
me.goldze.mvvmhabit.utils.RxUtils
;
import
me.goldze.mvvmhabit.utils.SPUtils
;
import
me.tatarka.bindingcollectionadapter2.ItemBinding
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
...
...
@@ -111,6 +114,7 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
//功率
public
ObservableField
<
String
>
power
=
new
ObservableField
<>(
""
);
public
ObservableField
<
Boolean
>
inventoryTypeStatus
=
new
ObservableField
<>(
false
);
private
Disposable
weightBus
;
...
...
@@ -124,7 +128,7 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
private
void
initData
()
{
inventoryTypeStatus
.
set
(
SPUtils
.
getInstance
().
getBoolean
(
Configs
.
SP_INVENTORY_STATUS
,
false
));
}
//获取功率
...
...
@@ -232,13 +236,26 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
}
});
public
BindingCommand
inventoryTypeChoiceOnClick
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
Configs
.
inventoryStatus
=
inventoryTypeStatus
.
get
();
if
(
inventoryTypeStatus
.
get
())
{
setGeneralInventoryFilter
();
}
else
{
setSpecialInventoryFilter
();
}
SPUtils
.
getInstance
().
put
(
Configs
.
SP_INVENTORY_STATUS
,
Configs
.
inventoryStatus
);
}
});
public
void
itemOnClick
(
BluetoothEntity
btEntity
)
{
BTManager
.
getInstance
().
stopDiscovery
();
stopBtService
();
bluetoothEntity
=
btEntity
;
//
showDialog("正在链接蓝牙...");
showDialog
(
"正在链接蓝牙..."
);
Intent
intent
=
new
Intent
(
getApplication
(),
BtService
.
class
);
intent
.
putExtra
(
"device"
,
bluetoothEntity
.
getBluetoothDevice
());
...
...
@@ -273,6 +290,57 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
}
}
/**
* 设置为标签最多的盘点
*
* @return
*/
private
int
setSpecialInventoryFilter
()
{
int
tsh
=
10
;
int
maxRepeat
=
1
;
int
cacheTime
=
0
;
int
maxMonitorTagInRangeTimeMs
=
400
;
int
maxMonitorTagOutRangeTimeMs
=
200
;
int
filterMode
=
2
;
maxRepeat
|=
(
filterMode
<<
14
);
return
setInventoryFilter
(
tsh
,
maxRepeat
,
cacheTime
,
maxMonitorTagInRangeTimeMs
,
maxMonitorTagOutRangeTimeMs
);
}
/**
* 设置为普通盘点
*
* @return
*/
private
int
setGeneralInventoryFilter
()
{
int
tsh
=
0
;
int
maxRepeat
=
1
;
int
cacheTime
=
0
;
int
maxMonitorTagInRangeTimeMs
=
0
;
int
maxMonitorTagOutRangeTimeMs
=
0
;
int
filterMode
=
0
;
maxRepeat
|=
(
filterMode
<<
14
);
return
setInventoryFilter
(
tsh
,
maxRepeat
,
cacheTime
,
maxMonitorTagInRangeTimeMs
,
maxMonitorTagOutRangeTimeMs
);
}
/**
* 设置盘点过滤门限值
*
* @param threshold 过滤门限,最大值为 10
* @param maxRepeatTimes 最大上报次数
* @param maxCacheTimeMs 最大缓存时间(ms)
* @return 0--成功 非零--失败
*/
public
int
setInventoryFilter
(
int
threshold
,
int
maxRepeatTimes
,
int
maxCacheTimeMs
,
int
maxMonitorTagInRangeTimeMs
,
int
maxMonitorTagOutRangeTimeMs
)
{
FilterParams
filterParams
=
new
FilterParams
();
filterParams
.
setThreshold
(
threshold
);
filterParams
.
setFilerFlag
(
maxRepeatTimes
);
filterParams
.
setMaxCacheTimeMs
(
maxCacheTimeMs
);
filterParams
.
setMaxMonitorTagInRangeTimeMs
(
maxMonitorTagInRangeTimeMs
);
filterParams
.
setMaxMonitorTagOutRangeTimeMs
(
maxMonitorTagOutRangeTimeMs
);
return
App
.
getInstance
().
getLinkage
().
setInventoryFilter
(
filterParams
);
}
@Override
public
void
onDiscoveryError
(
int
errorCode
,
@NonNull
String
errorMsg
)
{
switch
(
errorCode
)
{
...
...
@@ -353,8 +421,9 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
RxBus
.
getDefault
().
toObservable
(
EventMsg
.
class
).
subscribe
(
eventType
->
{
if
(
eventType
.
getAction
().
equals
(
EventTag
.
EVENT_BT_SUCC
))
{
ToastUtils
.
showShort
(
"蓝牙链接成功"
);
myHandler
.
sendEmptyMessage
(
0
);
// closeEvent.call();
}
else
if
(
eventType
.
getAction
().
equals
(
EventTag
.
EVENT_BT_FAIL
))
{
}
else
if
(
eventType
.
getAction
().
equals
(
EventTag
.
EVENT_BT_FAIL
))
{
ToastUtils
.
showShort
(
"蓝牙链接失败"
);
}
});
...
...
@@ -366,7 +435,15 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
super
.
removeRxBus
();
RxSubscriptions
.
remove
(
weightBus
);
}
@SuppressLint
(
"HandlerLeak"
)
private
Handler
myHandler
=
new
Handler
(){
@Override
public
void
handleMessage
(
@NonNull
Message
msg
)
{
super
.
handleMessage
(
msg
);
dismissDialog
();
finish
();
}
};
}
app/src/main/java/com/phlx/anchorcollect/util/ImageUtils.java
0 → 100644
View file @
52860942
package
com
.
phlx
.
anchorcollect
.
util
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.widget.Toast
;
import
androidx.annotation.Nullable
;
import
androidx.core.graphics.PathUtils
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.load.DataSource
;
import
com.bumptech.glide.load.engine.GlideException
;
import
com.bumptech.glide.request.RequestListener
;
import
com.bumptech.glide.request.target.Target
;
import
java.io.File
;
import
me.goldze.mvvmhabit.utils.ToastUtils
;
public
class
ImageUtils
{
/**
* 下载到本地
* @param context 上下文
* @param url 网络图
*/
private
void
saveImgToLocal
(
Context
context
,
String
url
)
{
//如果是网络图片,抠图的结果,需要先保存到本地
Glide
.
with
(
context
)
.
downloadOnly
()
.
load
(
url
)
.
listener
(
new
RequestListener
<
File
>()
{
@Override
public
boolean
onLoadFailed
(
@Nullable
GlideException
e
,
Object
model
,
Target
<
File
>
target
,
boolean
isFirstResource
)
{
Toast
.
makeText
(
context
,
"下载失败"
,
Toast
.
LENGTH_SHORT
).
show
();
return
false
;
}
@Override
public
boolean
onResourceReady
(
File
resource
,
Object
model
,
Target
<
File
>
target
,
DataSource
dataSource
,
boolean
isFirstResource
)
{
Toast
.
makeText
(
context
,
"下载成功"
,
Toast
.
LENGTH_SHORT
).
show
();
saveToAlbum
(
context
,
resource
.
getAbsolutePath
());
return
false
;
}
})
.
preload
();
}
/**
* 保存到相册中
* @param context 上下文
* @param srcPath 网络图保存到本地的缓存文件路径
*/
private
void
saveToAlbum
(
Context
context
,
String
srcPath
)
{
// String dcimPath = PathUtils.getExternalDcimPath();
// File file = new File(dcimPath, "content_" + System.currentTimeMillis() + ".png");
// boolean isCopySuccess = FileUtils.copy(srcPath, file.getAbsolutePath());
// if (isCopySuccess) {
// //发送广播通知
// context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + file.getAbsolutePath())));
// ToastUtils.showShort("图片保存到相册成功");
// } else {
// ToastUtils.showShort("图片保存到相册失败");
// }
}
}
app/src/main/res/layout/activity_login.xml
View file @
52860942
...
...
@@ -20,7 +20,7 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"@dimen/dp_40"
android:text=
"@string/app"
android:text=
"@string/app
_name
"
android:textColor=
"@color/white"
android:drawablePadding=
"@dimen/dp_10"
android:textSize=
"@dimen/sp_20"
...
...
@@ -30,6 +30,20 @@
binding:layout_constraintRight_toRightOf=
"parent"
binding:layout_constraintTop_toTopOf=
"parent"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/logo_version"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"@dimen/dp_20"
android:layout_marginRight=
"@dimen/dp_30"
android:text=
"@{viewModel.appVersion}"
android:textColor=
"@color/white"
android:drawablePadding=
"@dimen/dp_10"
android:textSize=
"@dimen/sp_12"
binding:layout_constraintBottom_toBottomOf=
"parent"
binding:layout_constraintRight_toRightOf=
"parent"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/login_frame"
android:layout_width=
"@dimen/dp_300"
...
...
app/src/main/res/layout/activity_setting.xml
View file @
52860942
...
...
@@ -116,5 +116,18 @@
binding:onClickCommand=
"@{viewModel.setPowerOnClick}"
/>
<CheckBox
android:id=
"@+id/cb_inventory_type"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_20"
android:text=
"多次盘点"
android:textColor=
"@color/white"
android:checked=
"@={viewModel.inventoryTypeStatus}"
binding:layout_constraintTop_toBottomOf=
"@+id/btn_get_power"
binding:layout_constraintLeft_toLeftOf=
"@+id/btn_get_power"
binding:onClickCommand=
"@{viewModel.inventoryTypeChoiceOnClick}"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ 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