aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-08-09 18:51:37 -0700
committerGitHub <noreply@github.com>2017-08-09 18:51:37 -0700
commit80ca6242b72fdcc606c41817e7025dab46006139 (patch)
treeb38f3922122a72be5950e2789666f6dbdd38e906 /app
parent1e2a2d77169b5de968e29873e13a78a0d8c94a18 (diff)
downloadfrost-80ca6242b72fdcc606c41817e7025dab46006139.tar.gz
frost-80ca6242b72fdcc606c41817e7025dab46006139.tar.bz2
frost-80ca6242b72fdcc606c41817e7025dab46006139.zip
Move glide loader to onCreate (#135)
Diffstat (limited to 'app')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt15
1 files changed, 5 insertions, 10 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
index eb991599..fa26502a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
@@ -12,6 +12,7 @@ import ca.allanwang.kau.utils.bindView
import ca.allanwang.kau.utils.fadeIn
import ca.allanwang.kau.utils.fadeOut
import com.bumptech.glide.Glide
+import com.bumptech.glide.RequestManager
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
@@ -44,6 +45,7 @@ class LoginActivity : BaseActivity() {
val profileObservable = SingleSubject.create<Boolean>()
val usernameObservable = SingleSubject.create<String>()
+ lateinit var profileLoader: RequestManager
// Helper to set and enable swipeRefresh
var refresh: Boolean
@@ -68,6 +70,7 @@ class LoginActivity : BaseActivity() {
loadInfo(cookie)
})
}
+ profileLoader = Glide.with(profile)
}
fun loadInfo(cookie: CookieModel) {
@@ -78,7 +81,7 @@ class LoginActivity : BaseActivity() {
(foundImage, name) ->
refresh = false
if (!foundImage) {
- L.eThrow("Could not get profile photo; Invalid userId?")
+ L.e("Could not get profile photo; Invalid userId?")
L.i(null, cookie.toString())
}
textview.text = String.format(getString(R.string.welcome), name)
@@ -102,7 +105,7 @@ class LoginActivity : BaseActivity() {
fun loadProfile(id: Long) {
- Glide.with(profile).load(PROFILE_PICTURE_URL(id)).withRoundIcon().listener(object : RequestListener<Drawable> {
+ profileLoader.load(PROFILE_PICTURE_URL(id)).withRoundIcon().listener(object : RequestListener<Drawable> {
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
profileObservable.onSuccess(true)
return false
@@ -119,12 +122,4 @@ class LoginActivity : BaseActivity() {
fun loadUsername(cookie: CookieModel) {
cookie.fetchUsername { usernameObservable.onSuccess(it) }
}
-
- override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
- if (requestCode == 999) {
- L.d("Result found for activity with result $resultCode")
- L.d("Intent data ${data?.extras.toString()}")
- } else
- super.onActivityResult(requestCode, resultCode, data)
- }
} \ No newline at end of file