From 7cc4405c097df32467124841e23426f99b1322ff Mon Sep 17 00:00:00 2001 From: len Date: Sun, 8 May 2016 17:27:49 +0200 Subject: [PATCH] Swipe down updates active category. Closes #292. Not sure I'll keep this --- .../ui/library/LibraryCategoryFragment.kt | 13 +++++++++++++ .../res/layout/fragment_library_category.xml | 19 +++++++++++++------ app/src/main/res/values/strings.xml | 1 + 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt index b130b9850..42e67a8fe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt @@ -9,10 +9,12 @@ import com.f2prateek.rx.preferences.Preference import eu.davidea.flexibleadapter.FlexibleAdapter import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga +import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.event.LibraryMangaEvent import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder import eu.kanade.tachiyomi.ui.base.fragment.BaseFragment import eu.kanade.tachiyomi.ui.manga.MangaActivity +import eu.kanade.tachiyomi.util.toast import kotlinx.android.synthetic.main.fragment_library_category.* import rx.Subscription @@ -99,6 +101,17 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli adapter.clearSelection() } } + + swipe_refresh.setOnRefreshListener { + if (!LibraryUpdateService.isRunning(activity)) { + libraryPresenter.categories.getOrNull(position)?.let { + LibraryUpdateService.start(activity, true, it) + context.toast(R.string.updating_category) + } + } + // It can be a very long operation, so we disable swipe refresh and show a toast. + swipe_refresh.isRefreshing = false + } } override fun onDestroyView() { diff --git a/app/src/main/res/layout/fragment_library_category.xml b/app/src/main/res/layout/fragment_library_category.xml index d3d94f1d2..46801572a 100644 --- a/app/src/main/res/layout/fragment_library_category.xml +++ b/app/src/main/res/layout/fragment_library_category.xml @@ -4,12 +4,19 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + android:layout_height="match_parent"> + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b66e32f07..ee70abb3f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -190,6 +190,7 @@ Title or author… Selected + Updating category This source requires you to log in