From 18c6472f32f2642e1318a915b006ec6a03d0ee0b Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 1 Nov 2018 10:09:27 +0100 Subject: [PATCH] Fix some stupid issues --- .idea/caches/build_file_checksums.ser | Bin 659 -> 661 bytes .../home/room/detail/RoomDetailFragment.kt | 4 +--- .../home/room/list/RoomListViewModel.kt | 2 +- .../features/login/LoginActivity.kt | 12 ++++-------- .../java/im/vector/matrix/android/api/Matrix.kt | 7 ++++++- .../room/timeline/DefaultTimelineHolder.kt | 1 + 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 3e19f42d04803496c8c732f7c0c89f9bdf2e9380..a7732719d686b5e6869d42c5a32e34d70c070ea6 100644 GIT binary patch delta 67 zcmV-J0KET`1(gMmm;}yMvBHs@h?8gmzapJ8-4f!BFNqE8lw$EA2~KnXDKAxXWpZ;b ZW^!R}V{d75lQID|0TGis0UMK50zST)8AkvB delta 65 zcmV-H0KWf~1(OAkm;}m*+|`kshz=(&RdZ!>b1!FMZf0^}lLZ1clOzGZ6Mxpspp() - private val currentSession = matrix.currentSession!! + private val currentSession = matrix.currentSession private var roomId by FragmentArgumentDelegate() private lateinit var timelineEventController: TimelineEventController private lateinit var room: Room @@ -77,8 +77,6 @@ class RoomDetailFragment : RiotFragment() { .placeholder(riotActivity.avatarDrawable(it.displayName)) .apply(RequestOptions.circleCropTransform()) .into(toolbarAvatarImageView) - - toolbarAvatarImageView.setImageDrawable(riotActivity.avatarDrawable(it.displayName)) if (it.topic.isNotEmpty()) { toolbarSubtitleView.visibility = View.VISIBLE toolbarSubtitleView.text = it.topic diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListViewModel.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListViewModel.kt index a8d9944f..706b8d75 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListViewModel.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListViewModel.kt @@ -17,7 +17,7 @@ class RoomListViewModel(initialState: RoomListViewState, @JvmStatic override fun create(activity: FragmentActivity, state: RoomListViewState): RoomListViewModel { val matrix = activity.get() - val currentSession = matrix.currentSession!! + val currentSession = matrix.currentSession return RoomListViewModel(state, currentSession) } } diff --git a/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt b/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt index ab9a5977..6b2a1290 100644 --- a/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt +++ b/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt @@ -38,7 +38,8 @@ class LoginActivity : RiotActivity() { authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback { override fun onSuccess(data: Session) { - openSessionAndGoToHome(data) + matrix.currentSession = data + goToHome() } override fun onFailure(failure: Failure) { @@ -50,16 +51,11 @@ class LoginActivity : RiotActivity() { private fun checkActiveSessions() { if (authenticator.hasActiveSessions()) { - val session = authenticator.getLastActiveSession() - session?.let { - openSessionAndGoToHome(it) - } + goToHome() } } - private fun openSessionAndGoToHome(session: Session) { - matrix.currentSession = session - session.open() + private fun goToHome() { val intent = HomeActivity.newIntent(this) startActivity(intent) finish() diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt index ac4c74a2..ee5d4969 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt @@ -19,7 +19,7 @@ class Matrix(matrixOptions: MatrixOptions) : KoinComponent { private val authenticator by inject() private val backgroundDetectionObserver by inject() - var currentSession: Session? = null + lateinit var currentSession: Session init { Monarchy.init(matrixOptions.context) @@ -28,6 +28,11 @@ class Matrix(matrixOptions: MatrixOptions) : KoinComponent { val authModule = AuthModule() loadKoinModules(listOf(matrixModule, networkModule, authModule)) ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver) + val lastActiveSession = authenticator.getLastActiveSession() + if (lastActiveSession != null) { + currentSession = lastActiveSession + currentSession.open() + } } fun authenticator(): Authenticator { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineHolder.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineHolder.kt index 1b587cb8..b76ec47f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineHolder.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineHolder.kt @@ -54,6 +54,7 @@ class DefaultTimelineHolder(private val roomId: String, val pagedListConfig = PagedList.Config.Builder() .setEnablePlaceholders(false) .setPageSize(PAGE_SIZE) + .setInitialLoadSizeHint(PAGE_SIZE) .setPrefetchDistance(10) .build()