|
@@ -5,15 +5,18 @@ import android.support.v4.app.DialogFragment
|
|
|
import android.support.v7.view.ActionMode
|
|
|
import android.support.v7.widget.DividerItemDecoration
|
|
|
import android.support.v7.widget.LinearLayoutManager
|
|
|
+import android.support.v7.widget.RecyclerView
|
|
|
import android.view.*
|
|
|
import com.afollestad.materialdialogs.MaterialDialog
|
|
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
import eu.kanade.tachiyomi.data.download.model.Download
|
|
|
+import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
|
|
import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder
|
|
|
import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment
|
|
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
|
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
|
|
+import eu.kanade.tachiyomi.util.toast
|
|
|
import eu.kanade.tachiyomi.widget.DeletingChaptersDialog
|
|
|
import kotlinx.android.synthetic.main.fragment_recent_chapters.*
|
|
|
import nucleus.factory.RequiresPresenter
|
|
@@ -73,6 +76,25 @@ class RecentChaptersFragment
|
|
|
adapter = RecentChaptersAdapter(this)
|
|
|
recycler.adapter = adapter
|
|
|
|
|
|
+ recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
+ override fun onScrollStateChanged(recycler: RecyclerView, newState: Int) {
|
|
|
+ // Disable swipe refresh when view is not at the top
|
|
|
+ val firstPos = (recycler.layoutManager as LinearLayoutManager)
|
|
|
+ .findFirstCompletelyVisibleItemPosition()
|
|
|
+ swipe_refresh.isEnabled = firstPos == 0
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ swipe_refresh.setDistanceToTriggerSync((2 * 64 * resources.displayMetrics.density).toInt())
|
|
|
+ swipe_refresh.setOnRefreshListener {
|
|
|
+ if (!LibraryUpdateService.isRunning(activity)) {
|
|
|
+ LibraryUpdateService.start(activity)
|
|
|
+ context.toast(R.string.action_update_library)
|
|
|
+ }
|
|
|
+ // It can be a very long operation, so we disable swipe refresh and show a toast.
|
|
|
+ swipe_refresh.isRefreshing = false
|
|
|
+ }
|
|
|
+
|
|
|
// Update toolbar text
|
|
|
setToolbarTitle(R.string.label_recent_updates)
|
|
|
}
|