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
429a4804
Commit
429a4804
authored
Feb 22, 2022
by
hywang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加配种记录功能
parent
199e5b54
Hide whitespace changes
Inline
Side-by-side
Showing
81 changed files
with
6289 additions
and
644 deletions
+6289
-644
build.gradle
app/build.gradle
+4
-0
Configs.java
app/src/main/java/com/phlx/anchorcollect/Configs.java
+1
-0
Repository.java
...src/main/java/com/phlx/anchorcollect/data/Repository.java
+44
-0
VMFactory.java
app/src/main/java/com/phlx/anchorcollect/data/VMFactory.java
+4
-0
ApiService.java
...ain/java/com/phlx/anchorcollect/data/http/ApiService.java
+72
-3
HttpDataSource.java
...java/com/phlx/anchorcollect/data/http/HttpDataSource.java
+50
-0
HttpDataSourceImpl.java
.../com/phlx/anchorcollect/data/http/HttpDataSourceImpl.java
+48
-0
DaoMaster.java
...rc/main/java/com/phlx/anchorcollect/db/gen/DaoMaster.java
+9
-3
DaoSession.java
...c/main/java/com/phlx/anchorcollect/db/gen/DaoSession.java
+42
-14
PerformanceEntityDao.java
...a/com/phlx/anchorcollect/db/gen/PerformanceEntityDao.java
+0
-504
BreedingRecordDetailEntity.java
...phlx/anchorcollect/entity/BreedingRecordDetailEntity.java
+364
-0
BreedingRecordEntity.java
...a/com/phlx/anchorcollect/entity/BreedingRecordEntity.java
+270
-0
PerformanceEntity.java
...java/com/phlx/anchorcollect/entity/PerformanceEntity.java
+20
-6
BasicsCollectFragment.java
...phlx/anchorcollect/ui/fragment/BasicsCollectFragment.java
+44
-5
BreedingRecordFragment.java
...hlx/anchorcollect/ui/fragment/BreedingRecordFragment.java
+440
-0
PerformanceFragment.java
...m/phlx/anchorcollect/ui/fragment/PerformanceFragment.java
+276
-0
CollectGridItem.java
.../phlx/anchorcollect/ui/fragment/list/CollectGridItem.java
+28
-2
BreedingRecordVM.java
...m/phlx/anchorcollect/ui/fragment/vm/BreedingRecordVM.java
+439
-0
CollectVM.java
...java/com/phlx/anchorcollect/ui/fragment/vm/CollectVM.java
+49
-50
PerformanceVM.java
.../com/phlx/anchorcollect/ui/fragment/vm/PerformanceVM.java
+83
-5
LoginVM.java
...rc/main/java/com/phlx/anchorcollect/ui/login/LoginVM.java
+21
-7
MainActivity.java
...ain/java/com/phlx/anchorcollect/ui/main/MainActivity.java
+71
-7
MainVM.java
app/src/main/java/com/phlx/anchorcollect/ui/main/MainVM.java
+22
-0
SettingVM.java
...ain/java/com/phlx/anchorcollect/ui/setting/SettingVM.java
+549
-10
SplashVM.java
.../main/java/com/phlx/anchorcollect/ui/splash/SplashVM.java
+14
-7
DateUtils.java
app/src/main/java/com/phlx/anchorcollect/util/DateUtils.java
+16
-0
EntityUtils.java
...rc/main/java/com/phlx/anchorcollect/util/EntityUtils.java
+1
-4
StringUtil.java
...src/main/java/com/phlx/anchorcollect/util/StringUtil.java
+38
-14
activity_setting.xml
app/src/main/res/layout/activity_setting.xml
+35
-1
fragment_breeding_record.xml
app/src/main/res/layout/fragment_breeding_record.xml
+163
-0
fragment_performance.xml
app/src/main/res/layout/fragment_performance.xml
+4
-1
item_collect_grid.xml
app/src/main/res/layout/item_collect_grid.xml
+12
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
.gitignore
mycontrol/.gitignore
+1
-0
build.gradle
mycontrol/build.gradle
+32
-0
proguard-rules.pro
mycontrol/proguard-rules.pro
+25
-0
ExampleInstrumentedTest.java
...t/java/com/lingber/mycontrol/ExampleInstrumentedTest.java
+26
-0
AndroidManifest.xml
mycontrol/src/main/AndroidManifest.xml
+10
-0
DataGridView.java
...java/com/lingber/mycontrol/datagridview/DataGridView.java
+888
-0
LingberUtil.java
.../java/com/lingber/mycontrol/datagridview/LingberUtil.java
+100
-0
PageNumberSelector.java
...om/lingber/mycontrol/datagridview/PageNumberSelector.java
+253
-0
RecyclerviewAdapter.java
...m/lingber/mycontrol/datagridview/RecyclerviewAdapter.java
+570
-0
ILanguageView.java
...om/lingber/mycontrol/datagridview/i18n/ILanguageView.java
+22
-0
LangTextView.java
...com/lingber/mycontrol/datagridview/i18n/LangTextView.java
+96
-0
StringUtil.java
.../lingber/mycontrol/datagridview/i18n/Util/StringUtil.java
+27
-0
ViewUtil.java
...om/lingber/mycontrol/datagridview/i18n/Util/ViewUtil.java
+21
-0
Keyboard.java
...rc/main/java/com/lingber/mycontrol/keyboard/Keyboard.java
+173
-0
ic_back.xml
mycontrol/src/main/res/drawable/ic_back.xml
+4
-0
ic_sure.xml
mycontrol/src/main/res/drawable/ic_sure.xml
+5
-0
lingber_border_shape.xml
mycontrol/src/main/res/drawable/lingber_border_shape.xml
+16
-0
lingber_checkbox_style.xml
mycontrol/src/main/res/drawable/lingber_checkbox_style.xml
+10
-0
lingber_date_picker_unavailable_msk_shape.xml
...es/drawable/lingber_date_picker_unavailable_msk_shape.xml
+6
-0
lingber_edittext_shape.xml
mycontrol/src/main/res/drawable/lingber_edittext_shape.xml
+7
-0
lingber_ic_add.xml
mycontrol/src/main/res/drawable/lingber_ic_add.xml
+12
-0
lingber_ic_backspacing.xml
mycontrol/src/main/res/drawable/lingber_ic_backspacing.xml
+9
-0
lingber_ic_checkbox_selected.xml
...ol/src/main/res/drawable/lingber_ic_checkbox_selected.xml
+12
-0
lingber_ic_checkbox_unselected.xml
.../src/main/res/drawable/lingber_ic_checkbox_unselected.xml
+11
-0
lingber_ic_down.xml
mycontrol/src/main/res/drawable/lingber_ic_down.xml
+12
-0
lingber_ic_downward.xml
mycontrol/src/main/res/drawable/lingber_ic_downward.xml
+4
-0
lingber_ic_fast_add.xml
mycontrol/src/main/res/drawable/lingber_ic_fast_add.xml
+12
-0
lingber_ic_fast_added.xml
mycontrol/src/main/res/drawable/lingber_ic_fast_added.xml
+9
-0
lingber_ic_sub.xml
mycontrol/src/main/res/drawable/lingber_ic_sub.xml
+12
-0
lingber_ic_up.xml
mycontrol/src/main/res/drawable/lingber_ic_up.xml
+12
-0
lingber_keyboard_default_style.xml
.../src/main/res/drawable/lingber_keyboard_default_style.xml
+20
-0
lingber_line_shape.xml
mycontrol/src/main/res/drawable/lingber_line_shape.xml
+10
-0
lingber_page_number_bg_shape.xml
...ol/src/main/res/drawable/lingber_page_number_bg_shape.xml
+7
-0
lingber_page_number_shape.xml
...ntrol/src/main/res/drawable/lingber_page_number_shape.xml
+7
-0
lingber_ripple_bg_btn.xml
mycontrol/src/main/res/drawable/lingber_ripple_bg_btn.xml
+15
-0
lingber_ripple_bg_btn_unavailable.xml
...c/main/res/drawable/lingber_ripple_bg_btn_unavailable.xml
+15
-0
lingber_textview_shape.xml
mycontrol/src/main/res/drawable/lingber_textview_shape.xml
+6
-0
lingber_datagridview_template.xml
...rol/src/main/res/layout/lingber_datagridview_template.xml
+94
-0
lingber_keyboard_template.xml
mycontrol/src/main/res/layout/lingber_keyboard_template.xml
+110
-0
lingber_number_controller_template.xml
...rc/main/res/layout/lingber_number_controller_template.xml
+28
-0
lingber_pagenumber_selector.xml
...ntrol/src/main/res/layout/lingber_pagenumber_selector.xml
+171
-0
lingber_recyclerview.xml
mycontrol/src/main/res/layout/lingber_recyclerview.xml
+13
-0
colors.xml
mycontrol/src/main/res/values/colors.xml
+10
-0
ids.xml
mycontrol/src/main/res/values/ids.xml
+72
-0
strings.xml
mycontrol/src/main/res/values/strings.xml
+3
-0
styles.xml
mycontrol/src/main/res/values/styles.xml
+59
-0
ExampleUnitTest.java
.../src/test/java/com/lingber/mycontrol/ExampleUnitTest.java
+17
-0
settings.gradle
settings.gradle
+1
-1
No files found.
app/build.gradle
View file @
429a4804
...
...
@@ -78,6 +78,7 @@ dependencies {
implementation
'com.contrarywind:Android-PickerView:4.1.9'
implementation
project
(
':mvvmhabit'
)
implementation
project
(
':appupdateX'
)
implementation
project
(
':mycontrol'
)
implementation
files
(
'libs/uhf.jar'
)
//生成主键
...
...
@@ -105,4 +106,7 @@ dependencies {
//ToastUtils
implementation
'com.github.getActivity:ToastUtils:9.2'
//表格
// implementation 'com.github.Lingber:Android_DataGridView:1.01'
}
\ No newline at end of file
app/src/main/java/com/phlx/anchorcollect/Configs.java
View file @
429a4804
...
...
@@ -71,6 +71,7 @@ public class Configs {
public
static
final
String
TREATMENT_RECORD
=
"treatment_record"
;
public
static
final
String
IMMUN_RECORD
=
"immun_record"
;
public
static
final
String
BREEDING_RECORD
=
"breeding_record"
;
public
static
final
String
BREEDING_RECORD_DETAIL
=
"breeding_record_detail"
;
//0 高频,1低频
public
static
String
FREQUENCY_CONFIG
=
"1"
;
...
...
app/src/main/java/com/phlx/anchorcollect/data/Repository.java
View file @
429a4804
...
...
@@ -5,10 +5,13 @@ import androidx.annotation.NonNull;
import
com.phlx.anchorcollect.data.http.HttpDataSource
;
import
com.phlx.anchorcollect.data.local.LocalDataSource
;
import
com.phlx.anchorcollect.entity.BreedingRecordDetailEntity
;
import
com.phlx.anchorcollect.entity.BreedingRecordEntity
;
import
com.phlx.anchorcollect.entity.CattleResumeEntity
;
import
com.phlx.anchorcollect.entity.DictEntity
;
import
com.phlx.anchorcollect.entity.GenData
;
import
com.phlx.anchorcollect.entity.LoginData
;
import
com.phlx.anchorcollect.entity.PerformanceEntity
;
import
com.phlx.anchorcollect.params.CollectResponse
;
import
com.phlx.anchorcollect.params.ListResponse
;
...
...
@@ -78,9 +81,50 @@ public class Repository extends BaseModel implements HttpDataSource, LocalDataSo
return
mHttpDataSource
.
downloadDict
();
}
@Override
public
Observable
<
ListResponse
<
PerformanceEntity
>>
downloadPerformanceList
(
Map
<
String
,
String
>
map
)
{
return
mHttpDataSource
.
downloadPerformanceList
(
map
);
}
@Override
public
Observable
<
CollectResponse
>
downloadPerformanceListSync
(
RequestBody
body
)
{
return
mHttpDataSource
.
downloadPerformanceListSync
(
body
);
}
@Override
public
Observable
<
CollectResponse
>
uploadPerformanceList
(
RequestBody
body
)
{
return
mHttpDataSource
.
uploadPerformanceList
(
body
);
}
@Override
public
Observable
<
ListResponse
<
BreedingRecordEntity
>>
downloadBreedingRecordList
(
Map
<
String
,
String
>
map
)
{
return
mHttpDataSource
.
downloadBreedingRecordList
(
map
);
}
@Override
public
Observable
<
CollectResponse
>
downloadBreedingRecordListSync
(
RequestBody
body
)
{
return
mHttpDataSource
.
downloadBreedingRecordListSync
(
body
);
}
@Override
public
Observable
<
CollectResponse
>
uploadBreedingRecordList
(
RequestBody
body
)
{
return
mHttpDataSource
.
uploadBreedingRecordList
(
body
);
}
@Override
public
Observable
<
ListResponse
<
BreedingRecordDetailEntity
>>
downloadBreedingRecordDetailList
(
Map
<
String
,
String
>
map
)
{
return
mHttpDataSource
.
downloadBreedingRecordDetailList
(
map
);
}
@Override
public
Observable
<
CollectResponse
>
downloadBreedingRecordDetailListSync
(
RequestBody
body
)
{
return
mHttpDataSource
.
downloadBreedingRecordDetailListSync
(
body
);
}
@Override
public
Observable
<
CollectResponse
>
uploadBreedingRecordDetailList
(
RequestBody
body
)
{
return
mHttpDataSource
.
uploadBreedingRecordDetailList
(
body
);
}
/****************************************************************************/
...
...
app/src/main/java/com/phlx/anchorcollect/data/VMFactory.java
View file @
429a4804
...
...
@@ -9,6 +9,7 @@ import androidx.lifecycle.ViewModel;
import
androidx.lifecycle.ViewModelProvider
;
import
com.phlx.anchorcollect.ui.fragment.vm.BasicsCollectVM
;
import
com.phlx.anchorcollect.ui.fragment.vm.BreedingRecordVM
;
import
com.phlx.anchorcollect.ui.fragment.vm.CollectListVM
;
import
com.phlx.anchorcollect.ui.fragment.vm.CollectVM
;
import
com.phlx.anchorcollect.ui.fragment.vm.PerformanceVM
;
...
...
@@ -80,6 +81,9 @@ public class VMFactory extends ViewModelProvider.NewInstanceFactory {
}
else
if
(
modelClass
.
isAssignableFrom
(
PerformanceVM
.
class
))
{
return
(
T
)
new
PerformanceVM
(
mApplication
,
repository
);
}
else
if
(
modelClass
.
isAssignableFrom
(
BreedingRecordVM
.
class
))
{
return
(
T
)
new
BreedingRecordVM
(
mApplication
,
repository
);
}
else
if
(
modelClass
.
isAssignableFrom
(
CollectVM
.
class
))
{
...
...
app/src/main/java/com/phlx/anchorcollect/data/http/ApiService.java
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
data
.
http
;
import
com.phlx.anchorcollect.entity.BreedingRecordDetailEntity
;
import
com.phlx.anchorcollect.entity.BreedingRecordEntity
;
import
com.phlx.anchorcollect.entity.CattleResumeEntity
;
import
com.phlx.anchorcollect.entity.DictEntity
;
import
com.phlx.anchorcollect.entity.GenData
;
import
com.phlx.anchorcollect.entity.LoginData
;
import
com.phlx.anchorcollect.entity.PerformanceEntity
;
import
com.phlx.anchorcollect.params.CollectResponse
;
import
com.phlx.anchorcollect.params.ListResponse
;
...
...
@@ -53,6 +56,12 @@ public interface ApiService {
@GET
(
"/api/gen/list"
)
Observable
<
CollectResponse
<
GenData
>>
genGet
();
/**
* 获取字典项列表
*/
@POST
(
"/api/dict/data/list"
)
Observable
<
ListResponse
<
DictEntity
>>
downloadDict
();
/**
* 获取基础信息列表
* SyncState 0根据记录更新,1重新更新
...
...
@@ -70,10 +79,70 @@ public interface ApiService {
Observable
<
CollectResponse
>
downloadCattleListSync
(
@Body
RequestBody
body
);
/**
* 获取字典项列表
* 获取性能测定列表
* SyncState 0根据记录更新,1重新更新
*/
@POST
(
"/api/dict/data/list"
)
Observable
<
ListResponse
<
DictEntity
>>
downloadDict
();
@FormUrlEncoded
@POST
(
"/api/performance/list"
)
Observable
<
ListResponse
<
PerformanceEntity
>>
downloadPerformanceList
(
@FieldMap
Map
<
String
,
String
>
map
);
/**
* 获取性能测定列表-返回
*/
@Headers
({
"Content-Type: application/json"
,
"Accept: application/json"
})
@POST
(
"/api/performance/sync/add"
)
Observable
<
CollectResponse
>
downloadPerformanceListSync
(
@Body
RequestBody
body
);
/**
* 上传性能测定列表
*/
@Headers
({
"Content-Type: application/json"
,
"Accept: application/json"
})
@POST
(
"/api/performance/add"
)
Observable
<
CollectResponse
>
uploadPerformanceList
(
@Body
RequestBody
body
);
/**
* 获取-配种记录主表-列表
* SyncState 0根据记录更新,1重新更新
*/
@FormUrlEncoded
@POST
(
"/api/cattlematingMaster/list"
)
Observable
<
ListResponse
<
BreedingRecordEntity
>>
downloadBreedingRecordList
(
@FieldMap
Map
<
String
,
String
>
map
);
/**
* 获取-配种记录主表-列表-返回
*/
@Headers
({
"Content-Type: application/json"
,
"Accept: application/json"
})
@POST
(
"/api/cattlematingMaster/sync/add"
)
Observable
<
CollectResponse
>
downloadBreedingRecordListSync
(
@Body
RequestBody
body
);
/**
* 上传-配种记录主表-列表
*/
@Headers
({
"Content-Type: application/json"
,
"Accept: application/json"
})
@POST
(
"/api/cattlematingMaster/add"
)
Observable
<
CollectResponse
>
uploadBreedingRecordList
(
@Body
RequestBody
body
);
/**
* 获取-配种记录子表-列表
* SyncState 0根据记录更新,1重新更新
*/
@FormUrlEncoded
@POST
(
"/api/cattlematingDetaill/list"
)
Observable
<
ListResponse
<
BreedingRecordDetailEntity
>>
downloadBreedingRecordDetailList
(
@FieldMap
Map
<
String
,
String
>
map
);
/**
* 获取-配种记录子表-列表-返回
*/
@Headers
({
"Content-Type: application/json"
,
"Accept: application/json"
})
@POST
(
"/api/cattlematingDetaill/sync/add"
)
Observable
<
CollectResponse
>
downloadBreedingRecordDetailListSync
(
@Body
RequestBody
body
);
/**
* 上传-配种记录子表-列表
*/
@Headers
({
"Content-Type: application/json"
,
"Accept: application/json"
})
@POST
(
"/api/cattlematingDetaill/add"
)
Observable
<
CollectResponse
>
uploadBreedingRecordDetailList
(
@Body
RequestBody
body
);
...
...
app/src/main/java/com/phlx/anchorcollect/data/http/HttpDataSource.java
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
data
.
http
;
import
com.phlx.anchorcollect.entity.BreedingRecordDetailEntity
;
import
com.phlx.anchorcollect.entity.BreedingRecordEntity
;
import
com.phlx.anchorcollect.entity.CattleResumeEntity
;
import
com.phlx.anchorcollect.entity.DictEntity
;
import
com.phlx.anchorcollect.entity.GenData
;
import
com.phlx.anchorcollect.entity.LoginData
;
import
com.phlx.anchorcollect.entity.PerformanceEntity
;
import
com.phlx.anchorcollect.params.CollectResponse
;
import
com.phlx.anchorcollect.params.ListResponse
;
...
...
@@ -16,6 +19,7 @@ import okhttp3.RequestBody;
import
retrofit2.http.Body
;
import
retrofit2.http.FieldMap
;
import
retrofit2.http.FormUrlEncoded
;
import
retrofit2.http.Headers
;
import
retrofit2.http.POST
;
/**
...
...
@@ -60,6 +64,52 @@ public interface HttpDataSource {
*/
Observable
<
ListResponse
<
DictEntity
>>
downloadDict
();
/**
* 获取性能测定列表
* SyncState 0根据记录更新,1重新更新
*/
Observable
<
ListResponse
<
PerformanceEntity
>>
downloadPerformanceList
(
@FieldMap
Map
<
String
,
String
>
map
);
/**
* 获取性能测定列表-返回
*/
Observable
<
CollectResponse
>
downloadPerformanceListSync
(
@Body
RequestBody
body
);
/**
* 上传性能测定列表
*/
Observable
<
CollectResponse
>
uploadPerformanceList
(
@Body
RequestBody
body
);
/**
* 获取-配种记录主表-列表
* SyncState 0根据记录更新,1重新更新
*/
Observable
<
ListResponse
<
BreedingRecordEntity
>>
downloadBreedingRecordList
(
@FieldMap
Map
<
String
,
String
>
map
);
/**
* 获取-配种记录主表-列表-返回
*/
Observable
<
CollectResponse
>
downloadBreedingRecordListSync
(
@Body
RequestBody
body
);
/**
* 上传-配种记录主表-列表
*/
Observable
<
CollectResponse
>
uploadBreedingRecordList
(
@Body
RequestBody
body
);
/**
* 获取-配种记录子表-列表
* SyncState 0根据记录更新,1重新更新
*/
Observable
<
ListResponse
<
BreedingRecordDetailEntity
>>
downloadBreedingRecordDetailList
(
@FieldMap
Map
<
String
,
String
>
map
);
/**
* 获取-配种记录子表-列表-返回
*/
Observable
<
CollectResponse
>
downloadBreedingRecordDetailListSync
(
@Body
RequestBody
body
);
/**
* 上传-配种记录子表-列表
*/
Observable
<
CollectResponse
>
uploadBreedingRecordDetailList
(
@Body
RequestBody
body
);
}
app/src/main/java/com/phlx/anchorcollect/data/http/HttpDataSourceImpl.java
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
data
.
http
;
import
com.phlx.anchorcollect.entity.BreedingRecordDetailEntity
;
import
com.phlx.anchorcollect.entity.BreedingRecordEntity
;
import
com.phlx.anchorcollect.entity.CattleResumeEntity
;
import
com.phlx.anchorcollect.entity.DictEntity
;
import
com.phlx.anchorcollect.entity.GenData
;
import
com.phlx.anchorcollect.entity.LoginData
;
import
com.phlx.anchorcollect.entity.PerformanceEntity
;
import
com.phlx.anchorcollect.params.CollectResponse
;
import
com.phlx.anchorcollect.params.ListResponse
;
...
...
@@ -67,4 +70,49 @@ public class HttpDataSourceImpl implements HttpDataSource {
public
Observable
<
ListResponse
<
DictEntity
>>
downloadDict
()
{
return
apiService
.
downloadDict
();
}
@Override
public
Observable
<
ListResponse
<
PerformanceEntity
>>
downloadPerformanceList
(
Map
<
String
,
String
>
map
)
{
return
apiService
.
downloadPerformanceList
(
map
);
}
@Override
public
Observable
<
CollectResponse
>
downloadPerformanceListSync
(
RequestBody
body
)
{
return
apiService
.
downloadPerformanceListSync
(
body
);
}
@Override
public
Observable
<
CollectResponse
>
uploadPerformanceList
(
RequestBody
body
)
{
return
apiService
.
uploadPerformanceList
(
body
);
}
@Override
public
Observable
<
ListResponse
<
BreedingRecordEntity
>>
downloadBreedingRecordList
(
Map
<
String
,
String
>
map
)
{
return
apiService
.
downloadBreedingRecordList
(
map
);
}
@Override
public
Observable
<
CollectResponse
>
downloadBreedingRecordListSync
(
RequestBody
body
)
{
return
apiService
.
downloadBreedingRecordListSync
(
body
);
}
@Override
public
Observable
<
CollectResponse
>
uploadBreedingRecordList
(
RequestBody
body
)
{
return
apiService
.
uploadBreedingRecordList
(
body
);
}
@Override
public
Observable
<
ListResponse
<
BreedingRecordDetailEntity
>>
downloadBreedingRecordDetailList
(
Map
<
String
,
String
>
map
)
{
return
apiService
.
downloadBreedingRecordDetailList
(
map
);
}
@Override
public
Observable
<
CollectResponse
>
downloadBreedingRecordDetailListSync
(
RequestBody
body
)
{
return
apiService
.
downloadBreedingRecordDetailListSync
(
body
);
}
@Override
public
Observable
<
CollectResponse
>
uploadBreedingRecordDetailList
(
RequestBody
body
)
{
return
apiService
.
uploadBreedingRecordDetailList
(
body
);
}
}
app/src/main/java/com/phlx/anchorcollect/db/gen/DaoMaster.java
View file @
429a4804
...
...
@@ -22,8 +22,11 @@ public class DaoMaster extends AbstractDaoMaster {
/** Creates underlying database table using DAOs. */
public
static
void
createAllTables
(
Database
db
,
boolean
ifNotExists
)
{
AncestryinfoEntityDao
.
createTable
(
db
,
ifNotExists
);
BreedingRecordDetailEntityDao
.
createTable
(
db
,
ifNotExists
);
BreedingRecordEntityDao
.
createTable
(
db
,
ifNotExists
);
CardEntityDao
.
createTable
(
db
,
ifNotExists
);
CattleResumeEntityDao
.
createTable
(
db
,
ifNotExists
);
DictEntityDao
.
createTable
(
db
,
ifNotExists
);
GenTableDao
.
createTable
(
db
,
ifNotExists
);
GenTableColumnDao
.
createTable
(
db
,
ifNotExists
);
ImmuneEntityDao
.
createTable
(
db
,
ifNotExists
);
...
...
@@ -31,14 +34,16 @@ public class DaoMaster extends AbstractDaoMaster {
PerformanceEntityDao
.
createTable
(
db
,
ifNotExists
);
UserRoleEntityDao
.
createTable
(
db
,
ifNotExists
);
WeightingEntityDao
.
createTable
(
db
,
ifNotExists
);
DictEntityDao
.
createTable
(
db
,
ifNotExists
);
}
/** Drops underlying database table using DAOs. */
public
static
void
dropAllTables
(
Database
db
,
boolean
ifExists
)
{
AncestryinfoEntityDao
.
dropTable
(
db
,
ifExists
);
BreedingRecordDetailEntityDao
.
dropTable
(
db
,
ifExists
);
BreedingRecordEntityDao
.
dropTable
(
db
,
ifExists
);
CardEntityDao
.
dropTable
(
db
,
ifExists
);
CattleResumeEntityDao
.
dropTable
(
db
,
ifExists
);
DictEntityDao
.
dropTable
(
db
,
ifExists
);
GenTableDao
.
dropTable
(
db
,
ifExists
);
GenTableColumnDao
.
dropTable
(
db
,
ifExists
);
ImmuneEntityDao
.
dropTable
(
db
,
ifExists
);
...
...
@@ -46,7 +51,6 @@ public class DaoMaster extends AbstractDaoMaster {
PerformanceEntityDao
.
dropTable
(
db
,
ifExists
);
UserRoleEntityDao
.
dropTable
(
db
,
ifExists
);
WeightingEntityDao
.
dropTable
(
db
,
ifExists
);
DictEntityDao
.
dropTable
(
db
,
ifExists
);
}
/**
...
...
@@ -66,8 +70,11 @@ public class DaoMaster extends AbstractDaoMaster {
public
DaoMaster
(
Database
db
)
{
super
(
db
,
SCHEMA_VERSION
);
registerDaoClass
(
AncestryinfoEntityDao
.
class
);
registerDaoClass
(
BreedingRecordDetailEntityDao
.
class
);
registerDaoClass
(
BreedingRecordEntityDao
.
class
);
registerDaoClass
(
CardEntityDao
.
class
);
registerDaoClass
(
CattleResumeEntityDao
.
class
);
registerDaoClass
(
DictEntityDao
.
class
);
registerDaoClass
(
GenTableDao
.
class
);
registerDaoClass
(
GenTableColumnDao
.
class
);
registerDaoClass
(
ImmuneEntityDao
.
class
);
...
...
@@ -75,7 +82,6 @@ public class DaoMaster extends AbstractDaoMaster {
registerDaoClass
(
PerformanceEntityDao
.
class
);
registerDaoClass
(
UserRoleEntityDao
.
class
);
registerDaoClass
(
WeightingEntityDao
.
class
);
registerDaoClass
(
DictEntityDao
.
class
);
}
public
DaoSession
newSession
()
{
...
...
app/src/main/java/com/phlx/anchorcollect/db/gen/DaoSession.java
View file @
429a4804
...
...
@@ -9,8 +9,11 @@ import org.greenrobot.greendao.identityscope.IdentityScopeType;
import
org.greenrobot.greendao.internal.DaoConfig
;
import
com.phlx.anchorcollect.entity.AncestryinfoEntity
;
import
com.phlx.anchorcollect.entity.BreedingRecordDetailEntity
;
import
com.phlx.anchorcollect.entity.BreedingRecordEntity
;
import
com.phlx.anchorcollect.entity.CardEntity
;
import
com.phlx.anchorcollect.entity.CattleResumeEntity
;
import
com.phlx.anchorcollect.entity.DictEntity
;
import
com.phlx.anchorcollect.entity.GenTable
;
import
com.phlx.anchorcollect.entity.GenTableColumn
;
import
com.phlx.anchorcollect.entity.ImmuneEntity
;
...
...
@@ -18,11 +21,13 @@ import com.phlx.anchorcollect.entity.MedicalEntity;
import
com.phlx.anchorcollect.entity.PerformanceEntity
;
import
com.phlx.anchorcollect.entity.UserRoleEntity
;
import
com.phlx.anchorcollect.entity.WeightingEntity
;
import
com.phlx.anchorcollect.entity.DictEntity
;
import
com.phlx.anchorcollect.db.gen.AncestryinfoEntityDao
;
import
com.phlx.anchorcollect.db.gen.BreedingRecordDetailEntityDao
;
import
com.phlx.anchorcollect.db.gen.BreedingRecordEntityDao
;
import
com.phlx.anchorcollect.db.gen.CardEntityDao
;
import
com.phlx.anchorcollect.db.gen.CattleResumeEntityDao
;
import
com.phlx.anchorcollect.db.gen.DictEntityDao
;
import
com.phlx.anchorcollect.db.gen.GenTableDao
;
import
com.phlx.anchorcollect.db.gen.GenTableColumnDao
;
import
com.phlx.anchorcollect.db.gen.ImmuneEntityDao
;
...
...
@@ -30,7 +35,6 @@ import com.phlx.anchorcollect.db.gen.MedicalEntityDao;
import
com.phlx.anchorcollect.db.gen.PerformanceEntityDao
;
import
com.phlx.anchorcollect.db.gen.UserRoleEntityDao
;
import
com.phlx.anchorcollect.db.gen.WeightingEntityDao
;
import
com.phlx.anchorcollect.db.gen.DictEntityDao
;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
...
...
@@ -42,8 +46,11 @@ import com.phlx.anchorcollect.db.gen.DictEntityDao;
public
class
DaoSession
extends
AbstractDaoSession
{
private
final
DaoConfig
ancestryinfoEntityDaoConfig
;
private
final
DaoConfig
breedingRecordDetailEntityDaoConfig
;
private
final
DaoConfig
breedingRecordEntityDaoConfig
;
private
final
DaoConfig
cardEntityDaoConfig
;
private
final
DaoConfig
cattleResumeEntityDaoConfig
;
private
final
DaoConfig
dictEntityDaoConfig
;
private
final
DaoConfig
genTableDaoConfig
;
private
final
DaoConfig
genTableColumnDaoConfig
;
private
final
DaoConfig
immuneEntityDaoConfig
;
...
...
@@ -51,11 +58,13 @@ public class DaoSession extends AbstractDaoSession {
private
final
DaoConfig
performanceEntityDaoConfig
;
private
final
DaoConfig
userRoleEntityDaoConfig
;
private
final
DaoConfig
weightingEntityDaoConfig
;
private
final
DaoConfig
dictEntityDaoConfig
;
private
final
AncestryinfoEntityDao
ancestryinfoEntityDao
;
private
final
BreedingRecordDetailEntityDao
breedingRecordDetailEntityDao
;
private
final
BreedingRecordEntityDao
breedingRecordEntityDao
;
private
final
CardEntityDao
cardEntityDao
;
private
final
CattleResumeEntityDao
cattleResumeEntityDao
;
private
final
DictEntityDao
dictEntityDao
;
private
final
GenTableDao
genTableDao
;
private
final
GenTableColumnDao
genTableColumnDao
;
private
final
ImmuneEntityDao
immuneEntityDao
;
...
...
@@ -63,7 +72,6 @@ public class DaoSession extends AbstractDaoSession {
private
final
PerformanceEntityDao
performanceEntityDao
;
private
final
UserRoleEntityDao
userRoleEntityDao
;
private
final
WeightingEntityDao
weightingEntityDao
;
private
final
DictEntityDao
dictEntityDao
;
public
DaoSession
(
Database
db
,
IdentityScopeType
type
,
Map
<
Class
<?
extends
AbstractDao
<?,
?>>,
DaoConfig
>
daoConfigMap
)
{
...
...
@@ -72,12 +80,21 @@ public class DaoSession extends AbstractDaoSession {
ancestryinfoEntityDaoConfig
=
daoConfigMap
.
get
(
AncestryinfoEntityDao
.
class
).
clone
();
ancestryinfoEntityDaoConfig
.
initIdentityScope
(
type
);
breedingRecordDetailEntityDaoConfig
=
daoConfigMap
.
get
(
BreedingRecordDetailEntityDao
.
class
).
clone
();
breedingRecordDetailEntityDaoConfig
.
initIdentityScope
(
type
);
breedingRecordEntityDaoConfig
=
daoConfigMap
.
get
(
BreedingRecordEntityDao
.
class
).
clone
();
breedingRecordEntityDaoConfig
.
initIdentityScope
(
type
);
cardEntityDaoConfig
=
daoConfigMap
.
get
(
CardEntityDao
.
class
).
clone
();
cardEntityDaoConfig
.
initIdentityScope
(
type
);
cattleResumeEntityDaoConfig
=
daoConfigMap
.
get
(
CattleResumeEntityDao
.
class
).
clone
();
cattleResumeEntityDaoConfig
.
initIdentityScope
(
type
);
dictEntityDaoConfig
=
daoConfigMap
.
get
(
DictEntityDao
.
class
).
clone
();
dictEntityDaoConfig
.
initIdentityScope
(
type
);
genTableDaoConfig
=
daoConfigMap
.
get
(
GenTableDao
.
class
).
clone
();
genTableDaoConfig
.
initIdentityScope
(
type
);
...
...
@@ -99,12 +116,12 @@ public class DaoSession extends AbstractDaoSession {
weightingEntityDaoConfig
=
daoConfigMap
.
get
(
WeightingEntityDao
.
class
).
clone
();
weightingEntityDaoConfig
.
initIdentityScope
(
type
);
dictEntityDaoConfig
=
daoConfigMap
.
get
(
DictEntityDao
.
class
).
clone
();
dictEntityDaoConfig
.
initIdentityScope
(
type
);
ancestryinfoEntityDao
=
new
AncestryinfoEntityDao
(
ancestryinfoEntityDaoConfig
,
this
);
breedingRecordDetailEntityDao
=
new
BreedingRecordDetailEntityDao
(
breedingRecordDetailEntityDaoConfig
,
this
);
breedingRecordEntityDao
=
new
BreedingRecordEntityDao
(
breedingRecordEntityDaoConfig
,
this
);
cardEntityDao
=
new
CardEntityDao
(
cardEntityDaoConfig
,
this
);
cattleResumeEntityDao
=
new
CattleResumeEntityDao
(
cattleResumeEntityDaoConfig
,
this
);
dictEntityDao
=
new
DictEntityDao
(
dictEntityDaoConfig
,
this
);
genTableDao
=
new
GenTableDao
(
genTableDaoConfig
,
this
);
genTableColumnDao
=
new
GenTableColumnDao
(
genTableColumnDaoConfig
,
this
);
immuneEntityDao
=
new
ImmuneEntityDao
(
immuneEntityDaoConfig
,
this
);
...
...
@@ -112,11 +129,13 @@ public class DaoSession extends AbstractDaoSession {
performanceEntityDao
=
new
PerformanceEntityDao
(
performanceEntityDaoConfig
,
this
);
userRoleEntityDao
=
new
UserRoleEntityDao
(
userRoleEntityDaoConfig
,
this
);
weightingEntityDao
=
new
WeightingEntityDao
(
weightingEntityDaoConfig
,
this
);
dictEntityDao
=
new
DictEntityDao
(
dictEntityDaoConfig
,
this
);
registerDao
(
AncestryinfoEntity
.
class
,
ancestryinfoEntityDao
);
registerDao
(
BreedingRecordDetailEntity
.
class
,
breedingRecordDetailEntityDao
);
registerDao
(
BreedingRecordEntity
.
class
,
breedingRecordEntityDao
);
registerDao
(
CardEntity
.
class
,
cardEntityDao
);
registerDao
(
CattleResumeEntity
.
class
,
cattleResumeEntityDao
);
registerDao
(
DictEntity
.
class
,
dictEntityDao
);
registerDao
(
GenTable
.
class
,
genTableDao
);
registerDao
(
GenTableColumn
.
class
,
genTableColumnDao
);
registerDao
(
ImmuneEntity
.
class
,
immuneEntityDao
);
...
...
@@ -124,13 +143,15 @@ public class DaoSession extends AbstractDaoSession {
registerDao
(
PerformanceEntity
.
class
,
performanceEntityDao
);
registerDao
(
UserRoleEntity
.
class
,
userRoleEntityDao
);
registerDao
(
WeightingEntity
.
class
,
weightingEntityDao
);
registerDao
(
DictEntity
.
class
,
dictEntityDao
);
}
public
void
clear
()
{
ancestryinfoEntityDaoConfig
.
clearIdentityScope
();
breedingRecordDetailEntityDaoConfig
.
clearIdentityScope
();
breedingRecordEntityDaoConfig
.
clearIdentityScope
();
cardEntityDaoConfig
.
clearIdentityScope
();
cattleResumeEntityDaoConfig
.
clearIdentityScope
();
dictEntityDaoConfig
.
clearIdentityScope
();
genTableDaoConfig
.
clearIdentityScope
();
genTableColumnDaoConfig
.
clearIdentityScope
();
immuneEntityDaoConfig
.
clearIdentityScope
();
...
...
@@ -138,13 +159,20 @@ public class DaoSession extends AbstractDaoSession {
performanceEntityDaoConfig
.
clearIdentityScope
();
userRoleEntityDaoConfig
.
clearIdentityScope
();
weightingEntityDaoConfig
.
clearIdentityScope
();
dictEntityDaoConfig
.
clearIdentityScope
();
}
public
AncestryinfoEntityDao
getAncestryinfoEntityDao
()
{
return
ancestryinfoEntityDao
;
}
public
BreedingRecordDetailEntityDao
getBreedingRecordDetailEntityDao
()
{
return
breedingRecordDetailEntityDao
;
}
public
BreedingRecordEntityDao
getBreedingRecordEntityDao
()
{
return
breedingRecordEntityDao
;
}
public
CardEntityDao
getCardEntityDao
()
{
return
cardEntityDao
;
}
...
...
@@ -153,6 +181,10 @@ public class DaoSession extends AbstractDaoSession {
return
cattleResumeEntityDao
;
}
public
DictEntityDao
getDictEntityDao
()
{
return
dictEntityDao
;
}
public
GenTableDao
getGenTableDao
()
{
return
genTableDao
;
}
...
...
@@ -181,8 +213,4 @@ public class DaoSession extends AbstractDaoSession {
return
weightingEntityDao
;
}
public
DictEntityDao
getDictEntityDao
()
{
return
dictEntityDao
;
}
}
app/src/main/java/com/phlx/anchorcollect/db/gen/PerformanceEntityDao.java
deleted
100644 → 0
View file @
199e5b54
package
com
.
phlx
.
anchorcollect
.
db
.
gen
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteStatement
;
import
org.greenrobot.greendao.AbstractDao
;
import
org.greenrobot.greendao.Property
;
import
org.greenrobot.greendao.internal.DaoConfig
;
import
org.greenrobot.greendao.database.Database
;
import
org.greenrobot.greendao.database.DatabaseStatement
;
import
com.phlx.anchorcollect.entity.PerformanceEntity
;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "PERFORMANCE_ENTITY".
*/
public
class
PerformanceEntityDao
extends
AbstractDao
<
PerformanceEntity
,
Void
>
{
public
static
final
String
TABLENAME
=
"PERFORMANCE_ENTITY"
;
/**
* Properties of entity PerformanceEntity.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public
static
class
Properties
{
public
final
static
Property
Unid
=
new
Property
(
0
,
String
.
class
,
"unid"
,
false
,
"UNID"
);
public
final
static
Property
CattleresumeId
=
new
Property
(
1
,
String
.
class
,
"cattleresumeId"
,
false
,
"CATTLERESUME_ID"
);
public
final
static
Property
Age
=
new
Property
(
2
,
String
.
class
,
"age"
,
false
,
"AGE"
);
public
final
static
Property
MeasureDate
=
new
Property
(
3
,
String
.
class
,
"measureDate"
,
false
,
"MEASURE_DATE"
);
public
final
static
Property
Height
=
new
Property
(
4
,
String
.
class
,
"height"
,
false
,
"HEIGHT"
);
public
final
static
Property
Length
=
new
Property
(
5
,
String
.
class
,
"length"
,
false
,
"LENGTH"
);
public
final
static
Property
Bust
=
new
Property
(
6
,
String
.
class
,
"bust"
,
false
,
"BUST"
);
public
final
static
Property
Weight
=
new
Property
(
7
,
String
.
class
,
"weight"
,
false
,
"WEIGHT"
);
public
final
static
Property
ChestWidth
=
new
Property
(
8
,
String
.
class
,
"chestWidth"
,
false
,
"CHEST_WIDTH"
);
public
final
static
Property
ChestDeep
=
new
Property
(
9
,
String
.
class
,
"chestDeep"
,
false
,
"CHEST_DEEP"
);
public
final
static
Property
WaistWidth
=
new
Property
(
10
,
String
.
class
,
"waistWidth"
,
false
,
"WAIST_WIDTH"
);
public
final
static
Property
CrossWidth
=
new
Property
(
11
,
String
.
class
,
"crossWidth"
,
false
,
"CROSS_WIDTH"
);
public
final
static
Property
GuanWei
=
new
Property
(
12
,
String
.
class
,
"guanWei"
,
false
,
"GUAN_WEI"
);
public
final
static
Property
EyeMuscleArea
=
new
Property
(
13
,
String
.
class
,
"eyeMuscleArea"
,
false
,
"EYE_MUSCLE_AREA"
);
public
final
static
Property
Grade
=
new
Property
(
14
,
String
.
class
,
"grade"
,
false
,
"GRADE"
);
public
final
static
Property
HairLength
=
new
Property
(
15
,
String
.
class
,
"hairLength"
,
false
,
"HAIR_LENGTH"
);
public
final
static
Property
HairFineness
=
new
Property
(
16
,
String
.
class
,
"hairFineness"
,
false
,
"HAIR_FINENESS"
);
public
final
static
Property
Shearing
=
new
Property
(
17
,
String
.
class
,
"shearing"
,
false
,
"SHEARING"
);
public
final
static
Property
BackWidth
=
new
Property
(
18
,
String
.
class
,
"backWidth"
,
false
,
"BACK_WIDTH"
);
public
final
static
Property
BreedRes
=
new
Property
(
19
,
String
.
class
,
"breedRes"
,
false
,
"BREED_RES"
);
public
final
static
Property
Health
=
new
Property
(
20
,
String
.
class
,
"health"
,
false
,
"HEALTH"
);
public
final
static
Property
Immune
=
new
Property
(
21
,
String
.
class
,
"immune"
,
false
,
"IMMUNE"
);
public
final
static
Property
DeptId
=
new
Property
(
22
,
String
.
class
,
"deptId"
,
false
,
"DEPT_ID"
);
public
final
static
Property
SearchValue
=
new
Property
(
23
,
String
.
class
,
"searchValue"
,
false
,
"SEARCH_VALUE"
);
public
final
static
Property
CreateBy
=
new
Property
(
24
,
String
.
class
,
"createBy"
,
false
,
"CREATE_BY"
);
public
final
static
Property
CreateTime
=
new
Property
(
25
,
String
.
class
,
"createTime"
,
false
,
"CREATE_TIME"
);
public
final
static
Property
UpdateBy
=
new
Property
(
26
,
String
.
class
,
"updateBy"
,
false
,
"UPDATE_BY"
);
public
final
static
Property
UpdateTime
=
new
Property
(
27
,
String
.
class
,
"updateTime"
,
false
,
"UPDATE_TIME"
);
public
final
static
Property
Remark
=
new
Property
(
28
,
String
.
class
,
"remark"
,
false
,
"REMARK"
);
}
public
PerformanceEntityDao
(
DaoConfig
config
)
{
super
(
config
);
}
public
PerformanceEntityDao
(
DaoConfig
config
,
DaoSession
daoSession
)
{
super
(
config
,
daoSession
);
}
/** Creates the underlying database table. */
public
static
void
createTable
(
Database
db
,
boolean
ifNotExists
)
{
String
constraint
=
ifNotExists
?
"IF NOT EXISTS "
:
""
;
db
.
execSQL
(
"CREATE TABLE "
+
constraint
+
"\"PERFORMANCE_ENTITY\" ("
+
//
"\"UNID\" TEXT,"
+
// 0: unid
"\"CATTLERESUME_ID\" TEXT,"
+
// 1: cattleresumeId
"\"AGE\" TEXT,"
+
// 2: age
"\"MEASURE_DATE\" TEXT,"
+
// 3: measureDate
"\"HEIGHT\" TEXT,"
+
// 4: height
"\"LENGTH\" TEXT,"
+
// 5: length
"\"BUST\" TEXT,"
+
// 6: bust
"\"WEIGHT\" TEXT,"
+
// 7: weight
"\"CHEST_WIDTH\" TEXT,"
+
// 8: chestWidth
"\"CHEST_DEEP\" TEXT,"
+
// 9: chestDeep
"\"WAIST_WIDTH\" TEXT,"
+
// 10: waistWidth
"\"CROSS_WIDTH\" TEXT,"
+
// 11: crossWidth
"\"GUAN_WEI\" TEXT,"
+
// 12: guanWei
"\"EYE_MUSCLE_AREA\" TEXT,"
+
// 13: eyeMuscleArea
"\"GRADE\" TEXT,"
+
// 14: grade
"\"HAIR_LENGTH\" TEXT,"
+
// 15: hairLength
"\"HAIR_FINENESS\" TEXT,"
+
// 16: hairFineness
"\"SHEARING\" TEXT,"
+
// 17: shearing
"\"BACK_WIDTH\" TEXT,"
+
// 18: backWidth
"\"BREED_RES\" TEXT,"
+
// 19: breedRes
"\"HEALTH\" TEXT,"
+
// 20: health
"\"IMMUNE\" TEXT,"
+
// 21: immune
"\"DEPT_ID\" TEXT,"
+
// 22: deptId
"\"SEARCH_VALUE\" TEXT,"
+
// 23: searchValue
"\"CREATE_BY\" TEXT,"
+
// 24: createBy
"\"CREATE_TIME\" TEXT,"
+
// 25: createTime
"\"UPDATE_BY\" TEXT,"
+
// 26: updateBy
"\"UPDATE_TIME\" TEXT,"
+
// 27: updateTime
"\"REMARK\" TEXT);"
);
// 28: remark
}
/** Drops the underlying database table. */
public
static
void
dropTable
(
Database
db
,
boolean
ifExists
)
{
String
sql
=
"DROP TABLE "
+
(
ifExists
?
"IF EXISTS "
:
""
)
+
"\"PERFORMANCE_ENTITY\""
;
db
.
execSQL
(
sql
);
}
@Override
protected
final
void
bindValues
(
DatabaseStatement
stmt
,
PerformanceEntity
entity
)
{
stmt
.
clearBindings
();
String
unid
=
entity
.
getUnid
();
if
(
unid
!=
null
)
{
stmt
.
bindString
(
1
,
unid
);
}
String
cattleresumeId
=
entity
.
getCattleresumeId
();
if
(
cattleresumeId
!=
null
)
{
stmt
.
bindString
(
2
,
cattleresumeId
);
}
String
age
=
entity
.
getAge
();
if
(
age
!=
null
)
{
stmt
.
bindString
(
3
,
age
);
}
String
measureDate
=
entity
.
getMeasureDate
();
if
(
measureDate
!=
null
)
{
stmt
.
bindString
(
4
,
measureDate
);
}
String
height
=
entity
.
getHeight
();
if
(
height
!=
null
)
{
stmt
.
bindString
(
5
,
height
);
}
String
length
=
entity
.
getLength
();
if
(
length
!=
null
)
{
stmt
.
bindString
(
6
,
length
);
}
String
bust
=
entity
.
getBust
();
if
(
bust
!=
null
)
{
stmt
.
bindString
(
7
,
bust
);
}
String
weight
=
entity
.
getWeight
();
if
(
weight
!=
null
)
{
stmt
.
bindString
(
8
,
weight
);
}
String
chestWidth
=
entity
.
getChestWidth
();
if
(
chestWidth
!=
null
)
{
stmt
.
bindString
(
9
,
chestWidth
);
}
String
chestDeep
=
entity
.
getChestDeep
();
if
(
chestDeep
!=
null
)
{
stmt
.
bindString
(
10
,
chestDeep
);
}
String
waistWidth
=
entity
.
getWaistWidth
();
if
(
waistWidth
!=
null
)
{
stmt
.
bindString
(
11
,
waistWidth
);
}
String
crossWidth
=
entity
.
getCrossWidth
();
if
(
crossWidth
!=
null
)
{
stmt
.
bindString
(
12
,
crossWidth
);
}
String
guanWei
=
entity
.
getGuanWei
();
if
(
guanWei
!=
null
)
{
stmt
.
bindString
(
13
,
guanWei
);
}
String
eyeMuscleArea
=
entity
.
getEyeMuscleArea
();
if
(
eyeMuscleArea
!=
null
)
{
stmt
.
bindString
(
14
,
eyeMuscleArea
);
}
String
grade
=
entity
.
getGrade
();
if
(
grade
!=
null
)
{
stmt
.
bindString
(
15
,
grade
);
}
String
hairLength
=
entity
.
getHairLength
();
if
(
hairLength
!=
null
)
{
stmt
.
bindString
(
16
,
hairLength
);
}
String
hairFineness
=
entity
.
getHairFineness
();
if
(
hairFineness
!=
null
)
{
stmt
.
bindString
(
17
,
hairFineness
);
}
String
shearing
=
entity
.
getShearing
();
if
(
shearing
!=
null
)
{
stmt
.
bindString
(
18
,
shearing
);
}
String
backWidth
=
entity
.
getBackWidth
();
if
(
backWidth
!=
null
)
{
stmt
.
bindString
(
19
,
backWidth
);
}
String
breedRes
=
entity
.
getBreedRes
();
if
(
breedRes
!=
null
)
{
stmt
.
bindString
(
20
,
breedRes
);
}
String
health
=
entity
.
getHealth
();
if
(
health
!=
null
)
{
stmt
.
bindString
(
21
,
health
);
}
String
immune
=
entity
.
getImmune
();
if
(
immune
!=
null
)
{
stmt
.
bindString
(
22
,
immune
);
}
String
deptId
=
entity
.
getDeptId
();
if
(
deptId
!=
null
)
{
stmt
.
bindString
(
23
,
deptId
);
}
String
searchValue
=
entity
.
getSearchValue
();
if
(
searchValue
!=
null
)
{
stmt
.
bindString
(
24
,
searchValue
);
}
String
createBy
=
entity
.
getCreateBy
();
if
(
createBy
!=
null
)
{
stmt
.
bindString
(
25
,
createBy
);
}
String
createTime
=
entity
.
getCreateTime
();
if
(
createTime
!=
null
)
{
stmt
.
bindString
(
26
,
createTime
);
}
String
updateBy
=
entity
.
getUpdateBy
();
if
(
updateBy
!=
null
)
{
stmt
.
bindString
(
27
,
updateBy
);
}
String
updateTime
=
entity
.
getUpdateTime
();
if
(
updateTime
!=
null
)
{
stmt
.
bindString
(
28
,
updateTime
);
}
String
remark
=
entity
.
getRemark
();
if
(
remark
!=
null
)
{
stmt
.
bindString
(
29
,
remark
);
}
}
@Override
protected
final
void
bindValues
(
SQLiteStatement
stmt
,
PerformanceEntity
entity
)
{
stmt
.
clearBindings
();
String
unid
=
entity
.
getUnid
();
if
(
unid
!=
null
)
{
stmt
.
bindString
(
1
,
unid
);
}
String
cattleresumeId
=
entity
.
getCattleresumeId
();
if
(
cattleresumeId
!=
null
)
{
stmt
.
bindString
(
2
,
cattleresumeId
);
}
String
age
=
entity
.
getAge
();
if
(
age
!=
null
)
{
stmt
.
bindString
(
3
,
age
);
}
String
measureDate
=
entity
.
getMeasureDate
();
if
(
measureDate
!=
null
)
{
stmt
.
bindString
(
4
,
measureDate
);
}
String
height
=
entity
.
getHeight
();
if
(
height
!=
null
)
{
stmt
.
bindString
(
5
,
height
);
}
String
length
=
entity
.
getLength
();
if
(
length
!=
null
)
{
stmt
.
bindString
(
6
,
length
);
}
String
bust
=
entity
.
getBust
();
if
(
bust
!=
null
)
{
stmt
.
bindString
(
7
,
bust
);
}
String
weight
=
entity
.
getWeight
();
if
(
weight
!=
null
)
{
stmt
.
bindString
(
8
,
weight
);
}
String
chestWidth
=
entity
.
getChestWidth
();
if
(
chestWidth
!=
null
)
{
stmt
.
bindString
(
9
,
chestWidth
);
}
String
chestDeep
=
entity
.
getChestDeep
();
if
(
chestDeep
!=
null
)
{
stmt
.
bindString
(
10
,
chestDeep
);
}
String
waistWidth
=
entity
.
getWaistWidth
();
if
(
waistWidth
!=
null
)
{
stmt
.
bindString
(
11
,
waistWidth
);
}
String
crossWidth
=
entity
.
getCrossWidth
();
if
(
crossWidth
!=
null
)
{
stmt
.
bindString
(
12
,
crossWidth
);
}
String
guanWei
=
entity
.
getGuanWei
();
if
(
guanWei
!=
null
)
{
stmt
.
bindString
(
13
,
guanWei
);
}
String
eyeMuscleArea
=
entity
.
getEyeMuscleArea
();
if
(
eyeMuscleArea
!=
null
)
{
stmt
.
bindString
(
14
,
eyeMuscleArea
);
}
String
grade
=
entity
.
getGrade
();
if
(
grade
!=
null
)
{
stmt
.
bindString
(
15
,
grade
);
}
String
hairLength
=
entity
.
getHairLength
();
if
(
hairLength
!=
null
)
{
stmt
.
bindString
(
16
,
hairLength
);
}
String
hairFineness
=
entity
.
getHairFineness
();
if
(
hairFineness
!=
null
)
{
stmt
.
bindString
(
17
,
hairFineness
);
}
String
shearing
=
entity
.
getShearing
();
if
(
shearing
!=
null
)
{
stmt
.
bindString
(
18
,
shearing
);
}
String
backWidth
=
entity
.
getBackWidth
();
if
(
backWidth
!=
null
)
{
stmt
.
bindString
(
19
,
backWidth
);
}
String
breedRes
=
entity
.
getBreedRes
();
if
(
breedRes
!=
null
)
{
stmt
.
bindString
(
20
,
breedRes
);
}
String
health
=
entity
.
getHealth
();
if
(
health
!=
null
)
{
stmt
.
bindString
(
21
,
health
);
}
String
immune
=
entity
.
getImmune
();
if
(
immune
!=
null
)
{
stmt
.
bindString
(
22
,
immune
);
}
String
deptId
=
entity
.
getDeptId
();
if
(
deptId
!=
null
)
{
stmt
.
bindString
(
23
,
deptId
);
}
String
searchValue
=
entity
.
getSearchValue
();
if
(
searchValue
!=
null
)
{
stmt
.
bindString
(
24
,
searchValue
);
}
String
createBy
=
entity
.
getCreateBy
();
if
(
createBy
!=
null
)
{
stmt
.
bindString
(
25
,
createBy
);
}
String
createTime
=
entity
.
getCreateTime
();
if
(
createTime
!=
null
)
{
stmt
.
bindString
(
26
,
createTime
);
}
String
updateBy
=
entity
.
getUpdateBy
();
if
(
updateBy
!=
null
)
{
stmt
.
bindString
(
27
,
updateBy
);
}
String
updateTime
=
entity
.
getUpdateTime
();
if
(
updateTime
!=
null
)
{
stmt
.
bindString
(
28
,
updateTime
);
}
String
remark
=
entity
.
getRemark
();
if
(
remark
!=
null
)
{
stmt
.
bindString
(
29
,
remark
);
}
}
@Override
public
Void
readKey
(
Cursor
cursor
,
int
offset
)
{
return
null
;
}
@Override
public
PerformanceEntity
readEntity
(
Cursor
cursor
,
int
offset
)
{
PerformanceEntity
entity
=
new
PerformanceEntity
(
//
cursor
.
isNull
(
offset
+
0
)
?
null
:
cursor
.
getString
(
offset
+
0
),
// unid
cursor
.
isNull
(
offset
+
1
)
?
null
:
cursor
.
getString
(
offset
+
1
),
// cattleresumeId
cursor
.
isNull
(
offset
+
2
)
?
null
:
cursor
.
getString
(
offset
+
2
),
// age
cursor
.
isNull
(
offset
+
3
)
?
null
:
cursor
.
getString
(
offset
+
3
),
// measureDate
cursor
.
isNull
(
offset
+
4
)
?
null
:
cursor
.
getString
(
offset
+
4
),
// height
cursor
.
isNull
(
offset
+
5
)
?
null
:
cursor
.
getString
(
offset
+
5
),
// length
cursor
.
isNull
(
offset
+
6
)
?
null
:
cursor
.
getString
(
offset
+
6
),
// bust
cursor
.
isNull
(
offset
+
7
)
?
null
:
cursor
.
getString
(
offset
+
7
),
// weight
cursor
.
isNull
(
offset
+
8
)
?
null
:
cursor
.
getString
(
offset
+
8
),
// chestWidth
cursor
.
isNull
(
offset
+
9
)
?
null
:
cursor
.
getString
(
offset
+
9
),
// chestDeep
cursor
.
isNull
(
offset
+
10
)
?
null
:
cursor
.
getString
(
offset
+
10
),
// waistWidth
cursor
.
isNull
(
offset
+
11
)
?
null
:
cursor
.
getString
(
offset
+
11
),
// crossWidth
cursor
.
isNull
(
offset
+
12
)
?
null
:
cursor
.
getString
(
offset
+
12
),
// guanWei
cursor
.
isNull
(
offset
+
13
)
?
null
:
cursor
.
getString
(
offset
+
13
),
// eyeMuscleArea
cursor
.
isNull
(
offset
+
14
)
?
null
:
cursor
.
getString
(
offset
+
14
),
// grade
cursor
.
isNull
(
offset
+
15
)
?
null
:
cursor
.
getString
(
offset
+
15
),
// hairLength
cursor
.
isNull
(
offset
+
16
)
?
null
:
cursor
.
getString
(
offset
+
16
),
// hairFineness
cursor
.
isNull
(
offset
+
17
)
?
null
:
cursor
.
getString
(
offset
+
17
),
// shearing
cursor
.
isNull
(
offset
+
18
)
?
null
:
cursor
.
getString
(
offset
+
18
),
// backWidth
cursor
.
isNull
(
offset
+
19
)
?
null
:
cursor
.
getString
(
offset
+
19
),
// breedRes
cursor
.
isNull
(
offset
+
20
)
?
null
:
cursor
.
getString
(
offset
+
20
),
// health
cursor
.
isNull
(
offset
+
21
)
?
null
:
cursor
.
getString
(
offset
+
21
),
// immune
cursor
.
isNull
(
offset
+
22
)
?
null
:
cursor
.
getString
(
offset
+
22
),
// deptId
cursor
.
isNull
(
offset
+
23
)
?
null
:
cursor
.
getString
(
offset
+
23
),
// searchValue
cursor
.
isNull
(
offset
+
24
)
?
null
:
cursor
.
getString
(
offset
+
24
),
// createBy
cursor
.
isNull
(
offset
+
25
)
?
null
:
cursor
.
getString
(
offset
+
25
),
// createTime
cursor
.
isNull
(
offset
+
26
)
?
null
:
cursor
.
getString
(
offset
+
26
),
// updateBy
cursor
.
isNull
(
offset
+
27
)
?
null
:
cursor
.
getString
(
offset
+
27
),
// updateTime
cursor
.
isNull
(
offset
+
28
)
?
null
:
cursor
.
getString
(
offset
+
28
)
// remark
);
return
entity
;
}
@Override
public
void
readEntity
(
Cursor
cursor
,
PerformanceEntity
entity
,
int
offset
)
{
entity
.
setUnid
(
cursor
.
isNull
(
offset
+
0
)
?
null
:
cursor
.
getString
(
offset
+
0
));
entity
.
setCattleresumeId
(
cursor
.
isNull
(
offset
+
1
)
?
null
:
cursor
.
getString
(
offset
+
1
));
entity
.
setAge
(
cursor
.
isNull
(
offset
+
2
)
?
null
:
cursor
.
getString
(
offset
+
2
));
entity
.
setMeasureDate
(
cursor
.
isNull
(
offset
+
3
)
?
null
:
cursor
.
getString
(
offset
+
3
));
entity
.
setHeight
(
cursor
.
isNull
(
offset
+
4
)
?
null
:
cursor
.
getString
(
offset
+
4
));
entity
.
setLength
(
cursor
.
isNull
(
offset
+
5
)
?
null
:
cursor
.
getString
(
offset
+
5
));
entity
.
setBust
(
cursor
.
isNull
(
offset
+
6
)
?
null
:
cursor
.
getString
(
offset
+
6
));
entity
.
setWeight
(
cursor
.
isNull
(
offset
+
7
)
?
null
:
cursor
.
getString
(
offset
+
7
));
entity
.
setChestWidth
(
cursor
.
isNull
(
offset
+
8
)
?
null
:
cursor
.
getString
(
offset
+
8
));
entity
.
setChestDeep
(
cursor
.
isNull
(
offset
+
9
)
?
null
:
cursor
.
getString
(
offset
+
9
));
entity
.
setWaistWidth
(
cursor
.
isNull
(
offset
+
10
)
?
null
:
cursor
.
getString
(
offset
+
10
));
entity
.
setCrossWidth
(
cursor
.
isNull
(
offset
+
11
)
?
null
:
cursor
.
getString
(
offset
+
11
));
entity
.
setGuanWei
(
cursor
.
isNull
(
offset
+
12
)
?
null
:
cursor
.
getString
(
offset
+
12
));
entity
.
setEyeMuscleArea
(
cursor
.
isNull
(
offset
+
13
)
?
null
:
cursor
.
getString
(
offset
+
13
));
entity
.
setGrade
(
cursor
.
isNull
(
offset
+
14
)
?
null
:
cursor
.
getString
(
offset
+
14
));
entity
.
setHairLength
(
cursor
.
isNull
(
offset
+
15
)
?
null
:
cursor
.
getString
(
offset
+
15
));
entity
.
setHairFineness
(
cursor
.
isNull
(
offset
+
16
)
?
null
:
cursor
.
getString
(
offset
+
16
));
entity
.
setShearing
(
cursor
.
isNull
(
offset
+
17
)
?
null
:
cursor
.
getString
(
offset
+
17
));
entity
.
setBackWidth
(
cursor
.
isNull
(
offset
+
18
)
?
null
:
cursor
.
getString
(
offset
+
18
));
entity
.
setBreedRes
(
cursor
.
isNull
(
offset
+
19
)
?
null
:
cursor
.
getString
(
offset
+
19
));
entity
.
setHealth
(
cursor
.
isNull
(
offset
+
20
)
?
null
:
cursor
.
getString
(
offset
+
20
));
entity
.
setImmune
(
cursor
.
isNull
(
offset
+
21
)
?
null
:
cursor
.
getString
(
offset
+
21
));
entity
.
setDeptId
(
cursor
.
isNull
(
offset
+
22
)
?
null
:
cursor
.
getString
(
offset
+
22
));
entity
.
setSearchValue
(
cursor
.
isNull
(
offset
+
23
)
?
null
:
cursor
.
getString
(
offset
+
23
));
entity
.
setCreateBy
(
cursor
.
isNull
(
offset
+
24
)
?
null
:
cursor
.
getString
(
offset
+
24
));
entity
.
setCreateTime
(
cursor
.
isNull
(
offset
+
25
)
?
null
:
cursor
.
getString
(
offset
+
25
));
entity
.
setUpdateBy
(
cursor
.
isNull
(
offset
+
26
)
?
null
:
cursor
.
getString
(
offset
+
26
));
entity
.
setUpdateTime
(
cursor
.
isNull
(
offset
+
27
)
?
null
:
cursor
.
getString
(
offset
+
27
));
entity
.
setRemark
(
cursor
.
isNull
(
offset
+
28
)
?
null
:
cursor
.
getString
(
offset
+
28
));
}
@Override
protected
final
Void
updateKeyAfterInsert
(
PerformanceEntity
entity
,
long
rowId
)
{
// Unsupported or missing PK type
return
null
;
}
@Override
public
Void
getKey
(
PerformanceEntity
entity
)
{
return
null
;
}
@Override
public
boolean
hasKey
(
PerformanceEntity
entity
)
{
// TODO
return
false
;
}
@Override
protected
final
boolean
isEntityUpdateable
()
{
return
true
;
}
}
app/src/main/java/com/phlx/anchorcollect/entity/BreedingRecordDetailEntity.java
0 → 100644
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
entity
;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
androidx.databinding.BaseObservable
;
import
org.greenrobot.greendao.annotation.Entity
;
import
org.greenrobot.greendao.annotation.Id
;
import
java.util.Date
;
import
org.greenrobot.greendao.annotation.Generated
;
/**
* 配种记子对象 zxgl_cattlemating_detaill
*
* @author phlx
* @date 2022-01-10
*/
@Entity
public
class
BreedingRecordDetailEntity
extends
BaseObservable
implements
Parcelable
{
/**
* unid
*/
@Id
(
autoincrement
=
false
)
private
String
unid
;
/**
* 主表ID
*/
private
String
fUnid
;
/**
* 配种方式;(本交,受精)
*/
private
String
matingStyle
;
/**
* 种畜耳标号
*/
private
String
cattleresumeId
;
/**
* 冻精批次号
*/
private
String
frozenSemenBatch
;
/**
* 配种日期
*/
private
String
matingDate
;
/**
* 是否返情
*/
private
String
isReturn
;
/**
* 返情日期
*/
private
String
backLoveDate
;
/**
* 预产日期
*/
private
String
dueDate
;
/**
* 配种成功
*/
private
String
pregnancy
;
/**
* 部门id
*/
private
String
deptId
;
/** 是否上传 0未上传,1已上传 */
private
String
uploadStatus
;
/** 搜索值 */
private
String
searchValue
;
/** 创建者 */
private
String
createBy
;
/** 创建时间 */
private
String
createTime
;
/** 更新者 */
private
String
updateBy
;
/** 更新时间 */
private
String
updateTime
;
/** 备注 */
private
String
remark
;
public
BreedingRecordDetailEntity
()
{
}
protected
BreedingRecordDetailEntity
(
Parcel
in
)
{
unid
=
in
.
readString
();
fUnid
=
in
.
readString
();
matingStyle
=
in
.
readString
();
cattleresumeId
=
in
.
readString
();
frozenSemenBatch
=
in
.
readString
();
matingDate
=
in
.
readString
();
isReturn
=
in
.
readString
();
backLoveDate
=
in
.
readString
();
dueDate
=
in
.
readString
();
pregnancy
=
in
.
readString
();
deptId
=
in
.
readString
();
uploadStatus
=
in
.
readString
();
searchValue
=
in
.
readString
();
createBy
=
in
.
readString
();
createTime
=
in
.
readString
();
updateBy
=
in
.
readString
();
updateTime
=
in
.
readString
();
remark
=
in
.
readString
();
}
@Generated
(
hash
=
2062840275
)
public
BreedingRecordDetailEntity
(
String
unid
,
String
fUnid
,
String
matingStyle
,
String
cattleresumeId
,
String
frozenSemenBatch
,
String
matingDate
,
String
isReturn
,
String
backLoveDate
,
String
dueDate
,
String
pregnancy
,
String
deptId
,
String
uploadStatus
,
String
searchValue
,
String
createBy
,
String
createTime
,
String
updateBy
,
String
updateTime
,
String
remark
)
{
this
.
unid
=
unid
;
this
.
fUnid
=
fUnid
;
this
.
matingStyle
=
matingStyle
;
this
.
cattleresumeId
=
cattleresumeId
;
this
.
frozenSemenBatch
=
frozenSemenBatch
;
this
.
matingDate
=
matingDate
;
this
.
isReturn
=
isReturn
;
this
.
backLoveDate
=
backLoveDate
;
this
.
dueDate
=
dueDate
;
this
.
pregnancy
=
pregnancy
;
this
.
deptId
=
deptId
;
this
.
uploadStatus
=
uploadStatus
;
this
.
searchValue
=
searchValue
;
this
.
createBy
=
createBy
;
this
.
createTime
=
createTime
;
this
.
updateBy
=
updateBy
;
this
.
updateTime
=
updateTime
;
this
.
remark
=
remark
;
}
@Override
public
void
writeToParcel
(
Parcel
dest
,
int
flags
)
{
dest
.
writeString
(
unid
);
dest
.
writeString
(
fUnid
);
dest
.
writeString
(
matingStyle
);
dest
.
writeString
(
cattleresumeId
);
dest
.
writeString
(
frozenSemenBatch
);
dest
.
writeString
(
matingDate
);
dest
.
writeString
(
isReturn
);
dest
.
writeString
(
backLoveDate
);
dest
.
writeString
(
dueDate
);
dest
.
writeString
(
pregnancy
);
dest
.
writeString
(
deptId
);
dest
.
writeString
(
uploadStatus
);
dest
.
writeString
(
searchValue
);
dest
.
writeString
(
createBy
);
dest
.
writeString
(
createTime
);
dest
.
writeString
(
updateBy
);
dest
.
writeString
(
updateTime
);
dest
.
writeString
(
remark
);
}
@Override
public
int
describeContents
()
{
return
0
;
}
public
static
final
Creator
<
BreedingRecordDetailEntity
>
CREATOR
=
new
Creator
<
BreedingRecordDetailEntity
>()
{
@Override
public
BreedingRecordDetailEntity
createFromParcel
(
Parcel
in
)
{
return
new
BreedingRecordDetailEntity
(
in
);
}
@Override
public
BreedingRecordDetailEntity
[]
newArray
(
int
size
)
{
return
new
BreedingRecordDetailEntity
[
size
];
}
};
public
String
getUnid
()
{
return
unid
;
}
public
void
setUnid
(
String
unid
)
{
this
.
unid
=
unid
;
}
public
String
getfUnid
()
{
return
fUnid
;
}
public
void
setfUnid
(
String
fUnid
)
{
this
.
fUnid
=
fUnid
;
}
public
String
getMatingStyle
()
{
return
matingStyle
;
}
public
void
setMatingStyle
(
String
matingStyle
)
{
this
.
matingStyle
=
matingStyle
;
}
public
String
getCattleresumeId
()
{
return
cattleresumeId
;
}
public
void
setCattleresumeId
(
String
cattleresumeId
)
{
this
.
cattleresumeId
=
cattleresumeId
;
}
public
String
getFrozenSemenBatch
()
{
return
frozenSemenBatch
;
}
public
void
setFrozenSemenBatch
(
String
frozenSemenBatch
)
{
this
.
frozenSemenBatch
=
frozenSemenBatch
;
}
public
String
getMatingDate
()
{
return
matingDate
;
}
public
void
setMatingDate
(
String
matingDate
)
{
this
.
matingDate
=
matingDate
;
}
public
String
getIsReturn
()
{
return
isReturn
;
}
public
void
setIsReturn
(
String
isReturn
)
{
this
.
isReturn
=
isReturn
;
}
public
String
getBackLoveDate
()
{
return
backLoveDate
;
}
public
void
setBackLoveDate
(
String
backLoveDate
)
{
this
.
backLoveDate
=
backLoveDate
;
}
public
String
getDueDate
()
{
return
dueDate
;
}
public
void
setDueDate
(
String
dueDate
)
{
this
.
dueDate
=
dueDate
;
}
public
String
getPregnancy
()
{
return
pregnancy
;
}
public
void
setPregnancy
(
String
pregnancy
)
{
this
.
pregnancy
=
pregnancy
;
}
public
String
getDeptId
()
{
return
deptId
;
}
public
void
setDeptId
(
String
deptId
)
{
this
.
deptId
=
deptId
;
}
public
String
getUploadStatus
()
{
return
uploadStatus
;
}
public
void
setUploadStatus
(
String
uploadStatus
)
{
this
.
uploadStatus
=
uploadStatus
;
}
public
String
getSearchValue
()
{
return
searchValue
;
}
public
void
setSearchValue
(
String
searchValue
)
{
this
.
searchValue
=
searchValue
;
}
public
String
getCreateBy
()
{
return
createBy
;
}
public
void
setCreateBy
(
String
createBy
)
{
this
.
createBy
=
createBy
;
}
public
String
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
String
createTime
)
{
this
.
createTime
=
createTime
;
}
public
String
getUpdateBy
()
{
return
updateBy
;
}
public
void
setUpdateBy
(
String
updateBy
)
{
this
.
updateBy
=
updateBy
;
}
public
String
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
String
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
String
getRemark
()
{
return
remark
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
@Override
public
String
toString
()
{
return
"BreedingRecordDetailEntity{"
+
"unid='"
+
unid
+
'\''
+
", fUnid='"
+
fUnid
+
'\''
+
", matingStyle='"
+
matingStyle
+
'\''
+
", cattleresumeId='"
+
cattleresumeId
+
'\''
+
", frozenSemenBatch='"
+
frozenSemenBatch
+
'\''
+
", matingDate='"
+
matingDate
+
'\''
+
", isReturn='"
+
isReturn
+
'\''
+
", backLoveDate='"
+
backLoveDate
+
'\''
+
", dueDate='"
+
dueDate
+
'\''
+
", pregnancy='"
+
pregnancy
+
'\''
+
", deptId='"
+
deptId
+
'\''
+
", uploadStatus='"
+
uploadStatus
+
'\''
+
", searchValue='"
+
searchValue
+
'\''
+
", createBy='"
+
createBy
+
'\''
+
", createTime='"
+
createTime
+
'\''
+
", updateBy='"
+
updateBy
+
'\''
+
", updateTime='"
+
updateTime
+
'\''
+
", remark='"
+
remark
+
'\''
+
'}'
;
}
public
String
getFUnid
()
{
return
this
.
fUnid
;
}
public
void
setFUnid
(
String
fUnid
)
{
this
.
fUnid
=
fUnid
;
}
}
app/src/main/java/com/phlx/anchorcollect/entity/BreedingRecordEntity.java
0 → 100644
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
entity
;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
androidx.databinding.BaseObservable
;
import
org.greenrobot.greendao.annotation.Entity
;
import
org.greenrobot.greendao.annotation.Id
;
import
java.util.List
;
import
org.greenrobot.greendao.annotation.Generated
;
/**
* 配种记录主对象 zxgl_cattlemating_master
*
* @author phlx
* @date 2022-01-10
*/
@Entity
public
class
BreedingRecordEntity
extends
BaseObservable
implements
Parcelable
{
/**
* unid
*/
@Id
(
autoincrement
=
false
)
private
String
unid
;
/**
* 母畜耳标号
*/
private
String
cattleresumeId
;
/**
* 饲养品种(利木赞;西门塔尔等)
*/
private
String
raiseVarieties
;
/**
* 所在地
*/
private
String
location
;
/**
* 所属种畜站
*/
private
String
breedingPlantId
;
/** 是否上传 0未上传,1已上传 */
private
String
uploadStatus
;
/**
* 部门id
*/
private
String
deptId
;
/** 搜索值 */
private
String
searchValue
;
/** 创建者 */
private
String
createBy
;
/** 创建时间 */
private
String
createTime
;
/** 更新者 */
private
String
updateBy
;
/** 更新时间 */
private
String
updateTime
;
/** 备注 */
private
String
remark
;
public
BreedingRecordEntity
()
{
}
protected
BreedingRecordEntity
(
Parcel
in
)
{
unid
=
in
.
readString
();
cattleresumeId
=
in
.
readString
();
raiseVarieties
=
in
.
readString
();
location
=
in
.
readString
();
breedingPlantId
=
in
.
readString
();
uploadStatus
=
in
.
readString
();
deptId
=
in
.
readString
();
searchValue
=
in
.
readString
();
createBy
=
in
.
readString
();
createTime
=
in
.
readString
();
updateBy
=
in
.
readString
();
updateTime
=
in
.
readString
();
remark
=
in
.
readString
();
}
@Generated
(
hash
=
1293154819
)
public
BreedingRecordEntity
(
String
unid
,
String
cattleresumeId
,
String
raiseVarieties
,
String
location
,
String
breedingPlantId
,
String
uploadStatus
,
String
deptId
,
String
searchValue
,
String
createBy
,
String
createTime
,
String
updateBy
,
String
updateTime
,
String
remark
)
{
this
.
unid
=
unid
;
this
.
cattleresumeId
=
cattleresumeId
;
this
.
raiseVarieties
=
raiseVarieties
;
this
.
location
=
location
;
this
.
breedingPlantId
=
breedingPlantId
;
this
.
uploadStatus
=
uploadStatus
;
this
.
deptId
=
deptId
;
this
.
searchValue
=
searchValue
;
this
.
createBy
=
createBy
;
this
.
createTime
=
createTime
;
this
.
updateBy
=
updateBy
;
this
.
updateTime
=
updateTime
;
this
.
remark
=
remark
;
}
@Override
public
void
writeToParcel
(
Parcel
dest
,
int
flags
)
{
dest
.
writeString
(
unid
);
dest
.
writeString
(
cattleresumeId
);
dest
.
writeString
(
raiseVarieties
);
dest
.
writeString
(
location
);
dest
.
writeString
(
breedingPlantId
);
dest
.
writeString
(
uploadStatus
);
dest
.
writeString
(
deptId
);
dest
.
writeString
(
searchValue
);
dest
.
writeString
(
createBy
);
dest
.
writeString
(
createTime
);
dest
.
writeString
(
updateBy
);
dest
.
writeString
(
updateTime
);
dest
.
writeString
(
remark
);
}
@Override
public
int
describeContents
()
{
return
0
;
}
public
static
final
Creator
<
BreedingRecordEntity
>
CREATOR
=
new
Creator
<
BreedingRecordEntity
>()
{
@Override
public
BreedingRecordEntity
createFromParcel
(
Parcel
in
)
{
return
new
BreedingRecordEntity
(
in
);
}
@Override
public
BreedingRecordEntity
[]
newArray
(
int
size
)
{
return
new
BreedingRecordEntity
[
size
];
}
};
public
String
getUnid
()
{
return
unid
;
}
public
void
setUnid
(
String
unid
)
{
this
.
unid
=
unid
;
}
public
String
getCattleresumeId
()
{
return
cattleresumeId
;
}
public
void
setCattleresumeId
(
String
cattleresumeId
)
{
this
.
cattleresumeId
=
cattleresumeId
;
}
public
String
getRaiseVarieties
()
{
return
raiseVarieties
;
}
public
void
setRaiseVarieties
(
String
raiseVarieties
)
{
this
.
raiseVarieties
=
raiseVarieties
;
}
public
String
getLocation
()
{
return
location
;
}
public
void
setLocation
(
String
location
)
{
this
.
location
=
location
;
}
public
String
getBreedingPlantId
()
{
return
breedingPlantId
;
}
public
void
setBreedingPlantId
(
String
breedingPlantId
)
{
this
.
breedingPlantId
=
breedingPlantId
;
}
public
String
getUploadStatus
()
{
return
uploadStatus
;
}
public
void
setUploadStatus
(
String
uploadStatus
)
{
this
.
uploadStatus
=
uploadStatus
;
}
public
String
getDeptId
()
{
return
deptId
;
}
public
void
setDeptId
(
String
deptId
)
{
this
.
deptId
=
deptId
;
}
public
String
getSearchValue
()
{
return
searchValue
;
}
public
void
setSearchValue
(
String
searchValue
)
{
this
.
searchValue
=
searchValue
;
}
public
String
getCreateBy
()
{
return
createBy
;
}
public
void
setCreateBy
(
String
createBy
)
{
this
.
createBy
=
createBy
;
}
public
String
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
String
createTime
)
{
this
.
createTime
=
createTime
;
}
public
String
getUpdateBy
()
{
return
updateBy
;
}
public
void
setUpdateBy
(
String
updateBy
)
{
this
.
updateBy
=
updateBy
;
}
public
String
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
String
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
String
getRemark
()
{
return
remark
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
@Override
public
String
toString
()
{
return
"BreedingRecordEntity{"
+
"unid='"
+
unid
+
'\''
+
", cattleresumeId='"
+
cattleresumeId
+
'\''
+
", raiseVarieties='"
+
raiseVarieties
+
'\''
+
", location='"
+
location
+
'\''
+
", breedingPlantId='"
+
breedingPlantId
+
'\''
+
", uploadStatus='"
+
uploadStatus
+
'\''
+
", deptId='"
+
deptId
+
'\''
+
", searchValue='"
+
searchValue
+
'\''
+
", createBy='"
+
createBy
+
'\''
+
", createTime='"
+
createTime
+
'\''
+
", updateBy='"
+
updateBy
+
'\''
+
", updateTime='"
+
updateTime
+
'\''
+
", remark='"
+
remark
+
'\''
+
'}'
;
}
}
app/src/main/java/com/phlx/anchorcollect/entity/PerformanceEntity.java
View file @
429a4804
...
...
@@ -11,8 +11,6 @@ import org.greenrobot.greendao.annotation.Id;
/**
* 种畜管理_性能测定表
* 作者 : lei
* 时间 : 2018/12/3 12 : 05
*/
@Entity
public
class
PerformanceEntity
extends
BaseObservable
implements
Parcelable
{
...
...
@@ -20,6 +18,7 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
/**
* unid
*/
@Id
(
autoincrement
=
false
)
private
String
unid
;
/**
...
...
@@ -127,6 +126,9 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
*/
private
String
immune
;
/** 是否上传 0未上传,1已上传 */
private
String
uploadStatus
;
/**
* 部门id
*/
...
...
@@ -176,6 +178,7 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
breedRes
=
in
.
readString
();
health
=
in
.
readString
();
immune
=
in
.
readString
();
uploadStatus
=
in
.
readString
();
deptId
=
in
.
readString
();
searchValue
=
in
.
readString
();
createBy
=
in
.
readString
();
...
...
@@ -185,14 +188,14 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
remark
=
in
.
readString
();
}
@Generated
(
hash
=
717472496
)
@Generated
(
hash
=
1092205671
)
public
PerformanceEntity
(
String
unid
,
String
cattleresumeId
,
String
age
,
String
measureDate
,
String
height
,
String
length
,
String
bust
,
String
weight
,
String
chestWidth
,
String
chestDeep
,
String
waistWidth
,
String
crossWidth
,
String
guanWei
,
String
eyeMuscleArea
,
String
grade
,
String
hairLength
,
String
hairFineness
,
String
shearing
,
String
backWidth
,
String
breedRes
,
String
health
,
String
immune
,
String
deptId
,
String
searchValue
,
String
createBy
,
String
createTime
,
String
updateBy
,
String
updateTime
,
String
remark
)
{
String
backWidth
,
String
breedRes
,
String
health
,
String
immune
,
String
uploadStatus
,
String
deptId
,
String
searchValue
,
String
createBy
,
String
createTime
,
String
updateBy
,
String
updateTime
,
String
remark
)
{
this
.
unid
=
unid
;
this
.
cattleresumeId
=
cattleresumeId
;
this
.
age
=
age
;
...
...
@@ -215,6 +218,7 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
this
.
breedRes
=
breedRes
;
this
.
health
=
health
;
this
.
immune
=
immune
;
this
.
uploadStatus
=
uploadStatus
;
this
.
deptId
=
deptId
;
this
.
searchValue
=
searchValue
;
this
.
createBy
=
createBy
;
...
...
@@ -248,6 +252,7 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
dest
.
writeString
(
breedRes
);
dest
.
writeString
(
health
);
dest
.
writeString
(
immune
);
dest
.
writeString
(
uploadStatus
);
dest
.
writeString
(
deptId
);
dest
.
writeString
(
searchValue
);
dest
.
writeString
(
createBy
);
...
...
@@ -450,6 +455,14 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
this
.
immune
=
immune
;
}
public
String
getUploadStatus
()
{
return
uploadStatus
;
}
public
void
setUploadStatus
(
String
uploadStatus
)
{
this
.
uploadStatus
=
uploadStatus
;
}
public
String
getDeptId
()
{
return
deptId
;
}
...
...
@@ -531,6 +544,7 @@ public class PerformanceEntity extends BaseObservable implements Parcelable {
", breedRes='"
+
breedRes
+
'\''
+
", health='"
+
health
+
'\''
+
", immune='"
+
immune
+
'\''
+
", uploadStatus='"
+
uploadStatus
+
'\''
+
", deptId='"
+
deptId
+
'\''
+
", searchValue='"
+
searchValue
+
'\''
+
", createBy='"
+
createBy
+
'\''
+
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/BasicsCollectFragment.java
View file @
429a4804
...
...
@@ -65,9 +65,15 @@ public class BasicsCollectFragment extends BaseFragment<FragmentBasicsCollectBin
private
ImagePicker
mImagePicker
;
public
static
BasicsCollectFragment
newInstance
()
{
BasicsCollectFragment
basicsCollectFragment
=
new
BasicsCollectFragment
();
return
basicsCollectFragment
;
private
static
class
SingletonClassInstance
{
private
static
final
BasicsCollectFragment
instance
=
new
BasicsCollectFragment
();
}
private
BasicsCollectFragment
()
{
}
public
static
BasicsCollectFragment
getInstance
()
{
return
SingletonClassInstance
.
instance
;
}
@Override
...
...
@@ -117,7 +123,7 @@ public class BasicsCollectFragment extends BaseFragment<FragmentBasicsCollectBin
if
(
viewModel
.
currentParamEntity
!=
null
)
{
switch
(
viewModel
.
currentParamEntity
.
getHtmlType
())
{
case
"checkbox"
:
//TODO 多选
showCheckboxDialog
(
viewModel
.
currentParamEntity
);
break
;
case
"input"
:
case
"textarea"
:
...
...
@@ -220,6 +226,38 @@ public class BasicsCollectFragment extends BaseFragment<FragmentBasicsCollectBin
.
show
();
}
//多选框
private
void
showCheckboxDialog
(
GenTableColumn
uiParamEntity
)
{
new
MaterialDialog
.
Builder
(
getActivity
()).
title
(
"系统信息"
).
content
(
"请选择!!!"
)
.
cancelable
(
false
).
canceledOnTouchOutside
(
false
)
.
positiveText
(
"确定"
)
.
items
(
DictUtils
.
getDistNameList
(
uiParamEntity
.
getDictType
()))
.
itemsCallbackMultiChoice
(
null
,
new
MaterialDialog
.
ListCallbackMultiChoice
()
{
@Override
public
boolean
onSelection
(
MaterialDialog
dialog
,
Integer
[]
which
,
CharSequence
[]
text
)
{
String
showName
=
""
;
String
content
=
""
;
List
<
DictEntity
>
distTypeList
=
DictUtils
.
getDistList
(
uiParamEntity
.
getDictType
());
if
(
which
!=
null
&&
which
.
length
>
0
)
{
for
(
Integer
i
:
which
)
{
showName
+=
distTypeList
.
get
(
i
).
getDictLabel
();
showName
+=
","
;
content
+=
distTypeList
.
get
(
i
).
getDictValue
();
content
+=
","
;
}
}
viewModel
.
currentParamEntity
.
setShowName
(
showName
);
viewModel
.
currentParamEntity
.
setContent
(
content
);
viewModel
.
currentParamEntity
.
notifyChange
();
return
true
;
}
}).
show
();
}
//输入框
private
void
showInputDialog
(
GenTableColumn
uiParamEntity
)
{
...
...
@@ -227,7 +265,8 @@ public class BasicsCollectFragment extends BaseFragment<FragmentBasicsCollectBin
if
(
uiParamEntity
.
getJavaType
().
equals
(
"Long"
)
||
uiParamEntity
.
getJavaType
().
equals
(
"Integer"
))
{
inputType
=
InputType
.
TYPE_CLASS_NUMBER
;
}
else
if
(
uiParamEntity
.
getJavaType
().
equals
(
"BigDecimal"
)
||
uiParamEntity
.
getJavaType
().
equals
(
"Duoble"
))
{
inputType
=
InputType
.
TYPE_CLASS_NUMBER
|
InputType
.
TYPE_NUMBER_FLAG_DECIMAL
|
InputType
.
TYPE_NUMBER_FLAG_SIGNED
;
;
inputType
=
InputType
.
TYPE_CLASS_NUMBER
|
InputType
.
TYPE_NUMBER_FLAG_DECIMAL
|
InputType
.
TYPE_NUMBER_FLAG_SIGNED
;
;
}
else
if
(
uiParamEntity
.
getJavaType
().
equals
(
"String"
))
{
inputType
=
InputType
.
TYPE_CLASS_TEXT
;
}
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/BreedingRecordFragment.java
0 → 100644
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
ui
.
fragment
;
import
android.Manifest
;
import
android.app.Dialog
;
import
android.os.Bundle
;
import
android.text.InputType
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.Window
;
import
android.widget.FrameLayout
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProviders
;
import
com.afollestad.materialdialogs.DialogAction
;
import
com.afollestad.materialdialogs.MaterialDialog
;
import
com.bigkoo.pickerview.builder.TimePickerBuilder
;
import
com.bigkoo.pickerview.listener.OnTimeSelectChangeListener
;
import
com.bigkoo.pickerview.listener.OnTimeSelectListener
;
import
com.bigkoo.pickerview.view.TimePickerView
;
import
com.lingber.mycontrol.datagridview.DataGridView
;
import
com.lingber.mycontrol.datagridview.RecyclerviewAdapter
;
import
com.phlx.anchorcollect.BR
;
import
com.phlx.anchorcollect.Configs
;
import
com.phlx.anchorcollect.R
;
import
com.phlx.anchorcollect.data.VMFactory
;
import
com.phlx.anchorcollect.databinding.FragmentBreedingRecordBinding
;
import
com.phlx.anchorcollect.entity.BreedingRecordDetailEntity
;
import
com.phlx.anchorcollect.entity.DictEntity
;
import
com.phlx.anchorcollect.entity.GenTableColumn
;
import
com.phlx.anchorcollect.ui.fragment.vm.BreedingRecordVM
;
import
com.phlx.anchorcollect.util.DictUtils
;
import
com.phlx.anchorcollect.util.ImagePicker
;
import
com.phlx.anchorcollect.util.StringUtil
;
import
com.phlx.anchorcollect.widget.SpaceItemDecoration
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
io.reactivex.functions.Consumer
;
import
me.goldze.mvvmhabit.base.BaseFragment
;
import
me.goldze.mvvmhabit.utils.ToastUtils
;
public
class
BreedingRecordFragment
extends
BaseFragment
<
FragmentBreedingRecordBinding
,
BreedingRecordVM
>
{
private
TimePickerView
pvTime
;
private
ImagePicker
mImagePicker
;
private
DataGridView
mDataGridView
;
private
static
class
SingletonClassInstance
{
private
static
final
BreedingRecordFragment
instance
=
new
BreedingRecordFragment
();
}
private
BreedingRecordFragment
()
{
}
public
static
BreedingRecordFragment
getInstance
()
{
return
BreedingRecordFragment
.
SingletonClassInstance
.
instance
;
}
@Override
public
int
initContentView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
return
R
.
layout
.
fragment_breeding_record
;
}
@Override
public
int
initVariableId
()
{
return
BR
.
viewModel
;
}
@Override
public
void
initParam
()
{
super
.
initParam
();
}
@Override
public
BreedingRecordVM
initViewModel
()
{
VMFactory
factory
=
VMFactory
.
getInstance
(
getActivity
().
getApplication
());
return
ViewModelProviders
.
of
(
this
,
factory
).
get
(
BreedingRecordVM
.
class
);
}
@Override
public
void
initData
()
{
super
.
initData
();
viewModel
.
initGen
();
binding
.
rvCollect
.
addItemDecoration
(
new
SpaceItemDecoration
(
16
));
binding
.
rvCollectDetail
.
addItemDecoration
(
new
SpaceItemDecoration
(
16
));
initTimePicker
();
initRecordGrid
();
}
@Override
public
void
initViewObservable
()
{
super
.
initViewObservable
();
viewModel
.
onCardClickEvent
.
observe
(
getActivity
(),
new
Observer
<
Boolean
>()
{
@Override
public
void
onChanged
(
Boolean
aBoolean
)
{
if
(
viewModel
.
currentParamEntity
!=
null
)
{
switch
(
viewModel
.
currentParamEntity
.
getHtmlType
())
{
case
"checkbox"
:
showCheckboxDialog
(
viewModel
.
currentParamEntity
);
break
;
case
"input"
:
case
"textarea"
:
showInputDialog
(
viewModel
.
currentParamEntity
);
break
;
case
"datetime"
:
showSelectDateDialog
(
viewModel
.
currentParamEntity
);
break
;
case
"select"
:
case
"radio"
:
showSpinnerDialog
(
viewModel
.
currentParamEntity
);
break
;
case
"photo"
:
if
(
viewModel
.
tag
.
get
().
equals
(
""
))
{
ToastUtils
.
showShort
(
"请先输入可视耳标号"
);
}
else
{
showPhotoDialog
(
viewModel
.
currentParamEntity
);
}
break
;
}
}
}
});
viewModel
.
onNotifyAllEvent
.
observe
(
getActivity
(),
new
Observer
<
Boolean
>()
{
@Override
public
void
onChanged
(
Boolean
aBoolean
)
{
if
(
aBoolean
)
{
viewModel
.
clearParamList
();
viewModel
.
clearDetailParamList
();
}
for
(
GenTableColumn
gtc
:
viewModel
.
uiList
)
{
gtc
.
notifyChange
();
}
viewModel
.
remarkParamEntity
.
notifyChange
();
binding
.
rvCollect
.
getAdapter
().
notifyDataSetChanged
();
binding
.
rvCollectDetail
.
getAdapter
().
notifyDataSetChanged
();
updateRecordData
();
}
});
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
();
}
});
}
//选择框
private
void
showSpinnerDialog
(
GenTableColumn
uiParamEntity
)
{
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
"标题"
)
// .positiveText("确认")
// .negativeText("取消")
.
items
(
DictUtils
.
getDistNameList
(
uiParamEntity
.
getDictType
()))
.
itemsCallback
(
new
MaterialDialog
.
ListCallback
()
{
@Override
public
void
onSelection
(
MaterialDialog
dialog
,
View
view
,
int
which
,
CharSequence
text
)
{
Toast
.
makeText
(
getActivity
(),
which
+
":"
+
text
.
toString
(),
Toast
.
LENGTH_SHORT
).
show
();
viewModel
.
currentParamEntity
.
setShowName
(
text
.
toString
());
List
<
DictEntity
>
distTypeList
=
DictUtils
.
getDistList
(
uiParamEntity
.
getDictType
());
viewModel
.
currentParamEntity
.
setContent
(
distTypeList
.
get
(
which
).
getDictValue
());
viewModel
.
currentParamEntity
.
notifyChange
();
}
})
.
show
();
}
//多选框
private
void
showCheckboxDialog
(
GenTableColumn
uiParamEntity
)
{
new
MaterialDialog
.
Builder
(
getActivity
()).
title
(
"系统信息"
).
content
(
"请选择!!!"
)
.
cancelable
(
false
).
canceledOnTouchOutside
(
false
)
.
positiveText
(
"确定"
)
.
items
(
DictUtils
.
getDistNameList
(
uiParamEntity
.
getDictType
()))
.
itemsCallbackMultiChoice
(
null
,
new
MaterialDialog
.
ListCallbackMultiChoice
()
{
@Override
public
boolean
onSelection
(
MaterialDialog
dialog
,
Integer
[]
which
,
CharSequence
[]
text
)
{
String
showName
=
""
;
String
content
=
""
;
List
<
DictEntity
>
distTypeList
=
DictUtils
.
getDistList
(
uiParamEntity
.
getDictType
());
if
(
which
!=
null
&&
which
.
length
>
0
)
{
for
(
Integer
i
:
which
)
{
showName
+=
distTypeList
.
get
(
i
).
getDictLabel
();
showName
+=
","
;
content
+=
distTypeList
.
get
(
i
).
getDictValue
();
content
+=
","
;
}
}
viewModel
.
currentParamEntity
.
setShowName
(
showName
);
viewModel
.
currentParamEntity
.
setContent
(
content
);
viewModel
.
currentParamEntity
.
notifyChange
();
return
true
;
}
}).
show
();
}
//输入框
private
void
showInputDialog
(
GenTableColumn
uiParamEntity
)
{
int
inputType
=
0
;
if
(
uiParamEntity
.
getJavaType
().
equals
(
"Long"
)
||
uiParamEntity
.
getJavaType
().
equals
(
"Integer"
))
{
inputType
=
InputType
.
TYPE_CLASS_NUMBER
;
}
else
if
(
uiParamEntity
.
getJavaType
().
equals
(
"BigDecimal"
)
||
uiParamEntity
.
getJavaType
().
equals
(
"Duoble"
))
{
inputType
=
InputType
.
TYPE_CLASS_NUMBER
|
InputType
.
TYPE_NUMBER_FLAG_DECIMAL
|
InputType
.
TYPE_NUMBER_FLAG_SIGNED
;
;
}
else
if
(
uiParamEntity
.
getJavaType
().
equals
(
"String"
))
{
inputType
=
InputType
.
TYPE_CLASS_TEXT
;
}
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
uiParamEntity
.
getColumnComment
())
// .iconRes(R.drawable.ic_logo)
.
content
(
"请输入"
)
// .widgetColor(Color.BLUE)//输入框光标的颜色
.
inputType
(
inputType
)
//可以输入的类型
//前2个一个是hint一个是预输入的文字
.
input
(
"输入"
+
uiParamEntity
.
getColumnComment
(),
uiParamEntity
.
getShowName
(),
new
MaterialDialog
.
InputCallback
()
{
@Override
public
void
onInput
(
@NonNull
MaterialDialog
dialog
,
CharSequence
input
)
{
Log
.
i
(
"scan"
,
"输入的是:"
+
input
);
}
})
.
onPositive
(
new
MaterialDialog
.
SingleButtonCallback
()
{
@Override
public
void
onClick
(
@NonNull
MaterialDialog
dialog
,
@NonNull
DialogAction
which
)
{
// dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
viewModel
.
currentParamEntity
.
setShowName
(
dialog
.
getInputEditText
().
getText
().
toString
());
viewModel
.
currentParamEntity
.
setContent
(
dialog
.
getInputEditText
().
getText
().
toString
());
viewModel
.
currentParamEntity
.
notifyChange
();
}
})
.
show
();
}
//拍照
private
void
showPhotoDialog
(
GenTableColumn
uiParamEntity
)
{
RxPermissions
rxPermissions
=
new
RxPermissions
(
getActivity
());
rxPermissions
.
request
(
Manifest
.
permission
.
CAMERA
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
.
subscribe
(
new
Consumer
<
Boolean
>()
{
@Override
public
void
accept
(
Boolean
aBoolean
)
throws
Exception
{
if
(
aBoolean
)
{
mImagePicker
.
show
(
getActivity
());
}
else
{
ToastUtils
.
showShort
(
"权限被拒绝"
);
}
}
});
}
//时间选择
private
void
showSelectDateDialog
(
GenTableColumn
uiParamEntity
)
{
pvTime
.
show
(
binding
.
card99
);
}
private
void
initTimePicker
()
{
//Dialog
pvTime
=
new
TimePickerBuilder
(
getActivity
(),
new
OnTimeSelectListener
()
{
@Override
public
void
onTimeSelect
(
Date
date
,
View
v
)
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
viewModel
.
currentParamEntity
.
setContent
(
dateFormat
.
format
(
date
));
viewModel
.
currentParamEntity
.
setShowName
(
dateFormat
.
format
(
date
));
viewModel
.
currentParamEntity
.
notifyChange
();
}
})
.
setTimeSelectChangeListener
(
new
OnTimeSelectChangeListener
()
{
@Override
public
void
onTimeSelectChanged
(
Date
date
)
{
}
})
.
setType
(
new
boolean
[]{
true
,
true
,
true
,
false
,
false
,
false
})
.
isDialog
(
true
)
//默认设置false ,内部实现将DecorView 作为它的父控件。
.
addOnCancelClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Log
.
i
(
"pvTime"
,
"onCancelClickListener"
);
}
})
.
setItemVisibleCount
(
5
)
//若设置偶数,实际值会加1(比如设置6,则最大可见条目为7)
.
setLineSpacingMultiplier
(
2.0f
)
.
isAlphaGradient
(
true
)
.
build
();
Dialog
mDialog
=
pvTime
.
getDialog
();
if
(
mDialog
!=
null
)
{
FrameLayout
.
LayoutParams
params
=
new
FrameLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
Gravity
.
CENTER
);
params
.
leftMargin
=
0
;
params
.
rightMargin
=
0
;
pvTime
.
getDialogContainerLayout
().
setLayoutParams
(
params
);
Window
dialogWindow
=
mDialog
.
getWindow
();
if
(
dialogWindow
!=
null
)
{
dialogWindow
.
setWindowAnimations
(
com
.
bigkoo
.
pickerview
.
R
.
style
.
picker_view_slide_anim
);
//修改动画样式
dialogWindow
.
setGravity
(
Gravity
.
CENTER
);
//改成Bottom,底部显示
dialogWindow
.
setDimAmount
(
0.3f
);
}
}
}
//配种详情列表
private
void
initRecordGrid
()
{
mDataGridView
=
binding
.
llDetailTitle
;
//初始化表头
List
<
String
>
headerStr
=
new
ArrayList
<>();
List
<
String
>
fieldNameStr
=
new
ArrayList
<>();
for
(
GenTableColumn
gtc
:
Configs
.
cattlematingDetaill
)
{
if
(
"1"
.
equals
(
gtc
.
getIsList
()))
{
headerStr
.
add
(
gtc
.
getColumnComment
());
fieldNameStr
.
add
(
gtc
.
getJavaField
());
}
}
// // 设置列数
mDataGridView
.
setColunms
(
headerStr
.
size
());
// // 设置表头内容
// mDataGridView.setHeaderHeight(30);
mDataGridView
.
setHeaderContent
(
StringUtil
.
listToStr
(
headerStr
));
// // 绑定字段
mDataGridView
.
setFieldNames
(
StringUtil
.
listToStr
(
fieldNameStr
));
// // 每个column占比
mDataGridView
.
setColunmWeight
(
StringUtil
.
getFloats
(
headerStr
.
size
()));
// // 每个单元格包含控件
mDataGridView
.
setCellContentView
(
StringUtil
.
getClasses
(
headerStr
.
size
()));
// 单行选中模式
mDataGridView
.
setSelectedMode
(
1
);
// 设置列数
// mDataGridView.setColunms(3);
// 设置行高
mDataGridView
.
setRowHeight
(
100
);
// 启用翻页
// mDataGridView.setFlipOverEnable(true, 9, getFragmentManager());
// 初始化表格
mDataGridView
.
initDataGridView
();
mDataGridView
.
setOnItemCellClickListener
(
new
RecyclerviewAdapter
.
OnItemCellClickListener
()
{
@Override
public
void
onClick
(
View
v
,
int
row
,
int
column
)
{
// ToastUtils.showShort("row:" + row + " column:" + column);
BreedingRecordDetailEntity
rowData
=
(
BreedingRecordDetailEntity
)
(
mDataGridView
.
getRowData
(
row
));
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
"替换提示"
)
.
content
(
"要把配种数据替换成:"
+
rowData
.
getUnid
()
+
"吗?"
)
.
positiveText
(
"确定"
)
.
negativeText
(
"取消"
)
.
onPositive
(
new
MaterialDialog
.
SingleButtonCallback
()
{
@Override
public
void
onClick
(
@NonNull
MaterialDialog
dialog
,
@NonNull
DialogAction
which
)
{
if
(
which
==
DialogAction
.
POSITIVE
)
{
viewModel
.
initDetaileData
(
rowData
);
}
}
}).
show
();
}
});
updateRecordData
();
}
//刷新数据
private
void
updateRecordData
()
{
// 设置数据源
List
<
BreedingRecordDetailEntity
>
dataSource
=
viewModel
.
getDetail
();
// 设置数据源
if
(
dataSource
==
null
)
{
dataSource
=
new
ArrayList
<>();
}
mDataGridView
.
setDataSource
(
dataSource
);
mDataGridView
.
updateAll
();
}
@Override
public
void
onHiddenChanged
(
boolean
hidden
)
{
super
.
onHiddenChanged
(
hidden
);
if
(
this
!=
null
&&
!
hidden
)
{
viewModel
.
clearParamList
();
viewModel
.
clearDetailParamList
();
viewModel
.
queryBreedingRecord
();
}
}
}
app/src/main/java/com/phlx/anchorcollect/ui/fragment/PerformanceFragment.java
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
ui
.
fragment
;
import
android.Manifest
;
import
android.app.Dialog
;
import
android.os.Bundle
;
import
android.text.InputType
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.Window
;
import
android.widget.FrameLayout
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProviders
;
import
com.afollestad.materialdialogs.DialogAction
;
import
com.afollestad.materialdialogs.MaterialDialog
;
import
com.bigkoo.pickerview.builder.TimePickerBuilder
;
import
com.bigkoo.pickerview.listener.OnTimeSelectChangeListener
;
import
com.bigkoo.pickerview.listener.OnTimeSelectListener
;
import
com.bigkoo.pickerview.view.TimePickerView
;
import
com.phlx.anchorcollect.R
;
import
com.phlx.anchorcollect.data.VMFactory
;
import
com.phlx.anchorcollect.databinding.FragmentPerformanceBinding
;
import
com.phlx.anchorcollect.entity.DictEntity
;
import
com.phlx.anchorcollect.entity.GenTableColumn
;
import
com.phlx.anchorcollect.rfid.ModuleManager
;
import
com.phlx.anchorcollect.ui.fragment.vm.BasicsCollectVM
;
import
com.phlx.anchorcollect.ui.fragment.vm.PerformanceVM
;
import
com.phlx.anchorcollect.util.DictUtils
;
import
com.phlx.anchorcollect.util.ImagePicker
;
import
com.phlx.anchorcollect.widget.SpaceItemDecoration
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
io.reactivex.functions.Consumer
;
import
me.goldze.mvvmhabit.base.BaseFragment
;
import
me.goldze.mvvmhabit.utils.ToastUtils
;
import
me.tatarka.bindingcollectionadapter2.BR
;
public
class
PerformanceFragment
extends
BaseFragment
<
FragmentPerformanceBinding
,
PerformanceVM
>
{
private
TimePickerView
pvTime
;
private
ImagePicker
mImagePicker
;
private
static
class
SingletonClassInstance
{
private
static
final
PerformanceFragment
instance
=
new
PerformanceFragment
();
}
private
PerformanceFragment
()
{
}
public
static
PerformanceFragment
getInstance
()
{
return
PerformanceFragment
.
SingletonClassInstance
.
instance
;
}
@Override
public
int
initContentView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
return
R
.
layout
.
fragment_performance
;
...
...
@@ -46,10 +91,241 @@ public class PerformanceFragment extends BaseFragment<FragmentPerformanceBinding
viewModel
.
initGen
();
binding
.
rvCollect
.
addItemDecoration
(
new
SpaceItemDecoration
(
16
));
initTimePicker
();
}
@Override
public
void
initViewObservable
()
{
super
.
initViewObservable
();
viewModel
.
onCardClickEvent
.
observe
(
getActivity
(),
new
Observer
<
Boolean
>()
{
@Override
public
void
onChanged
(
Boolean
aBoolean
)
{
if
(
viewModel
.
currentParamEntity
!=
null
)
{
switch
(
viewModel
.
currentParamEntity
.
getHtmlType
())
{
case
"checkbox"
:
showCheckboxDialog
(
viewModel
.
currentParamEntity
);
break
;
case
"input"
:
case
"textarea"
:
showInputDialog
(
viewModel
.
currentParamEntity
);
break
;
case
"datetime"
:
showSelectDateDialog
(
viewModel
.
currentParamEntity
);
break
;
case
"select"
:
case
"radio"
:
showSpinnerDialog
(
viewModel
.
currentParamEntity
);
break
;
case
"photo"
:
if
(
viewModel
.
tag
.
get
().
equals
(
""
))
{
ToastUtils
.
showShort
(
"请先输入可视耳标号"
);
}
else
{
showPhotoDialog
(
viewModel
.
currentParamEntity
);
}
break
;
}
}
}
});
viewModel
.
onNotifyAllEvent
.
observe
(
getActivity
(),
new
Observer
<
Boolean
>()
{
@Override
public
void
onChanged
(
Boolean
aBoolean
)
{
if
(
aBoolean
)
viewModel
.
clearParamList
();
for
(
GenTableColumn
gtc
:
viewModel
.
uiList
)
{
gtc
.
notifyChange
();
}
viewModel
.
remarkParamEntity
.
notifyChange
();
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
();
}
});
}
//选择框
private
void
showSpinnerDialog
(
GenTableColumn
uiParamEntity
)
{
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
"标题"
)
// .positiveText("确认")
// .negativeText("取消")
.
items
(
DictUtils
.
getDistNameList
(
uiParamEntity
.
getDictType
()))
.
itemsCallback
(
new
MaterialDialog
.
ListCallback
()
{
@Override
public
void
onSelection
(
MaterialDialog
dialog
,
View
view
,
int
which
,
CharSequence
text
)
{
Toast
.
makeText
(
getActivity
(),
which
+
":"
+
text
.
toString
(),
Toast
.
LENGTH_SHORT
).
show
();
viewModel
.
currentParamEntity
.
setShowName
(
text
.
toString
());
List
<
DictEntity
>
distTypeList
=
DictUtils
.
getDistList
(
uiParamEntity
.
getDictType
());
viewModel
.
currentParamEntity
.
setContent
(
distTypeList
.
get
(
which
).
getDictValue
());
viewModel
.
currentParamEntity
.
notifyChange
();
}
})
.
show
();
}
//多选框
private
void
showCheckboxDialog
(
GenTableColumn
uiParamEntity
)
{
new
MaterialDialog
.
Builder
(
getActivity
()).
title
(
"系统信息"
).
content
(
"请选择!!!"
)
.
cancelable
(
false
).
canceledOnTouchOutside
(
false
)
.
positiveText
(
"确定"
)
.
items
(
DictUtils
.
getDistNameList
(
uiParamEntity
.
getDictType
()))
.
itemsCallbackMultiChoice
(
null
,
new
MaterialDialog
.
ListCallbackMultiChoice
()
{
@Override
public
boolean
onSelection
(
MaterialDialog
dialog
,
Integer
[]
which
,
CharSequence
[]
text
)
{
String
showName
=
""
;
String
content
=
""
;
List
<
DictEntity
>
distTypeList
=
DictUtils
.
getDistList
(
uiParamEntity
.
getDictType
());
if
(
which
!=
null
&&
which
.
length
>
0
)
{
for
(
Integer
i
:
which
)
{
showName
+=
distTypeList
.
get
(
i
).
getDictLabel
();
showName
+=
","
;
content
+=
distTypeList
.
get
(
i
).
getDictValue
();
content
+=
","
;
}
}
viewModel
.
currentParamEntity
.
setShowName
(
showName
);
viewModel
.
currentParamEntity
.
setContent
(
content
);
viewModel
.
currentParamEntity
.
notifyChange
();
return
true
;
}
}).
show
();
}
//输入框
private
void
showInputDialog
(
GenTableColumn
uiParamEntity
)
{
int
inputType
=
0
;
if
(
uiParamEntity
.
getJavaType
().
equals
(
"Long"
)
||
uiParamEntity
.
getJavaType
().
equals
(
"Integer"
))
{
inputType
=
InputType
.
TYPE_CLASS_NUMBER
;
}
else
if
(
uiParamEntity
.
getJavaType
().
equals
(
"BigDecimal"
)
||
uiParamEntity
.
getJavaType
().
equals
(
"Duoble"
))
{
inputType
=
InputType
.
TYPE_CLASS_NUMBER
|
InputType
.
TYPE_NUMBER_FLAG_DECIMAL
|
InputType
.
TYPE_NUMBER_FLAG_SIGNED
;
;
}
else
if
(
uiParamEntity
.
getJavaType
().
equals
(
"String"
))
{
inputType
=
InputType
.
TYPE_CLASS_TEXT
;
}
new
MaterialDialog
.
Builder
(
getActivity
())
.
title
(
uiParamEntity
.
getColumnComment
())
// .iconRes(R.drawable.ic_logo)
.
content
(
"请输入"
)
// .widgetColor(Color.BLUE)//输入框光标的颜色
.
inputType
(
inputType
)
//可以输入的类型
//前2个一个是hint一个是预输入的文字
.
input
(
"输入"
+
uiParamEntity
.
getColumnComment
(),
uiParamEntity
.
getShowName
(),
new
MaterialDialog
.
InputCallback
()
{
@Override
public
void
onInput
(
@NonNull
MaterialDialog
dialog
,
CharSequence
input
)
{
Log
.
i
(
"scan"
,
"输入的是:"
+
input
);
}
})
.
onPositive
(
new
MaterialDialog
.
SingleButtonCallback
()
{
@Override
public
void
onClick
(
@NonNull
MaterialDialog
dialog
,
@NonNull
DialogAction
which
)
{
// dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
viewModel
.
currentParamEntity
.
setShowName
(
dialog
.
getInputEditText
().
getText
().
toString
());
viewModel
.
currentParamEntity
.
setContent
(
dialog
.
getInputEditText
().
getText
().
toString
());
viewModel
.
currentParamEntity
.
notifyChange
();
}
})
.
show
();
}
//拍照
private
void
showPhotoDialog
(
GenTableColumn
uiParamEntity
)
{
RxPermissions
rxPermissions
=
new
RxPermissions
(
getActivity
());
rxPermissions
.
request
(
Manifest
.
permission
.
CAMERA
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
.
subscribe
(
new
Consumer
<
Boolean
>()
{
@Override
public
void
accept
(
Boolean
aBoolean
)
throws
Exception
{
if
(
aBoolean
)
{
mImagePicker
.
show
(
getActivity
());
}
else
{
ToastUtils
.
showShort
(
"权限被拒绝"
);
}
}
});
}
//时间选择
private
void
showSelectDateDialog
(
GenTableColumn
uiParamEntity
)
{
pvTime
.
show
(
binding
.
card99
);
}
private
void
initTimePicker
()
{
//Dialog
pvTime
=
new
TimePickerBuilder
(
getActivity
(),
new
OnTimeSelectListener
()
{
@Override
public
void
onTimeSelect
(
Date
date
,
View
v
)
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
viewModel
.
currentParamEntity
.
setContent
(
dateFormat
.
format
(
date
));
viewModel
.
currentParamEntity
.
setShowName
(
dateFormat
.
format
(
date
));
viewModel
.
currentParamEntity
.
notifyChange
();
}
})
.
setTimeSelectChangeListener
(
new
OnTimeSelectChangeListener
()
{
@Override
public
void
onTimeSelectChanged
(
Date
date
)
{
}
})
.
setType
(
new
boolean
[]{
true
,
true
,
true
,
false
,
false
,
false
})
.
isDialog
(
true
)
//默认设置false ,内部实现将DecorView 作为它的父控件。
.
addOnCancelClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Log
.
i
(
"pvTime"
,
"onCancelClickListener"
);
}
})
.
setItemVisibleCount
(
5
)
//若设置偶数,实际值会加1(比如设置6,则最大可见条目为7)
.
setLineSpacingMultiplier
(
2.0f
)
.
isAlphaGradient
(
true
)
.
build
();
Dialog
mDialog
=
pvTime
.
getDialog
();
if
(
mDialog
!=
null
)
{
FrameLayout
.
LayoutParams
params
=
new
FrameLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
Gravity
.
CENTER
);
params
.
leftMargin
=
0
;
params
.
rightMargin
=
0
;
pvTime
.
getDialogContainerLayout
().
setLayoutParams
(
params
);
Window
dialogWindow
=
mDialog
.
getWindow
();
if
(
dialogWindow
!=
null
)
{
dialogWindow
.
setWindowAnimations
(
com
.
bigkoo
.
pickerview
.
R
.
style
.
picker_view_slide_anim
);
//修改动画样式
dialogWindow
.
setGravity
(
Gravity
.
CENTER
);
//改成Bottom,底部显示
dialogWindow
.
setDimAmount
(
0.3f
);
}
}
}
}
app/src/main/java/com/phlx/anchorcollect/ui/fragment/list/CollectGridItem.java
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
ui
.
fragment
.
list
;
import
android.view.View
;
import
androidx.annotation.NonNull
;
import
androidx.databinding.ObservableField
;
import
com.phlx.anchorcollect.Configs
;
import
com.phlx.anchorcollect.R
;
import
com.phlx.anchorcollect.entity.GenTableColumn
;
import
com.phlx.anchorcollect.ui.fragment.vm.BasicsCollectVM
;
import
com.phlx.anchorcollect.ui.fragment.vm.BreedingRecordVM
;
import
com.phlx.anchorcollect.ui.fragment.vm.PerformanceVM
;
import
cn.hutool.core.util.IdUtil
;
import
me.goldze.mvvmhabit.base.BaseViewModel
;
import
me.goldze.mvvmhabit.base.ItemViewModel
;
import
me.goldze.mvvmhabit.binding.command.BindingAction
;
...
...
@@ -18,12 +24,29 @@ public class CollectGridItem extends ItemViewModel<BaseViewModel> {
public
ObservableField
<
GenTableColumn
>
entity
=
new
ObservableField
<>();
public
ObservableField
<
Integer
>
titleGrayColor
=
new
ObservableField
<>(
View
.
VISIBLE
);
public
ObservableField
<
Integer
>
titleBlueColor
=
new
ObservableField
<>(
View
.
GONE
);
private
String
fragmentType
;
public
CollectGridItem
(
@NonNull
BaseViewModel
viewModel
,
GenTableColumn
entity
,
String
fragmentType
)
{
super
(
viewModel
);
this
.
entity
.
set
(
entity
);
this
.
fragmentType
=
fragmentType
;
initView
();
}
private
void
initView
(){
if
(
"1"
.
equals
(
entity
.
get
().
getIsEdit
())){
titleGrayColor
.
set
(
View
.
GONE
);
titleBlueColor
.
set
(
View
.
VISIBLE
);
}
else
{
titleGrayColor
.
set
(
View
.
VISIBLE
);
titleBlueColor
.
set
(
View
.
GONE
);
}
}
public
BindingCommand
onItemClickCommand
=
new
BindingCommand
(
new
BindingAction
()
{
...
...
@@ -35,7 +58,7 @@ public class CollectGridItem extends ItemViewModel<BaseViewModel> {
((
BasicsCollectVM
)
viewModel
).
onItemClick
(
entity
.
get
());
break
;
case
Configs
.
SIGN_MEASURE
:
((
PerformanceVM
)
viewModel
).
onItemClick
(
entity
.
get
());
break
;
case
Configs
.
WEIGHTING_MANAGE
:
...
...
@@ -47,7 +70,10 @@ public class CollectGridItem extends ItemViewModel<BaseViewModel> {
break
;
case
Configs
.
BREEDING_RECORD
:
((
BreedingRecordVM
)
viewModel
).
onItemClick
(
entity
.
get
());
break
;
case
Configs
.
BREEDING_RECORD_DETAIL
:
((
BreedingRecordVM
)
viewModel
).
onItemClick
(
entity
.
get
());
break
;
}
}
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/vm/BreedingRecordVM.java
0 → 100644
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
ui
.
fragment
.
vm
;
import
android.app.Application
;
import
android.graphics.drawable.Drawable
;
import
android.os.Environment
;
import
androidx.annotation.NonNull
;
import
androidx.databinding.ObservableArrayList
;
import
androidx.databinding.ObservableField
;
import
androidx.databinding.ObservableList
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.phlx.anchorcollect.BR
;
import
com.phlx.anchorcollect.Configs
;
import
com.phlx.anchorcollect.R
;
import
com.phlx.anchorcollect.data.Repository
;
import
com.phlx.anchorcollect.db.DbUtil
;
import
com.phlx.anchorcollect.db.gen.BreedingRecordDetailEntityDao
;
import
com.phlx.anchorcollect.db.gen.BreedingRecordEntityDao
;
import
com.phlx.anchorcollect.db.gen.DictEntityDao
;
import
com.phlx.anchorcollect.db.interf.DbIDUCallBack
;
import
com.phlx.anchorcollect.db.interf.DbQueryCallBack
;
import
com.phlx.anchorcollect.entity.BreedingRecordDetailEntity
;
import
com.phlx.anchorcollect.entity.BreedingRecordEntity
;
import
com.phlx.anchorcollect.entity.DictEntity
;
import
com.phlx.anchorcollect.entity.GenTableColumn
;
import
com.phlx.anchorcollect.ui.fragment.list.CollectGridItem
;
import
com.phlx.anchorcollect.util.DateUtils
;
import
com.phlx.anchorcollect.util.EntityUtils
;
import
org.greenrobot.greendao.query.QueryBuilder
;
import
java.io.File
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
cn.hutool.core.util.IdUtil
;
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.event.SingleLiveEvent
;
import
me.goldze.mvvmhabit.utils.SPUtils
;
import
me.goldze.mvvmhabit.utils.StringUtils
;
import
me.goldze.mvvmhabit.utils.ToastUtils
;
import
me.tatarka.bindingcollectionadapter2.ItemBinding
;
public
class
BreedingRecordVM
extends
BaseViewModel
<
Repository
>
{
public
Drawable
drawableImg
;
//照片路径
private
String
imgUrl
;
private
File
imgFile
;
//存放非list控件
public
List
<
GenTableColumn
>
uiList
=
new
ArrayList
<>();
public
GenTableColumn
currentParamEntity
;
public
GenTableColumn
remarkParamEntity
=
new
GenTableColumn
();
//给RecyclerView添加ObservableList
public
ObservableList
<
CollectGridItem
>
observableList
=
new
ObservableArrayList
<>();
//主表
public
ObservableList
<
CollectGridItem
>
detailObservableList
=
new
ObservableArrayList
<>();
//详情
//给RecyclerView添加ItemBinding
public
ItemBinding
<
CollectGridItem
>
itemBinding
=
ItemBinding
.
of
(
BR
.
viewModel
,
R
.
layout
.
item_collect_grid
);
public
SingleLiveEvent
<
Boolean
>
onCattleClickEvent
=
new
SingleLiveEvent
<>();
public
SingleLiveEvent
<
Boolean
>
onCardClickEvent
=
new
SingleLiveEvent
<>();
public
SingleLiveEvent
<
Boolean
>
onTagClickEvent
=
new
SingleLiveEvent
<>();
public
SingleLiveEvent
<
Boolean
>
onNotifyAllEvent
=
new
SingleLiveEvent
<>();
//true是清空页面
public
SingleLiveEvent
<
String
>
onShowDialogEvent
=
new
SingleLiveEvent
<>();
//弹窗提示
public
ObservableField
<
String
>
tag
=
new
ObservableField
<>(
""
);
public
ObservableField
<
String
>
weight
=
new
ObservableField
<>(
"125.5"
);
private
BreedingRecordEntity
tempEntity
;
private
BreedingRecordDetailEntity
tempDetailEntity
;
private
SimpleDateFormat
dateFormat
;
private
List
<
BreedingRecordEntity
>
uploadData
;
private
List
<
BreedingRecordDetailEntity
>
detailUploadData
;
private
List
<
BreedingRecordDetailEntity
>
detailList
;
public
BreedingRecordVM
(
@NonNull
Application
application
,
Repository
model
)
{
super
(
application
,
model
);
}
public
void
initGen
()
{
imgUrl
=
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
"/collect/picture/"
+
"anchorCiq"
+
tag
+
".jpg"
;
imgFile
=
new
File
(
imgUrl
);
for
(
GenTableColumn
gtc
:
Configs
.
cattlematingMaster
)
{
CollectGridItem
cgi
=
new
CollectGridItem
(
this
,
gtc
,
Configs
.
BREEDING_RECORD
);
observableList
.
add
(
cgi
);
}
for
(
GenTableColumn
gtc
:
Configs
.
cattlematingDetaill
)
{
CollectGridItem
cgi
=
new
CollectGridItem
(
this
,
gtc
,
Configs
.
BREEDING_RECORD_DETAIL
);
detailObservableList
.
add
(
cgi
);
}
//初始化一下备注
remarkParamEntity
.
setColumnName
(
"备注"
);
remarkParamEntity
.
setContent
(
""
);
remarkParamEntity
.
setShowName
(
""
);
remarkParamEntity
.
setColumnComment
(
"备注"
);
remarkParamEntity
.
setHtmlType
(
"input"
);
remarkParamEntity
.
setJavaType
(
"String"
);
}
public
void
queryBreedingRecord
()
{
QueryBuilder
<
BreedingRecordEntity
>
builder
=
DbUtil
.
getInstance
().
getQueryBuilder
(
BreedingRecordEntity
.
class
)
.
where
(
BreedingRecordEntityDao
.
Properties
.
CattleresumeId
.
eq
(
Configs
.
tempUnid
)
,
BreedingRecordEntityDao
.
Properties
.
CreateTime
.
like
(
DateUtils
.
getYear
()
+
"%"
)
)
.
orderDesc
(
BreedingRecordEntityDao
.
Properties
.
CreateTime
);
DbUtil
.
getInstance
().
setDbQueryCallBack
(
new
DbQueryCallBack
<
BreedingRecordEntity
>()
{
@Override
public
void
onSuccess
(
List
<
BreedingRecordEntity
>
result
)
{
clearDetailParamList
();
if
(
result
!=
null
&&
result
.
size
()
>
0
)
{
initData
(
result
.
get
(
0
));
}
else
{
initData
(
null
);
onNotifyAllEvent
.
setValue
(
true
);
}
}
@Override
public
void
onFailed
()
{
onNotifyAllEvent
.
setValue
(
true
);
ToastUtils
.
showShort
(
"配种记录主表-数据库查询失败"
);
}
}).
queryAsyncAll
(
BreedingRecordEntity
.
class
,
builder
);
}
//初始化主表
private
void
initData
(
BreedingRecordEntity
breedingRecordEntity
)
{
tempEntity
=
new
BreedingRecordEntity
();
if
(
breedingRecordEntity
==
null
)
{
onNotifyAllEvent
.
setValue
(
true
);
}
else
{
//拿到unid 创建人 创建时间 部门id
tempEntity
.
setUnid
(
breedingRecordEntity
.
getUnid
());
tempEntity
.
setCreateBy
(
breedingRecordEntity
.
getCreateBy
());
tempEntity
.
setCreateTime
(
breedingRecordEntity
.
getCreateTime
());
tempEntity
.
setDeptId
(
breedingRecordEntity
.
getDeptId
());
String
[]
filedName
=
EntityUtils
.
getFiledName
(
breedingRecordEntity
);
for
(
String
name
:
filedName
)
{
for
(
GenTableColumn
gtc
:
Configs
.
cattlematingMaster
)
{
if
(
name
.
equals
(
gtc
.
getJavaField
()))
{
try
{
Object
fieldValueByName
=
EntityUtils
.
getFieldValueByName
(
name
,
breedingRecordEntity
);
String
value
=
fieldValueByName
==
null
?
""
:
fieldValueByName
.
toString
();
// Log.e("fieldValue:", "key:" + name + " | value:" + value);
gtc
.
setContent
(
value
);
String
showName
=
value
;
// 如果是选择的,查字典项
if
(!
StringUtils
.
isEmpty
(
gtc
.
getDictType
()))
{
QueryBuilder
<
DictEntity
>
builder
=
DbUtil
.
getInstance
().
getQueryBuilder
(
DictEntity
.
class
)
.
where
(
DictEntityDao
.
Properties
.
DictType
.
eq
(
gtc
.
getDictType
())
,
DictEntityDao
.
Properties
.
DictValue
.
eq
(
value
));
List
<
DictEntity
>
dictEntities
=
DbUtil
.
getInstance
().
queryAll
(
DictEntity
.
class
,
builder
);
if
(
dictEntities
!=
null
&&
dictEntities
.
size
()
>
0
)
{
showName
=
dictEntities
.
get
(
0
).
getDictLabel
();
}
}
gtc
.
setShowName
(
showName
);
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
}
}
}
initDetailList
(
breedingRecordEntity
);
}
}
//初始化详情列表
private
void
initDetailList
(
BreedingRecordEntity
breedingRecordEntity
)
{
QueryBuilder
<
BreedingRecordDetailEntity
>
builder
=
DbUtil
.
getInstance
().
getQueryBuilder
(
BreedingRecordDetailEntity
.
class
)
.
where
(
BreedingRecordDetailEntityDao
.
Properties
.
FUnid
.
eq
(
breedingRecordEntity
.
getUnid
()));
DbUtil
.
getInstance
().
setDbQueryCallBack
(
new
DbQueryCallBack
<
BreedingRecordDetailEntity
>()
{
@Override
public
void
onSuccess
(
List
<
BreedingRecordDetailEntity
>
result
)
{
if
(
result
!=
null
&&
result
.
size
()
>
0
)
{
detailList
=
result
;
}
onNotifyAllEvent
.
setValue
(
false
);
}
@Override
public
void
onFailed
()
{
onNotifyAllEvent
.
setValue
(
true
);
ToastUtils
.
showShort
(
"配种记录子表-数据库查询失败"
);
}
}).
queryAsyncAll
(
BreedingRecordDetailEntity
.
class
,
builder
);
}
public
List
<
BreedingRecordDetailEntity
>
getDetail
()
{
return
detailList
;
}
public
void
initDetaileData
(
BreedingRecordDetailEntity
brdEntity
)
{
if
(
brdEntity
!=
null
)
{
// onNotifyAllEvent.setValue(true);
// } else {
//拿到unid 创建人 创建时间 部门id
tempDetailEntity
.
setUnid
(
brdEntity
.
getUnid
());
tempDetailEntity
.
setCreateBy
(
brdEntity
.
getCreateBy
());
tempDetailEntity
.
setCreateTime
(
brdEntity
.
getCreateTime
());
tempDetailEntity
.
setDeptId
(
brdEntity
.
getDeptId
());
String
[]
filedName
=
EntityUtils
.
getFiledName
(
brdEntity
);
for
(
String
name
:
filedName
)
{
for
(
GenTableColumn
gtc
:
Configs
.
cattlematingDetaill
)
{
if
(
name
.
equals
(
gtc
.
getJavaField
()))
{
try
{
Object
fieldValueByName
=
EntityUtils
.
getFieldValueByName
(
name
,
brdEntity
);
String
value
=
fieldValueByName
==
null
?
""
:
fieldValueByName
.
toString
();
// Log.e("fieldValue:", "key:" + name + " | value:" + value);
gtc
.
setContent
(
value
);
String
showName
=
value
;
// 如果是选择的,查字典项
if
(!
StringUtils
.
isEmpty
(
gtc
.
getDictType
()))
{
QueryBuilder
<
DictEntity
>
builder
=
DbUtil
.
getInstance
().
getQueryBuilder
(
DictEntity
.
class
)
.
where
(
DictEntityDao
.
Properties
.
DictType
.
eq
(
gtc
.
getDictType
())
,
DictEntityDao
.
Properties
.
DictValue
.
eq
(
value
));
List
<
DictEntity
>
dictEntities
=
DbUtil
.
getInstance
().
queryAll
(
DictEntity
.
class
,
builder
);
if
(
dictEntities
!=
null
&&
dictEntities
.
size
()
>
0
)
{
showName
=
dictEntities
.
get
(
0
).
getDictLabel
();
}
}
gtc
.
setShowName
(
showName
);
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
}
}
onNotifyAllEvent
.
setValue
(
false
);
}
}
}
public
void
onItemClick
(
GenTableColumn
entity
)
{
if
(
StringUtils
.
isEmpty
(
Configs
.
tempUnid
))
{
ToastUtils
.
showShort
(
"请扫描耳标或者输入耳标信息"
);
return
;
}
if
(!
"1"
.
equals
(
entity
.
getIsEdit
()))
return
;
currentParamEntity
=
entity
;
onCardClickEvent
.
call
();
}
public
void
click
(
int
id
)
{
if
(
StringUtils
.
isEmpty
(
Configs
.
tempUnid
))
{
ToastUtils
.
showShort
(
"请扫描耳标或者输入耳标信息"
);
return
;
}
//99备注,100照片
if
(
id
==
99
)
{
currentParamEntity
=
remarkParamEntity
;
}
else
{
currentParamEntity
=
uiList
.
get
(
id
);
}
if
(!
"1"
.
equals
(
currentParamEntity
.
getIsEdit
()))
return
;
onCardClickEvent
.
call
();
}
private
void
queryBreeding
(
String
tag
)
{
}
public
BindingCommand
onSaveClick
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
saveBreedingRecord
();
}
});
//保存主表
private
void
saveBreedingRecord
()
{
JsonObject
jsonObject
=
new
JsonObject
();
for
(
GenTableColumn
gtc
:
Configs
.
cattlematingMaster
)
{
jsonObject
.
addProperty
(
gtc
.
getJavaField
(),
gtc
.
getContent
());
}
Gson
gson
=
new
Gson
();
BreedingRecordEntity
breedingRecordEntity
=
gson
.
fromJson
(
jsonObject
,
BreedingRecordEntity
.
class
);
if
(
tempEntity
.
getUnid
()
==
null
)
{
//新增
breedingRecordEntity
.
setUnid
(
IdUtil
.
createSnowflake
(
3
,
1
).
nextId
()
+
""
);
breedingRecordEntity
.
setDeptId
(
SPUtils
.
getInstance
().
getString
(
Configs
.
SP_DEPT_ID
));
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
breedingRecordEntity
.
setCreateTime
(
dateFormat
.
format
(
new
Date
()));
breedingRecordEntity
.
setCreateBy
(
SPUtils
.
getInstance
().
getString
(
Configs
.
SP_LOGIN_NAME
));
}
else
{
breedingRecordEntity
.
setUnid
(
tempEntity
.
getUnid
());
breedingRecordEntity
.
setCreateBy
(
tempEntity
.
getCreateBy
());
breedingRecordEntity
.
setCreateTime
(
tempEntity
.
getCreateTime
());
breedingRecordEntity
.
setDeptId
(
tempEntity
.
getDeptId
());
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
breedingRecordEntity
.
setUpdateTime
(
dateFormat
.
format
(
new
Date
()));
breedingRecordEntity
.
setUpdateBy
(
SPUtils
.
getInstance
().
getString
(
Configs
.
SP_LOGIN_NAME
));
}
breedingRecordEntity
.
setUploadStatus
(
"0"
);
tempDetailEntity
.
setfUnid
(
breedingRecordEntity
.
getUnid
());
//子表 外键
uploadData
=
new
ArrayList
<>();
uploadData
.
add
(
breedingRecordEntity
);
DbUtil
.
getInstance
().
setDbIDUCallBack
(
new
DbIDUCallBack
()
{
@Override
public
void
onNotification
(
boolean
result
)
{
dismissDialog
();
if
(
result
)
{
saveBreedingRecordDetail
();
onShowDialogEvent
.
setValue
(
"保存-配种记录主表-成功!"
);
}
else
{
ToastUtils
.
showShort
(
"保存-配种记录主表-失败"
);
}
}
}).
insertAsyncBatch
(
BreedingRecordEntity
.
class
,
uploadData
);
}
//保存子表
private
void
saveBreedingRecordDetail
()
{
JsonObject
jsonObject
=
new
JsonObject
();
for
(
GenTableColumn
gtc
:
Configs
.
cattlematingDetaill
)
{
jsonObject
.
addProperty
(
gtc
.
getJavaField
(),
gtc
.
getContent
());
}
Gson
gson
=
new
Gson
();
BreedingRecordDetailEntity
breedingRecordDetailEntity
=
gson
.
fromJson
(
jsonObject
,
BreedingRecordDetailEntity
.
class
);
if
(
tempDetailEntity
.
getUnid
()
==
null
)
{
//新增
breedingRecordDetailEntity
.
setUnid
(
IdUtil
.
createSnowflake
(
3
,
1
).
nextId
()
+
""
);
breedingRecordDetailEntity
.
setDeptId
(
SPUtils
.
getInstance
().
getString
(
Configs
.
SP_DEPT_ID
));
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
breedingRecordDetailEntity
.
setCreateTime
(
dateFormat
.
format
(
new
Date
()));
breedingRecordDetailEntity
.
setCreateBy
(
SPUtils
.
getInstance
().
getString
(
Configs
.
SP_LOGIN_NAME
));
}
else
{
breedingRecordDetailEntity
.
setUnid
(
tempDetailEntity
.
getUnid
());
breedingRecordDetailEntity
.
setCreateBy
(
tempDetailEntity
.
getCreateBy
());
breedingRecordDetailEntity
.
setCreateTime
(
tempDetailEntity
.
getCreateTime
());
breedingRecordDetailEntity
.
setDeptId
(
tempDetailEntity
.
getDeptId
());
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
breedingRecordDetailEntity
.
setUpdateTime
(
dateFormat
.
format
(
new
Date
()));
breedingRecordDetailEntity
.
setUpdateBy
(
SPUtils
.
getInstance
().
getString
(
Configs
.
SP_LOGIN_NAME
));
}
breedingRecordDetailEntity
.
setUploadStatus
(
"0"
);
breedingRecordDetailEntity
.
setfUnid
(
tempDetailEntity
.
getfUnid
());
detailUploadData
=
new
ArrayList
<>();
detailUploadData
.
add
(
breedingRecordDetailEntity
);
DbUtil
.
getInstance
().
setDbIDUCallBack
(
new
DbIDUCallBack
()
{
@Override
public
void
onNotification
(
boolean
result
)
{
dismissDialog
();
if
(
result
)
{
clearDetailParamList
();
initDetailList
(
tempEntity
);
onNotifyAllEvent
.
setValue
(
false
);
onShowDialogEvent
.
setValue
(
"保存-配种记录子表-成功!"
);
}
else
{
ToastUtils
.
showShort
(
"保存-配种记录子表-失败"
);
}
}
}).
insertAsyncBatch
(
BreedingRecordDetailEntity
.
class
,
detailUploadData
);
}
//清空数据源
public
void
clearParamList
()
{
tempEntity
=
new
BreedingRecordEntity
();
for
(
GenTableColumn
gtc
:
Configs
.
cattlematingMaster
)
{
gtc
.
setShowName
(
""
);
gtc
.
setContent
(
""
);
}
}
//清空数据源
public
void
clearDetailParamList
()
{
tempDetailEntity
=
new
BreedingRecordDetailEntity
();
//备注清除数据
remarkParamEntity
.
setContent
(
""
);
remarkParamEntity
.
setShowName
(
""
);
currentParamEntity
=
new
GenTableColumn
();
for
(
GenTableColumn
gtc
:
Configs
.
cattlematingDetaill
)
{
gtc
.
setShowName
(
""
);
gtc
.
setContent
(
""
);
}
}
}
app/src/main/java/com/phlx/anchorcollect/ui/fragment/vm/CollectVM.java
View file @
429a4804
...
...
@@ -15,7 +15,6 @@ import com.phlx.anchorcollect.db.DbUtil;
import
com.phlx.anchorcollect.db.gen.CardEntityDao
;
import
com.phlx.anchorcollect.db.gen.ImmuneEntityDao
;
import
com.phlx.anchorcollect.db.gen.MedicalEntityDao
;
import
com.phlx.anchorcollect.db.gen.PerformanceEntityDao
;
import
com.phlx.anchorcollect.db.gen.WeightingEntityDao
;
import
com.phlx.anchorcollect.db.interf.DbIDUCallBack
;
import
com.phlx.anchorcollect.db.interf.DbQueryCallBack
;
...
...
@@ -257,53 +256,53 @@ public class CollectVM extends BaseViewModel<Repository> {
* 体征测定-查询数据库
*/
private
void
querySign
(
String
tag
)
{
QueryBuilder
<
PerformanceEntity
>
builder
=
DbUtil
.
getInstance
().
getQueryBuilder
(
PerformanceEntity
.
class
).
where
(
PerformanceEntityDao
.
Properties
.
RegistrationNo
.
eq
(
tag
));
DbUtil
.
getInstance
().
setDbQueryCallBack
(
new
DbQueryCallBack
<
PerformanceEntity
>()
{
@Override
public
void
onSuccess
(
List
<
PerformanceEntity
>
result
)
{
if
(
result
!=
null
&&
result
.
size
()
>
0
)
{
uiList
.
get
(
0
).
setValue
(
result
.
get
(
0
).
getAge
());
uiList
.
get
(
0
).
setName
(
result
.
get
(
0
).
getAge
());
uiList
.
get
(
1
).
setValue
(
result
.
get
(
0
).
getMeasureDate
());
uiList
.
get
(
1
).
setName
(
result
.
get
(
0
).
getMeasureDate
());
uiList
.
get
(
2
).
setValue
(
result
.
get
(
0
).
getHeight
());
uiList
.
get
(
2
).
setName
(
result
.
get
(
0
).
getHeight
());
uiList
.
get
(
3
).
setValue
(
result
.
get
(
0
).
getLength
());
uiList
.
get
(
3
).
setName
(
result
.
get
(
0
).
getLength
());
uiList
.
get
(
4
).
setValue
(
result
.
get
(
0
).
getBust
());
uiList
.
get
(
4
).
setName
(
result
.
get
(
0
).
getBust
());
uiList
.
get
(
5
).
setValue
(
result
.
get
(
0
).
getChestWidth
());
uiList
.
get
(
5
).
setName
(
result
.
get
(
0
).
getChestWidth
());
uiList
.
get
(
6
).
setValue
(
result
.
get
(
0
).
getChestDeep
());
uiList
.
get
(
6
).
setName
(
result
.
get
(
0
).
getChestDeep
());
uiList
.
get
(
7
).
setValue
(
result
.
get
(
0
).
getWaistWidth
());
uiList
.
get
(
7
).
setName
(
result
.
get
(
0
).
getWaistWidth
());
uiList
.
get
(
8
).
setValue
(
result
.
get
(
0
).
getCrossWidth
());
uiList
.
get
(
8
).
setName
(
result
.
get
(
0
).
getCrossWidth
());
uiList
.
get
(
9
).
setValue
(
result
.
get
(
0
).
getGuanWei
());
uiList
.
get
(
9
).
setName
(
result
.
get
(
0
).
getGuanWei
());
uiList
.
get
(
10
).
setValue
(
result
.
get
(
0
).
getHairLength
());
uiList
.
get
(
10
).
setName
(
result
.
get
(
0
).
getHairLength
());
uiList
.
get
(
11
).
setValue
(
result
.
get
(
0
).
getEyeMuscleArea
());
uiList
.
get
(
11
).
setName
(
result
.
get
(
0
).
getEyeMuscleArea
());
uiList
.
get
(
12
).
setValue
(
result
.
get
(
0
).
getBreedRes
());
uiList
.
get
(
12
).
setName
(
result
.
get
(
0
).
getBreedRes
());
onNotifyAllEvent
.
setValue
(
false
);
}
else
{
onNotifyAllEvent
.
setValue
(
true
);
}
Configs
.
tempTag
=
""
;
}
@Override
public
void
onFailed
()
{
Configs
.
tempTag
=
""
;
ToastUtils
.
showShort
(
"体征测定数据库查询失败"
);
}
}).
queryAsyncAll
(
PerformanceEntity
.
class
,
builder
);
//
QueryBuilder<PerformanceEntity> builder =
//
DbUtil.getInstance().getQueryBuilder(PerformanceEntity.class).where(PerformanceEntityDao.Properties.RegistrationNo.eq(tag));
//
DbUtil.getInstance().setDbQueryCallBack(new DbQueryCallBack<PerformanceEntity>() {
//
@Override
//
public void onSuccess(List<PerformanceEntity> result) {
//
//
if (result != null && result.size() > 0) {
//
uiList.get(0).setValue(result.get(0).getAge());
//
uiList.get(0).setName(result.get(0).getAge());
//
uiList.get(1).setValue(result.get(0).getMeasureDate());
//
uiList.get(1).setName(result.get(0).getMeasureDate());
//
uiList.get(2).setValue(result.get(0).getHeight());
//
uiList.get(2).setName(result.get(0).getHeight());
//
uiList.get(3).setValue(result.get(0).getLength());
//
uiList.get(3).setName(result.get(0).getLength());
//
uiList.get(4).setValue(result.get(0).getBust());
//
uiList.get(4).setName(result.get(0).getBust());
//
uiList.get(5).setValue(result.get(0).getChestWidth());
//
uiList.get(5).setName(result.get(0).getChestWidth());
//
uiList.get(6).setValue(result.get(0).getChestDeep());
//
uiList.get(6).setName(result.get(0).getChestDeep());
//
uiList.get(7).setValue(result.get(0).getWaistWidth());
//
uiList.get(7).setName(result.get(0).getWaistWidth());
//
uiList.get(8).setValue(result.get(0).getCrossWidth());
//
uiList.get(8).setName(result.get(0).getCrossWidth());
//
uiList.get(9).setValue(result.get(0).getGuanWei());
//
uiList.get(9).setName(result.get(0).getGuanWei());
//
uiList.get(10).setValue(result.get(0).getHairLength());
//
uiList.get(10).setName(result.get(0).getHairLength());
//
uiList.get(11).setValue(result.get(0).getEyeMuscleArea());
//
uiList.get(11).setName(result.get(0).getEyeMuscleArea());
//
uiList.get(12).setValue(result.get(0).getBreedRes());
//
uiList.get(12).setName(result.get(0).getBreedRes());
//
onNotifyAllEvent.setValue(false);
//
} else {
//
onNotifyAllEvent.setValue(true);
//
}
//
//
Configs.tempTag = "";
//
}
//
//
@Override
//
public void onFailed() {
//
Configs.tempTag = "";
//
ToastUtils.showShort("体征测定数据库查询失败");
//
}
//
}).queryAsyncAll(PerformanceEntity.class, builder);
}
/**
...
...
@@ -499,8 +498,8 @@ public class CollectVM extends BaseViewModel<Repository> {
List
<
PerformanceEntity
>
uploadData
=
new
ArrayList
<>();
PerformanceEntity
_entity
=
new
PerformanceEntity
();
_entity
.
setUnid
(
Long
.
parseLong
(
tag
.
get
()));
_entity
.
setRegistrationNo
(
tag
.
get
());
//
_entity.setUnid(Long.parseLong(tag.get()));
//
_entity.setRegistrationNo(tag.get());
_entity
.
setWeight
(
weight
.
get
());
_entity
.
setAge
(
uiList
.
get
(
0
).
getValue
());
_entity
.
setMeasureDate
(
uiList
.
get
(
1
).
getValue
());
...
...
app/src/main/java/com/phlx/anchorcollect/ui/fragment/vm/PerformanceVM.java
View file @
429a4804
...
...
@@ -9,19 +9,31 @@ import androidx.databinding.ObservableArrayList;
import
androidx.databinding.ObservableField
;
import
androidx.databinding.ObservableList
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.phlx.anchorcollect.BR
;
import
com.phlx.anchorcollect.Configs
;
import
com.phlx.anchorcollect.R
;
import
com.phlx.anchorcollect.data.Repository
;
import
com.phlx.anchorcollect.db.DbUtil
;
import
com.phlx.anchorcollect.db.interf.DbIDUCallBack
;
import
com.phlx.anchorcollect.entity.GenTableColumn
;
import
com.phlx.anchorcollect.entity.PerformanceEntity
;
import
com.phlx.anchorcollect.ui.fragment.list.CollectGridItem
;
import
com.phlx.anchorcollect.util.EntityUtils
;
import
java.io.File
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
cn.hutool.core.util.IdUtil
;
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.event.SingleLiveEvent
;
import
me.goldze.mvvmhabit.utils.SPUtils
;
import
me.goldze.mvvmhabit.utils.StringUtils
;
import
me.goldze.mvvmhabit.utils.ToastUtils
;
import
me.tatarka.bindingcollectionadapter2.ItemBinding
;
...
...
@@ -48,9 +60,18 @@ public class PerformanceVM extends BaseViewModel<Repository> {
public
SingleLiveEvent
<
Boolean
>
onTagClickEvent
=
new
SingleLiveEvent
<>();
public
SingleLiveEvent
<
Boolean
>
onNotifyAllEvent
=
new
SingleLiveEvent
<>();
//true是清空页面
public
SingleLiveEvent
<
String
>
onShowDialogEvent
=
new
SingleLiveEvent
<>();
//弹窗提示
public
ObservableField
<
String
>
tag
=
new
ObservableField
<>(
""
);
public
ObservableField
<
String
>
weight
=
new
ObservableField
<>(
"125.5"
);
private
long
uuid
;
private
SimpleDateFormat
dateFormat
;
private
List
<
PerformanceEntity
>
uploadData
;
public
PerformanceVM
(
@NonNull
Application
application
,
Repository
model
)
{
super
(
application
,
model
);
}
...
...
@@ -63,7 +84,7 @@ public class PerformanceVM extends BaseViewModel<Repository> {
imgFile
=
new
File
(
imgUrl
);
for
(
GenTableColumn
gtc
:
Configs
.
performance
)
{
CollectGridItem
cgi
=
new
CollectGridItem
(
this
,
gtc
,
Configs
.
BASE_ARCHIVES
);
CollectGridItem
cgi
=
new
CollectGridItem
(
this
,
gtc
,
Configs
.
SIGN_MEASURE
);
observableList
.
add
(
cgi
);
}
...
...
@@ -75,14 +96,14 @@ public class PerformanceVM extends BaseViewModel<Repository> {
remarkParamEntity
.
setHtmlType
(
"input"
);
remarkParamEntity
.
setJavaType
(
"String"
);
uuid
=
IdUtil
.
createSnowflake
(
3
,
1
).
nextId
();
}
public
void
initData
(
String
tag
)
{
imgUrl
=
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
"/collect/picture/"
+
"anchorCiq"
+
tag
+
".jpg"
;
imgFile
=
new
File
(
imgUrl
);
uuid
=
IdUtil
.
createSnowflake
(
3
,
1
).
nextId
();
queryPerformance
(
tag
);
}
...
...
@@ -123,5 +144,62 @@ public class PerformanceVM extends BaseViewModel<Repository> {
}
public
BindingCommand
onSaveClick
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
savePerformance
();
}
});
private
void
savePerformance
()
{
JsonObject
jsonObject
=
new
JsonObject
();
for
(
GenTableColumn
gtc
:
Configs
.
performance
)
{
jsonObject
.
addProperty
(
gtc
.
getJavaField
(),
gtc
.
getContent
());
}
Gson
gson
=
new
Gson
();
PerformanceEntity
performanceEntity
=
gson
.
fromJson
(
jsonObject
,
PerformanceEntity
.
class
);
performanceEntity
.
setUnid
(
uuid
+
""
);
performanceEntity
.
setUploadStatus
(
"0"
);
performanceEntity
.
setDeptId
(
SPUtils
.
getInstance
().
getString
(
Configs
.
SP_DEPT_ID
));
performanceEntity
.
setCreateBy
(
SPUtils
.
getInstance
().
getString
(
Configs
.
SP_LOGIN_NAME
));
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
performanceEntity
.
setCreateTime
(
dateFormat
.
format
(
new
Date
()));
uploadData
=
new
ArrayList
<>();
uploadData
.
add
(
performanceEntity
);
DbUtil
.
getInstance
().
setDbIDUCallBack
(
new
DbIDUCallBack
()
{
@Override
public
void
onNotification
(
boolean
result
)
{
dismissDialog
();
if
(
result
)
{
clearParamList
();
onShowDialogEvent
.
setValue
(
"保存性能测定成功!"
);
}
else
{
ToastUtils
.
showShort
(
"保存性能测定失败"
);
}
}
}).
insertAsyncBatch
(
PerformanceEntity
.
class
,
uploadData
);
}
//清空数据源
public
void
clearParamList
()
{
//备注清除数据
remarkParamEntity
.
setContent
(
""
);
remarkParamEntity
.
setShowName
(
""
);
currentParamEntity
=
new
GenTableColumn
();
uuid
=
IdUtil
.
createSnowflake
(
3
,
1
).
nextId
();
for
(
GenTableColumn
gtc
:
Configs
.
cattleresume
)
{
gtc
.
setShowName
(
""
);
gtc
.
setContent
(
""
);
}
}
}
app/src/main/java/com/phlx/anchorcollect/ui/login/LoginVM.java
View file @
429a4804
...
...
@@ -228,43 +228,57 @@ public class LoginVM extends BaseViewModel<Repository> {
case
"cattleresume"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile0
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()));
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
cattleresume
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile0
);
break
;
case
"performance"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile1
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()));
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
performance
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile1
);
break
;
case
"weightMan"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile2
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()));
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
weightMan
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile2
);
break
;
case
"medicalrecords"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile3
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()));
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
medicalrecords
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile3
);
break
;
case
"immunebatch"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile4
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()));
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
immunebatch
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile4
);
break
;
case
"cattlematingMaster"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile5
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()));
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
cattlematingMaster
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile5
);
break
;
case
"cattlematingDetaill"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile6
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()));
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
cattlematingDetaill
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile6
);
break
;
}
...
...
app/src/main/java/com/phlx/anchorcollect/ui/main/MainActivity.java
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
ui
.
main
;
import
android.os.Bundle
;
import
android.view.KeyEvent
;
import
androidx.annotation.NonNull
;
import
androidx.fragment.app.FragmentTransaction
;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProviders
;
import
com.afollestad.materialdialogs.DialogAction
;
import
com.afollestad.materialdialogs.MaterialDialog
;
import
com.phlx.anchorcollect.BR
;
import
com.phlx.anchorcollect.Configs
;
import
com.phlx.anchorcollect.R
;
import
com.phlx.anchorcollect.data.VMFactory
;
import
com.phlx.anchorcollect.databinding.ActivityMainBinding
;
import
com.phlx.anchorcollect.rfid.ModuleManager
;
import
com.phlx.anchorcollect.ui.base.BaseActivity
;
import
com.phlx.anchorcollect.ui.fragment.BasicsCollectFragment
;
import
com.phlx.anchorcollect.ui.fragment.BreedingRecordFragment
;
import
com.phlx.anchorcollect.ui.fragment.CollectFragment
;
import
com.phlx.anchorcollect.ui.fragment.CollectListFragment
;
import
com.phlx.anchorcollect.ui.fragment.PerformanceFragment
;
...
...
@@ -25,8 +31,8 @@ public class MainActivity extends BaseActivity<ActivityMainBinding, MainVM> {
private
BasicsCollectFragment
_basicsCollectFragment
;
private
PerformanceFragment
_performanceFragment
;
private
BreedingRecordFragment
_breedingRecordFragment
;
private
CollectListFragment
_collectListFragment
;
@Override
public
int
initContentView
(
Bundle
savedInstanceState
)
{
...
...
@@ -81,10 +87,12 @@ public class MainActivity extends BaseActivity<ActivityMainBinding, MainVM> {
transaction
=
getSupportFragmentManager
().
beginTransaction
();
_basicsCollectFragment
=
BasicsCollectFragment
.
newInstance
();
_collectListFragment
=
CollectListFragment
.
newInstance
(
collectType
);
_basicsCollectFragment
=
BasicsCollectFragment
.
getInstance
();
_performanceFragment
=
PerformanceFragment
.
getInstance
();
_breedingRecordFragment
=
BreedingRecordFragment
.
getInstance
();
transaction
.
add
(
R
.
id
.
frameLayout
,
_basicsCollectFragment
);
transaction
.
add
(
R
.
id
.
frameLayout
,
_collectListFragment
);
transaction
.
add
(
R
.
id
.
frameLayout
,
_performanceFragment
);
transaction
.
add
(
R
.
id
.
frameLayout
,
_breedingRecordFragment
);
transaction
.
commit
();
labelSwitching
(
0
);
}
...
...
@@ -93,23 +101,79 @@ public class MainActivity extends BaseActivity<ActivityMainBinding, MainVM> {
transaction
=
getSupportFragmentManager
().
beginTransaction
();
transaction
.
hide
(
_basicsCollectFragment
);
transaction
.
hide
(
_collectListFragment
);
transaction
.
hide
(
_performanceFragment
);
transaction
.
hide
(
_breedingRecordFragment
);
binding
.
tvTab0
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
color_font_non_focus
));
binding
.
tvTab1
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
color_font_non_focus
));
binding
.
tvTab5
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
color_font_non_focus
));
switch
(
position
)
{
case
0
:
transaction
.
show
(
_basicsCollectFragment
);
binding
.
tvTab0
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
colorPrimary
));
break
;
case
1
:
transaction
.
show
(
_
collectList
Fragment
);
transaction
.
show
(
_
performance
Fragment
);
binding
.
tvTab1
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
colorPrimary
));
break
;
case
2
:
// transaction.show(_performanceFragment);
// binding.tvTab1.setTextColor(getResources().getColor(R.color.colorPrimary));
break
;
case
3
:
// transaction.show(_performanceFragment);
// binding.tvTab1.setTextColor(getResources().getColor(R.color.colorPrimary));
break
;
case
4
:
// transaction.show(_performanceFragment);
// binding.tvTab1.setTextColor(getResources().getColor(R.color.colorPrimary));
break
;
case
5
:
transaction
.
show
(
_breedingRecordFragment
);
binding
.
tvTab5
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
colorPrimary
));
break
;
}
transaction
.
commit
();
}
/**
* 监听Back键按下事件
*/
@Override
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
)
{
// MessageDialog.show("系统提示", "是否退出程序?", "确定", "取消")
// .setOkButton(new OnDialogButtonClickListener<MessageDialog>() {
// @Override
// public boolean onClick(MessageDialog baseDialog, View v) {
// ModuleManager.destroyLibSO();
// finish();
// android.os.Process.killProcess(android.os.Process.myPid());
// return false;
// }
// })
// .setCancelButton(new OnDialogButtonClickListener<MessageDialog>() {
// @Override
// public boolean onClick(MessageDialog baseDialog, View v) {
// return false;
// }
// })
// ;
new
MaterialDialog
.
Builder
(
this
).
title
(
"系统提示"
).
content
(
"是否退出程序?"
).
positiveText
(
"确定"
).
negativeText
(
"取消"
).
onAny
(
new
MaterialDialog
.
SingleButtonCallback
()
{
@Override
public
void
onClick
(
@NonNull
MaterialDialog
dialog
,
@NonNull
DialogAction
which
)
{
if
(
which
==
DialogAction
.
POSITIVE
)
{
ModuleManager
.
destroyLibSO
();
finish
();
android
.
os
.
Process
.
killProcess
(
android
.
os
.
Process
.
myPid
());
}
}
}).
show
();
return
true
;
}
return
super
.
onKeyDown
(
keyCode
,
event
);
}
}
app/src/main/java/com/phlx/anchorcollect/ui/main/MainVM.java
View file @
429a4804
...
...
@@ -27,6 +27,8 @@ 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
;
public
class
MainVM
extends
MainBarVM
<
Repository
>
{
...
...
@@ -65,6 +67,10 @@ public class MainVM extends MainBarVM<Repository> {
public
BindingCommand
OnSignMeasureClickCommand
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
if
(
StringUtils
.
isEmpty
(
Configs
.
tempUnid
)){
ToastUtils
.
showShort
(
"请先扫描耳标"
);
return
;
}
onTabClickEvent
.
setValue
(
1
);
}
});
...
...
@@ -73,6 +79,10 @@ public class MainVM extends MainBarVM<Repository> {
public
BindingCommand
OnWeightingManageClickCommand
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
if
(
StringUtils
.
isEmpty
(
Configs
.
tempUnid
)){
ToastUtils
.
showShort
(
"请先扫描耳标"
);
return
;
}
onTabClickEvent
.
setValue
(
2
);
}
});
...
...
@@ -81,6 +91,10 @@ public class MainVM extends MainBarVM<Repository> {
public
BindingCommand
OnTreatmentRecordClickCommand
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
if
(
StringUtils
.
isEmpty
(
Configs
.
tempUnid
)){
ToastUtils
.
showShort
(
"请先扫描耳标"
);
return
;
}
onTabClickEvent
.
setValue
(
3
);
}
});
...
...
@@ -89,6 +103,10 @@ public class MainVM extends MainBarVM<Repository> {
public
BindingCommand
OnImmunRecordClickCommand
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
if
(
StringUtils
.
isEmpty
(
Configs
.
tempUnid
)){
ToastUtils
.
showShort
(
"请先扫描耳标"
);
return
;
}
onTabClickEvent
.
setValue
(
4
);
}
});
...
...
@@ -97,6 +115,10 @@ public class MainVM extends MainBarVM<Repository> {
public
BindingCommand
OnBreedingRecordClickCommand
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
if
(
StringUtils
.
isEmpty
(
Configs
.
tempUnid
)){
ToastUtils
.
showShort
(
"请先扫描耳标"
);
return
;
}
onTabClickEvent
.
setValue
(
5
);
}
});
...
...
app/src/main/java/com/phlx/anchorcollect/ui/setting/SettingVM.java
View file @
429a4804
...
...
@@ -16,33 +16,36 @@ import android.util.SparseIntArray;
import
androidx.annotation.NonNull
;
import
androidx.databinding.ObservableArrayList
;
import
androidx.databinding.ObservableField
;
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
;
import
com.phlx.anchorcollect.data.Repository
;
import
com.phlx.anchorcollect.data.VMFactory
;
import
com.phlx.anchorcollect.db.DbUtil
;
import
com.phlx.anchorcollect.db.gen.BreedingRecordDetailEntityDao
;
import
com.phlx.anchorcollect.db.gen.BreedingRecordEntityDao
;
import
com.phlx.anchorcollect.db.gen.PerformanceEntityDao
;
import
com.phlx.anchorcollect.db.interf.DbIDUCallBack
;
import
com.phlx.anchorcollect.db.interf.DbQueryCallBack
;
import
com.phlx.anchorcollect.entity.BreedingRecordDetailEntity
;
import
com.phlx.anchorcollect.entity.BreedingRecordEntity
;
import
com.phlx.anchorcollect.entity.CattleResumeEntity
;
import
com.phlx.anchorcollect.entity.LoginData
;
import
com.phlx.anchorcollect.entity.UserRoleEntity
;
import
com.phlx.anchorcollect.entity.PerformanceEntity
;
import
com.phlx.anchorcollect.params.CollectResponse
;
import
com.phlx.anchorcollect.params.ListResponse
;
import
com.phlx.anchorcollect.params.PostParams
;
import
com.phlx.anchorcollect.rfid.InventoryManger
;
import
com.phlx.anchorcollect.ui.splash.SplashActivity
;
import
com.phlx.anchorcollect.util.EntityUtils
;
import
com.phlx.anchorcollect.util.TextUtil
;
import
com.uhf.structures.InventoryData
;
import
com.uhf.structures.InventoryParams
;
import
com.uhf.structures.OnInventoryListener
;
import
org.greenrobot.greendao.query.QueryBuilder
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -60,7 +63,6 @@ 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
;
...
...
@@ -94,12 +96,44 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
//错误提示
public
SingleLiveEvent
<
String
>
errorEvent
=
new
SingleLiveEvent
<>();
public
ObservableField
<
String
>
cattleresumeCount
=
new
ObservableField
<>(
"0"
);
public
ObservableField
<
String
>
performanceCount
=
new
ObservableField
<>(
"0"
);
public
ObservableField
<
String
>
weightManCount
=
new
ObservableField
<>(
"0"
);
public
ObservableField
<
String
>
medicalrecordsCount
=
new
ObservableField
<>(
"0"
);
public
ObservableField
<
String
>
immunebatchCount
=
new
ObservableField
<>(
"0"
);
public
ObservableField
<
String
>
cattlematingMasterCount
=
new
ObservableField
<>(
"0"
);
public
ObservableField
<
String
>
cattlematingDetaillCount
=
new
ObservableField
<>(
"0"
);
public
SettingVM
(
@NonNull
Application
application
,
Repository
model
)
{
super
(
application
,
model
);
initInventory
();
//设置盘点数据监听
App
.
getInstance
().
getLinkage
().
setOnInventoryListener
(
this
);
initData
();
}
private
void
initData
()
{
QueryBuilder
<
PerformanceEntity
>
builder
=
DbUtil
.
getInstance
().
getQueryBuilder
(
PerformanceEntity
.
class
)
.
where
(
PerformanceEntityDao
.
Properties
.
UploadStatus
.
eq
(
"0"
));
DbUtil
.
getInstance
().
setDbQueryCallBack
(
new
DbQueryCallBack
<
PerformanceEntity
>()
{
@Override
public
void
onSuccess
(
List
<
PerformanceEntity
>
result
)
{
if
(
result
!=
null
&&
result
.
size
()
>
0
)
{
performanceCount
.
set
(
result
.
size
()
+
""
);
}
}
@Override
public
void
onFailed
()
{
ToastUtils
.
showShort
(
"查询性能测定数量失败!"
);
dismissDialog
();
}
}).
queryAsyncAll
(
PerformanceEntity
.
class
,
builder
);
}
private
void
initInventory
()
{
...
...
@@ -195,7 +229,7 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
public
BindingCommand
OnSignMeasureSyncClickCommand
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
querySignMeasure
();
}
});
...
...
@@ -223,7 +257,14 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
public
BindingCommand
OnBreedingRecordSyncClickCommand
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
queryBreedingRecord
();
}
});
public
BindingCommand
OnBreedingRecordDetailSyncClickCommand
=
new
BindingCommand
(
new
BindingAction
()
{
@Override
public
void
call
()
{
queryBreedingRecordDetail
();
}
});
...
...
@@ -379,6 +420,11 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
}
};
/**===========================================基础数据================================================= */
/**
* 下载基础数据
*/
private
void
requestBaseArchives
()
{
//SyncState 0根据记录更新,1重新更新
...
...
@@ -423,6 +469,7 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
}
}
else
{
dismissDialog
();
errorEvent
.
setValue
(
"服务器 :"
+
response
.
getMsg
());
}
},
(
Consumer
<
ResponseThrowable
>)
throwable
->
{
...
...
@@ -432,6 +479,9 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
);
}
/**
* 返回-基础数据-成功
*/
private
void
requestBaseArchivesSync
(
List
<
String
>
ids
)
{
// Map<String, String> syncParam = new HashMap<>();
...
...
@@ -447,11 +497,267 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
// .doOnSubscribe(disposable -> showDialog("正在同步基础数据..."))
.
subscribe
((
Consumer
<
CollectResponse
>)
response
->
{
dismissDialog
();
KLog
.
e
(
"requestBaseArchivesSync"
,
response
.
toString
());
if
(
response
.
getCode
()
==
0
)
{
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"同步基础数据成功!"
);
requestBaseArchives
();
}
else
{
dismissDialog
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"服务器:"
+
response
.
getMsg
());
}
},
(
Consumer
<
ResponseThrowable
>)
throwable
->
{
dismissDialog
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
throwable
.
message
);
})
);
}
/**===========================================性能测定================================================= */
/**
* 下载-性能测定
*/
private
void
requestSignMeasure
()
{
//SyncState 0根据记录更新,1重新更新
Map
<
String
,
String
>
requestParam
=
new
HashMap
<>();
List
<
PerformanceEntity
>
queryList
=
DbUtil
.
getInstance
().
queryAll
(
PerformanceEntity
.
class
);
if
(
queryList
==
null
||
queryList
.
size
()
==
0
)
requestParam
.
put
(
"SyncState"
,
"1"
);
else
requestParam
.
put
(
"SyncState"
,
"0"
);
addSubscribe
(
model
.
downloadPerformanceList
(
requestParam
)
.
compose
(
RxUtils
.
bindToLifecycle
(
getLifecycleProvider
()))
.
compose
(
RxUtils
.
schedulersTransformer
())
.
compose
(
RxUtils
.
exceptionTransformer
())
// .doOnSubscribe(disposable -> showDialog("正在同步性能测定数据..."))
.
subscribe
((
Consumer
<
ListResponse
<
PerformanceEntity
>>)
response
->
{
if
(
response
.
getCode
()
==
0
)
{
if
(
response
.
getData
()
!=
null
&&
response
.
getData
().
size
()
>
0
)
{
KLog
.
e
(
"--PerformanceEntity--"
+
response
.
getData
().
size
());
List
<
String
>
ids
=
new
ArrayList
<>();
for
(
PerformanceEntity
cre
:
response
.
getData
())
{
cre
.
setUploadStatus
(
"1"
);
ids
.
add
(
cre
.
getUnid
());
}
DbUtil
.
getInstance
().
setDbIDUCallBack
(
new
DbIDUCallBack
()
{
@Override
public
void
onNotification
(
boolean
result
)
{
if
(
result
)
{
requestSignMeasureSync
(
ids
);
}
else
{
dismissDialog
();
errorEvent
.
setValue
(
"保存性能测定数据失败!"
);
}
}
}).
insertAsyncBatch
(
PerformanceEntity
.
class
,
response
.
getData
());
}
else
{
dismissDialog
();
}
}
else
{
errorEvent
.
setValue
(
"服务器 :"
+
response
.
getMsg
());
}
},
(
Consumer
<
ResponseThrowable
>)
throwable
->
{
querySignMeasure
();
KLog
.
e
(
throwable
.
message
);
})
);
}
/**
* 同步-性能测定-成功
*/
private
void
requestSignMeasureSync
(
List
<
String
>
ids
)
{
// Map<String, String> syncParam = new HashMap<>();
// syncParam.put("ids", new Gson().toJson(ids).toString());
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json"
),
new
Gson
().
toJson
(
ids
));
// KLog.e("label", postParams.toString());
addSubscribe
(
model
.
downloadPerformanceListSync
(
body
)
.
compose
(
RxUtils
.
bindToLifecycle
(
getLifecycleProvider
()))
.
compose
(
RxUtils
.
schedulersTransformer
())
.
compose
(
RxUtils
.
exceptionTransformer
())
// .doOnSubscribe(disposable -> showDialog("正在同步基础数据..."))
.
subscribe
((
Consumer
<
CollectResponse
>)
response
->
{
KLog
.
e
(
"requestSignMeasureSync"
,
response
.
toString
());
if
(
response
.
getCode
()
==
0
)
{
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"同步性能测定数据成功!"
);
requestSignMeasure
();
}
else
{
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"服务器:"
+
response
.
getMsg
());
dismissDialog
();
}
},
(
Consumer
<
ResponseThrowable
>)
throwable
->
{
dismissDialog
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
throwable
.
message
);
})
);
}
/**
* 查询-性能测定
*/
private
void
querySignMeasure
()
{
QueryBuilder
<
PerformanceEntity
>
builder
=
DbUtil
.
getInstance
().
getQueryBuilder
(
PerformanceEntity
.
class
)
.
where
(
PerformanceEntityDao
.
Properties
.
UploadStatus
.
eq
(
"0"
))
.
limit
(
10
);
DbUtil
.
getInstance
().
setDbQueryCallBack
(
new
DbQueryCallBack
<
PerformanceEntity
>()
{
@Override
public
void
onSuccess
(
List
<
PerformanceEntity
>
result
)
{
if
(
result
!=
null
&&
result
.
size
()
>
0
)
{
uploadSignMeasure
(
result
);
}
else
{
requestSignMeasure
();
}
}
@Override
public
void
onFailed
()
{
ToastUtils
.
showShort
(
"查询性能测定失败!"
);
dismissDialog
();
}
}).
queryAsyncAll
(
PerformanceEntity
.
class
,
builder
);
}
/**
* 上传-性能测定
*/
private
void
uploadSignMeasure
(
List
<
PerformanceEntity
>
performanceEntities
)
{
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json"
),
new
Gson
().
toJson
(
performanceEntities
));
// KLog.e("label", postParams.toString());
addSubscribe
(
model
.
uploadPerformanceList
(
body
)
.
compose
(
RxUtils
.
bindToLifecycle
(
getLifecycleProvider
()))
.
compose
(
RxUtils
.
schedulersTransformer
())
.
compose
(
RxUtils
.
exceptionTransformer
())
.
doOnSubscribe
(
disposable
->
showDialog
(
"正在同步性能测定数据..."
))
.
subscribe
((
Consumer
<
CollectResponse
>)
response
->
{
dismissDialog
();
KLog
.
e
(
"requestSignMeasureSync"
,
response
.
toString
());
for
(
PerformanceEntity
pe
:
performanceEntities
)
{
pe
.
setUploadStatus
(
"1"
);
}
if
(
response
.
getCode
()
==
0
)
{
DbUtil
.
getInstance
().
setDbIDUCallBack
(
new
DbIDUCallBack
()
{
@Override
public
void
onNotification
(
boolean
result
)
{
if
(
result
)
{
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"上传性能测定数据成功!"
);
querySignMeasure
();
}
else
{
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"修改性能测定数据失败"
);
}
}
}).
updateAsyncBatch
(
PerformanceEntity
.
class
,
performanceEntities
);
}
else
{
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"服务器:"
+
response
.
getMsg
());
requestSignMeasure
();
}
},
(
Consumer
<
ResponseThrowable
>)
throwable
->
{
dismissDialog
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
throwable
.
message
);
})
);
}
/**===========================================配种记录================================================= */
/**
* 下载-配种记录主表-
*/
private
void
requestBreedingRecord
()
{
//SyncState 0根据记录更新,1重新更新
Map
<
String
,
String
>
requestParam
=
new
HashMap
<>();
List
<
BreedingRecordEntity
>
queryList
=
DbUtil
.
getInstance
().
queryAll
(
BreedingRecordEntity
.
class
);
if
(
queryList
==
null
||
queryList
.
size
()
==
0
)
requestParam
.
put
(
"SyncState"
,
"1"
);
else
requestParam
.
put
(
"SyncState"
,
"0"
);
addSubscribe
(
model
.
downloadBreedingRecordList
(
requestParam
)
.
compose
(
RxUtils
.
bindToLifecycle
(
getLifecycleProvider
()))
.
compose
(
RxUtils
.
schedulersTransformer
())
.
compose
(
RxUtils
.
exceptionTransformer
())
// .doOnSubscribe(disposable -> showDialog("正在同步配种记录主表数据..."))
.
subscribe
((
Consumer
<
ListResponse
<
BreedingRecordEntity
>>)
response
->
{
if
(
response
.
getCode
()
==
0
)
{
if
(
response
.
getData
()
!=
null
&&
response
.
getData
().
size
()
>
0
)
{
KLog
.
e
(
"--BreedingRecordEntity--"
+
response
.
getData
().
size
());
List
<
String
>
ids
=
new
ArrayList
<>();
for
(
BreedingRecordEntity
cre
:
response
.
getData
())
{
cre
.
setUploadStatus
(
"1"
);
ids
.
add
(
cre
.
getUnid
());
}
DbUtil
.
getInstance
().
setDbIDUCallBack
(
new
DbIDUCallBack
()
{
@Override
public
void
onNotification
(
boolean
result
)
{
if
(
result
)
{
requestBreedingRecordSync
(
ids
);
}
else
{
dismissDialog
();
errorEvent
.
setValue
(
"保存配种记录主表数据失败!"
);
}
}
}).
insertAsyncBatch
(
BreedingRecordEntity
.
class
,
response
.
getData
());
}
else
{
dismissDialog
();
}
}
else
{
errorEvent
.
setValue
(
"服务器 :"
+
response
.
getMsg
());
}
},
(
Consumer
<
ResponseThrowable
>)
throwable
->
{
KLog
.
e
(
throwable
.
message
);
})
);
}
/**
* 上传-配种记录主表-成功
*/
private
void
requestBreedingRecordSync
(
List
<
String
>
ids
)
{
// Map<String, String> syncParam = new HashMap<>();
// syncParam.put("ids", new Gson().toJson(ids).toString());
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json"
),
new
Gson
().
toJson
(
ids
));
// KLog.e("label", postParams.toString());
addSubscribe
(
model
.
downloadBreedingRecordListSync
(
body
)
.
compose
(
RxUtils
.
bindToLifecycle
(
getLifecycleProvider
()))
.
compose
(
RxUtils
.
schedulersTransformer
())
.
compose
(
RxUtils
.
exceptionTransformer
())
// .doOnSubscribe(disposable -> showDialog("正在同步基础数据..."))
.
subscribe
((
Consumer
<
CollectResponse
>)
response
->
{
dismissDialog
();
KLog
.
e
(
"downloadBreedingRecordListSync"
,
response
.
toString
());
if
(
response
.
getCode
()
==
0
)
{
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"同步配种主表数据成功!"
);
requestBreedingRecord
();
}
else
{
dismissDialog
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"服务器:"
+
response
.
getMsg
());
}
},
(
Consumer
<
ResponseThrowable
>)
throwable
->
{
...
...
@@ -461,5 +767,238 @@ public class SettingVM extends BaseViewModel<Repository> implements DiscoveryLis
);
}
/**
* 查询-配种记录主表-
*/
private
void
queryBreedingRecord
()
{
QueryBuilder
<
BreedingRecordEntity
>
builder
=
DbUtil
.
getInstance
().
getQueryBuilder
(
BreedingRecordEntity
.
class
)
.
where
(
BreedingRecordEntityDao
.
Properties
.
UploadStatus
.
eq
(
"0"
))
.
limit
(
10
);
DbUtil
.
getInstance
().
setDbQueryCallBack
(
new
DbQueryCallBack
<
BreedingRecordEntity
>()
{
@Override
public
void
onSuccess
(
List
<
BreedingRecordEntity
>
result
)
{
if
(
result
!=
null
&&
result
.
size
()
>
0
)
{
uploadBreedingRecord
(
result
);
}
else
{
requestBreedingRecord
();
}
}
@Override
public
void
onFailed
()
{
ToastUtils
.
showShort
(
"查询-配种记录主表-失败!"
);
dismissDialog
();
}
}).
queryAsyncAll
(
BreedingRecordEntity
.
class
,
builder
);
}
/**
* 上传-配种记录主表-
*/
private
void
uploadBreedingRecord
(
List
<
BreedingRecordEntity
>
breedingRecordEntities
)
{
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json"
),
new
Gson
().
toJson
(
breedingRecordEntities
));
// KLog.e("label", postParams.toString());
addSubscribe
(
model
.
uploadBreedingRecordList
(
body
)
.
compose
(
RxUtils
.
bindToLifecycle
(
getLifecycleProvider
()))
.
compose
(
RxUtils
.
schedulersTransformer
())
.
compose
(
RxUtils
.
exceptionTransformer
())
.
doOnSubscribe
(
disposable
->
showDialog
(
"正在同步-配种记录主表-数据..."
))
.
subscribe
((
Consumer
<
CollectResponse
>)
response
->
{
if
(
response
.
getCode
()
==
0
)
{
KLog
.
e
(
"uploadBreedingRecord"
,
response
.
toString
());
for
(
BreedingRecordEntity
pe
:
breedingRecordEntities
)
{
pe
.
setUploadStatus
(
"1"
);
}
DbUtil
.
getInstance
().
setDbIDUCallBack
(
new
DbIDUCallBack
()
{
@Override
public
void
onNotification
(
boolean
result
)
{
if
(
result
)
{
queryBreedingRecord
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"上传-配种记录主表-数据成功!"
);
}
else
{
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"修改-配种记录主表-数据失败"
);
}
}
}).
updateAsyncBatch
(
BreedingRecordEntity
.
class
,
breedingRecordEntities
);
}
else
{
dismissDialog
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"服务器:"
+
response
.
getMsg
());
requestBreedingRecord
();
}
},
(
Consumer
<
ResponseThrowable
>)
throwable
->
{
dismissDialog
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
throwable
.
message
);
})
);
}
/**===========================================配种记录-子表================================================= */
/**
* 下载-配种记录子表-
*/
private
void
requestBreedingRecordDetail
()
{
//SyncState 0根据记录更新,1重新更新
Map
<
String
,
String
>
requestParam
=
new
HashMap
<>();
List
<
BreedingRecordDetailEntity
>
queryList
=
DbUtil
.
getInstance
().
queryAll
(
BreedingRecordDetailEntity
.
class
);
if
(
queryList
==
null
||
queryList
.
size
()
==
0
)
requestParam
.
put
(
"SyncState"
,
"1"
);
else
requestParam
.
put
(
"SyncState"
,
"0"
);
addSubscribe
(
model
.
downloadBreedingRecordDetailList
(
requestParam
)
.
compose
(
RxUtils
.
bindToLifecycle
(
getLifecycleProvider
()))
.
compose
(
RxUtils
.
schedulersTransformer
())
.
compose
(
RxUtils
.
exceptionTransformer
())
// .doOnSubscribe(disposable -> showDialog("正在同步配种记录主表数据..."))
.
subscribe
((
Consumer
<
ListResponse
<
BreedingRecordDetailEntity
>>)
response
->
{
if
(
response
.
getCode
()
==
0
)
{
if
(
response
.
getData
()
!=
null
&&
response
.
getData
().
size
()
>
0
)
{
KLog
.
e
(
"--BreedingRecordDetailEntity--"
+
response
.
getData
().
size
());
List
<
String
>
ids
=
new
ArrayList
<>();
for
(
BreedingRecordDetailEntity
cre
:
response
.
getData
())
{
cre
.
setUploadStatus
(
"1"
);
ids
.
add
(
cre
.
getUnid
());
}
DbUtil
.
getInstance
().
setDbIDUCallBack
(
new
DbIDUCallBack
()
{
@Override
public
void
onNotification
(
boolean
result
)
{
if
(
result
)
{
requestBreedingRecordDetailSync
(
ids
);
}
else
{
dismissDialog
();
errorEvent
.
setValue
(
"保存配种记录子表数据失败!"
);
}
}
}).
insertAsyncBatch
(
BreedingRecordDetailEntity
.
class
,
response
.
getData
());
}
else
{
dismissDialog
();
}
}
else
{
errorEvent
.
setValue
(
"服务器 :"
+
response
.
getMsg
());
}
},
(
Consumer
<
ResponseThrowable
>)
throwable
->
{
KLog
.
e
(
throwable
.
message
);
})
);
}
/**
* 上传-配种记录子表-成功
*/
private
void
requestBreedingRecordDetailSync
(
List
<
String
>
ids
)
{
// Map<String, String> syncParam = new HashMap<>();
// syncParam.put("ids", new Gson().toJson(ids).toString());
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json"
),
new
Gson
().
toJson
(
ids
));
// KLog.e("label", postParams.toString());
addSubscribe
(
model
.
downloadBreedingRecordDetailListSync
(
body
)
.
compose
(
RxUtils
.
bindToLifecycle
(
getLifecycleProvider
()))
.
compose
(
RxUtils
.
schedulersTransformer
())
.
compose
(
RxUtils
.
exceptionTransformer
())
// .doOnSubscribe(disposable -> showDialog("正在同步基础数据..."))
.
subscribe
((
Consumer
<
CollectResponse
>)
response
->
{
dismissDialog
();
KLog
.
e
(
"requestBreedingRecordDetailSync"
,
response
.
toString
());
if
(
response
.
getCode
()
==
0
)
{
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"同步配种记录子表数据成功!"
);
queryBreedingRecordDetail
();
}
else
{
dismissDialog
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"服务器:"
+
response
.
getMsg
());
}
},
(
Consumer
<
ResponseThrowable
>)
throwable
->
{
dismissDialog
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
throwable
.
message
);
})
);
}
/**
* 查询-配种记录子表-
*/
private
void
queryBreedingRecordDetail
()
{
QueryBuilder
<
BreedingRecordDetailEntity
>
builder
=
DbUtil
.
getInstance
().
getQueryBuilder
(
BreedingRecordDetailEntity
.
class
)
.
where
(
BreedingRecordDetailEntityDao
.
Properties
.
UploadStatus
.
eq
(
"0"
))
.
limit
(
10
);
DbUtil
.
getInstance
().
setDbQueryCallBack
(
new
DbQueryCallBack
<
BreedingRecordDetailEntity
>()
{
@Override
public
void
onSuccess
(
List
<
BreedingRecordDetailEntity
>
result
)
{
if
(
result
!=
null
&&
result
.
size
()
>
0
)
{
uploadBreedingRecordDetail
(
result
);
}
else
{
requestBreedingRecordDetail
();
}
}
@Override
public
void
onFailed
()
{
ToastUtils
.
showShort
(
"查询-配种记录子表-失败!"
);
dismissDialog
();
}
}).
queryAsyncAll
(
BreedingRecordDetailEntity
.
class
,
builder
);
}
/**
* 上传-配种记录子表-
*/
private
void
uploadBreedingRecordDetail
(
List
<
BreedingRecordDetailEntity
>
breedingRecordDetailEntities
)
{
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json"
),
new
Gson
().
toJson
(
breedingRecordDetailEntities
));
// KLog.e("label", postParams.toString());
addSubscribe
(
model
.
uploadBreedingRecordDetailList
(
body
)
.
compose
(
RxUtils
.
bindToLifecycle
(
getLifecycleProvider
()))
.
compose
(
RxUtils
.
schedulersTransformer
())
.
compose
(
RxUtils
.
exceptionTransformer
())
.
doOnSubscribe
(
disposable
->
showDialog
(
"正在同步-配种记录子表-数据..."
))
.
subscribe
((
Consumer
<
CollectResponse
>)
response
->
{
if
(
response
.
getCode
()
==
0
)
{
KLog
.
e
(
"uploadBreedingRecordDetail"
,
response
.
toString
());
for
(
BreedingRecordDetailEntity
pe
:
breedingRecordDetailEntities
)
{
pe
.
setUploadStatus
(
"1"
);
}
DbUtil
.
getInstance
().
setDbIDUCallBack
(
new
DbIDUCallBack
()
{
@Override
public
void
onNotification
(
boolean
result
)
{
if
(
result
)
{
queryBreedingRecordDetail
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"上传-配种记录子表-数据成功!"
);
}
else
{
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"修改-配种记录子表-数据失败"
);
}
}
}).
updateAsyncBatch
(
BreedingRecordDetailEntity
.
class
,
breedingRecordDetailEntities
);
}
else
{
dismissDialog
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
"服务器:"
+
response
.
getMsg
());
requestBreedingRecordDetail
();
}
},
(
Consumer
<
ResponseThrowable
>)
throwable
->
{
dismissDialog
();
me
.
goldze
.
mvvmhabit
.
utils
.
ToastUtils
.
showShort
(
throwable
.
message
);
})
);
}
}
app/src/main/java/com/phlx/anchorcollect/ui/splash/SplashVM.java
View file @
429a4804
...
...
@@ -162,49 +162,56 @@ public class SplashVM extends MainBarVM<Repository> {
case
"cattleresume"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile0
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()))
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
cattleresume
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile0
);
break
;
case
"performance"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile1
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()))
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
performance
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile1
);
break
;
case
"weightMan"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile2
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()))
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
weightMan
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile2
);
break
;
case
"medicalrecords"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile3
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()))
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
medicalrecords
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile3
);
break
;
case
"immunebatch"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile4
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()))
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
immunebatch
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile4
);
break
;
case
"cattlematingMaster"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile5
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()))
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
cattlematingMaster
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile5
);
break
;
case
"cattlematingDetaill"
:
QueryBuilder
<
GenTableColumn
>
builderDetaile6
=
DbUtil
.
getInstance
().
getQueryBuilder
(
GenTableColumn
.
class
)
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
()))
.
where
(
GenTableColumnDao
.
Properties
.
TableId
.
eq
(
gt
.
getTableId
())
,
GenTableColumnDao
.
Properties
.
IsQuery
.
eq
(
"1"
))
.
orderDesc
(
GenTableColumnDao
.
Properties
.
Sort
);
Configs
.
cattlematingDetaill
=
DbUtil
.
getInstance
().
queryAll
(
GenTableColumn
.
class
,
builderDetaile6
);
break
;
...
...
app/src/main/java/com/phlx/anchorcollect/util/DateUtils.java
0 → 100644
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
util
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
public
class
DateUtils
{
public
static
String
getYear
(){
String
year
=
""
;
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy"
);
year
=
simpleDateFormat
.
format
(
new
Date
());
return
year
;
}
}
app/src/main/java/com/phlx/anchorcollect/util/EntityUtils.java
View file @
429a4804
...
...
@@ -48,15 +48,12 @@ public class EntityUtils {
return
value
;
}
catch
(
NoSuchMethodException
e
)
{
e
.
printStackTrace
();
}
catch
(
SecurityException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalArgumentException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
return
null
;
...
...
app/src/main/java/com/phlx/anchorcollect/util/StringUtil.java
View file @
429a4804
package
com
.
phlx
.
anchorcollect
.
util
;
import
android.widget.TextView
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -39,10 +41,10 @@ public class StringUtil {
BigDecimal
divide
=
new
BigDecimal
(
32
);
BigDecimal
decimal
=
new
BigDecimal
(
i
);
String
res
=
""
;
while
(
BigDecimal
.
ZERO
.
compareTo
(
decimal
)
!=
0
){
while
(
BigDecimal
.
ZERO
.
compareTo
(
decimal
)
!=
0
)
{
BigDecimal
[]
divRes
=
decimal
.
divideAndRemainder
(
divide
);
decimal
=
divRes
[
0
];
res
=
s36bit_const
.
charAt
(
divRes
[
1
].
intValue
())
+
res
;
res
=
s36bit_const
.
charAt
(
divRes
[
1
].
intValue
())
+
res
;
}
return
res
;
}
...
...
@@ -54,25 +56,20 @@ public class StringUtil {
* @param hexString 16进制格式的字符串
* @return 转换后的字节数组
**/
public
static
byte
[]
stringToByte
(
String
hexString
)
{
public
static
byte
[]
stringToByte
(
String
hexString
)
{
hexString
=
hexString
.
toLowerCase
();
int
length
=
hexString
.
length
();
if
(
length
%
2
!=
0
)
{
if
(
length
%
2
!=
0
)
{
length
=
length
+
1
;
}
final
byte
[]
byteArray
=
new
byte
[
length
/
2
];
int
k
=
0
;
for
(
int
i
=
0
;
i
<
byteArray
.
length
;
i
++)
{
// 因为是16进制,最多只会占用4位,转换成字节需要两个16进制的字符,高位在先
for
(
int
i
=
0
;
i
<
byteArray
.
length
;
i
++)
{
// 因为是16进制,最多只会占用4位,转换成字节需要两个16进制的字符,高位在先
byte
low
;
byte
high
=
(
byte
)
(
Character
.
digit
(
hexString
.
charAt
(
k
),
16
)
&
0xff
);
if
((
k
+
1
)
==
hexString
.
length
())
{
if
((
k
+
1
)
==
hexString
.
length
())
{
low
=
0
;
}
else
{
}
else
{
low
=
(
byte
)
(
Character
.
digit
(
hexString
.
charAt
(
k
+
1
),
16
)
&
0xff
);
}
byteArray
[
i
]
=
(
byte
)
(
high
<<
4
|
low
);
...
...
@@ -81,11 +78,38 @@ public class StringUtil {
return
byteArray
;
}
public
static
List
<
String
>
strToList
(
String
[]
strings
){
public
static
List
<
String
>
strToList
(
String
[]
strings
)
{
List
<
String
>
stringArrayList
=
new
ArrayList
<>();
for
(
String
str
:
strings
)
{
for
(
String
str
:
strings
)
{
stringArrayList
.
add
(
str
);
}
return
stringArrayList
;
}
public
static
String
[]
listToStr
(
List
<
String
>
list
)
{
if
(
list
==
null
)
return
null
;
String
[]
strings
=
new
String
[
list
.
size
()];
int
i
=
0
;
for
(
String
str
:
list
)
{
strings
[
i
]
=
str
;
i
++;
}
return
strings
;
}
public
static
float
[]
getFloats
(
int
count
)
{
float
[]
floats
=
new
float
[
count
];
for
(
int
i
=
0
;
i
<
count
;
i
++){
floats
[
i
]
=
1.0f
;
}
return
floats
;
}
public
static
Class
[]
getClasses
(
int
count
)
{
Class
[]
textViews
=
new
Class
[
count
];
for
(
int
i
=
0
;
i
<
count
;
i
++){
textViews
[
i
]
=
TextView
.
class
;
}
return
textViews
;
}
}
app/src/main/res/layout/activity_setting.xml
View file @
429a4804
...
...
@@ -258,7 +258,7 @@
android:text=
"@string/breeding_record"
binding:layout_constraintTop_toBottomOf=
"@+id/btn_immun_record_sync"
binding:layout_constraintLeft_toLeftOf=
"@+id/btn_base_archives_sync"
binding:layout_constraintBottom_to
BottomOf=
"parent
"
binding:layout_constraintBottom_to
TopOf=
"@+id/btn_breeding_record_detail_sync
"
binding:onClickCommand=
"@{viewModel.OnBreedingRecordSyncClickCommand}"
/>
...
...
@@ -283,6 +283,40 @@
binding:layout_constraintLeft_toRightOf=
"@+id/tv_breeding_record_count"
binding:layout_constraintBaseline_toBaselineOf=
"@+id/btn_breeding_record_sync"
/>
<!-- breeding_record_detail -->
<androidx.appcompat.widget.AppCompatButton
android:id=
"@+id/btn_breeding_record_detail_sync"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/breeding_record_detail"
binding:layout_constraintTop_toBottomOf=
"@+id/btn_breeding_record_sync"
binding:layout_constraintLeft_toLeftOf=
"@+id/btn_base_archives_sync"
binding:layout_constraintBottom_toBottomOf=
"parent"
binding:onClickCommand=
"@{viewModel.OnBreedingRecordDetailSyncClickCommand}"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/tv_breeding_record_detail_count"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"5dp"
android:text=
"(0)"
android:textColor=
"@color/white"
binding:layout_constraintLeft_toRightOf=
"@+id/btn_breeding_record_detail_sync"
binding:layout_constraintBaseline_toBaselineOf=
"@+id/btn_breeding_record_detail_sync"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/tv_breeding_record_detail_time"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"15dp"
android:text=
"222"
android:textColor=
"@color/white"
binding:layout_constraintLeft_toRightOf=
"@+id/tv_breeding_record_detail_count"
binding:layout_constraintBaseline_toBaselineOf=
"@+id/tv_breeding_record_detail_count"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
app/src/main/res/layout/fragment_breeding_record.xml
0 → 100644
View file @
429a4804
<layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/tools"
xmlns:binding=
"http://schemas.android.com/apk/res-auto"
app:ignore=
"NamespaceTypo"
>
<data>
<import
type=
"me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter"
/>
<import
type=
"me.goldze.mvvmhabit.binding.viewadapter.recyclerview.LayoutManagers"
/>
<import
type=
"me.goldze.mvvmhabit.binding.viewadapter.recyclerview.LineManagers"
/>
<variable
name=
"viewModel"
type=
"com.phlx.anchorcollect.ui.fragment.vm.BreedingRecordVM"
/>
<variable
name=
"spinnerAdapter"
type=
"android.widget.ArrayAdapter"
/>
<variable
name=
"adapter"
type=
"BindingRecyclerViewAdapter"
/>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/color_bg"
android:padding=
"5dp"
>
<androidx.core.widget.NestedScrollView
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
binding:layout_constraintTop_toTopOf=
"parent"
binding:layout_constraintLeft_toLeftOf=
"parent"
binding:layout_constraintRight_toRightOf=
"parent"
binding:layout_constraintBottom_toTopOf=
"@+id/card_99"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/color_bg"
>
<TextView
android:id=
"@+id/tv_rfid_text"
android:layout_width=
"0dp"
android:layout_height=
"@dimen/dp_32"
android:background=
"@drawable/bg_radius_stroke_white_5"
android:gravity=
"center"
android:hint=
"未扫到电子耳标"
android:text=
""
android:textColor=
"@color/white"
binding:layout_constraintLeft_toLeftOf=
"parent"
binding:layout_constraintRight_toRightOf=
"parent"
binding:layout_constraintTop_toTopOf=
"parent"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_collect"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"-5dp"
android:layout_marginTop=
"5dp"
android:nestedScrollingEnabled=
"false"
binding:adapter=
"@{adapter}"
binding:itemBinding=
"@{viewModel.itemBinding}"
binding:items=
"@{viewModel.observableList}"
binding:layoutManager=
"@{LayoutManagers.grid(5)}"
binding:layout_constraintBottom_toTopOf=
"@+id/ll_detail_title"
binding:layout_constraintLeft_toLeftOf=
"parent"
binding:layout_constraintRight_toRightOf=
"parent"
binding:layout_constraintTop_toBottomOf=
"@+id/tv_rfid_text"
/>
<com.lingber.mycontrol.datagridview.DataGridView
android:id=
"@+id/ll_detail_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:dividerSize=
"1"
app:row_height=
"50"
app:show_header=
"true"
binding:layout_constraintLeft_toLeftOf=
"parent"
binding:layout_constraintRight_toRightOf=
"parent"
binding:layout_constraintTop_toBottomOf=
"@+id/rv_collect"
>
</com.lingber.mycontrol.datagridview.DataGridView>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_collect_detail"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"-5dp"
android:layout_marginTop=
"5dp"
android:nestedScrollingEnabled=
"false"
binding:adapter=
"@{adapter}"
binding:itemBinding=
"@{viewModel.itemBinding}"
binding:items=
"@{viewModel.detailObservableList}"
binding:layoutManager=
"@{LayoutManagers.grid(5)}"
binding:layout_constraintBottom_toBottomOf=
"parent"
binding:layout_constraintLeft_toLeftOf=
"parent"
binding:layout_constraintRight_toRightOf=
"parent"
binding:layout_constraintTop_toBottomOf=
"@+id/ll_detail_title"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<androidx.appcompat.widget.LinearLayoutCompat
android:id=
"@+id/card_99"
android:layout_width=
"0dp"
android:layout_height=
"37dp"
android:background=
"@drawable/bg_radius_white_5"
android:onClick=
"@{() ->viewModel.click(99)}"
android:orientation=
"vertical"
android:padding=
"5dp"
binding:layout_constraintBottom_toBottomOf=
"parent"
binding:layout_constraintLeft_toLeftOf=
"parent"
binding:layout_constraintRight_toLeftOf=
"@+id/card_save"
>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/tv_title_16"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"备注"
android:textColor=
"@color/colorPrimary"
android:textSize=
"@dimen/sp_8"
/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"1dp"
android:text=
"@{viewModel.remarkParamEntity.showName}"
android:textColor=
"@color/black"
android:textSize=
"@dimen/sp_8"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:id=
"@+id/card_save"
android:layout_width=
"100dp"
android:layout_height=
"37dp"
android:layout_marginLeft=
"5dp"
android:background=
"@drawable/bg_radius_white_5"
binding:layout_constraintBottom_toBottomOf=
"parent"
binding:layout_constraintRight_toRightOf=
"parent"
>
<!-- binding:onClickCommand="@{viewModel.onCardSaveClick}"-->
<androidx.appcompat.widget.AppCompatTextView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/bg_button_orange_gradient"
android:gravity=
"center"
android:text=
"保存"
android:textColor=
"@color/white"
android:textSize=
"@dimen/sp_12"
binding:onClickCommand=
"@{viewModel.onSaveClick}"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
app/src/main/res/layout/fragment_performance.xml
View file @
429a4804
...
...
@@ -49,6 +49,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_marginTop=
"5dp"
android:layout_marginLeft=
"-5dp"
binding:adapter=
"@{adapter}"
binding:itemBinding=
"@{viewModel.itemBinding}"
binding:items=
"@{viewModel.observableList}"
...
...
@@ -106,7 +107,9 @@
android:gravity=
"center"
android:text=
"保存"
android:textColor=
"@color/white"
android:textSize=
"@dimen/sp_12"
/>
android:textSize=
"@dimen/sp_12"
binding:onClickCommand=
"@{viewModel.onSaveClick}"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
app/src/main/res/layout/item_collect_grid.xml
View file @
429a4804
...
...
@@ -27,6 +27,18 @@
android:singleLine=
"true"
android:maxLines=
"1"
android:textColor=
"@color/color_font_null"
android:visibility=
"@{viewModel.titleGrayColor}"
android:textSize=
"@dimen/sp_8"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/tv_title_1"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@{viewModel.entity.columnComment}"
android:singleLine=
"true"
android:maxLines=
"1"
android:textColor=
"@color/colorPrimary"
android:visibility=
"@{viewModel.titleBlueColor}"
android:textSize=
"@dimen/sp_8"
/>
<androidx.appcompat.widget.AppCompatTextView
...
...
app/src/main/res/values/strings.xml
View file @
429a4804
...
...
@@ -23,6 +23,7 @@
<string
name=
"treatment_record"
>
诊疗记录
</string>
<string
name=
"immun_record"
>
免疫记录
</string>
<string
name=
"breeding_record"
>
配种记录
</string>
<string
name=
"breeding_record_detail"
>
配种详情
</string>
...
...
mycontrol/.gitignore
0 → 100644
View file @
429a4804
/build
mycontrol/build.gradle
0 → 100644
View file @
429a4804
apply
plugin:
'com.android.library'
group
=
'com.github.Lingber'
android
{
compileSdkVersion
29
buildToolsVersion
'29.0.3'
defaultConfig
{
minSdkVersion
16
targetSdkVersion
29
versionCode
1
versionName
"1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled
=
true
}
buildTypes
{
release
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
}
dependencies
{
compile
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
androidTestCompile
(
'com.android.support.test.espresso:espresso-core:2.2.2'
,
{
exclude
group:
'com.android.support'
,
module:
'support-annotations'
})
compile
'com.android.support:design:25.+'
compile
'com.android.support:appcompat-v7:25.+'
compile
'com.android.support.constraint:constraint-layout:1.0.2'
testCompile
'junit:junit:4.12'
}
mycontrol/proguard-rules.pro
0 → 100644
View file @
429a4804
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\android\SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
mycontrol/src/androidTest/java/com/lingber/mycontrol/ExampleInstrumentedTest.java
0 → 100644
View file @
429a4804
package
com
.
lingber
.
mycontrol
;
import
android.content.Context
;
import
android.support.test.InstrumentationRegistry
;
import
android.support.test.runner.AndroidJUnit4
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
static
org
.
junit
.
Assert
.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith
(
AndroidJUnit4
.
class
)
public
class
ExampleInstrumentedTest
{
@Test
public
void
useAppContext
()
throws
Exception
{
// Context of the app under test.
Context
appContext
=
InstrumentationRegistry
.
getTargetContext
();
assertEquals
(
"com.lingber.mycontrol.test"
,
appContext
.
getPackageName
());
}
}
mycontrol/src/main/AndroidManifest.xml
0 → 100644
View file @
429a4804
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.lingber.mycontrol"
>
<application
android:allowBackup=
"true"
android:label=
"@string/app_name"
android:supportsRtl=
"true"
>
</application>
</manifest>
mycontrol/src/main/java/com/lingber/mycontrol/datagridview/DataGridView.java
0 → 100644
View file @
429a4804
package
com
.
lingber
.
mycontrol
.
datagridview
;
import
android.app.FragmentManager
;
import
android.content.Context
;
import
android.content.res.TypedArray
;
import
android.graphics.drawable.GradientDrawable
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.util.AttributeSet
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
androidx.annotation.Nullable
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.lingber.mycontrol.R
;
import
com.lingber.mycontrol.datagridview.i18n.LangTextView
;
import
com.lingber.mycontrol.datagridview.i18n.Util.ViewUtil
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Author :ShuboLin
* @CreatTime: 2020-05-14 18:40.
* @Description:
*/
public
class
DataGridView
<
T
>
extends
LinearLayout
implements
View
.
OnClickListener
{
private
Context
mContext
;
private
View
mView
;
/**
* 包含组件
**/
private
LinearLayout
mLlHeader
;
private
RecyclerView
mRecyclerView
;
private
ImageButton
mBtnPrev
;
private
ImageButton
mBtnNext
;
/**
* RecyclerView适配器
**/
private
RecyclerviewAdapter
mAdapter
;
/**
* 表格方向
**/
private
int
mOrientation
=
LinearLayoutManager
.
VERTICAL
;
/**
* 列宽
**/
private
float
[]
colunmsWeight
;
/**
* 表头内容
**/
private
String
[]
headerContent
;
/**
* 表头高度
**/
private
int
headerHeight
=
50
;
/**
* 表头背景
**/
private
int
headerBackgroundColorResId
=
R
.
color
.
colorBlue
;
/**
* 是否显示表头
**/
private
boolean
isShowHeader
=
false
;
/**
* 行高
**/
private
int
rowHeight
;
/**
* 列数
**/
private
int
colunms
;
/**
* 分割线粗细
**/
private
int
dividerSize
;
/**
* 分割线颜色
**/
private
int
dividerColorResId
=
R
.
color
.
colorGray
;
/**
* 列表底色
**/
private
int
rvContentColorResId
=
R
.
color
.
colorWhite
;
/**
* 行选中后底色
**/
private
int
selectedBackgroundColorResId
=
R
.
color
.
colorCyan
;
/**
* 选中模式 0关闭选中 1单选 2多选
**/
private
int
selectedMode
=
0
;
/**
* 控件类型
**/
private
Class
[]
contentViewsClass
;
/**
* 各列绑定字段
**/
private
String
[]
fieldNames
;
/**
* 数据源
**/
private
List
<
Object
>
dataSource
;
/**
* 是否启用排序功能
**/
private
Map
<
Integer
,
Integer
>
sortEnableMap
=
new
HashMap
<>();
/**
* 圆角设置 左上 右上 左下 右下
**/
private
float
[]
arrRadius
=
new
float
[]{
14
,
14
,
14
,
14
};
/**
* 是否开启快速添加功能
**/
private
boolean
isFastAdd
=
false
;
/**
* 是否启用翻页
**/
private
boolean
flipOverEnable
=
false
;
/**
* 页码View
**/
private
RelativeLayout
mRvPageNumber
;
/**
* 当前页码View
**/
private
TextView
mTvCurrentPageNumber
;
/**
* 最大页码View
**/
private
TextView
mTvMaxPageNumber
;
/**
* 当前页码
**/
private
int
mPageNumber
=
0
;
/**
* 每页数据条数
**/
private
int
mPageItems
=
6
;
/**
* 当前页数据
**/
private
List
<
Object
>
pageDatas
=
new
ArrayList
<>();
/**
* 分页器
**/
private
HashMap
<
Integer
,
List
<
Object
>>
mPager
=
new
HashMap
<>();
private
FragmentManager
mFragmentManager
;
/**
* 是否可滑动
**/
private
boolean
mSlidable
=
false
;
public
final
String
BTN_PREV
=
"prev"
;
public
final
String
BTN_NEXT
=
"next"
;
public
DataGridView
(
Context
context
)
{
super
(
context
);
}
public
DataGridView
(
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
init
(
context
,
attrs
);
}
public
DataGridView
(
Context
context
,
@Nullable
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
init
(
context
,
attrs
);
}
private
void
init
(
Context
context
,
AttributeSet
attrs
)
{
this
.
mContext
=
context
;
this
.
mView
=
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
lingber_datagridview_template
,
this
);
mLlHeader
=
(
LinearLayout
)
mView
.
findViewById
(
R
.
id
.
ll_header
);
mRecyclerView
=
(
RecyclerView
)
mView
.
findViewById
(
R
.
id
.
rv_rv1
);
mBtnPrev
=
(
ImageButton
)
mView
.
findViewById
(
R
.
id
.
btn_prev
);
mBtnNext
=
(
ImageButton
)
mView
.
findViewById
(
R
.
id
.
btn_next
);
mRvPageNumber
=
(
RelativeLayout
)
mView
.
findViewById
(
R
.
id
.
rv_page_number
);
mTvCurrentPageNumber
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_current_page
);
mTvMaxPageNumber
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_count_page
);
// 获取控件属性
TypedArray
a
=
mContext
.
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
DataGridView
);
// 设置各包含组件
// 是否显示表头
setHeaderDisplayable
(
a
.
getBoolean
(
R
.
styleable
.
DataGridView_show_header
,
true
));
// 设置列数
setColunms
(
a
.
getInt
(
R
.
styleable
.
DataGridView_column
,
0
));
// 设置行高
setRowHeight
(
a
.
getInt
(
R
.
styleable
.
DataGridView_row_height
,
40
));
// 设置分割线大小
setDividerSize
(
a
.
getInt
(
R
.
styleable
.
DataGridView_dividerSize
,
2
));
// 设置单元格包含控件
setCellContentView
(
new
Class
[
colunms
]);
// 是否启用翻页
setFlipOverEnable
(
flipOverEnable
,
null
,
null
);
}
/**
* 设置表头是否可见
**/
public
void
setHeaderDisplayable
(
boolean
isShow
)
{
this
.
isShowHeader
=
isShow
;
if
(
isShow
)
{
mLlHeader
.
setVisibility
(
VISIBLE
);
}
else
{
mLlHeader
.
setVisibility
(
GONE
);
}
}
/**
* 设置翻页控件是否可见、当前页面数据条数
**/
public
void
setFlipOverEnable
(
boolean
enable
,
Integer
pageItems
,
FragmentManager
fragmentManager
)
{
this
.
flipOverEnable
=
enable
;
if
(
enable
)
{
mBtnPrev
.
setVisibility
(
VISIBLE
);
mBtnNext
.
setVisibility
(
VISIBLE
);
mRvPageNumber
.
setVisibility
(
VISIBLE
);
// 点击监听
mBtnPrev
.
setTag
(
BTN_PREV
);
mBtnNext
.
setTag
(
BTN_NEXT
);
mBtnPrev
.
setOnClickListener
(
new
OnFlipOverBtnOnClickListener
());
mBtnNext
.
setOnClickListener
(
new
OnFlipOverBtnOnClickListener
());
mRvPageNumber
.
setOnClickListener
(
new
OnPageNumberViewOnClickListener
());
}
else
{
mBtnPrev
.
setVisibility
(
GONE
);
mBtnNext
.
setVisibility
(
GONE
);
mRvPageNumber
.
setVisibility
(
GONE
);
}
if
(
pageItems
!=
null
)
{
this
.
mPageItems
=
pageItems
;
}
if
(
fragmentManager
!=
null
)
{
this
.
mFragmentManager
=
fragmentManager
;
}
}
/**
* 设置页码是否可见
**/
public
void
setPageNumberEnable
(
boolean
enable
)
{
if
(
enable
)
{
mRvPageNumber
.
setVisibility
(
VISIBLE
);
}
else
{
mRvPageNumber
.
setVisibility
(
GONE
);
}
}
/**
* 页码点击事件
**/
private
class
OnPageNumberViewOnClickListener
implements
OnClickListener
{
@Override
public
void
onClick
(
View
v
)
{
Bundle
bundle
=
new
Bundle
();
bundle
.
putInt
(
"lastPageNumber"
,
mPager
.
size
());
bundle
.
putInt
(
"currentPageNumber"
,
mPageNumber
);
PageNumberSelector
dialog
=
new
PageNumberSelector
();
dialog
.
setArguments
(
bundle
);
if
(
mFragmentManager
==
null
)
{
return
;
}
dialog
.
show
(
mFragmentManager
,
dialog
.
getTag
());
dialog
.
setOnGetPageNumberListener
(
new
PageNumberSelector
.
OnGetPageNumberListener
()
{
@Override
public
void
getPageNumber
(
int
pageNumber
)
{
mPageNumber
=
pageNumber
;
mTvCurrentPageNumber
.
setText
(
mPageNumber
+
""
);
setPageChangeBtnCliable
();
refrashPageByPageNumber
();
}
});
}
}
/**
* 翻页按钮点击事件
**/
private
class
OnFlipOverBtnOnClickListener
implements
OnClickListener
{
@Override
public
void
onClick
(
View
v
)
{
if
(
BTN_PREV
.
equals
(
v
.
getTag
()))
{
if
(
mPageNumber
<=
1
)
{
return
;
}
mPageNumber
--;
}
else
{
if
(
mPageNumber
>=
mPager
.
size
())
{
return
;
}
mPageNumber
++;
}
setPageChangeBtnCliable
();
refrashPageByPageNumber
();
if
(
mOnSwitchPageNumberListener
!=
null
)
{
mOnSwitchPageNumberListener
.
onClick
(
v
.
getTag
().
toString
());
}
}
}
/**
* 设置切换页面按钮是否可点击
**/
private
void
setPageChangeBtnCliable
()
{
if
(
mPager
.
size
()
==
0
&&
mPageNumber
==
0
)
{
mBtnPrev
.
setBackgroundResource
(
R
.
drawable
.
lingber_ripple_bg_btn_unavailable
);
mBtnNext
.
setBackgroundResource
(
R
.
drawable
.
lingber_ripple_bg_btn_unavailable
);
mBtnPrev
.
setEnabled
(
false
);
mBtnNext
.
setEnabled
(
false
);
return
;
}
if
(
mPageNumber
<=
1
)
{
mBtnPrev
.
setBackgroundResource
(
R
.
drawable
.
lingber_ripple_bg_btn_unavailable
);
mBtnPrev
.
setEnabled
(
false
);
}
else
{
mBtnPrev
.
setBackgroundResource
(
R
.
drawable
.
lingber_ripple_bg_btn
);
mBtnPrev
.
setEnabled
(
true
);
}
if
(
mPageNumber
>=
mPager
.
size
())
{
mBtnNext
.
setBackgroundResource
(
R
.
drawable
.
lingber_ripple_bg_btn_unavailable
);
mBtnNext
.
setEnabled
(
false
);
}
else
{
mBtnNext
.
setBackgroundResource
(
R
.
drawable
.
lingber_ripple_bg_btn
);
mBtnNext
.
setEnabled
(
true
);
}
}
/**
* 根据页码刷新页面数据
**/
private
void
refrashPageByPageNumber
()
{
if
(
mPager
.
get
(
mPageNumber
)
==
null
)
{
return
;
}
pageDatas
.
clear
();
pageDatas
.
addAll
(
mPager
.
get
(
mPageNumber
));
if
(
mAdapter
!=
null
)
{
mAdapter
.
notifyDataSetChanged
();
// 设置View的复用池子大小,会不会影响性能待验证
//mRecyclerView.setItemViewCacheSize(dataSource.size());
mRecyclerView
.
setItemViewCacheSize
(
pageDatas
.
size
());
mAdapter
.
refreshAllRowStyle
();
updatePageNumberView
();
}
}
/**
* 设置是否可滑动
**/
public
void
setSlidable
(
boolean
slidable
)
{
this
.
mSlidable
=
slidable
;
}
/**
* 滑动控制
**/
private
LinearLayoutManager
setScrollEnable
(
Context
context
,
final
boolean
enable
)
{
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
context
)
{
@Override
public
boolean
canScrollVertically
()
{
if
(
enable
)
{
return
super
.
canScrollVertically
();
}
else
{
return
false
;
}
}
@Override
public
boolean
canScrollHorizontally
()
{
if
(
enable
)
{
return
super
.
canScrollVertically
();
}
else
{
return
false
;
}
}
};
return
layoutManager
;
}
/**
* 设置表格方向 暂时不可用
**/
private
void
setmOrientation
(
int
orientation
)
{
this
.
mOrientation
=
orientation
;
}
/**
* 设置表头高度
**/
public
void
setHeaderHeight
(
int
headerHeight
)
{
this
.
headerHeight
=
headerHeight
;
}
/**
* 设置表头背景
**/
public
void
setHeaderBackgroundColorResId
(
int
headerBackgroundColorResId
)
{
this
.
headerBackgroundColorResId
=
headerBackgroundColorResId
;
}
/**
* 设置列数
**/
public
void
setColunms
(
int
colunms
)
{
this
.
colunms
=
colunms
;
}
/**
* 设置行高
**/
public
void
setRowHeight
(
int
rowHeight
)
{
this
.
rowHeight
=
rowHeight
;
}
/**
* 设置分割线粗细
**/
public
void
setDividerSize
(
int
size
)
{
this
.
dividerSize
=
size
;
}
/**
* 设置分割线颜色
**/
public
void
setDividerColor
(
int
colorResId
)
{
this
.
dividerColorResId
=
colorResId
;
}
/**
* 设置列表底色
**/
public
void
setRvContentColorResId
(
int
colorResId
)
{
this
.
rvContentColorResId
=
colorResId
;
}
/**
* 设置列表单元格包含控件
**/
public
void
setCellContentView
(
Class
[]
contentViewsClass
)
{
this
.
contentViewsClass
=
contentViewsClass
;
}
/**
* 设置各列绑定字段
**/
public
void
setFieldNames
(
String
[]
fieldNames
)
{
this
.
fieldNames
=
fieldNames
;
}
/**
* 设置行选中后底色
**/
public
void
setSetRowIsSelectedBackgroundColor
(
int
colorResId
)
{
this
.
selectedBackgroundColorResId
=
colorResId
;
}
/**
* 设置选中模式 0关闭选择 1单选 2多选
**/
public
void
setSelectedMode
(
int
mode
)
{
this
.
selectedMode
=
mode
;
}
/**
* 设置表头内容
**/
public
void
setHeaderContent
(
String
[]
headerContent
)
{
this
.
headerContent
=
headerContent
;
}
/**
* 设置表头内容
**/
public
void
setHeaderContentByStringId
(
int
[]
arrResId
)
{
String
[]
headercontent
=
new
String
[
arrResId
.
length
];
for
(
int
i
=
0
;
i
<
arrResId
.
length
;
i
++)
{
headercontent
[
i
]
=
String
.
valueOf
(
arrResId
[
i
]);
}
this
.
headerContent
=
headercontent
;
}
/**
* 设置colunm宽度
**/
public
void
setColunmWeight
(
float
[]
colunmsWeight
)
{
this
.
colunmsWeight
=
colunmsWeight
;
}
/**
* 开启/关闭排序功能
**/
public
void
setSortIsEnabled
(
int
[]
colunmNo
,
boolean
enable
)
{
for
(
int
i
=
0
;
i
<
colunmNo
.
length
;
i
++)
{
sortEnableMap
.
put
(
colunmNo
[
i
],
colunmNo
[
i
]);
}
}
/**
* 设置圆角
**/
public
void
setRadius
(
float
[]
radius
)
{
if
(
radius
.
length
==
4
)
{
for
(
int
i
=
0
;
i
<
radius
.
length
;
i
++)
{
if
(
radius
[
i
]
>
0
)
{
this
.
arrRadius
[
i
]
=
radius
[
i
];
}
}
}
}
/**
* 设置快速添加功能
**/
public
void
setFastAdd
(
boolean
fastAdd
)
{
this
.
isFastAdd
=
fastAdd
;
}
/**
* 初始化
**/
public
void
initDataGridView
()
{
if
(
colunmsWeight
.
length
!=
0
)
{
if
(
headerContent
!=
null
)
{
if
(
headerContent
.
length
!=
0
)
{
setHeader
(
headerContent
,
colunmsWeight
);
}
}
if
(
flipOverEnable
)
{
initPager
(
this
.
dataSource
);
}
//setRecyclerView(this.dataSource, this.colunms, this.rowHeight, this.colunmsWeight, this.dividerSize, this.dividerColorResId, this.rvContentColorResId, this.selectedBackgroundColorResId, this.selectedMode, this.contentViewsClass, this.fieldNames, this.arrRadius, this.isFastAdd, this.flipOverEnable);
setRecyclerView
(
this
.
pageDatas
,
this
.
colunms
,
this
.
rowHeight
,
this
.
colunmsWeight
,
this
.
dividerSize
,
this
.
dividerColorResId
,
this
.
rvContentColorResId
,
this
.
selectedBackgroundColorResId
,
this
.
selectedMode
,
this
.
contentViewsClass
,
this
.
fieldNames
,
this
.
arrRadius
,
this
.
isFastAdd
);
}
}
/**
* 设置数据源
**/
public
void
setDataSource
(
List
<
T
>
dataSource
)
{
this
.
dataSource
=
(
List
<
Object
>)
dataSource
;
// 设置View的复用池子大小,会不会影响性能待验证
//mRecyclerView.setItemViewCacheSize(dataSource.size());
initPager
((
List
<
Object
>)
dataSource
);
mRecyclerView
.
setItemViewCacheSize
(
pageDatas
.
size
());
}
/**
* 初始化分页器
**/
private
void
initPager
(
List
<
Object
>
dataSource
)
{
// 配置分页器
if
(
flipOverEnable
)
{
mPager
.
clear
();
for
(
int
i
=
0
;
i
<
dataSource
.
size
();
i
++)
{
int
pageNumber
=
(
i
/
mPageItems
)
+
1
;
if
(
i
%
mPageItems
==
0
)
{
List
<
Object
>
datas
=
new
ArrayList
<>();
datas
.
add
(
dataSource
.
get
(
i
));
mPager
.
put
(
pageNumber
,
datas
);
}
else
{
mPager
.
get
(
pageNumber
).
add
(
dataSource
.
get
(
i
));
}
}
if
(
mPageNumber
>=
mPager
.
size
())
{
mPageNumber
=
mPager
.
size
();
}
else
if
(
mPageNumber
==
0
)
{
mPageNumber
=
1
;
}
// 更新样式
setPageChangeBtnCliable
();
updatePageNumberView
();
}
// 设置当前页面数据源
pageDatas
.
clear
();
if
(
mPager
.
get
(
mPageNumber
)
!=
null
)
{
pageDatas
.
addAll
(
mPager
.
get
(
mPageNumber
));
}
else
{
pageDatas
.
addAll
(
dataSource
);
}
}
/**
* 更新页码View
**/
private
void
updatePageNumberView
()
{
mTvCurrentPageNumber
.
setText
(
String
.
valueOf
(
mPageNumber
));
mTvMaxPageNumber
.
setText
(
String
.
valueOf
(
mPager
.
size
()));
}
/**
* 获取当前数据集
**/
public
List
<
Object
>
getDataSource
()
{
return
this
.
dataSource
;
}
/**
* 获取当前页面数据集
**/
public
List
<
Object
>
getPageDatas
()
{
return
this
.
pageDatas
;
}
/**
* 页码点击监听事件
**/
public
interface
OnSwitchPageNumberListener
{
void
onClick
(
String
type
);
}
private
OnSwitchPageNumberListener
mOnSwitchPageNumberListener
;
public
void
setOnSwitchPageNumberListener
(
OnSwitchPageNumberListener
onSwitchPageNumberListener
)
{
this
.
mOnSwitchPageNumberListener
=
onSwitchPageNumberListener
;
}
/**
* 返回选中Data
**/
public
List
<
Object
>
getSelectedRowsData
()
{
if
(
mAdapter
!=
null
)
{
return
mAdapter
.
getSelectedRowsData
();
}
else
{
return
null
;
}
}
/**
* 返回指定Row的Data
**/
public
Object
getRowData
(
int
row
)
{
if
(
mAdapter
!=
null
)
{
return
mAdapter
.
getRowData
(
row
);
}
else
{
return
null
;
}
}
/**
* 更新某一行数据
**/
public
void
updateARow
(
int
row
)
{
if
(
mAdapter
!=
null
)
{
initPager
(
dataSource
);
mAdapter
.
notifyItemChanged
(
row
);
mAdapter
.
refreshAllRowStyle
();
}
}
/**
* 更新数据(清除所有选中行样式)
**/
public
void
updateAll
()
{
if
(
mAdapter
!=
null
)
{
initPager
(
dataSource
);
mAdapter
.
notifyDataSetChanged
();
// 设置View的复用池子大小,会不会影响性能待验证
//mRecyclerView.setItemViewCacheSize(dataSource.size());
mRecyclerView
.
setItemViewCacheSize
(
pageDatas
.
size
());
mAdapter
.
refreshAllRowStyle
();
}
}
/**
* 更新数据(清除除选中外的所有行样式)
**/
public
void
updateAllExceptSelected
()
{
if
(
mAdapter
!=
null
)
{
initPager
(
dataSource
);
mAdapter
.
notifyDataSetChanged
();
// 设置View的复用池子大小,会不会影响性能待验证
//mRecyclerView.setItemViewCacheSize(dataSource.size());
mRecyclerView
.
setItemViewCacheSize
(
pageDatas
.
size
());
mAdapter
.
refreshUnselectedRowStyle
();
}
}
/**
* 设置表头
**/
private
void
setHeader
(
String
[]
headerContent
,
float
[]
colunmsWeight
)
{
if
(
headerContent
.
length
==
colunmsWeight
.
length
)
{
for
(
int
i
=
0
;
i
<
headerContent
.
length
;
i
++)
{
// 增加LinearLayout
LinearLayout
mHeaderItemLayout
=
new
LinearLayout
(
getContext
());
LayoutParams
headerItemLayoutParams
=
new
LayoutParams
(
0
,
LayoutParams
.
MATCH_PARENT
,
colunmsWeight
[
i
]);
//headerItemLayoutParams.setMargins(0, 0, this.dividerSize, 0);
headerItemLayoutParams
.
setMargins
(
0
,
0
,
0
,
0
);
mHeaderItemLayout
.
setLayoutParams
(
headerItemLayoutParams
);
mHeaderItemLayout
.
setBackgroundResource
(
headerBackgroundColorResId
);
mHeaderItemLayout
.
setOrientation
(
LinearLayout
.
HORIZONTAL
);
// 圆角设置
if
(
i
==
0
||
i
==
headerContent
.
length
-
1
)
{
// 左右两边设置圆角
GradientDrawable
gd
=
new
GradientDrawable
();
if
(
i
==
0
)
{
gd
.
setCornerRadii
(
new
float
[]{
arrRadius
[
0
],
arrRadius
[
0
],
0
,
0
,
0
,
0
,
0
,
0
});
}
else
{
gd
.
setCornerRadii
(
new
float
[]{
0
,
0
,
arrRadius
[
0
],
arrRadius
[
0
],
0
,
0
,
0
,
0
});
}
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
gd
.
setColor
(
getResources
().
getColor
(
headerBackgroundColorResId
,
null
));
}
else
{
gd
.
setColor
(
getResources
().
getColor
(
headerBackgroundColorResId
));
}
mHeaderItemLayout
.
setBackground
(
gd
);
}
mHeaderItemLayout
.
setGravity
(
Gravity
.
CENTER
);
mHeaderItemLayout
.
setId
(
getResources
().
getIdentifier
(
"header_item"
+
i
,
"id"
,
getContext
().
getPackageName
()));
mHeaderItemLayout
.
setTag
(
i
);
mHeaderItemLayout
.
setOnClickListener
(
this
);
// 设置表头文字
TextView
mTextView
=
new
TextView
(
getContext
());
LayoutParams
tvLayoutParams
=
new
LayoutParams
(
LayoutParams
.
WRAP_CONTENT
,
LayoutParams
.
MATCH_PARENT
);
mTextView
.
setGravity
(
Gravity
.
CENTER_VERTICAL
);
mTextView
.
setTextSize
(
10
);
if
(
headerContent
[
i
]
!=
null
)
{
mTextView
.
setText
(
headerContent
[
i
]);
}
// 设置表头文字(多语言)
// LangTextView mTextView = new LangTextView(getContext());
// LayoutParams tvLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
// mTextView.setGravity(Gravity.CENTER_VERTICAL);
// mTextView.setTextSize(22);
// if(headerContent[i]!=null){
// mTextView.setTextById(Integer.parseInt(headerContent[i]));
// }
// 设置表头图标
ImageView
mImageView
=
new
ImageView
(
getContext
());
LayoutParams
imLayoutParams
=
new
LayoutParams
(
LayoutParams
.
WRAP_CONTENT
,
LayoutParams
.
MATCH_PARENT
);
mImageView
.
setImageResource
(
R
.
drawable
.
lingber_ic_downward
);
mImageView
.
setId
(
getResources
().
getIdentifier
(
"header_sort_icon_item"
+
i
,
"id"
,
getContext
().
getPackageName
()));
// 是否开启排序功能
if
(
sortEnableMap
.
get
(
i
)
!=
null
)
{
mImageView
.
setVisibility
(
VISIBLE
);
}
else
{
mImageView
.
setVisibility
(
GONE
);
}
mHeaderItemLayout
.
addView
(
mTextView
,
tvLayoutParams
);
mHeaderItemLayout
.
addView
(
mImageView
,
imLayoutParams
);
mLlHeader
.
setLayoutParams
(
new
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
headerHeight
));
mLlHeader
.
addView
(
mHeaderItemLayout
,
headerItemLayoutParams
);
}
// 设置圆角
GradientDrawable
gd
=
new
GradientDrawable
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
gd
.
setColor
(
getResources
().
getColor
(
dividerColorResId
,
null
));
}
else
{
gd
.
setColor
(
getResources
().
getColor
(
dividerColorResId
));
}
gd
.
setCornerRadii
(
new
float
[]{
arrRadius
[
0
],
arrRadius
[
0
],
arrRadius
[
1
],
arrRadius
[
1
],
0
,
0
,
0
,
0
});
mLlHeader
.
setBackground
(
gd
);
}
}
/**
* 设置表格内容
**/
private
void
setRecyclerView
(
List
<
Object
>
dataSource
,
int
colunms
,
int
rowHeight
,
float
[]
colunmsWeight
,
int
dividerSize
,
int
dividerColorResId
,
int
rvContentColorResId
,
int
selectedBackgroundResId
,
int
setSelectedMode
,
Class
[]
contentViewsClass
,
String
[]
fieldNames
,
float
[]
radius
,
boolean
isFastAdd
)
{
mAdapter
=
new
RecyclerviewAdapter
(
getContext
(),
dataSource
,
rowHeight
,
colunms
,
colunmsWeight
,
dividerSize
,
dividerColorResId
,
rvContentColorResId
,
selectedBackgroundResId
,
setSelectedMode
,
contentViewsClass
,
fieldNames
,
radius
,
isFastAdd
);
LinearLayoutManager
manager
=
setScrollEnable
(
getContext
(),
mSlidable
);
manager
.
setOrientation
(
mOrientation
);
mRecyclerView
.
setLayoutManager
(
manager
);
mRecyclerView
.
setAdapter
(
mAdapter
);
}
/**
* 内部实现表头点击事件
**/
@Override
public
void
onClick
(
View
v
)
{
if
(
sortEnableMap
.
get
(
v
.
getTag
())
!=
null
)
{
int
resId
=
getResources
().
getIdentifier
(
"header_sort_icon_item"
+
v
.
getTag
(),
"id"
,
getContext
().
getPackageName
());
View
view
=
mView
.
findViewById
(
resId
);
float
rotation
=
view
.
getRotation
();
if
(
rotation
==
180
)
{
view
.
animate
().
rotation
(
0
);
LingberUtil
.
objectSort
(
pageDatas
,
fieldNames
[
Integer
.
parseInt
(
v
.
getTag
().
toString
())],
"asce"
);
//LingberUtil.objectSort(dataSource, fieldNames[Integer.parseInt(v.getTag().toString())], "asce");
//SortUtil.arrSort(dataSource, Integer.parseInt(v.getTag().toString()),"asce");
}
else
{
view
.
animate
().
rotation
(
180
);
LingberUtil
.
objectSort
(
pageDatas
,
fieldNames
[
Integer
.
parseInt
(
v
.
getTag
().
toString
())],
"desc"
);
//LingberUtil.objectSort(dataSource, fieldNames[Integer.parseInt(v.getTag().toString())], "desc");
//SortUtil.arrSort(dataSource, Integer.parseInt(v.getTag().toString()),"desc");
}
mAdapter
.
notifyDataSetChanged
();
}
}
/**
* 设置单元格控件点击事件监听
**/
public
void
setOnItemCellContentClickListener
(
RecyclerviewAdapter
.
OnItemCellContentClickListener
onItemCellContentClickListener
)
{
mAdapter
.
setOnItemCellContentClickListener
(
onItemCellContentClickListener
);
}
/**
* 设置单元格控件点击事件监听
**/
public
void
setOnItemCellClickListener
(
RecyclerviewAdapter
.
OnItemCellClickListener
onItemCellClickListener
)
{
mAdapter
.
setOnItemCellClickListener
(
onItemCellClickListener
);
}
/**
* 获取指定单元格View
**/
public
View
getItemCellView
(
int
row
,
int
column
)
{
return
mAdapter
.
getItemCellView
(
row
,
column
);
}
/**
* 获取指定单元格控件View
**/
public
View
getItemCellContentView
(
int
row
,
int
column
)
{
return
mAdapter
.
getItemCellContentView
(
row
,
column
);
}
/**
* 获取当前页码
**/
public
int
getCurrentPageNumber
()
{
return
this
.
mPageNumber
;
}
/**
* 获取每页数据条数
**/
public
int
getPageItems
()
{
return
this
.
mPageItems
;
}
/**
* 刷新语言
**/
public
void
reFreshLanguage
()
{
ViewUtil
.
updateViewLanguage
(
this
);
}
}
mycontrol/src/main/java/com/lingber/mycontrol/datagridview/LingberUtil.java
0 → 100644
View file @
429a4804
package
com
.
lingber
.
mycontrol
.
datagridview
;
import
java.lang.reflect.Field
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
/**
* @Author :ShuboLin
* @CreatTime: 2020-06-02 15:21.
* @Description: 工具类
*/
public
class
LingberUtil
<
T
>
{
/**根据字段名称获取字段值**/
public
static
String
getFieldValueByName
(
String
name
,
Object
object
){
if
(
object
==
null
||
name
==
null
){
return
null
;
}
Field
[]
fields
=
object
.
getClass
().
getDeclaredFields
();
String
[]
types1
={
"int"
,
"java.lang.String"
,
"boolean"
,
"char"
,
"float"
,
"double"
,
"long"
,
"short"
,
"byte"
};
String
[]
types2
={
"java.lang.Integer"
,
"java.lang.String"
,
"java.lang.Boolean"
,
"java.lang.Character"
,
"java.lang.Float"
,
"java.lang.Double"
,
"java.lang.Long"
,
"java.lang.Short"
,
"java.lang.Byte"
};
for
(
int
j
=
0
;
j
<
fields
.
length
;
j
++)
{
fields
[
j
].
setAccessible
(
true
);
// 字段名
if
(
fields
[
j
].
getName
().
equals
(
name
)){
// 字段值
for
(
int
i
=
0
;
i
<
types1
.
length
;
i
++){
if
(
fields
[
j
].
getType
().
getName
().
equalsIgnoreCase
(
types1
[
i
])||
fields
[
j
].
getType
().
getName
().
equalsIgnoreCase
(
types2
[
i
])){
try
{
if
(
fields
[
j
].
get
(
object
)!=
null
){
return
fields
[
j
].
get
(
object
)+
""
;
}
else
{
return
null
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
return
null
;
}
/**
* @author ShuboLin
* @CreatTime 2020-06-02 17:52
* @Param1 数据源
* @Param2 排第几个
* @Param3 排序方法
* @Description 排序数组
*/
public
static
void
arrSort
(
List
<
String
[]>
list
,
final
int
sortIndex
,
final
String
sortType
){
Collections
.
sort
(
list
,
new
Comparator
<
String
[]>()
{
@Override
public
int
compare
(
String
[]
o1
,
String
[]
o2
)
{
int
ret
=
0
;
if
((
o1
.
length
==
o2
.
length
)&&
sortIndex
<=
o1
.
length
){
if
(
o1
[
sortIndex
]!=
null
&&
o2
[
sortIndex
]!=
null
){
if
(
sortType
!=
null
&&
"asce"
.
equals
(
sortType
)){
// 升序
ret
=
o1
[
sortIndex
].
compareTo
(
o2
[
sortIndex
]);
}
else
{
// 降序
ret
=
o2
[
sortIndex
].
compareTo
(
o1
[
sortIndex
]);
}
}
}
return
ret
;
}
});
}
/**
* @author ShuboLin
* @CreatTime 2020-06-02 17:52
* @Param1 数据源
* @Param2 字段名
* @Param3 排序方法
* @Description 排序对象
*/
public
static
void
objectSort
(
List
<
Object
>
list
,
final
String
fieldName
,
final
String
sortType
){
Collections
.
sort
(
list
,
new
Comparator
<
Object
>()
{
@Override
public
int
compare
(
Object
o1
,
Object
o2
)
{
int
ret
=
0
;
if
(
sortType
!=
null
&&
fieldName
!=
null
&&
"asce"
.
equals
(
sortType
)){
// 升序
ret
=
getFieldValueByName
(
fieldName
,
o1
).
compareTo
(
LingberUtil
.
getFieldValueByName
(
fieldName
,
o2
));
}
else
{
// 降序
ret
=
getFieldValueByName
(
fieldName
,
o2
).
compareTo
(
LingberUtil
.
getFieldValueByName
(
fieldName
,
o1
));
}
return
ret
;
}
});
}
}
mycontrol/src/main/java/com/lingber/mycontrol/datagridview/PageNumberSelector.java
0 → 100644
View file @
429a4804
package
com
.
lingber
.
mycontrol
.
datagridview
;
import
android.app.Dialog
;
import
android.app.DialogFragment
;
import
android.graphics.Color
;
import
android.os.Bundle
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.view.Gravity
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
com.lingber.mycontrol.R
;
import
java.lang.reflect.Method
;
/**
* @Author :ShuboLin
* @CreatTime: 2021-03-02 9:43.
* @Description: 页码选择器
*/
public
class
PageNumberSelector
extends
DialogFragment
implements
View
.
OnClickListener
{
private
TextView
mTvKey1
;
private
TextView
mTvKey2
;
private
TextView
mTvKey3
;
private
TextView
mTvKey4
;
private
TextView
mTvKey5
;
private
TextView
mTvKey6
;
private
TextView
mTvKey7
;
private
TextView
mTvKey8
;
private
TextView
mTvKey9
;
private
TextView
mTvKey0
;
private
ImageView
mTvKeyBackspacing
;
private
EditText
mEditText
;
private
TextView
mTvLastPageNumber
;
private
ImageButton
mBtnReturn
;
private
ImageButton
mBtnOk
;
private
Integer
lastPageNumber
;
private
Integer
currentPageNumber
;
@Override
public
Dialog
onCreateDialog
(
Bundle
savedInstanceState
)
{
Dialog
mDialog
=
new
Dialog
(
getActivity
());
mDialog
.
requestWindowFeature
(
Window
.
FEATURE_NO_TITLE
);
mDialog
.
setContentView
(
R
.
layout
.
lingber_pagenumber_selector
);
// 允许点击其它空白地方消失弹窗
mDialog
.
setCanceledOnTouchOutside
(
true
);
Window
window
=
mDialog
.
getWindow
();
WindowManager
.
LayoutParams
layoutParams
;
if
(
window
!=
null
)
{
window
.
getDecorView
().
setPadding
(
0
,
0
,
0
,
0
);
layoutParams
=
window
.
getAttributes
();
layoutParams
.
gravity
=
Gravity
.
CENTER
;
layoutParams
.
height
=
500
;
layoutParams
.
width
=
850
;
window
.
setAttributes
(
layoutParams
);
// 必须
window
.
getDecorView
().
setBackgroundColor
(
Color
.
GREEN
);
window
.
setBackgroundDrawableResource
(
android
.
R
.
color
.
transparent
);
}
// 获取参数
lastPageNumber
=
getArguments
().
getInt
(
"lastPageNumber"
);
currentPageNumber
=
getArguments
().
getInt
(
"currentPageNumber"
);
if
(
lastPageNumber
==
null
){
lastPageNumber
=
0
;
}
if
(
currentPageNumber
==
null
){
currentPageNumber
=
0
;
}
doBinding
(
mDialog
);
// 绑定EditText键盘
bindKeyBoard
();
return
mDialog
;
}
/** 绑定控件**/
private
void
doBinding
(
Dialog
mDialog
){
mEditText
=
(
EditText
)
mDialog
.
findViewById
(
R
.
id
.
et_barcode_input
);
mTvLastPageNumber
=
(
TextView
)
mDialog
.
findViewById
(
R
.
id
.
tv_last_page_number
);
mBtnReturn
=
(
ImageButton
)
mDialog
.
findViewById
(
R
.
id
.
btn_return
);
mBtnOk
=
(
ImageButton
)
mDialog
.
findViewById
(
R
.
id
.
btn_ok
);
mTvKey1
=
(
TextView
)
mDialog
.
findViewById
(
R
.
id
.
tv_key_1
);
mTvKey2
=
(
TextView
)
mDialog
.
findViewById
(
R
.
id
.
tv_key_2
);
mTvKey3
=
(
TextView
)
mDialog
.
findViewById
(
R
.
id
.
tv_key_3
);
mTvKey4
=
(
TextView
)
mDialog
.
findViewById
(
R
.
id
.
tv_key_4
);
mTvKey5
=
(
TextView
)
mDialog
.
findViewById
(
R
.
id
.
tv_key_5
);
mTvKey6
=
(
TextView
)
mDialog
.
findViewById
(
R
.
id
.
tv_key_6
);
mTvKey7
=
(
TextView
)
mDialog
.
findViewById
(
R
.
id
.
tv_key_7
);
mTvKey8
=
(
TextView
)
mDialog
.
findViewById
(
R
.
id
.
tv_key_8
);
mTvKey9
=
(
TextView
)
mDialog
.
findViewById
(
R
.
id
.
tv_key_9
);
mTvKey0
=
(
TextView
)
mDialog
.
findViewById
(
R
.
id
.
tv_key_0
);
mTvKeyBackspacing
=
(
ImageView
)
mDialog
.
findViewById
(
R
.
id
.
iv_backspace
);
mBtnReturn
.
setOnClickListener
(
this
);
mBtnOk
.
setOnClickListener
(
this
);
mTvKey1
.
setOnClickListener
(
this
);
mTvKey2
.
setOnClickListener
(
this
);
mTvKey3
.
setOnClickListener
(
this
);
mTvKey4
.
setOnClickListener
(
this
);
mTvKey5
.
setOnClickListener
(
this
);
mTvKey6
.
setOnClickListener
(
this
);
mTvKey7
.
setOnClickListener
(
this
);
mTvKey8
.
setOnClickListener
(
this
);
mTvKey9
.
setOnClickListener
(
this
);
mTvKey0
.
setOnClickListener
(
this
);
mTvKeyBackspacing
.
setOnClickListener
(
this
);
mBtnReturn
.
setTag
(
"return"
);
mBtnOk
.
setTag
(
"ok"
);
mTvKeyBackspacing
.
setTag
(
"backspacing"
);
mTvLastPageNumber
.
setText
(
lastPageNumber
+
""
);
mEditText
.
setText
(
currentPageNumber
+
""
);
// 回退长按事件
mTvKeyBackspacing
.
setOnLongClickListener
(
new
View
.
OnLongClickListener
()
{
@Override
public
boolean
onLongClick
(
View
v
)
{
if
(
mEditText
!=
null
){
mEditText
.
setText
(
""
);
mEditText
.
setSelection
(
mEditText
.
getText
().
length
());
}
return
false
;
}
});
// 页码最大输入值限制
if
(
lastPageNumber
==
0
){
mEditText
.
setEnabled
(
false
);
mBtnOk
.
setVisibility
(
View
.
GONE
);
}
mEditText
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
}
@Override
public
void
afterTextChanged
(
Editable
s
)
{
String
text
=
mEditText
.
getText
().
toString
();
if
(
text
.
isEmpty
()){
return
;
}
if
(
Integer
.
valueOf
(
text
)>
lastPageNumber
){
mEditText
.
setText
(
lastPageNumber
+
""
);
}
if
(
Integer
.
valueOf
(
text
)
==
0
){
mEditText
.
setText
(
""
);
}
}
});
}
@Override
public
void
onClick
(
View
v
)
{
if
(
"backspacing"
.
equals
(
v
.
getTag
())){
String
text
=
mEditText
.
getText
().
toString
();
if
(
text
.
length
()==
0
){
return
;
}
mEditText
.
setText
(
text
.
substring
(
0
,
text
.
length
()-
1
));
mEditText
.
setSelection
(
mEditText
.
getText
().
length
());
return
;
}
if
(
"ok"
.
equals
(
v
.
getTag
())){
String
text
=
mEditText
.
getText
().
toString
();
if
(
text
.
isEmpty
()){
return
;
}
currentPageNumber
=
Integer
.
valueOf
(
text
);
if
(
mOnGetPageNumberListener
!=
null
){
mOnGetPageNumberListener
.
getPageNumber
(
currentPageNumber
);
}
dismiss
();
return
;
}
if
(
"return"
.
equals
(
v
.
getTag
())){
dismiss
();
return
;
}
if
(
lastPageNumber
==
0
){
return
;
}
String
text
=
mEditText
.
getText
().
toString
();
TextView
textView
=
(
TextView
)
v
;
mEditText
.
setText
(
text
+
textView
.
getText
().
toString
());
mEditText
.
setSelection
(
mEditText
.
getText
().
length
());
}
/** 绑定小键盘**/
private
void
bindKeyBoard
(){
// 禁止系统自带键盘弹出
Class
<
EditText
>
cls
=
EditText
.
class
;
Method
method
;
try
{
method
=
cls
.
getMethod
(
"setShowSoftInputOnFocus"
,
boolean
.
class
);
method
.
setAccessible
(
true
);
method
.
invoke
(
mEditText
,
false
);
}
catch
(
Exception
e
)
{
}
}
@Override
public
void
onDestroyView
()
{
super
.
onDestroyView
();
}
/** 选择页码回调**/
private
OnGetPageNumberListener
mOnGetPageNumberListener
;
public
void
setOnGetPageNumberListener
(
OnGetPageNumberListener
getPageNumberListener
){
this
.
mOnGetPageNumberListener
=
getPageNumberListener
;
}
public
interface
OnGetPageNumberListener
{
void
getPageNumber
(
int
pageNumber
);
}
}
mycontrol/src/main/java/com/lingber/mycontrol/datagridview/RecyclerviewAdapter.java
0 → 100644
View file @
429a4804
package
com
.
lingber
.
mycontrol
.
datagridview
;
import
android.content.Context
;
import
android.graphics.drawable.GradientDrawable
;
import
android.os.Build
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Button
;
import
android.widget.CheckBox
;
import
android.widget.EditText
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.lingber.mycontrol.R
;
import
com.lingber.mycontrol.datagridview.i18n.LangTextView
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Author :ShuboLin
* @CreatTime: 2020-05-07 13:55.
* @Description: RecyclerView适配器
*/
public
class
RecyclerviewAdapter
extends
RecyclerView
.
Adapter
<
RecyclerviewAdapter
.
RvViewHolder
>
{
private
Context
context
;
private
List
<
Object
>
dataSource
;
private
View
inflater
;
private
LinearLayout
mRecyclerView
;
private
List
<
RvViewHolder
>
holders
=
new
ArrayList
<>();
private
int
height
;
private
int
colunms
;
private
float
[]
colunmsWeight
;
private
int
dividerSize
;
private
int
dividerColorResId
;
private
int
rvContentColorResId
;
private
int
selectedBackgroundResId
;
private
Map
<
Integer
,
Boolean
>
selectedMap
=
new
HashMap
<>();
private
int
selectedMode
;
/**
* 单选模式
**/
private
final
int
RADIO_MODE
=
1
;
/**
* 多选模式
**/
private
final
int
MULTI_MODE
=
2
;
/**
* 设置单元格包含控件
**/
private
Class
<
View
>[]
contentViewsClass
;
/**
* 各单元格对应的字段名
**/
private
String
[]
fieldNames
;
/**
* 圆角
**/
float
[]
radius
;
/**
* 是否开启快速添加功能
**/
private
boolean
isFastAdd
=
false
;
/**
* 构造函数
**/
public
RecyclerviewAdapter
(
Context
context
,
List
<
Object
>
dataSource
,
int
height
,
int
colunms
,
float
[]
colunmsWeight
,
int
dividerSize
,
int
dividerColorResId
,
int
rvContentColorResId
,
int
selectedBackgroundResId
,
int
selectedMode
,
Class
[]
contentViewsClass
,
String
[]
fieldNames
,
float
[]
radius
,
boolean
isFastAdd
)
{
this
.
context
=
context
;
this
.
dataSource
=
dataSource
;
this
.
height
=
height
;
this
.
colunms
=
colunms
;
this
.
colunmsWeight
=
colunmsWeight
;
this
.
dividerSize
=
dividerSize
;
this
.
dividerColorResId
=
dividerColorResId
;
this
.
rvContentColorResId
=
rvContentColorResId
;
this
.
selectedBackgroundResId
=
selectedBackgroundResId
;
this
.
selectedMode
=
selectedMode
;
this
.
contentViewsClass
=
contentViewsClass
;
this
.
fieldNames
=
fieldNames
;
this
.
radius
=
radius
;
this
.
isFastAdd
=
isFastAdd
;
}
@Override
public
RvViewHolder
onCreateViewHolder
(
ViewGroup
parent
,
int
viewType
)
{
inflater
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
lingber_recyclerview
,
parent
,
false
);
this
.
mRecyclerView
=
(
LinearLayout
)
inflater
.
findViewById
(
R
.
id
.
ll_recyclerview
);
// 设置分割线颜色
mRecyclerView
.
setBackgroundResource
(
dividerColorResId
);
// 设置单行高度
RecyclerView
.
LayoutParams
params
=
(
RecyclerView
.
LayoutParams
)
inflater
.
getLayoutParams
();
params
.
height
=
height
;
inflater
.
setLayoutParams
(
params
);
//手动添加
for
(
int
i
=
0
;
i
<
colunms
;
i
++)
{
// item
LinearLayout
mItemLayout
=
new
LinearLayout
(
inflater
.
getContext
());
LinearLayout
.
LayoutParams
itemLayoutParams
=
new
LinearLayout
.
LayoutParams
(
0
,
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
colunmsWeight
[
i
]);
itemLayoutParams
.
setMargins
(
0
,
0
,
0
,
this
.
dividerSize
);
mItemLayout
.
setLayoutParams
(
itemLayoutParams
);
mItemLayout
.
setBackgroundResource
(
rvContentColorResId
);
mItemLayout
.
setGravity
(
Gravity
.
CENTER
);
mItemLayout
.
setId
(
inflater
.
getResources
().
getIdentifier
(
"item_cell"
+
i
,
"id"
,
inflater
.
getContext
().
getPackageName
()));
// 设置item内容
TextView
mContentView
=
getViewByClass
(
this
.
contentViewsClass
[
i
]);
// 检查是否设置快速添加样式
/* if(isFastAdd&&i==0){
mContentView.setBackgroundResource(R.drawable.lingber_ic_fast_add);
}*/
LinearLayout
.
LayoutParams
etLayoutParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
,
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
);
mContentView
.
setGravity
(
Gravity
.
CENTER
);
mContentView
.
setTextSize
(
8
);
//mContentView.setBackground(null);
mContentView
.
setId
(
inflater
.
getResources
().
getIdentifier
(
"item_cell_content"
+
i
,
"id"
,
inflater
.
getContext
().
getPackageName
()));
mItemLayout
.
addView
(
mContentView
,
etLayoutParams
);
mRecyclerView
.
addView
(
mItemLayout
,
itemLayoutParams
);
}
// 管理Item
RvViewHolder
rvViewHolder
=
new
RvViewHolder
(
inflater
);
return
rvViewHolder
;
}
/**
* 根据控件类型返回控件实体
* 目前只支持四种:
* TextView EditView CheckBox Button
**/
private
TextView
getViewByClass
(
Class
mClass
)
{
if
(
mClass
!=
null
)
{
if
(
EditText
.
class
.
equals
(
mClass
))
{
return
new
EditText
(
context
);
}
else
if
(
CheckBox
.
class
.
equals
(
mClass
))
{
CheckBox
cbItem
=
new
CheckBox
(
context
);
// 自定义CheckBox样式
cbItem
.
setBackgroundResource
(
R
.
drawable
.
lingber_checkbox_style
);
cbItem
.
setButtonDrawable
(
null
);
return
cbItem
;
}
else
if
(
Button
.
class
.
equals
(
mClass
))
{
return
new
Button
(
context
);
}
else
if
(
LangTextView
.
class
.
equals
(
mClass
))
{
// 自定义多语言Textview
return
new
LangTextView
(
context
);
}
else
{
// TextView 为基本控件类型
return
new
TextView
(
context
);
}
}
else
{
// TextView 为基本控件类型
return
new
TextView
(
context
);
}
}
@Override
public
void
onViewRecycled
(
RvViewHolder
holder
)
{
super
.
onViewRecycled
(
holder
);
// 重要!删除旧的holder,否则部分子项不可点击。
holders
.
remove
(
holder
);
}
@Override
public
void
onBindViewHolder
(
RvViewHolder
holder
,
int
position
)
{
// 添加holder
holders
.
add
(
holder
);
// 将数据和控件绑定
for
(
int
i
=
0
;
i
<
colunms
;
i
++)
{
String
contentValue
=
LingberUtil
.
getFieldValueByName
(
fieldNames
[
i
],
dataSource
.
get
(
position
));
if
(
CheckBox
.
class
.
equals
(
this
.
contentViewsClass
[
i
]))
{
CheckBox
checkBox
=
(
CheckBox
)
holder
.
arrContentView
[
i
];
if
(
contentValue
!=
null
)
{
checkBox
.
setChecked
(
Boolean
.
valueOf
(
contentValue
));
}
else
{
checkBox
.
setChecked
(
false
);
}
}
else
{
if
(
contentValue
!=
null
)
{
holder
.
arrContentView
[
i
].
setText
(
contentValue
);
/* // 设置已添加样式
if(isFastAdd&&i==0){
holder.arrContentView[i].setBackgroundResource(R.drawable.lingber_ic_fast_added);
}*/
}
else
{
/* // 设置快速添加样式
if(isFastAdd&&i==0){
holder.arrContentView[i].setBackgroundResource(R.drawable.lingber_ic_fast_add);
}*/
holder
.
arrContentView
[
i
].
setText
(
""
);
}
}
//holder.arrContentView[i].setText(dataSource.get(position)[i]);
holder
.
arrLinearLayout
[
i
].
setTag
(
position
);
holder
.
arrContentView
[
i
].
setTag
(
position
);
holder
.
arrLinearLayout
[
i
].
setOnClickListener
(
new
ItemCellClickListener
(
position
,
i
,
this
.
mOnItemCellClickListener
));
holder
.
arrContentView
[
i
].
setOnClickListener
(
new
ItemCellContentClickListener
(
position
,
i
,
this
.
mOnItemCellContentClickListener
));
// 设置Item圆角
if
((
i
==
0
||
i
==
(
colunms
-
1
))
&&
(
position
==
dataSource
.
size
()
-
1
))
{
int
resId
=
rvContentColorResId
;
Boolean
rowIsSelected
=
selectedMap
.
get
(
position
);
if
(
rowIsSelected
!=
null
)
{
if
(
rowIsSelected
)
{
resId
=
this
.
selectedBackgroundResId
;
}
}
GradientDrawable
gd
=
new
GradientDrawable
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
gd
.
setColor
(
context
.
getResources
().
getColor
(
resId
,
null
));
}
else
{
gd
.
setColor
(
context
.
getResources
().
getColor
(
resId
));
}
if
(
i
==
0
)
{
gd
.
setCornerRadii
(
new
float
[]{
0
,
0
,
0
,
0
,
0
,
0
,
radius
[
3
],
radius
[
3
]});
}
else
{
gd
.
setCornerRadii
(
new
float
[]{
0
,
0
,
0
,
0
,
radius
[
2
],
radius
[
2
],
0
,
0
});
}
holder
.
arrLinearLayout
[
i
].
setBackground
(
gd
);
}
}
if
(
position
==
dataSource
.
size
()
-
1
)
{
// 设置本条View圆角
GradientDrawable
gd
=
new
GradientDrawable
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
gd
.
setColor
(
context
.
getResources
().
getColor
(
dividerColorResId
,
null
));
}
else
{
gd
.
setColor
(
context
.
getResources
().
getColor
(
dividerColorResId
));
}
gd
.
setCornerRadii
(
new
float
[]{
0
,
0
,
0
,
0
,
radius
[
3
],
radius
[
3
],
radius
[
2
],
radius
[
2
]});
mRecyclerView
.
setBackground
(
gd
);
}
// 设置初始选中样式-非选中
this
.
selectedMap
.
put
(
position
,
false
);
}
@Override
public
int
getItemCount
()
{
// 返回Item总条数
return
dataSource
.
size
();
}
/**
* 返回当前选中Data
**/
public
List
<
Object
>
getSelectedRowsData
()
{
List
<
Object
>
datas
=
new
ArrayList
<>();
for
(
Integer
key
:
selectedMap
.
keySet
())
{
if
(
selectedMap
.
get
(
key
)
!=
null
)
{
if
(
selectedMap
.
get
(
key
))
{
if
(
key
<
dataSource
.
size
())
{
datas
.
add
(
dataSource
.
get
(
key
));
}
}
}
}
return
datas
;
}
/**
* 返回指定Row的Data
**/
public
Object
getRowData
(
int
row
)
{
Object
data
=
new
Object
();
if
(
row
<
dataSource
.
size
())
{
data
=
dataSource
.
get
(
row
);
}
return
data
;
}
/**
* 多选模式
**/
private
void
multiselectMode
(
int
position
)
{
Boolean
rowIsSelected
=
selectedMap
.
get
(
position
);
if
(
rowIsSelected
!=
null
)
{
RvViewHolder
holder
=
null
;
for
(
int
i
=
0
;
i
<
holders
.
size
();
i
++)
{
if
(
holders
.
get
(
i
).
getLayoutPosition
()
==
position
)
{
holder
=
holders
.
get
(
i
);
}
}
int
resId
;
if
(
rowIsSelected
)
{
resId
=
this
.
rvContentColorResId
;
selectedMap
.
put
(
position
,
false
);
}
else
{
resId
=
this
.
selectedBackgroundResId
;
selectedMap
.
put
(
position
,
true
);
}
if
(
holder
!=
null
)
{
for
(
int
i
=
0
;
i
<
holder
.
arrLinearLayout
.
length
;
i
++)
{
holder
.
arrLinearLayout
[
i
].
setBackgroundResource
(
resId
);
}
}
}
}
/**
* 单选模式
**/
private
void
radioMode
(
int
position
)
{
for
(
int
i
=
0
;
i
<
holders
.
size
();
i
++)
{
RvViewHolder
holder
=
holders
.
get
(
i
);
int
resId
;
int
currentPosition
=
holder
.
getLayoutPosition
();
Boolean
rowIsSelected
=
selectedMap
.
get
(
currentPosition
);
if
(
rowIsSelected
!=
null
)
{
if
(
currentPosition
==
position
)
{
// 当前选中行
if
(
rowIsSelected
)
{
resId
=
this
.
rvContentColorResId
;
selectedMap
.
put
(
position
,
false
);
}
else
{
resId
=
this
.
selectedBackgroundResId
;
selectedMap
.
put
(
position
,
true
);
}
if
(
holder
!=
null
)
{
for
(
int
j
=
0
;
j
<
holder
.
arrLinearLayout
.
length
;
j
++)
{
holder
.
arrLinearLayout
[
j
].
setBackgroundResource
(
resId
);
}
}
}
else
{
// 非当前行,清除样式
if
(
selectedMap
.
get
(
currentPosition
)
!=
null
)
{
if
(
selectedMap
.
get
(
currentPosition
))
{
selectedMap
.
put
(
currentPosition
,
false
);
resId
=
this
.
rvContentColorResId
;
if
(
holder
!=
null
)
{
for
(
int
j
=
0
;
j
<
holder
.
arrLinearLayout
.
length
;
j
++)
{
holder
.
arrLinearLayout
[
j
].
setBackgroundResource
(
resId
);
}
}
}
}
}
}
}
}
/**
* @author ShuboLin
* @CreatTime 2021-02-03 9:03
* @Description 刷新非选中行样式
*/
public
void
refreshUnselectedRowStyle
()
{
for
(
int
i
=
0
;
i
<
holders
.
size
();
i
++)
{
RvViewHolder
holder
=
holders
.
get
(
i
);
int
resId
;
int
currentPosition
=
holder
.
getLayoutPosition
();
Boolean
rowIsSelected
=
selectedMap
.
get
(
currentPosition
);
if
(
rowIsSelected
!=
null
)
{
if
(!
selectedMap
.
get
(
currentPosition
))
{
selectedMap
.
put
(
currentPosition
,
false
);
resId
=
this
.
rvContentColorResId
;
if
(
holder
!=
null
)
{
for
(
int
j
=
0
;
j
<
holder
.
arrLinearLayout
.
length
;
j
++)
{
holder
.
arrLinearLayout
[
j
].
setBackgroundResource
(
resId
);
}
}
}
}
}
}
/**
* @author ShuboLin
* @CreatTime 2021-02-03 9:03
* @Description 刷新所有行样式(全部置为非选中)
*/
public
void
refreshAllRowStyle
()
{
for
(
int
i
=
0
;
i
<
holders
.
size
();
i
++)
{
RvViewHolder
holder
=
holders
.
get
(
i
);
int
resId
;
int
currentPosition
=
holder
.
getLayoutPosition
();
Boolean
rowIsSelected
=
selectedMap
.
get
(
currentPosition
);
if
(
rowIsSelected
!=
null
)
{
//if(!selectedMap.get(currentPosition)){
selectedMap
.
put
(
currentPosition
,
false
);
resId
=
this
.
rvContentColorResId
;
if
(
holder
!=
null
)
{
for
(
int
j
=
0
;
j
<
holder
.
arrLinearLayout
.
length
;
j
++)
{
holder
.
arrLinearLayout
[
j
].
setBackgroundResource
(
resId
);
}
}
//}
}
}
}
/**
* 内部类 绑定各控件
**/
class
RvViewHolder
extends
RecyclerView
.
ViewHolder
{
LinearLayout
[]
arrLinearLayout
=
new
LinearLayout
[
colunms
];
TextView
[]
arrContentView
=
new
TextView
[
colunms
];
public
RvViewHolder
(
View
itemView
)
{
super
(
itemView
);
for
(
int
i
=
0
;
i
<
colunms
;
i
++)
{
arrLinearLayout
[
i
]
=
(
LinearLayout
)
inflater
.
findViewById
(
inflater
.
getResources
().
getIdentifier
(
"item_cell"
+
i
,
"id"
,
inflater
.
getContext
().
getPackageName
()));
arrContentView
[
i
]
=
(
TextView
)
inflater
.
findViewById
(
inflater
.
getResources
().
getIdentifier
(
"item_cell_content"
+
i
,
"id"
,
inflater
.
getContext
().
getPackageName
()));
}
}
}
/**
* @author ShuboLin
* @CreatTime 2020-05-20 14:04
* @Description 获取指定单元格View
*/
public
View
getItemCellView
(
int
row
,
int
column
)
{
View
view
=
null
;
if
(
holders
!=
null
)
{
RvViewHolder
holder
=
null
;
for
(
int
i
=
0
;
i
<
holders
.
size
();
i
++)
{
if
(
holders
.
get
(
i
).
getLayoutPosition
()
==
row
)
{
holder
=
holders
.
get
(
i
);
}
}
if
(
holder
!=
null
)
{
if
(
holder
.
arrLinearLayout
.
length
>
column
)
{
view
=
holder
.
arrLinearLayout
[
column
];
}
}
}
return
view
;
}
/**
* @author ShuboLin
* @CreatTime 2020-05-20 14:04
* @Description 获取指定单元格控件View
*/
public
View
getItemCellContentView
(
int
row
,
int
column
)
{
View
view
=
null
;
if
(
holders
!=
null
)
{
RvViewHolder
holder
=
null
;
for
(
int
i
=
0
;
i
<
holders
.
size
();
i
++)
{
if
(
holders
.
get
(
i
).
getLayoutPosition
()
==
row
)
{
holder
=
holders
.
get
(
i
);
}
}
if
(
holder
!=
null
)
{
if
(
holder
.
arrContentView
.
length
>
column
)
{
view
=
holder
.
arrContentView
[
column
];
}
}
}
return
view
;
}
/**
* @author ShuboLin
* @CreatTime 2020-05-20 8:48
* @Description 监听单元格控件点击事件
*/
public
interface
OnItemCellContentClickListener
{
void
onClick
(
View
v
,
int
row
,
int
column
);
}
private
OnItemCellContentClickListener
mOnItemCellContentClickListener
;
public
void
setOnItemCellContentClickListener
(
OnItemCellContentClickListener
onItemCellContentClickListener
)
{
this
.
mOnItemCellContentClickListener
=
onItemCellContentClickListener
;
}
class
ItemCellContentClickListener
implements
View
.
OnClickListener
{
int
column
=
0
;
int
row
=
0
;
OnItemCellContentClickListener
mOnItemCellContentClickListener
;
public
ItemCellContentClickListener
(
int
row
,
int
column
,
OnItemCellContentClickListener
onItemCellContentClickListener
)
{
this
.
column
=
column
;
this
.
row
=
row
;
this
.
mOnItemCellContentClickListener
=
onItemCellContentClickListener
;
}
@Override
public
void
onClick
(
View
v
)
{
// 更新选中样式
updateSelectedStyle
(
v
);
if
(
mOnItemCellContentClickListener
!=
null
)
{
mOnItemCellContentClickListener
.
onClick
(
v
,
row
,
column
);
}
}
}
/**
* @author ShuboLin
* @CreatTime 2020-05-20 8:48
* @Description 监听单元格点击事件
*/
public
interface
OnItemCellClickListener
{
void
onClick
(
View
v
,
int
row
,
int
column
);
}
private
OnItemCellClickListener
mOnItemCellClickListener
;
public
void
setOnItemCellClickListener
(
OnItemCellClickListener
onItemCellClickListener
)
{
this
.
mOnItemCellClickListener
=
onItemCellClickListener
;
}
class
ItemCellClickListener
implements
View
.
OnClickListener
{
int
column
=
0
;
int
row
=
0
;
OnItemCellClickListener
onItemCellClickListener
;
public
ItemCellClickListener
(
int
row
,
int
column
,
OnItemCellClickListener
onItemCellClickListener
)
{
this
.
column
=
column
;
this
.
row
=
row
;
this
.
onItemCellClickListener
=
onItemCellClickListener
;
}
@Override
public
void
onClick
(
View
v
)
{
// 更新选中样式
updateSelectedStyle
(
v
);
if
(
onItemCellClickListener
!=
null
)
{
onItemCellClickListener
.
onClick
(
v
,
row
,
column
);
}
}
}
/**
* 点击事件触发更新选中样式
**/
private
void
updateSelectedStyle
(
View
v
)
{
int
position
=
(
int
)
v
.
getTag
();
if
(
position
>=
holders
.
size
())
{
return
;
}
RvViewHolder
holder
=
holders
.
get
(
position
);
if
(
holder
!=
null
)
{
// 选择模式
switch
(
selectedMode
)
{
case
RADIO_MODE:
radioMode
(
position
);
break
;
case
MULTI_MODE:
multiselectMode
(
position
);
break
;
default
:
break
;
}
}
}
/**
* 解决数据错乱问题
**/
@Override
public
int
getItemViewType
(
int
position
)
{
return
position
;
}
}
mycontrol/src/main/java/com/lingber/mycontrol/datagridview/i18n/ILanguageView.java
0 → 100644
View file @
429a4804
package
com
.
lingber
.
mycontrol
.
datagridview
.
i18n
;
import
androidx.annotation.ArrayRes
;
import
androidx.annotation.StringRes
;
/**
* @Author: huangtao
* @Date: 2019-07-17 19:23
* @Description: 多语言切换接口
*/
public
interface
ILanguageView
{
String
ANDROIDXML
=
"http://schemas.android.com/apk/res/android"
;
//由于setText无法被重写,需要添加以下三个必要的方法,如果你的app不需要对多语言的textview修改值(只是xml写死就够了),那就不需要实现他们
void
setTextById
(
@StringRes
int
id
);
//手动设置textId
void
setTextWithString
(
String
text
);
//手动去掉textId,不然重新加载语言的时候会被重置掉
void
setTextByArrayAndIndex
(
@ArrayRes
int
arrId
,
@StringRes
int
arrIndex
);
//手动通过TextArray设置语言
void
reLoadLanguage
();
//修改语言时主要调用的方法
}
mycontrol/src/main/java/com/lingber/mycontrol/datagridview/i18n/LangTextView.java
0 → 100644
View file @
429a4804
package
com
.
lingber
.
mycontrol
.
datagridview
.
i18n
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
androidx.annotation.ArrayRes
;
import
androidx.annotation.StringRes
;
import
androidx.appcompat.widget.AppCompatTextView
;
import
com.lingber.mycontrol.datagridview.i18n.Util.StringUtil
;
/**
* @author ShuboLin
* @CreatTime 2020-05-22 10:54
* @Description 多语言TextView控件
*/
public
class
LangTextView
extends
AppCompatTextView
implements
ILanguageView
{
private
int
textId
;
//文字id
private
int
hintId
;
//hint的id
private
int
arrResId
,
arrResIndex
;
public
LangTextView
(
Context
context
)
{
super
(
context
);
init
(
context
,
null
);
}
public
LangTextView
(
Context
paramContext
,
AttributeSet
paramAttributeSet
)
{
super
(
paramContext
,
paramAttributeSet
);
init
(
paramContext
,
paramAttributeSet
);
}
public
LangTextView
(
Context
paramContext
,
AttributeSet
paramAttributeSet
,
int
paramInt
)
{
super
(
paramContext
,
paramAttributeSet
,
paramInt
);
init
(
paramContext
,
paramAttributeSet
);
}
/**
* 初始化获取xml的资源id
*
* @param context
* @param attributeSet
*/
private
void
init
(
Context
context
,
AttributeSet
attributeSet
)
{
if
(
attributeSet
!=
null
)
{
String
textValue
=
attributeSet
.
getAttributeValue
(
ANDROIDXML
,
"text"
);
if
(!(
textValue
==
null
||
textValue
.
length
()
<
2
))
{
//如果是 android:text="@string/testText"
//textValue会长这样 @156878785,去掉@号就是资源id
textId
=
StringUtil
.
string2int
(
textValue
.
substring
(
1
,
textValue
.
length
()));
}
String
hintValue
=
attributeSet
.
getAttributeValue
(
ANDROIDXML
,
"hint"
);
if
(!(
hintValue
==
null
||
hintValue
.
length
()
<
2
))
{
hintId
=
StringUtil
.
string2int
(
hintValue
.
substring
(
1
,
hintValue
.
length
()));
}
}
}
@Override
public
void
setTextById
(
@StringRes
int
strId
)
{
this
.
textId
=
strId
;
setText
(
strId
);
}
@Override
public
void
setTextWithString
(
String
text
)
{
this
.
textId
=
0
;
setText
(
text
);
}
@Override
public
void
setTextByArrayAndIndex
(
@ArrayRes
int
arrId
,
@StringRes
int
arrIndex
)
{
arrResId
=
arrId
;
arrResIndex
=
arrIndex
;
String
[]
strs
=
getContext
().
getResources
().
getStringArray
(
arrId
);
setText
(
strs
[
arrIndex
]);
}
@Override
public
void
reLoadLanguage
()
{
try
{
if
(
textId
>
0
)
{
setText
(
textId
);
}
else
if
(
arrResId
>
0
)
{
String
[]
strs
=
getContext
().
getResources
().
getStringArray
(
arrResId
);
setText
(
strs
[
arrResIndex
]);
}
if
(
hintId
>
0
)
{
setHint
(
hintId
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
mycontrol/src/main/java/com/lingber/mycontrol/datagridview/i18n/Util/StringUtil.java
0 → 100644
View file @
429a4804
package
com
.
lingber
.
mycontrol
.
datagridview
.
i18n
.
Util
;
public
class
StringUtil
{
public
static
int
string2int
(
String
str
)
{
return
string2int
(
str
,
0
);
}
public
static
int
string2int
(
String
str
,
int
def
)
{
try
{
return
Integer
.
valueOf
(
str
);
}
catch
(
Exception
e
)
{
}
return
def
;
}
public
static
Double
string2Double
(
String
str
){
try
{
return
Double
.
parseDouble
(
str
);
}
catch
(
Exception
e
)
{
}
return
0
D
;
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
string2Double
(
"66.546512"
));
}
}
mycontrol/src/main/java/com/lingber/mycontrol/datagridview/i18n/Util/ViewUtil.java
0 → 100644
View file @
429a4804
package
com
.
lingber
.
mycontrol
.
datagridview
.
i18n
.
Util
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
com.lingber.mycontrol.datagridview.i18n.ILanguageView
;
public
class
ViewUtil
{
public
static
void
updateViewLanguage
(
View
view
)
{
if
(
view
instanceof
ViewGroup
)
{
ViewGroup
vg
=
(
ViewGroup
)
view
;
int
count
=
vg
.
getChildCount
();
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
updateViewLanguage
(
vg
.
getChildAt
(
i
));
}
}
else
if
(
view
instanceof
ILanguageView
)
{
ILanguageView
tv
=
(
ILanguageView
)
view
;
tv
.
reLoadLanguage
();
}
}
}
mycontrol/src/main/java/com/lingber/mycontrol/keyboard/Keyboard.java
0 → 100644
View file @
429a4804
package
com
.
lingber
.
mycontrol
.
keyboard
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
androidx.annotation.Nullable
;
import
com.lingber.mycontrol.R
;
import
java.lang.reflect.Method
;
/**
* @Author :ShuboLin
* @CreatTime: 2020-06-04 10:34.
* @Description: 键盘
*/
public
class
Keyboard
extends
LinearLayout
implements
View
.
OnClickListener
{
private
Context
mContext
;
private
View
mView
;
private
EditText
mEditText
=
null
;
private
EditText
[]
arrEditText
=
new
EditText
[]{};
private
TextView
mTvKey1
;
private
TextView
mTvKey2
;
private
TextView
mTvKey3
;
private
TextView
mTvKey4
;
private
TextView
mTvKey5
;
private
TextView
mTvKey6
;
private
TextView
mTvKey7
;
private
TextView
mTvKey8
;
private
TextView
mTvKey9
;
private
TextView
mTvKey0
;
private
ImageView
mTvKeyBackspacing
;
private
TextView
mTvKeyHash
;
public
Keyboard
(
Context
context
)
{
super
(
context
);
}
public
Keyboard
(
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
init
(
context
,
attrs
);
}
public
Keyboard
(
Context
context
,
@Nullable
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
init
(
context
,
attrs
);
}
private
void
init
(
Context
context
,
AttributeSet
attrs
){
this
.
mContext
=
context
;
this
.
mView
=
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
lingber_keyboard_template
,
this
);
// 获取控件属性
//TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.NumberController);
// 设置配置属性
//setmRang(a.getInt(R.styleable.NumberController_range, 1));
// 绑定控件
doBinding
();
}
/** 绑定控件**/
private
void
doBinding
(){
mTvKey1
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_key_1
);
mTvKey2
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_key_2
);
mTvKey3
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_key_3
);
mTvKey4
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_key_4
);
mTvKey5
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_key_5
);
mTvKey6
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_key_6
);
mTvKey7
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_key_7
);
mTvKey8
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_key_8
);
mTvKey9
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_key_9
);
mTvKey0
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_key_0
);
mTvKeyBackspacing
=
(
ImageView
)
mView
.
findViewById
(
R
.
id
.
iv_backspace
);
mTvKeyHash
=
(
TextView
)
mView
.
findViewById
(
R
.
id
.
tv_key_hash
);
mTvKey1
.
setOnClickListener
(
this
);
mTvKey2
.
setOnClickListener
(
this
);
mTvKey3
.
setOnClickListener
(
this
);
mTvKey4
.
setOnClickListener
(
this
);
mTvKey5
.
setOnClickListener
(
this
);
mTvKey6
.
setOnClickListener
(
this
);
mTvKey7
.
setOnClickListener
(
this
);
mTvKey8
.
setOnClickListener
(
this
);
mTvKey9
.
setOnClickListener
(
this
);
mTvKey0
.
setOnClickListener
(
this
);
mTvKeyHash
.
setOnClickListener
(
this
);
mTvKeyBackspacing
.
setOnClickListener
(
this
);
mTvKeyBackspacing
.
setTag
(
"backspacing"
);
// 回退长按事件
mTvKeyBackspacing
.
setOnLongClickListener
(
new
OnLongClickListener
()
{
@Override
public
boolean
onLongClick
(
View
v
)
{
if
(
mEditText
!=
null
){
mEditText
.
setText
(
""
);
mEditText
.
setSelection
(
mEditText
.
getText
().
length
());
}
return
false
;
}
});
}
/** 设置当前mEditText**/
public
void
setEditText
(
EditText
editText
){
this
.
mEditText
=
editText
;
}
/** 设置绑定小键盘的EditText**/
public
void
setArrEditText
(
EditText
[]
arrEditText
){
if
(
arrEditText
==
null
){
return
;
}
this
.
arrEditText
=
arrEditText
;
// 绑定EditText键盘
bindKeyBoard
();
}
@Override
public
void
onClick
(
View
v
)
{
if
(
mEditText
!=
null
){
if
(
"backspacing"
.
equals
(
v
.
getTag
())){
String
text
=
mEditText
.
getText
().
toString
();
if
(
text
.
length
()==
0
){
return
;
}
mEditText
.
setText
(
text
.
substring
(
0
,
text
.
length
()-
1
));
mEditText
.
setSelection
(
mEditText
.
getText
().
length
());
return
;
}
String
text
=
mEditText
.
getText
().
toString
();
TextView
textView
=
(
TextView
)
v
;
mEditText
.
setText
(
text
+
textView
.
getText
().
toString
());
mEditText
.
setSelection
(
mEditText
.
getText
().
length
());
}
}
/** 绑定小键盘**/
private
void
bindKeyBoard
(){
// 监听焦点状态改变
for
(
int
i
=
0
;
i
<
arrEditText
.
length
;
i
++){
arrEditText
[
i
].
setOnFocusChangeListener
(
new
View
.
OnFocusChangeListener
()
{
@Override
public
void
onFocusChange
(
View
v
,
boolean
hasFocus
)
{
if
(
hasFocus
){
mEditText
=
(
EditText
)
v
;
}
}
});
}
// 禁止系统自带键盘弹出
Class
<
EditText
>
cls
=
EditText
.
class
;
Method
method
;
try
{
method
=
cls
.
getMethod
(
"setShowSoftInputOnFocus"
,
boolean
.
class
);
method
.
setAccessible
(
true
);
for
(
int
i
=
0
;
i
<
arrEditText
.
length
;
i
++){
method
.
invoke
(
arrEditText
[
i
],
false
);
}
}
catch
(
Exception
e
)
{
}
}
}
mycontrol/src/main/res/drawable/ic_back.xml
0 → 100644
View file @
429a4804
<vector
android:height=
"50dp"
android:viewportHeight=
"1024.0"
android:viewportWidth=
"1024.0"
android:width=
"50dp"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<path
android:fillColor=
"#2c2c2c"
android:pathData=
"M622.7,284.9 L447.7,284.9 447.7,142.8 64,334.7l383.8,191.9L447.7,384.8l189.4,0c149.9,0 224.9,62.8 224.9,188.4 0,129.9 -77.4,194.9 -232.3,194.9L188,768.1l0,99.9L634.1,868c211.2,0 316.8,-95.1 316.8,-285.3C950.9,384.2 841.5,284.9 622.7,284.9z"
/>
</vector>
mycontrol/src/main/res/drawable/ic_sure.xml
0 → 100644
View file @
429a4804
<vector
android:height=
"50dp"
android:viewportHeight=
"1024.0"
android:viewportWidth=
"1024.0"
android:width=
"50dp"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<path
android:fillAlpha=
".01"
android:fillColor=
"#2c2c2c"
android:pathData=
"M0,0h1024v1024H0z"
/>
<path
android:fillColor=
"#2c2c2c"
android:pathData=
"M418.7,648.8l441.1,-431a36.6,36.6 0,0 1,51.6 0.5l41.3,41.9a36.6,36.6 0,0 1,-0.6 51.9l-486.6,473.6a66.5,66.5 0,0 1,-46.7 18.9,66.5 66.5,0 0,1 -46.6,-18.9L71.2,490.1a36.6,36.6 0,0 1,1.4 -53.4l42.4,-37.6a36.6,36.6 0,0 1,49.8 1.2L418.7,648.8z"
/>
</vector>
mycontrol/src/main/res/drawable/lingber_border_shape.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<stroke
android:width=
"2dp"
android:color=
"@color/colorGray"
/>
<padding
android:bottom=
"2dp"
android:left=
"2dp"
android:right=
"2dp"
android:top=
"2dp"
/>
<corners
android:topLeftRadius=
"14px"
android:topRightRadius=
"14px"
android:bottomRightRadius=
"14px"
android:bottomLeftRadius=
"14px"
/>
</shape>
</item>
</selector>
\ No newline at end of file
mycontrol/src/main/res/drawable/lingber_checkbox_style.xml
0 → 100644
View file @
429a4804
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:drawable=
"@drawable/lingber_ic_checkbox_selected"
android:state_checked=
"true"
/>
<item
android:drawable=
"@drawable/lingber_ic_checkbox_unselected"
android:state_checked=
"false"
/>
<item
android:drawable=
"@drawable/lingber_ic_checkbox_unselected"
/>
</selector>
\ No newline at end of file
mycontrol/src/main/res/drawable/lingber_date_picker_unavailable_msk_shape.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<solid
android:color=
"@color/colorGray"
/>
<corners
android:topLeftRadius=
"6dp"
android:topRightRadius=
"6dp"
android:bottomLeftRadius=
"6dp"
android:bottomRightRadius=
"6dp"
/>
</shape>
\ No newline at end of file
mycontrol/src/main/res/drawable/lingber_edittext_shape.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<solid
android:color=
"#ffffffff"
/>
<stroke
android:width=
"1dp"
android:color=
"#ff515151"
/>
<corners
android:topLeftRadius=
"6dp"
android:topRightRadius=
"6dp"
android:bottomLeftRadius=
"6dp"
android:bottomRightRadius=
"6dp"
/>
</shape>
\ No newline at end of file
mycontrol/src/main/res/drawable/lingber_ic_add.xml
0 → 100644
View file @
429a4804
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"80dp"
android:height=
"60dp"
android:viewportWidth=
"80.0"
android:viewportHeight=
"60.0"
>
<path
android:pathData=
"M68,60L12,60A12,12 0,0 1,0 48L0,12A12,12 0,0 1,12 0L68,0A12,12 0,0 1,80 12L80,48A12,12 0,0 1,68 60z"
android:fillColor=
"#afd5fa"
/>
<path
android:pathData=
"M38,44v-12h-12a2,2 0,1 1,0 -4h12v-12a2,2 0,0 1,4 0v12h12a2,2 0,1 1,0 4h-12v12a2,2 0,1 1,-4 0Z"
android:fillColor=
"#333"
/>
</vector>
mycontrol/src/main/res/drawable/lingber_ic_backspacing.xml
0 → 100644
View file @
429a4804
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"62dp"
android:height=
"46dp"
android:viewportWidth=
"62.0"
android:viewportHeight=
"46.0"
>
<path
android:pathData=
"M56.56,0h-33.13a5.41,5.41 0,0 0,-3.85 1.62l-18.52,18.78a3.72,3.72 0,0 0,0 5.2l18.52,18.78a5.41,5.41 0,0 0,3.85 1.62h33.13a5.48,5.48 0,0 0,5.44 -5.52v-34.96A5.48,5.48 0,0 0,56.56 0ZM52.06,31.63a2.79,2.79 0,0 1,0 3.9,2.69 2.69,0 0,1 -3.85,0l-8.51,-8.63 -8.51,8.63a2.69,2.69 0,0 1,-3.85 0,2.79 2.79,0 0,1 0,-3.9l8.51,-8.63 -8.51,-8.63a2.79,2.79 0,0 1,0 -3.9,2.69 2.69,0 0,1 3.85,0l8.51,8.63 8.51,-8.63a2.69,2.69 0,0 1,3.85 0,2.79 2.79,0 0,1 0,3.9l-8.51,8.63Z"
android:fillColor=
"#398bdc"
/>
</vector>
mycontrol/src/main/res/drawable/lingber_ic_checkbox_selected.xml
0 → 100644
View file @
429a4804
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"44dp"
android:height=
"44dp"
android:viewportWidth=
"44.0"
android:viewportHeight=
"44.0"
>
<path
android:pathData=
"M10,0L34,0A10,10 0,0 1,44 10L44,34A10,10 0,0 1,34 44L10,44A10,10 0,0 1,0 34L0,10A10,10 0,0 1,10 0z"
android:fillColor=
"#398bdc"
/>
<path
android:pathData=
"M18.07,30.8a1.8,1.8 0,0 1,-1.28 -0.53l-7.46,-7.51a1.83,1.83 0,0 1,0 -2.58,1.8 1.8,0 0,1 2.56,0l6.18,6.23 12.58,-12.67a1.8,1.8 0,0 1,2.56 0,1.83 1.83,0 0,1 0,2.58l-13.85,13.96A1.8,1.8 0,0 1,18.07 30.8Z"
android:fillColor=
"#fff"
/>
</vector>
mycontrol/src/main/res/drawable/lingber_ic_checkbox_unselected.xml
0 → 100644
View file @
429a4804
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"44dp"
android:height=
"44dp"
android:viewportWidth=
"44.0"
android:viewportHeight=
"44.0"
>
<path
android:pathData=
"M10,1L34,1A9,9 0,0 1,43 10L43,34A9,9 0,0 1,34 43L10,43A9,9 0,0 1,1 34L1,10A9,9 0,0 1,10 1z"
android:strokeColor=
"#398bdc"
android:fillColor=
"#00000000"
android:strokeWidth=
"2"
/>
</vector>
mycontrol/src/main/res/drawable/lingber_ic_down.xml
0 → 100644
View file @
429a4804
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"30dp"
android:height=
"40dp"
android:viewportWidth=
"30.0"
android:viewportHeight=
"40.0"
>
<path
android:pathData=
"M30,23.985a2.048,2.048 0,0 0,-0.544 -1.4,1.775 1.775,0 0,0 -2.628,0L15,35.209 3.172,22.582a1.775,1.775 110.83,0 0,-2.628 0,2.08 2.08,0 0,0 0,2.806L13.686,39.419a1.776,1.776 66.793,0 0,2.628 0L29.456,25.388A2.05,2.05 79.859,0 0,30 23.985Z"
android:fillColor=
"#333"
/>
<path
android:pathData=
"M30,1.985a2.048,2.048 53.039,0 0,-0.544 -1.4,1.775 1.775,126.829 0,0 -2.628,0L15,13.209 3.172,0.582a1.775,1.775 129.246,0 0,-2.628 0,2.08 2.08,0 0,0 0,2.806L13.686,17.419a1.776,1.776 63.807,0 0,2.628 0L29.456,3.388A2.05,2.05 65.508,0 0,30 1.985Z"
android:fillColor=
"#333"
/>
</vector>
mycontrol/src/main/res/drawable/lingber_ic_downward.xml
0 → 100644
View file @
429a4804
<vector
android:height=
"24dp"
android:viewportHeight=
"1024.0"
android:viewportWidth=
"1024.0"
android:width=
"24dp"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<path
android:fillColor=
"#FF000000"
android:pathData=
"M246.8,336.5h530.4a14.6,14.6 0,0 1,12.2 22.7l-265.3,397.9a14.6,14.6 0,0 1,-24.3 0L234.6,359.1a14.6,14.6 0,0 1,12.2 -22.7z"
/>
</vector>
mycontrol/src/main/res/drawable/lingber_ic_fast_add.xml
0 → 100644
View file @
429a4804
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"54dp"
android:height=
"54dp"
android:viewportWidth=
"54.001"
android:viewportHeight=
"54.001"
>
<path
android:pathData=
"M27,0a27,27 0,1 0,27 27A27.03,27.03 0,0 0,27 0ZM27,50.14a23.14,23.14 0,1 1,23.14 -23.14A23.17,23.17 0,0 1,27 50.14Z"
android:fillColor=
"#398bdc"
/>
<path
android:pathData=
"M40.49,25.05h-11.57v-11.57a1.93,1.93 0,1 0,-3.86 0v11.57h-11.57a1.93,1.93 0,0 0,0 3.86h11.57v11.57a1.93,1.93 0,0 0,3.86 0v-11.57h11.57a1.93,1.93 0,1 0,0 -3.86Z"
android:fillColor=
"#398bdc"
/>
</vector>
mycontrol/src/main/res/drawable/lingber_ic_fast_added.xml
0 → 100644
View file @
429a4804
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"54dp"
android:height=
"54dp"
android:viewportWidth=
"54.0"
android:viewportHeight=
"54.0"
>
<path
android:pathData=
"M27,27m-27,0a27,27 0,1 1,54 0a27,27 0,1 1,-54 0"
android:fillColor=
"#afd5fa"
/>
</vector>
mycontrol/src/main/res/drawable/lingber_ic_sub.xml
0 → 100644
View file @
429a4804
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"80dp"
android:height=
"60dp"
android:viewportWidth=
"80.0"
android:viewportHeight=
"60.0"
>
<path
android:pathData=
"M12,0L68,0A12,12 0,0 1,80 12L80,48A12,12 0,0 1,68 60L12,60A12,12 0,0 1,0 48L0,12A12,12 0,0 1,12 0z"
android:fillColor=
"#afd5fa"
/>
<path
android:pathData=
"M26,28L54,28A2,2 0,0 1,56 30L56,30A2,2 0,0 1,54 32L26,32A2,2 0,0 1,24 30L24,30A2,2 0,0 1,26 28z"
android:fillColor=
"#333"
/>
</vector>
mycontrol/src/main/res/drawable/lingber_ic_up.xml
0 → 100644
View file @
429a4804
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"30dp"
android:height=
"40dp"
android:viewportWidth=
"30.0"
android:viewportHeight=
"40.0"
>
<path
android:pathData=
"M30,16.015a2.048,2.048 0,0 1,-0.544 1.4,1.775 1.775,124.324 0,1 -2.628,0L15,4.791 3.172,17.418a1.775,1.775 123.921,0 1,-2.628 0,2.08 2.08,0 0,1 0,-2.806L13.686,0.581a1.776,1.776 0,0 1,2.628 0L29.456,14.612A2.05,2.05 125.752,0 1,30 16.015Z"
android:fillColor=
"#333"
/>
<path
android:pathData=
"M30,38.015a2.048,2.048 0,0 1,-0.544 1.4,1.775 1.775,0 0,1 -2.628,0L15,26.791 3.172,39.418a1.775,1.775 83.922,0 1,-2.628 0,2.08 2.08,111.741 0,1 0,-2.806L13.686,22.581a1.776,1.776 0,0 1,2.628 0L29.456,36.612A2.05,2.05 0,0 1,30 38.015Z"
android:fillColor=
"#333"
/>
</vector>
mycontrol/src/main/res/drawable/lingber_keyboard_default_style.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<ripple
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:color=
"#a4c4e4"
tools:targetApi=
"lollipop"
>
<item>
<shape
android:shape=
"rectangle"
>
<solid
android:color=
"#FFFFFF"
/>
<corners
android:radius=
"16dp"
/>
</shape>
</item>
</ripple>
</item>
</layer-list>
mycontrol/src/main/res/drawable/lingber_line_shape.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"line"
>
<stroke
android:width=
"1dp"
android:color=
"@color/colorGray"
/>
</shape>
</item>
</selector>
\ No newline at end of file
mycontrol/src/main/res/drawable/lingber_page_number_bg_shape.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<solid
android:color=
"#F0F3F5"
/>
<stroke
android:width=
"1dp"
android:color=
"#ff515151"
/>
<corners
android:topLeftRadius=
"12dp"
android:topRightRadius=
"12dp"
android:bottomLeftRadius=
"12dp"
android:bottomRightRadius=
"12dp"
/>
</shape>
\ No newline at end of file
mycontrol/src/main/res/drawable/lingber_page_number_shape.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<solid
android:color=
"#ffffff"
/>
<stroke
android:width=
"1dp"
android:color=
"#ff515151"
/>
<corners
android:topLeftRadius=
"12dp"
android:topRightRadius=
"12dp"
android:bottomLeftRadius=
"12dp"
android:bottomRightRadius=
"12dp"
/>
</shape>
\ No newline at end of file
mycontrol/src/main/res/drawable/lingber_ripple_bg_btn.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:color=
"#5D646E"
tools:targetApi=
"lollipop"
>
<item>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<!-- 填充的颜色 -->
<solid
android:color=
"#AFD0FA"
/>
<!-- 设置矩形的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners
android:radius=
"12dip"
/>
</shape>
</item>
</ripple>
\ No newline at end of file
mycontrol/src/main/res/drawable/lingber_ripple_bg_btn_unavailable.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:color=
"#5D646E"
tools:targetApi=
"lollipop"
>
<item>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<!-- 填充的颜色 -->
<solid
android:color=
"#DCDCDC"
/>
<!-- 设置矩形的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners
android:radius=
"12dip"
/>
</shape>
</item>
</ripple>
\ No newline at end of file
mycontrol/src/main/res/drawable/lingber_textview_shape.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<solid
android:color=
"@color/colorGray"
/>
<corners
android:topLeftRadius=
"6dp"
android:topRightRadius=
"6dp"
android:bottomLeftRadius=
"6dp"
android:bottomRightRadius=
"6dp"
/>
</shape>
\ No newline at end of file
mycontrol/src/main/res/layout/lingber_datagridview_template.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/lingber_border_shape"
>
<!--Header-->
<LinearLayout
android:id=
"@+id/ll_header"
android:layout_width=
"match_parent"
android:layout_height=
"42dp"
android:orientation=
"horizontal"
>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"2dp"
android:background=
"@drawable/lingber_line_shape"
>
</LinearLayout>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<!--RecyclerView-->
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_rv1"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_alignParentTop=
"true"
>
</androidx.recyclerview.widget.RecyclerView>
<ImageButton
android:id=
"@+id/btn_prev"
android:layout_width=
"60dp"
android:layout_height=
"60dp"
android:layout_alignParentTop=
"true"
android:layout_alignParentRight=
"true"
android:src=
"@drawable/lingber_ic_up"
android:background=
"@drawable/lingber_ripple_bg_btn"
android:layout_marginBottom=
"10dp"
android:layout_marginRight=
"10dp"
android:layout_marginTop=
"10dp"
/>
<RelativeLayout
android:id=
"@+id/rv_page_number"
android:layout_width=
"60dp"
android:layout_height=
"100dp"
android:layout_below=
"@+id/btn_prev"
android:layout_alignParentRight=
"true"
android:layout_marginBottom=
"10dp"
android:layout_marginRight=
"10dp"
android:background=
"@drawable/lingber_page_number_shape"
>
<TextView
android:id=
"@+id/tv_current_page"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textSize=
"20sp"
android:textColor=
"#ff515151"
android:layout_centerHorizontal=
"true"
android:layout_above=
"@+id/tv_delimiter"
/>
<TextView
android:id=
"@+id/tv_delimiter"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textSize=
"20sp"
android:textColor=
"#ff515151"
android:layout_centerInParent=
"true"
android:text=
"/"
/>
<TextView
android:id=
"@+id/tv_count_page"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textSize=
"20sp"
android:textColor=
"#ff515151"
android:layout_centerHorizontal=
"true"
android:layout_below=
"@+id/tv_delimiter"
/>
</RelativeLayout>
<ImageButton
android:id=
"@+id/btn_next"
android:layout_width=
"60dp"
android:layout_height=
"60dp"
android:layout_alignParentRight=
"true"
android:layout_below=
"@+id/rv_page_number"
android:src=
"@drawable/lingber_ic_down"
android:background=
"@drawable/lingber_ripple_bg_btn"
android:layout_marginRight=
"10dp"
/>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
mycontrol/src/main/res/layout/lingber_keyboard_template.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center"
>
<!--软键盘输入 Start-->
<android.support.constraint.ConstraintLayout
android:id=
"@+id/cl_soft_keyboard"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
android:id=
"@+id/tv_key_1"
style=
"@style/keyboardBtn"
android:text=
"1"
/>
<TextView
android:id=
"@+id/tv_key_2"
style=
"@style/keyboardBtn"
android:layout_marginStart=
"50dp"
android:layout_marginTop=
"0dp"
android:text=
"2"
app:layout_constraintStart_toEndOf=
"@id/tv_key_1"
app:layout_constraintTop_toTopOf=
"@id/tv_key_1"
/>
<TextView
android:id=
"@+id/tv_key_3"
style=
"@style/keyboardBtn"
android:layout_marginStart=
"50dp"
android:layout_marginTop=
"0dp"
android:text=
"3"
app:layout_constraintStart_toEndOf=
"@id/tv_key_2"
app:layout_constraintTop_toTopOf=
"@id/tv_key_2"
/>
<TextView
android:id=
"@+id/tv_key_4"
style=
"@style/keyboardBtn"
android:text=
"4"
app:layout_constraintStart_toStartOf=
"@id/tv_key_1"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_1"
/>
<TextView
android:id=
"@+id/tv_key_5"
style=
"@style/keyboardBtn"
android:text=
"5"
app:layout_constraintStart_toStartOf=
"@id/tv_key_2"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_2"
/>
<TextView
android:id=
"@+id/tv_key_6"
style=
"@style/keyboardBtn"
android:text=
"6"
app:layout_constraintStart_toStartOf=
"@id/tv_key_3"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_3"
/>
<TextView
android:id=
"@+id/tv_key_7"
style=
"@style/keyboardBtn"
android:text=
"7"
app:layout_constraintStart_toStartOf=
"@id/tv_key_4"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_4"
/>
<TextView
android:id=
"@+id/tv_key_8"
style=
"@style/keyboardBtn"
android:text=
"8"
app:layout_constraintStart_toStartOf=
"@id/tv_key_5"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_5"
/>
<TextView
android:id=
"@+id/tv_key_9"
style=
"@style/keyboardBtn"
android:text=
"9"
app:layout_constraintStart_toStartOf=
"@id/tv_key_6"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_6"
/>
<TextView
android:id=
"@+id/tv_key_hash"
style=
"@style/keyboardBtn"
android:text=
"#"
app:layout_constraintStart_toStartOf=
"@id/tv_key_7"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_7"
/>
<TextView
android:id=
"@+id/tv_key_0"
style=
"@style/keyboardBtn"
android:text=
"0"
app:layout_constraintStart_toStartOf=
"@id/tv_key_8"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_8"
/>
<ImageView
android:id=
"@+id/iv_backspace"
style=
"@style/keyboardBtn"
android:paddingBottom=
"20dp"
android:paddingEnd=
"20dp"
android:paddingStart=
"15dp"
android:paddingTop=
"20dp"
android:src=
"@drawable/lingber_ic_backspacing"
app:layout_constraintStart_toStartOf=
"@id/tv_key_9"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_9"
/>
</android.support.constraint.ConstraintLayout>
<!--软键盘输入 End-->
</LinearLayout>
\ No newline at end of file
mycontrol/src/main/res/layout/lingber_number_controller_template.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"horizontal"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<!--sub-->
<Button
android:id=
"@+id/btn_sub"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/lingber_ic_sub"
/>
<!--Text-->
<TextView
android:id=
"@+id/tv_show_number"
android:layout_width=
"100dp"
android:layout_height=
"wrap_content"
android:textSize=
"22sp"
android:gravity=
"center"
/>
<!--Add-->
<Button
android:id=
"@+id/btn_add"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/lingber_ic_add"
/>
</LinearLayout>
\ No newline at end of file
mycontrol/src/main/res/layout/lingber_pagenumber_selector.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"horizontal"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center"
android:background=
"@drawable/lingber_page_number_bg_shape"
>
<!--软键盘输入 Start-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl_soft_keyboard"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:layout_margin=
"20dp"
>
<TextView
android:id=
"@+id/tv_key_1"
style=
"@style/keyboardBtn"
android:text=
"1"
/>
<TextView
android:id=
"@+id/tv_key_2"
style=
"@style/keyboardBtn"
android:layout_marginStart=
"50dp"
android:layout_marginTop=
"0dp"
android:text=
"2"
app:layout_constraintStart_toEndOf=
"@id/tv_key_1"
app:layout_constraintTop_toTopOf=
"@id/tv_key_1"
/>
<TextView
android:id=
"@+id/tv_key_3"
style=
"@style/keyboardBtn"
android:layout_marginStart=
"50dp"
android:layout_marginTop=
"0dp"
android:text=
"3"
app:layout_constraintStart_toEndOf=
"@id/tv_key_2"
app:layout_constraintTop_toTopOf=
"@id/tv_key_2"
/>
<TextView
android:id=
"@+id/tv_key_4"
style=
"@style/keyboardBtn"
android:text=
"4"
app:layout_constraintStart_toStartOf=
"@id/tv_key_1"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_1"
/>
<TextView
android:id=
"@+id/tv_key_5"
style=
"@style/keyboardBtn"
android:text=
"5"
app:layout_constraintStart_toStartOf=
"@id/tv_key_2"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_2"
/>
<TextView
android:id=
"@+id/tv_key_6"
style=
"@style/keyboardBtn"
android:text=
"6"
app:layout_constraintStart_toStartOf=
"@id/tv_key_3"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_3"
/>
<TextView
android:id=
"@+id/tv_key_7"
style=
"@style/keyboardBtn"
android:text=
"7"
app:layout_constraintStart_toStartOf=
"@id/tv_key_4"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_4"
/>
<TextView
android:id=
"@+id/tv_key_8"
style=
"@style/keyboardBtn"
android:text=
"8"
app:layout_constraintStart_toStartOf=
"@id/tv_key_5"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_5"
/>
<TextView
android:id=
"@+id/tv_key_9"
style=
"@style/keyboardBtn"
android:text=
"9"
app:layout_constraintStart_toStartOf=
"@id/tv_key_6"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_6"
/>
<TextView
android:id=
"@+id/tv_key_hash"
style=
"@style/keyboardBtn"
android:text=
""
app:layout_constraintStart_toStartOf=
"@id/tv_key_7"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_7"
/>
<TextView
android:id=
"@+id/tv_key_0"
style=
"@style/keyboardBtn"
android:text=
"0"
app:layout_constraintStart_toStartOf=
"@id/tv_key_8"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_8"
/>
<ImageView
android:id=
"@+id/iv_backspace"
style=
"@style/keyboardBtn"
android:paddingBottom=
"20dp"
android:paddingEnd=
"20dp"
android:paddingStart=
"15dp"
android:paddingTop=
"20dp"
android:src=
"@drawable/lingber_ic_backspacing"
app:layout_constraintStart_toStartOf=
"@id/tv_key_9"
app:layout_constraintTop_toBottomOf=
"@id/tv_key_9"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!--软键盘输入 End-->
<!--页码输入区 Start-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl_page_number_input"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:layout_margin=
"20dp"
android:focusable=
"true"
android:focusableInTouchMode=
"true"
>
<EditText
android:id=
"@+id/et_barcode_input"
style=
"@style/InputBoxStyle"
android:layout_weight=
"1"
android:inputType=
"text"
android:maxLength=
"100"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
/>
<TextView
android:id=
"@+id/tv_delimiter"
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_marginTop=
"20dp"
android:textSize=
"48sp"
app:layout_constraintTop_toBottomOf=
"@+id/et_barcode_input"
android:text=
"/"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
/>
<TextView
android:id=
"@+id/tv_last_page_number"
android:layout_width=
"180dp"
android:layout_height=
"90dp"
android:background=
"@drawable/lingber_textview_shape"
app:layout_constraintTop_toBottomOf=
"@+id/tv_delimiter"
android:layout_marginTop=
"20dp"
android:gravity=
"center"
android:textSize=
"32sp"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
/>
<ImageButton
android:id=
"@+id/btn_ok"
style=
"@style/BtnStyle"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
android:src=
"@drawable/ic_sure"
/>
<ImageButton
android:id=
"@+id/btn_return"
style=
"@style/BtnStyle"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintRight_toLeftOf=
"@+id/btn_ok"
android:layout_marginRight=
"20dp"
android:src=
"@drawable/ic_back"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!--页码输入区 End-->
</LinearLayout>
\ No newline at end of file
mycontrol/src/main/res/layout/lingber_recyclerview.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"84.3dp"
>
<LinearLayout
android:id=
"@+id/ll_recyclerview"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"horizontal"
>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
mycontrol/src/main/res/values/colors.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name=
"colorBlue"
>
#D7E9F5
</color>
<color
name=
"colorHeader"
>
#398BDC
</color>
<color
name=
"colorWhite"
>
#FFFFFF
</color>
<color
name=
"colorCyan"
>
#BCEAE3
</color>
<color
name=
"colorGray"
>
#DBDBDB
</color>
</resources>
\ No newline at end of file
mycontrol/src/main/res/values/ids.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item
name=
"header_item0"
type=
"id"
/>
<item
name=
"header_item1"
type=
"id"
/>
<item
name=
"header_item2"
type=
"id"
/>
<item
name=
"header_item3"
type=
"id"
/>
<item
name=
"header_item4"
type=
"id"
/>
<item
name=
"header_item5"
type=
"id"
/>
<item
name=
"header_item6"
type=
"id"
/>
<item
name=
"header_item7"
type=
"id"
/>
<item
name=
"header_item8"
type=
"id"
/>
<item
name=
"header_item9"
type=
"id"
/>
<item
name=
"header_item10"
type=
"id"
/>
<item
name=
"header_item11"
type=
"id"
/>
<item
name=
"header_item12"
type=
"id"
/>
<item
name=
"header_item13"
type=
"id"
/>
<item
name=
"header_item14"
type=
"id"
/>
<item
name=
"header_item15"
type=
"id"
/>
<item
name=
"header_sort_icon_item0"
type=
"id"
/>
<item
name=
"header_sort_icon_item1"
type=
"id"
/>
<item
name=
"header_sort_icon_item2"
type=
"id"
/>
<item
name=
"header_sort_icon_item3"
type=
"id"
/>
<item
name=
"header_sort_icon_item4"
type=
"id"
/>
<item
name=
"header_sort_icon_item5"
type=
"id"
/>
<item
name=
"header_sort_icon_item6"
type=
"id"
/>
<item
name=
"header_sort_icon_item7"
type=
"id"
/>
<item
name=
"header_sort_icon_item8"
type=
"id"
/>
<item
name=
"header_sort_icon_item9"
type=
"id"
/>
<item
name=
"header_sort_icon_item10"
type=
"id"
/>
<item
name=
"header_sort_icon_item11"
type=
"id"
/>
<item
name=
"header_sort_icon_item12"
type=
"id"
/>
<item
name=
"header_sort_icon_item13"
type=
"id"
/>
<item
name=
"header_sort_icon_item14"
type=
"id"
/>
<item
name=
"header_sort_icon_item15"
type=
"id"
/>
<item
name=
"item_cell0"
type=
"id"
/>
<item
name=
"item_cell1"
type=
"id"
/>
<item
name=
"item_cell2"
type=
"id"
/>
<item
name=
"item_cell3"
type=
"id"
/>
<item
name=
"item_cell4"
type=
"id"
/>
<item
name=
"item_cell5"
type=
"id"
/>
<item
name=
"item_cell6"
type=
"id"
/>
<item
name=
"item_cell7"
type=
"id"
/>
<item
name=
"item_cell8"
type=
"id"
/>
<item
name=
"item_cell9"
type=
"id"
/>
<item
name=
"item_cell10"
type=
"id"
/>
<item
name=
"item_cell11"
type=
"id"
/>
<item
name=
"item_cell12"
type=
"id"
/>
<item
name=
"item_cell13"
type=
"id"
/>
<item
name=
"item_cell14"
type=
"id"
/>
<item
name=
"item_cell15"
type=
"id"
/>
<item
name=
"item_cell_content0"
type=
"id"
/>
<item
name=
"item_cell_content1"
type=
"id"
/>
<item
name=
"item_cell_content2"
type=
"id"
/>
<item
name=
"item_cell_content3"
type=
"id"
/>
<item
name=
"item_cell_content4"
type=
"id"
/>
<item
name=
"item_cell_content5"
type=
"id"
/>
<item
name=
"item_cell_content6"
type=
"id"
/>
<item
name=
"item_cell_content7"
type=
"id"
/>
<item
name=
"item_cell_content8"
type=
"id"
/>
<item
name=
"item_cell_content9"
type=
"id"
/>
<item
name=
"item_cell_content10"
type=
"id"
/>
<item
name=
"item_cell_content11"
type=
"id"
/>
<item
name=
"item_cell_content12"
type=
"id"
/>
<item
name=
"item_cell_content13"
type=
"id"
/>
<item
name=
"item_cell_content14"
type=
"id"
/>
<item
name=
"item_cell_content15"
type=
"id"
/>
</resources>
\ No newline at end of file
mycontrol/src/main/res/values/strings.xml
0 → 100644
View file @
429a4804
<resources>
<string
name=
"app_name"
>
MyControl
</string>
</resources>
mycontrol/src/main/res/values/styles.xml
0 → 100644
View file @
429a4804
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable
name=
"DataGridView"
>
<attr
name=
"column"
format=
"integer"
/>
<attr
name=
"row_height"
format=
"integer"
/>
<attr
name=
"show_header"
format=
"boolean"
/>
<attr
name=
"orientation"
format=
"integer"
/>
<attr
name=
"dividerSize"
format=
"integer"
/>
</declare-styleable>
<declare-styleable
name=
"NumberController"
>
<attr
name=
"stride"
format=
"integer"
/>
<attr
name=
"allow_minus"
format=
"boolean"
/>
<attr
name=
"init_value"
format=
"integer"
/>
<attr
name=
"max"
format=
"integer"
/>
<attr
name=
"min"
format=
"integer"
/>
</declare-styleable>
<declare-styleable
name=
"Keyboard"
>
</declare-styleable>
<style
name=
"MyCheckBoxTheme"
parent=
"Widget.AppCompat.CompoundButton.CheckBox"
>
<item
name=
"android:button"
>
@drawable/lingber_checkbox_style
</item>
</style>
<style
name=
"keyboardBtn"
>
<item
name=
"android:layout_width"
>
94dp
</item>
<item
name=
"android:layout_height"
>
94dp
</item>
<item
name=
"android:layout_marginTop"
>
20dp
</item>
<item
name=
"android:background"
>
@drawable/lingber_keyboard_default_style
</item>
<item
name=
"android:clickable"
>
true
</item>
<item
name=
"android:gravity"
>
center
</item>
<item
name=
"android:textSize"
>
40sp
</item>
</style>
<!--按钮样式-->
<style
name=
"BtnStyle"
>
<item
name=
"android:layout_width"
>
180dp
</item>
<item
name=
"android:layout_height"
>
60dp
</item>
<item
name=
"android:textSize"
>
22sp
</item>
<item
name=
"android:textColor"
>
#ff333333
</item>
<item
name=
"android:background"
>
@drawable/lingber_ripple_bg_btn
</item>
<item
name=
"android:maxLines"
>
1
</item>
<item
name=
"android:ellipsize"
>
end
</item>
</style>
<!--输入框样式-->
<style
name=
"InputBoxStyle"
>
<item
name=
"android:layout_width"
>
180dp
</item>
<item
name=
"android:layout_height"
>
90dp
</item>
<item
name=
"android:textSize"
>
32sp
</item>
<item
name=
"android:textCursorDrawable"
>
@null
</item>
<item
name=
"android:background"
>
@drawable/lingber_edittext_shape
</item>
<item
name=
"android:textColorHint"
>
#FFC2C2C2
</item>
<item
name=
"android:gravity"
>
center
</item>
</style>
</resources>
\ No newline at end of file
mycontrol/src/test/java/com/lingber/mycontrol/ExampleUnitTest.java
0 → 100644
View file @
429a4804
package
com
.
lingber
.
mycontrol
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public
class
ExampleUnitTest
{
@Test
public
void
addition_isCorrect
()
throws
Exception
{
assertEquals
(
4
,
2
+
2
);
}
}
\ No newline at end of file
settings.gradle
View file @
429a4804
include
':app'
,
':mvvmhabit'
,
':appupdateX'
include
':app'
,
':mvvmhabit'
,
':appupdateX'
,
':mycontrol'
rootProject
.
name
=
"AnchorCollect"
\ 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