mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-22 21:41:15 +01:00
Updates to category refresh ui
Pager: swipe refresh remains visible until updates are done Single List: using a refresh icon instead of UPDATE text button
This commit is contained in:
parent
97e92d0a3d
commit
975de673f0
@ -125,7 +125,6 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
}, category.name))
|
||||
if (!inQueue)
|
||||
LibraryUpdateService.start(context, category)
|
||||
swipe_refresh.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,6 +176,10 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subscriptions += controller.stopRefreshRelay.subscribe {
|
||||
swipe_refresh?.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun canDrag(): Boolean {
|
||||
@ -215,6 +218,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
adapter.setItems(mangaForCategory)
|
||||
|
||||
swipe_refresh.isEnabled = !preferences.hideCategories().getOrDefault()
|
||||
swipe_refresh.isRefreshing = LibraryUpdateService.categoryInQueue(category.id)
|
||||
|
||||
if (adapter.mode == SelectableAdapter.Mode.MULTI) {
|
||||
controller.selectedMangas.forEach { manga ->
|
||||
|
@ -122,6 +122,8 @@ open class LibraryController(
|
||||
*/
|
||||
val reorganizeRelay: PublishRelay<Pair<Int, Int>> = PublishRelay.create()
|
||||
|
||||
val stopRefreshRelay: PublishRelay<Boolean> = PublishRelay.create()
|
||||
|
||||
/**
|
||||
* Number of manga per row in grid mode.
|
||||
*/
|
||||
@ -292,6 +294,7 @@ open class LibraryController(
|
||||
|
||||
override fun onUpdateManga(manga: LibraryManga) {
|
||||
if (manga.id != null) presenter.updateManga(manga)
|
||||
else stopRefreshRelay.call(true)
|
||||
}
|
||||
|
||||
override fun onDetach(view: View) {
|
||||
|
@ -4,14 +4,12 @@ import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.view.menu.MenuBuilder
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.SelectableAdapter
|
||||
import eu.davidea.flexibleadapter.items.AbstractHeaderItem
|
||||
@ -22,7 +20,6 @@ import eu.kanade.tachiyomi.data.database.models.Category
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
@ -79,8 +76,7 @@ class LibraryHeaderItem(private val categoryF: (Int) -> Category, val catId: Int
|
||||
|
||||
private val sectionText: TextView = view.findViewById(R.id.category_title)
|
||||
private val sortText: TextView = view.findViewById(R.id.category_sort)
|
||||
private val updateButton: MaterialButton = view.findViewById(R.id.update_button)
|
||||
private val catProgress: ProgressBar = view.findViewById(R.id.cat_progress)
|
||||
private val updateButton: ImageView = view.findViewById(R.id.update_button)
|
||||
private val checkboxImage: ImageView = view.findViewById(R.id.checkbox)
|
||||
|
||||
init {
|
||||
@ -91,6 +87,7 @@ class LibraryHeaderItem(private val categoryF: (Int) -> Category, val catId: Int
|
||||
sortText.compoundDrawablesRelative[2]?.mutate()?.setTint(
|
||||
ContextCompat.getColor(contentView.context, R.color.gray_button))
|
||||
}
|
||||
updateButton.drawable.mutate()
|
||||
}
|
||||
|
||||
fun bind(category: Category) {
|
||||
@ -115,23 +112,23 @@ class LibraryHeaderItem(private val categoryF: (Int) -> Category, val catId: Int
|
||||
when {
|
||||
adapter.mode == SelectableAdapter.Mode.MULTI -> {
|
||||
checkboxImage.visible()
|
||||
catProgress.gone()
|
||||
updateButton.gone()
|
||||
setSelection()
|
||||
}
|
||||
category.id == -1 -> {
|
||||
checkboxImage.gone()
|
||||
catProgress.gone()
|
||||
updateButton.gone()
|
||||
}
|
||||
LibraryUpdateService.categoryInQueue(category.id) -> {
|
||||
checkboxImage.gone()
|
||||
catProgress.visible()
|
||||
updateButton.gone()
|
||||
updateButton.drawable.setTint(ContextCompat.getColor(itemView.context,
|
||||
R.color.material_on_surface_disabled))
|
||||
updateButton.visible()
|
||||
}
|
||||
else -> {
|
||||
checkboxImage.gone()
|
||||
catProgress.gone()
|
||||
updateButton.drawable.setTint(itemView.context.getResourceColor(
|
||||
R.attr.colorAccent))
|
||||
updateButton.visible()
|
||||
}
|
||||
}
|
||||
@ -139,10 +136,8 @@ class LibraryHeaderItem(private val categoryF: (Int) -> Category, val catId: Int
|
||||
|
||||
private fun addCategoryToUpdate() {
|
||||
if (adapter.libraryListener.updateCategory(adapterPosition)) {
|
||||
updateButton.gone()
|
||||
launchUI {
|
||||
adapter.notifyItemChanged(adapterPosition)
|
||||
}
|
||||
updateButton.drawable.setTint(ContextCompat.getColor(itemView.context,
|
||||
R.color.material_on_surface_disabled))
|
||||
}
|
||||
}
|
||||
private fun showCatSortOptions() {
|
||||
|
@ -56,33 +56,22 @@
|
||||
app:layout_constraintStart_toEndOf="@id/update_button"
|
||||
app:layout_constraintWidth_min="1dp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
<ImageView
|
||||
android:id="@+id/update_button"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:padding="5dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:text="@string/ext_update"
|
||||
android:textColor="?android:attr/colorAccent"
|
||||
app:layout_constraintBaseline_toBaselineOf="@id/category_title"
|
||||
android:layout_marginBottom="6dp"
|
||||
tools:tint="?attr/colorAccent"
|
||||
android:src="@drawable/ic_refresh_white_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/space"
|
||||
app:layout_constraintStart_toEndOf="@+id/category_title"
|
||||
app:layout_constraintWidth_default="wrap"
|
||||
app:rippleColor="@color/fullRippleColor" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/cat_progress"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:indeterminate="true"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/category_title"
|
||||
app:layout_constraintEnd_toStartOf="@+id/category_sort"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@+id/category_title"
|
||||
app:layout_constraintTop_toTopOf="@+id/category_title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/category_sort"
|
||||
android:layout_width="wrap_content"
|
||||
|
Loading…
x
Reference in New Issue
Block a user