-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5bba340
commit 8c7a64e
Showing
10 changed files
with
239 additions
and
21 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
sample/src/main/java/com/drake/brv/sample/model/NestedListModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.drake.brv.sample.model | ||
|
||
@kotlinx.serialization.Serializable | ||
data class NestedListModel( | ||
var title: String = "", | ||
var list: List<String> = listOf() | ||
) |
32 changes: 32 additions & 0 deletions
32
sample/src/main/java/com/drake/brv/sample/ui/fragment/NestedListFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<FragmentNestedListBinding>(R.layout.fragment_nested_list) { | ||
override fun initView() { | ||
binding.rv.setup { | ||
addType<NestedListModel>(R.layout.item_nested_horizontal_rv) | ||
onCreate { | ||
getBinding<ItemNestedHorizontalRvBinding>().rv.setup { | ||
addType<String>(R.layout.item_simple_horizontal) | ||
} | ||
} | ||
onBind { | ||
val model = getModel<NestedListModel>() | ||
getBinding<ItemNestedHorizontalRvBinding>().rv.models = model.list | ||
} | ||
} | ||
} | ||
|
||
override fun initData() { | ||
binding.rv.models = SerializationConverter.jsonDecoder.decodeFromStream<List<NestedListModel>>(resources.openRawResource(R.raw.list_nested)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,9 @@ | ||
<!-- | ||
~ Copyright (C) 2018 Drake, Inc. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="M2,17h2v0.5L3,17.5v1h1v0.5L2,19v1h3v-4L2,16v1zM3,8h1L4,4L2,4v1h1v3zM2,11h1.8L2,13.1v0.9h3v-1L3.2,13L5,10.9L5,10L2,10v1zM7,5v2h14L21,5L7,5zM7,19h14v-2L7,17v2zM7,13h14v-2L7,11v2z" /> | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M9,18h12v-2L9,16v2zM3,6v2h18L21,6L3,6zM9,13h12v-2L9,11v2z" | ||
android:fillColor="#000000" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M5,13h14v-2L5,11v2zM3,17h14v-2L3,15v2zM7,7v2h14L21,7L7,7z" | ||
android:fillColor="#000000" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/rv" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> | ||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<data> | ||
|
||
<variable | ||
name="m" | ||
type="com.drake.brv.sample.model.NestedListModel" /> | ||
|
||
</data> | ||
|
||
<androidx.appcompat.widget.LinearLayoutCompat | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:paddingBottom="20dp"> | ||
|
||
<TextView | ||
android:id="@+id/tvTitle" | ||
android:layout_width="match_parent" | ||
android:layout_height="50dp" | ||
android:gravity="center_vertical" | ||
android:paddingHorizontal="16dp" | ||
android:text="@{m.title}" | ||
android:textSize="18dp" | ||
android:textStyle="bold" | ||
tools:text="视频" /> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/rv" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
tools:listitem="@layout/item_simple_horizontal" /> | ||
|
||
</androidx.appcompat.widget.LinearLayoutCompat> | ||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
~ Copyright (C) 2018 Drake, Inc. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<FrameLayout | ||
android:id="@+id/item" | ||
android:layout_width="100dp" | ||
android:layout_height="100dp" | ||
android:layout_marginLeft="16dp" | ||
android:background="@drawable/bg_card" | ||
android:foreground="?selectableItemBackgroundBorderless"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" /> | ||
|
||
</FrameLayout> | ||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
[ | ||
{ | ||
"title": "推荐", | ||
"list": [ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5", | ||
"6", | ||
"7", | ||
"8" | ||
] | ||
}, | ||
{ | ||
"title": "课堂", | ||
"list": [ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5", | ||
"6", | ||
"7", | ||
"8" | ||
] | ||
}, | ||
{ | ||
"title": "视频", | ||
"list": [ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5", | ||
"6", | ||
"7", | ||
"8" | ||
] | ||
}, | ||
{ | ||
"title": "分享", | ||
"list": [ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5", | ||
"6", | ||
"7", | ||
"8" | ||
] | ||
}, | ||
{ | ||
"title": "文档", | ||
"list": [ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5", | ||
"6", | ||
"7", | ||
"8" | ||
] | ||
}, | ||
{ | ||
"title": "分享", | ||
"list": [ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5", | ||
"6", | ||
"7", | ||
"8" | ||
] | ||
}, | ||
{ | ||
"title": "其他", | ||
"list": [ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5", | ||
"6", | ||
"7", | ||
"8" | ||
] | ||
} | ||
] |