-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathnote.txt
202 lines (182 loc) · 7.68 KB
/
note.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// val carouselModel = CarouselModel_()
// .id(it.id)
// .padding(Carousel.Padding.dp(16, 2, 16, 2, 8))
// .models(
// it.projects.map {
// TrendingProjectView_(context)
// .id(it.id)
// .model(it)
// }
// )
//
// trendingProjectWrapperView {
// id("trending.project.wrapper.wiew")
// trendingProject(carouselModel)
// }
// trendingProjectWrapperView {
// id("trending.project.wrapper.wiew")
// trendingProject(it.projects)
// }
<!-- <?xml version="1.0" encoding="utf-8"?>-->
<!--<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
<!--xmlns:app="http://schemas.android.com/apk/res-auto"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:orientation="vertical">-->
<!--<FrameLayout-->
<!-- android:id="@+id/background"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="0dp"-->
<!-- android:layout_marginLeft="@dimen/_16sdp"-->
<!-- android:layout_marginRight="@dimen/_16sdp"-->
<!-- android:background="@drawable/layout_bg_corner"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->
<!--<TextView-->
<!-- android:id="@+id/project_name_tv"-->
<!-- style="@style/Text.Header"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginStart="@dimen/_16sdp"-->
<!-- android:layout_marginLeft="@dimen/_16sdp"-->
<!-- android:layout_marginTop="@dimen/_8sdp"-->
<!-- android:paddingBottom="@dimen/_8sdp"-->
<!-- android:text="Trending"-->
<!-- android:textSize="@dimen/_14ssp"-->
<!-- app:layout_constraintLeft_toLeftOf="@+id/background"-->
<!-- app:layout_constraintTop_toTopOf="@+id/background" />-->
<!--<com.airbnb.epoxy.Carousel-->
<!-- android:id="@+id/project_carousel"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginBottom="@dimen/_16sdp"-->
<!-- android:layout_marginLeft="@dimen/_4sdp"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintLeft_toLeftOf="@+id/project_name_tv"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/project_name_tv" />-->
<!--</androidx.constraintlayout.widget.ConstraintLayout>-->
// Load more
private val loadMoreScrollListener: EndlessRecyclerViewScrollListener by lazy {
object : EndlessRecyclerViewScrollListener(home_rv.layoutManager!!) {
override fun onLoadMore(page: Int) {
homeViewModel.loadNextProjects(page + 1)
}
}
}
home_rv.addOnScrollListener(loadMoreScrollListener)
object ShowLoadMore : HomeUiState()
object HideLoadMore : HomeUiState()
@AutoModel
lateinit var loadMoreView: LoadMoreView_
loadMoreView.addIf(shouldShowLoadMore, this)
private fun showLoadMore() {
homeItemController.showLoadMore()
}
private fun hideLoadMore() {
homeItemController.hideLoadMore()
}
fun showLoadMore() {
shouldShowLoadMore = true
}
fun hideLoadMore() {
shouldShowLoadMore = false
}
private var shouldShowLoadMore = false
fun loadNextProjects(page: Int) {
_state.value = HomeUiState.ShowLoadMore
disposables += homeInteractor.getUserProjectsFlowable(page)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
if (it.isEmpty()) {
_state.value = HomeUiState.HideLoadMore
} else {
_state.value = HomeUiState.NextProjectResult(it)
}
},
{ _state.value = HomeUiState.ShowError(it) }
)
}
is HomeUiState.NextProjectResult -> {
homeItemController.addProjects(state.list.toMutableList())
}
data class NextProjectResult(val model: UiModel<List<ProjectUiModel>>) : HomeUiState()
fun addProjects(data: MutableList<ProjectUiModel>) {
this.projects.addAll(data)
requestModelBuild()
}
//
trendingProjects.map { model ->
TrendingProjectView_(context)
.id(model.id)
.model(model)
.addIf(this.trendingProjects.isNotEmpty(), this)
}
//
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/_16sdp"
android:layout_marginRight="@dimen/_16sdp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/project_name_tv"
style="@style/Text.Header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_16sdp"
android:layout_marginLeft="@dimen/_16sdp"
android:layout_marginBottom="@dimen/_8sdp"
android:layout_marginTop="@dimen/_8sdp"
android:textSize="@dimen/_14ssp"
tools:text="Kovie" />
<TextView
android:id="@+id/project_description_tv"
style="@style/Text.Body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/project_name_tv"
android:layout_marginLeft="@dimen/_16sdp"
android:layout_marginRight="@dimen/_16sdp"
android:layout_marginBottom="@dimen/_8sdp"
android:textColor="#4f5b62"
android:textSize="@dimen/_12ssp"
tools:text="Kovie is kotlin movie android project use MovieDb API build with MVP architecture, Dagger, and RxJava" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/project_description_tv"
android:layout_marginLeft="@dimen/_16sdp"
android:layout_marginRight="@dimen/_16sdp"
android:layout_marginBottom="@dimen/_16sdp"
android:gravity="end"
android:orientation="horizontal">
<TextView
android:id="@+id/project_stars_tv"
style="@style/Text.Body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/_16sdp"
android:layout_marginRight="@dimen/_16sdp"
android:textColor="#4f5b62"
android:textSize="@dimen/_12ssp"
tools:text="Stars: 6" />
<TextView
android:id="@+id/project_language_tv"
style="@style/Text.Body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#4f5b62"
android:textSize="@dimen/_12ssp"
tools:text="Language: Kotlin" />
</LinearLayout>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>