aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-01-18 23:23:56 -0500
committerAllan Wang <me@allanwang.ca>2018-01-20 16:42:37 -0500
commitd766100c297bc094491de150f24c04719ffa8f4e (patch)
treeb69863dace2fcb45d5fd25c276ca450e07305c44 /app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
parent78b3cc41e4c9f8d141ad46ee75e476fa2d177f19 (diff)
downloadfrost-d766100c297bc094491de150f24c04719ffa8f4e.tar.gz
frost-d766100c297bc094491de150f24c04719ffa8f4e.tar.bz2
frost-d766100c297bc094491de150f24c04719ffa8f4e.zip
Enhancement/speed up (#650)
* Revert back to m.facebook * Add initial speedup * Update theme * Fix link press for event status * Move web states to fb const * Fix images and email * Fix up flyweight for requests * Ensure frost request is synchronous * Prepare diff utils * Improve speed and fix blank overlay * Update comments * Add debugger and fix searchview * Theme discover pages. Resolves #654 * Fix duplicate reload * Fix image loading * Update changelog * Update tests * Rename test Update dependencies Update gitignore
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt57
1 files changed, 39 insertions, 18 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
index 809b6090..43653382 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
@@ -14,8 +14,9 @@ import com.pitchedapps.frost.contracts.FrostContentCore
import com.pitchedapps.frost.contracts.FrostContentParent
import com.pitchedapps.frost.contracts.MainActivityContract
import com.pitchedapps.frost.facebook.FbItem
+import com.pitchedapps.frost.facebook.WEB_LOAD_DELAY
+import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
-import com.pitchedapps.frost.web.WEB_LOAD_DELAY
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.subjects.BehaviorSubject
@@ -84,10 +85,13 @@ abstract class FrostContentView<out T> @JvmOverloads constructor(
else
progress.progress = it
}
- refreshObservable.observeOn(AndroidSchedulers.mainThread()).subscribe {
- refresh.isRefreshing = it
- refresh.isEnabled = true
- }
+
+ refreshObservable
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe {
+ refresh.isRefreshing = it
+ refresh.isEnabled = true
+ }
refresh.setOnRefreshListener { coreView.reload(true) }
reloadThemeSelf()
@@ -127,25 +131,42 @@ abstract class FrostContentView<out T> @JvmOverloads constructor(
core.destroy()
}
+ private var dispose: Disposable? = null
+ private var transitionStart: Long = -1
+
/**
* Hook onto the refresh observable for one cycle
* Animate toggles between the fancy ripple and the basic fade
* The cycle only starts on the first load since there may have been another process when this is registered
*/
- override fun registerTransition(animate: Boolean) {
+ override fun registerTransition(urlChanged: Boolean, animate: Boolean): Boolean {
+ if (!urlChanged && dispose != null) {
+ L.v { "Consuming url load" }
+ return false // still in progress; do not bother with load
+ }
+ L.v { "Registered transition" }
with(coreView) {
- var dispose: Disposable? = null
- var loading = false
- dispose = refreshObservable.subscribeOn(AndroidSchedulers.mainThread()).subscribe {
- if (it) {
- loading = true
- if (isVisible) fadeOut(duration = 200L)
- } else if (loading) {
- dispose?.dispose()
- if (animate && Prefs.animate) circularReveal(offset = WEB_LOAD_DELAY)
- else fadeIn(duration = 100L)
- }
- }
+ var loading = dispose != null
+ dispose?.dispose()
+ dispose = refreshObservable
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe {
+ if (it) {
+ loading = true
+ transitionStart = System.currentTimeMillis()
+ clearAnimation()
+ if (isVisible)
+ fadeOut(duration = 200L)
+ } else if (loading) {
+ loading = false
+ if (animate && Prefs.animate) circularReveal(offset = WEB_LOAD_DELAY)
+ else fadeIn(duration = 200L, offset = WEB_LOAD_DELAY)
+ L.v { "Transition loaded in ${System.currentTimeMillis() - transitionStart} ms" }
+ dispose?.dispose()
+ dispose = null
+ }
+ }
}
+ return true
}
} \ No newline at end of file