Update feed by pull-to-refresh

This commit is contained in:
Koitharu
2023-04-15 17:02:46 +03:00
parent 85710acb3a
commit 32b1ee9e7b
2 changed files with 7 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ import android.view.ViewGroup
import androidx.core.graphics.Insets
import androidx.core.view.updatePadding
import androidx.fragment.app.viewModels
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import coil.ImageLoader
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
@@ -33,7 +34,7 @@ import javax.inject.Inject
class FeedFragment :
BaseFragment<FragmentFeedBinding>(),
PaginationScrollListener.Callback,
MangaListListener {
MangaListListener, SwipeRefreshLayout.OnRefreshListener {
@Inject
lateinit var coil: ImageLoader
@@ -64,7 +65,7 @@ class FeedFragment :
with(binding.swipeRefreshLayout) {
setProgressBackgroundColorSchemeColor(context.getThemeColor(com.google.android.material.R.attr.colorPrimary))
setColorSchemeColors(context.getThemeColor(com.google.android.material.R.attr.colorOnPrimary))
isEnabled = false
setOnRefreshListener(this@FeedFragment)
}
addMenuProvider(
FeedMenuProvider(
@@ -94,6 +95,10 @@ class FeedFragment :
)
}
override fun onRefresh() {
TrackWorker.startNow(context ?: return)
}
override fun onRetryClick(error: Throwable) = Unit
override fun onUpdateFilter(tags: Set<MangaTag>) = Unit

View File

@@ -6,7 +6,6 @@ import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.core.view.MenuProvider
import com.google.android.material.snackbar.Snackbar
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.base.ui.dialog.CheckBoxAlertDialog
import org.koitharu.kotatsu.settings.SettingsActivity
@@ -28,13 +27,6 @@ class FeedMenuProvider(
override fun onMenuItemSelected(menuItem: MenuItem): Boolean = when (menuItem.itemId) {
R.id.action_update -> {
TrackWorker.startNow(context)
val snackbar = Snackbar.make(
snackbarHost,
R.string.feed_will_update_soon,
Snackbar.LENGTH_LONG,
)
snackbar.anchorView = anchorView
snackbar.show()
true
}