diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt | 19 |
1 files changed, 7 insertions, 12 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 47c286fa..67f07635 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,8 +81,8 @@ class LoginActivity : BaseActivity() { (foundImage, name) -> refresh = false if (!foundImage) { - L.eThrow("Could not get profile photo; Invalid userId?") - L.i("-\t$cookie") + L.e("Could not get profile photo; Invalid userId?") + L.i(null, cookie.toString()) } textview.text = String.format(getString(R.string.welcome), name) textview.fadeIn() @@ -102,14 +105,14 @@ 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 } override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean { - if (e != null) L.e(e, "Profile loading exception") + e.logFrostAnswers( "Profile loading exception") profileObservable.onSuccess(false) 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 |