Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitff98eb9

Browse files
committed
config的set/get方法改为字段设置
1 parente2420a8 commitff98eb9

File tree

8 files changed

+23
-92
lines changed

8 files changed

+23
-92
lines changed

‎emptyview/src/main/java/com/runnchild/emptyview/EmptyView.kt‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ class EmptyView @JvmOverloads constructor(
4040
context:Context,attrs:AttributeSet? =null,defStyleAttr:Int =0
4141
) : FrameLayout(context, attrs, defStyleAttr), IEmptyView {
4242

43-
privatevar binding:EmptyViewBinding=
44-
EmptyViewBinding.inflate(LayoutInflater.from(context),this,true)
43+
privatevar binding=EmptyViewBinding.inflate(LayoutInflater.from(context),this,true)
4544

46-
overridefunsetConfig(config:EmptyViewConfig) {
47-
binding.viewModel= config
48-
}
49-
50-
overridefungetViewModel():EmptyViewConfig?= binding.viewModel
45+
overridevarconfig:EmptyViewConfig?
46+
get()=binding.config
47+
set(value) {
48+
binding.config= value
49+
}
5150
}
Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
packagecom.runnchild.emptyview
22

3-
importandroid.graphics.Color
4-
importandroid.graphics.drawable.Drawable
53
importandroid.widget.ImageView
64
importandroid.widget.TextView
7-
importandroidx.core.graphics.drawable.toDrawable
85
importandroidx.databinding.ObservableBoolean
96
importandroidx.databinding.ObservableField
107

@@ -39,67 +36,4 @@ class EmptyViewConfig {
3936
refreshBuilder.notifyChange()
4037
}
4138
}
42-
}
43-
44-
classEmptyBuilder(valstate:EmptyState =EmptyState.EMPTY_DATA) {
45-
var tip:String?=null
46-
set(value) {
47-
tip {
48-
text= value
49-
}
50-
field= value
51-
}
52-
var subTip:String?=null
53-
set(value) {
54-
subTip {
55-
text= value
56-
}
57-
field= value
58-
}
59-
60-
var btnVisible:Boolean=true
61-
62-
var btnText:String?="刷新"
63-
set(value) {
64-
refreshBtn {
65-
text= value
66-
}
67-
field= value
68-
}
69-
var btnClick: ()->Unit= {}
70-
var iconDrawable:Drawable?=Color.GRAY.toDrawable()
71-
set(value) {
72-
icon {
73-
setImageDrawable(value)
74-
}
75-
field= value
76-
}
77-
78-
var refreshBuilder: (TextView.()->Unit)?=null
79-
var tipBuilder: (TextView.()->Unit)?=null
80-
var subTipBuilder: (TextView.()->Unit)?=null
81-
var iconBuilder: (ImageView.()->Unit)?=null
82-
83-
funrefreshBtn(build:TextView.()->Unit) {
84-
refreshBuilder= build
85-
}
86-
87-
funtip(build:TextView.()->Unit) {
88-
tipBuilder= build
89-
}
90-
91-
funsubTip(build:TextView.()->Unit) {
92-
subTipBuilder= build
93-
}
94-
95-
funicon(build:ImageView.()->Unit) {
96-
iconBuilder= build
97-
}
98-
}
99-
100-
enumclassEmptyState {
101-
EMPTY_NET_DISCONNECT,
102-
EMPTY_NET_UNAVAILABLE,
103-
EMPTY_SERVICE,
104-
EMPTY_DATA,
10539
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
packagecom.runnchild.emptyview
22

33
interfaceIEmptyView {
4-
5-
funsetConfig(config:EmptyViewConfig)
6-
7-
fungetViewModel():EmptyViewConfig?
4+
var config:EmptyViewConfig?
85
}

‎emptyview/src/main/res/layout/empty_view.xml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<data>
77

88
<variable
9-
name="viewModel"
9+
name="config"
1010
type="com.runnchild.emptyview.EmptyViewConfig" />
1111
</data>
1212

@@ -19,7 +19,7 @@
1919
<ImageView
2020
android:layout_width="wrap_content"
2121
android:layout_height="wrap_content"
22-
app:imageBuilder="@{viewModel.iconBuilder}"
22+
app:imageBuilder="@{config.iconBuilder}"
2323
tools:layout_height="140dp"
2424
tools:layout_width="140dp"
2525
tools:src="@color/cardview_shadow_start_color" />
@@ -29,7 +29,7 @@
2929
android:layout_height="wrap_content"
3030
android:layout_marginTop="10dp"
3131
android:textSize="17sp"
32-
app:textBuilder="@{viewModel.tipBuilder}"
32+
app:textBuilder="@{config.tipBuilder}"
3333
tools:text="网络未连接" />
3434

3535
<TextView
@@ -38,7 +38,7 @@
3838
android:layout_marginTop="5dp"
3939
android:textColor="#b2b2b2"
4040
android:textSize="13sp"
41-
app:textBuilder="@{viewModel.subTipBuilder}"
41+
app:textBuilder="@{config.subTipBuilder}"
4242
tools:text="请检查你的网络设置后刷新" />
4343

4444
<TextView
@@ -52,9 +52,9 @@
5252
android:minHeight="35dp"
5353
android:textColor="@android:color/white"
5454
android:textSize="16sp"
55-
app:defaultClick="@{viewModel.refreshClick}"
56-
app:textBuilder="@{viewModel.refreshBuilder}"
57-
app:visible="@{viewModel.btnVisible}"
55+
app:defaultClick="@{config.refreshClick}"
56+
app:textBuilder="@{config.refreshBuilder}"
57+
app:visible="@{config.btnVisible}"
5858
tools:text="刷新" />
5959
</LinearLayout>
6060
</layout>

‎list/src/main/java/com/rongc/list/ability/AbsListAbility.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ abstract class AbsListAbility(val viewModel: BaseViewModel, val listHost: IListH
7878
val providerAdapter= adapter
7979
if (providerAdapterisBaseQuickAdapter<*,*>) {
8080
val emptyView= providerEmptyView()?:return
81-
emptyView.setConfig(emptyConfig)
81+
emptyView.config=emptyConfig
8282
providerAdapter.setEmptyView(emptyViewasView)
8383
// providerAdapter.headerWithEmptyEnable = true
8484
// providerAdapter.footerWithEmptyEnable = true

‎list/src/main/java/com/rongc/list/binding/ViewPager2Binding.kt‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ fun ViewPager2.setupEmptyView(
203203
):EmptyViewConfig? {
204204
if (enable) {
205205
fungetEmptyView():IEmptyView {
206-
val emptyViewModel= emptyView?.getViewModel()?:EmptyViewConfig()
206+
val emptyViewModel= emptyView?.config?:EmptyViewConfig()
207207
return (emptyView?:EmptyView(context)).run {
208-
setConfig(emptyViewModel)
208+
config=emptyViewModel
209209
this
210210
}
211211
}
@@ -220,12 +220,12 @@ fun ViewPager2.setupEmptyView(
220220
}
221221
it.setEmptyView(iEmptyasView)
222222
iEmpty.removeFromParent()
223-
iEmpty.getViewModel()
223+
iEmpty.config
224224
}
225225
isBaseFragmentPagerAdapter<*>-> {
226226
val emptyView1= getEmptyView()
227-
it.setEmptyData(emptyView1.getViewModel()!!)
228-
emptyView1.getViewModel()
227+
it.setEmptyData(emptyView1.config!!)
228+
emptyView1.config
229229
}
230230
else->null
231231
}

‎list/src/main/java/com/rongc/list/viewmodel/BaseListViewModel.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.rongc.feature.vo.isSuccess
1313
importcom.rongc.list.PageIndicator
1414
importcom.rongc.list.ability.emptyState
1515
importcom.rongc.list.binding.LoadStatus
16+
importcom.runnchild.emptyview.EmptyState
1617
importcom.scwang.smart.refresh.layout.listener.OnLoadMoreListener
1718
importcom.scwang.smart.refresh.layout.listener.OnRefreshListener
1819

@@ -65,7 +66,7 @@ abstract class BaseListViewModel<T> : BaseViewModel() {
6566
field= value
6667
}
6768

68-
val setupEmptyView=MutableLiveData<com.runnchild.emptyview.EmptyState>()
69+
val setupEmptyView=MutableLiveData<EmptyState>()
6970

7071
privateval_request=MutableLiveData<Int>()
7172

‎list/src/main/java/com/rongc/list/viewpager2/EmptyListFragment.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ open class EmptyListFragment : Fragment(), IPagerItem<EmptyViewConfig> {
2828
}
2929

3030
overridefunconvert(position:Int,item:EmptyViewConfig,payloads:MutableList<Any>?) {
31-
(viewasIEmptyView).setConfig(item)
31+
(viewasIEmptyView).config=item
3232
}
3333
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp