Fix broken menu after clicking source, move latest to the top
This commit is contained in:
parent
c049ce9018
commit
a2cda24e01
@ -43,12 +43,12 @@ class IndexAdapter(val controller: IndexController) :
|
|||||||
|
|
||||||
// stores and recycles views as they are scrolled off screen
|
// stores and recycles views as they are scrolled off screen
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
private val browseAdapter = IndexCardAdapter(controller)
|
|
||||||
private var browseLastBoundResults: List<IndexCardItem>? = null
|
|
||||||
|
|
||||||
private val latestAdapter = IndexCardAdapter(controller)
|
private val latestAdapter = IndexCardAdapter(controller)
|
||||||
private var latestLastBoundResults: List<IndexCardItem>? = null
|
private var latestLastBoundResults: List<IndexCardItem>? = null
|
||||||
|
|
||||||
|
private val browseAdapter = IndexCardAdapter(controller)
|
||||||
|
private var browseLastBoundResults: List<IndexCardItem>? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
binding.browseBarWrapper.clicks()
|
binding.browseBarWrapper.clicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
@ -61,32 +61,11 @@ class IndexAdapter(val controller: IndexController) :
|
|||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
binding.browseRecycler.layoutManager = LinearLayoutManager(itemView.context, LinearLayoutManager.HORIZONTAL, false)
|
|
||||||
binding.browseRecycler.adapter = browseAdapter
|
|
||||||
|
|
||||||
binding.latestRecycler.layoutManager = LinearLayoutManager(itemView.context, LinearLayoutManager.HORIZONTAL, false)
|
binding.latestRecycler.layoutManager = LinearLayoutManager(itemView.context, LinearLayoutManager.HORIZONTAL, false)
|
||||||
binding.latestRecycler.adapter = latestAdapter
|
binding.latestRecycler.adapter = latestAdapter
|
||||||
}
|
|
||||||
|
|
||||||
fun bindBrowse(browseResults: List<IndexCardItem>?) {
|
binding.browseRecycler.layoutManager = LinearLayoutManager(itemView.context, LinearLayoutManager.HORIZONTAL, false)
|
||||||
when {
|
binding.browseRecycler.adapter = browseAdapter
|
||||||
browseResults == null -> {
|
|
||||||
binding.browseProgress.isVisible = true
|
|
||||||
showBrowseResultsHolder()
|
|
||||||
}
|
|
||||||
browseResults.isEmpty() -> {
|
|
||||||
binding.browseProgress.isVisible = false
|
|
||||||
showBrowseNoResults()
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
binding.browseProgress.isVisible = false
|
|
||||||
showBrowseResultsHolder()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (browseResults !== browseLastBoundResults) {
|
|
||||||
browseAdapter.updateDataSet(browseResults)
|
|
||||||
browseLastBoundResults = browseResults
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bindLatest(latestResults: List<IndexCardItem>?) {
|
fun bindLatest(latestResults: List<IndexCardItem>?) {
|
||||||
@ -110,24 +89,41 @@ class IndexAdapter(val controller: IndexController) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showBrowseResultsHolder() {
|
fun bindBrowse(browseResults: List<IndexCardItem>?) {
|
||||||
binding.browseNoResultsFound.isVisible = false
|
when {
|
||||||
binding.browseCard.isVisible = true
|
browseResults == null -> {
|
||||||
}
|
binding.browseProgress.isVisible = true
|
||||||
|
showBrowseResultsHolder()
|
||||||
private fun showBrowseNoResults() {
|
}
|
||||||
binding.browseNoResultsFound.isVisible = true
|
browseResults.isEmpty() -> {
|
||||||
binding.browseCard.isVisible = false
|
binding.browseProgress.isVisible = false
|
||||||
|
showBrowseNoResults()
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
binding.browseProgress.isVisible = false
|
||||||
|
showBrowseResultsHolder()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (browseResults !== browseLastBoundResults) {
|
||||||
|
browseAdapter.updateDataSet(browseResults)
|
||||||
|
browseLastBoundResults = browseResults
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showLatestResultsHolder() {
|
private fun showLatestResultsHolder() {
|
||||||
binding.latestNoResultsFound.isVisible = false
|
binding.latestNoResultsFound.isVisible = false
|
||||||
binding.latestCard.isVisible = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showLatestNoResults() {
|
private fun showLatestNoResults() {
|
||||||
binding.latestNoResultsFound.isVisible = true
|
binding.latestNoResultsFound.isVisible = true
|
||||||
binding.latestCard.isVisible = false
|
}
|
||||||
|
|
||||||
|
private fun showBrowseResultsHolder() {
|
||||||
|
binding.browseNoResultsFound.isVisible = false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showBrowseNoResults() {
|
||||||
|
binding.browseNoResultsFound.isVisible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setLatestImage(manga: Manga) {
|
fun setLatestImage(manga: Manga) {
|
||||||
|
@ -6,6 +6,70 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/latest_bar_wrapper"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/latest"
|
||||||
|
style="@style/TextAppearance.Regular.SubHeading"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="@dimen/material_component_text_fields_padding_above_and_below_label"
|
||||||
|
android:text="@string/latest"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/latest_bar_more_icon"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/latest_bar_more_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:contentDescription="@string/label_more"
|
||||||
|
android:padding="@dimen/material_component_text_fields_padding_above_and_below_label"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/ic_arrow_forward_24dp"
|
||||||
|
app:tint="?android:attr/textColorPrimary" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/latest_no_results_found"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="@dimen/material_component_text_fields_padding_above_and_below_label"
|
||||||
|
android:paddingEnd="@dimen/material_component_text_fields_padding_above_and_below_label"
|
||||||
|
android:paddingBottom="@dimen/material_component_text_fields_padding_above_and_below_label"
|
||||||
|
android:text="@string/no_results_found"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/latest_progress"
|
||||||
|
style="?android:attr/progressBarStyleSmall"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/latest_recycler"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="12dp"
|
||||||
|
android:paddingEnd="12dp"
|
||||||
|
tools:listitem="@layout/global_search_controller_card_item" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -53,100 +117,21 @@
|
|||||||
android:text="@string/no_results_found"
|
android:text="@string/no_results_found"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:id="@+id/browse_card"
|
|
||||||
style="@style/Theme.Widget.CardView.Item"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:minHeight="144dp">
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/browse_progress"
|
|
||||||
style="?android:attr/progressBarStyleSmall"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/browse_recycler"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:paddingStart="4dp"
|
|
||||||
android:paddingEnd="4dp"
|
|
||||||
tools:listitem="@layout/global_search_controller_card_item" />
|
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/latest_bar_wrapper"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?attr/selectableItemBackground">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/latest"
|
|
||||||
style="@style/TextAppearance.Regular.SubHeading"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="@dimen/material_component_text_fields_padding_above_and_below_label"
|
|
||||||
android:text="@string/latest"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/latest_bar_more_icon"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/latest_bar_more_icon"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:contentDescription="@string/label_more"
|
|
||||||
android:padding="@dimen/material_component_text_fields_padding_above_and_below_label"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:srcCompat="@drawable/ic_arrow_forward_24dp"
|
|
||||||
app:tint="?android:attr/textColorPrimary" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/latest_no_results_found"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingStart="@dimen/material_component_text_fields_padding_above_and_below_label"
|
|
||||||
android:paddingEnd="@dimen/material_component_text_fields_padding_above_and_below_label"
|
|
||||||
android:paddingBottom="@dimen/material_component_text_fields_padding_above_and_below_label"
|
|
||||||
android:text="@string/no_results_found"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:id="@+id/latest_card"
|
|
||||||
style="@style/Theme.Widget.CardView.Item"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:minHeight="144dp">
|
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/latest_progress"
|
android:id="@+id/browse_progress"
|
||||||
style="?android:attr/progressBarStyleSmall"
|
style="?android:attr/progressBarStyleSmall"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center" />
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/latest_recycler"
|
android:id="@+id/browse_recycler"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:clipToPadding="false"
|
android:paddingStart="12dp"
|
||||||
android:orientation="horizontal"
|
android:paddingEnd="12dp"
|
||||||
android:paddingStart="4dp"
|
|
||||||
android:paddingEnd="4dp"
|
|
||||||
tools:listitem="@layout/global_search_controller_card_item" />
|
tools:listitem="@layout/global_search_controller_card_item" />
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user