From 8c7a64eeb982f62ab7269f5c89314adba61b6eae Mon Sep 17 00:00:00 2001 From: drake Date: Sat, 14 Jan 2023 18:59:11 +0800 Subject: [PATCH] =?UTF-8?q?sample:=20=E7=A4=BA=E4=BE=8B-=E5=B5=8C=E5=A5=97?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../drake/brv/sample/model/NestedListModel.kt | 7 ++ .../sample/ui/fragment/NestedListFragment.kt | 32 +++++++ sample/src/main/res/drawable/ic_group.xml | 26 +----- .../src/main/res/drawable/ic_nested_list.xml | 9 ++ .../main/res/layout/fragment_nested_list.xml | 11 +++ .../res/layout/item_nested_horizontal_rv.xml | 40 ++++++++ .../res/layout/item_simple_horizontal.xml | 33 +++++++ sample/src/main/res/menu/menu_main.xml | 4 + sample/src/main/res/navigation/nav_main.xml | 5 + sample/src/main/res/raw/list_nested.json | 93 +++++++++++++++++++ 10 files changed, 239 insertions(+), 21 deletions(-) create mode 100644 sample/src/main/java/com/drake/brv/sample/model/NestedListModel.kt create mode 100644 sample/src/main/java/com/drake/brv/sample/ui/fragment/NestedListFragment.kt create mode 100644 sample/src/main/res/drawable/ic_nested_list.xml create mode 100644 sample/src/main/res/layout/fragment_nested_list.xml create mode 100644 sample/src/main/res/layout/item_nested_horizontal_rv.xml create mode 100644 sample/src/main/res/layout/item_simple_horizontal.xml create mode 100644 sample/src/main/res/raw/list_nested.json diff --git a/sample/src/main/java/com/drake/brv/sample/model/NestedListModel.kt b/sample/src/main/java/com/drake/brv/sample/model/NestedListModel.kt new file mode 100644 index 000000000..e6ea7b5a4 --- /dev/null +++ b/sample/src/main/java/com/drake/brv/sample/model/NestedListModel.kt @@ -0,0 +1,7 @@ +package com.drake.brv.sample.model + +@kotlinx.serialization.Serializable +data class NestedListModel( + var title: String = "", + var list: List = listOf() +) \ No newline at end of file diff --git a/sample/src/main/java/com/drake/brv/sample/ui/fragment/NestedListFragment.kt b/sample/src/main/java/com/drake/brv/sample/ui/fragment/NestedListFragment.kt new file mode 100644 index 000000000..7976615c5 --- /dev/null +++ b/sample/src/main/java/com/drake/brv/sample/ui/fragment/NestedListFragment.kt @@ -0,0 +1,32 @@ +package com.drake.brv.sample.ui.fragment + +import com.drake.brv.sample.R +import com.drake.brv.sample.component.net.SerializationConverter +import com.drake.brv.sample.databinding.FragmentNestedListBinding +import com.drake.brv.sample.databinding.ItemNestedHorizontalRvBinding +import com.drake.brv.sample.model.NestedListModel +import com.drake.brv.utils.models +import com.drake.brv.utils.setup +import com.drake.engine.base.EngineFragment +import kotlinx.serialization.json.decodeFromStream + +class NestedListFragment : EngineFragment(R.layout.fragment_nested_list) { + override fun initView() { + binding.rv.setup { + addType(R.layout.item_nested_horizontal_rv) + onCreate { + getBinding().rv.setup { + addType(R.layout.item_simple_horizontal) + } + } + onBind { + val model = getModel() + getBinding().rv.models = model.list + } + } + } + + override fun initData() { + binding.rv.models = SerializationConverter.jsonDecoder.decodeFromStream>(resources.openRawResource(R.raw.list_nested)) + } +} \ No newline at end of file diff --git a/sample/src/main/res/drawable/ic_group.xml b/sample/src/main/res/drawable/ic_group.xml index 980b01aac..5c681aa23 100644 --- a/sample/src/main/res/drawable/ic_group.xml +++ b/sample/src/main/res/drawable/ic_group.xml @@ -1,25 +1,9 @@ - - - + android:viewportWidth="24" + android:viewportHeight="24"> + diff --git a/sample/src/main/res/drawable/ic_nested_list.xml b/sample/src/main/res/drawable/ic_nested_list.xml new file mode 100644 index 000000000..42510c10a --- /dev/null +++ b/sample/src/main/res/drawable/ic_nested_list.xml @@ -0,0 +1,9 @@ + + + diff --git a/sample/src/main/res/layout/fragment_nested_list.xml b/sample/src/main/res/layout/fragment_nested_list.xml new file mode 100644 index 000000000..19716d63b --- /dev/null +++ b/sample/src/main/res/layout/fragment_nested_list.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/sample/src/main/res/layout/item_nested_horizontal_rv.xml b/sample/src/main/res/layout/item_nested_horizontal_rv.xml new file mode 100644 index 000000000..654efd28f --- /dev/null +++ b/sample/src/main/res/layout/item_nested_horizontal_rv.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sample/src/main/res/layout/item_simple_horizontal.xml b/sample/src/main/res/layout/item_simple_horizontal.xml new file mode 100644 index 000000000..7322d9b68 --- /dev/null +++ b/sample/src/main/res/layout/item_simple_horizontal.xml @@ -0,0 +1,33 @@ + + + + + + + + + + diff --git a/sample/src/main/res/menu/menu_main.xml b/sample/src/main/res/menu/menu_main.xml index a264b645c..2e917e6be 100644 --- a/sample/src/main/res/menu/menu_main.xml +++ b/sample/src/main/res/menu/menu_main.xml @@ -43,6 +43,10 @@ android:id="@+id/nav_group.xml" android:icon="@drawable/ic_group" android:title="分组" /> + +