Fix some stupid issues

This commit is contained in:
ganfra 2018-11-01 10:09:27 +01:00
parent ea51420c74
commit 18c6472f32
6 changed files with 13 additions and 13 deletions

View file

@ -34,7 +34,7 @@ class RoomDetailFragment : RiotFragment() {
} }
private val matrix by inject<Matrix>() private val matrix by inject<Matrix>()
private val currentSession = matrix.currentSession!! private val currentSession = matrix.currentSession
private var roomId by FragmentArgumentDelegate<String>() private var roomId by FragmentArgumentDelegate<String>()
private lateinit var timelineEventController: TimelineEventController private lateinit var timelineEventController: TimelineEventController
private lateinit var room: Room private lateinit var room: Room
@ -77,8 +77,6 @@ class RoomDetailFragment : RiotFragment() {
.placeholder(riotActivity.avatarDrawable(it.displayName)) .placeholder(riotActivity.avatarDrawable(it.displayName))
.apply(RequestOptions.circleCropTransform()) .apply(RequestOptions.circleCropTransform())
.into(toolbarAvatarImageView) .into(toolbarAvatarImageView)
toolbarAvatarImageView.setImageDrawable(riotActivity.avatarDrawable(it.displayName))
if (it.topic.isNotEmpty()) { if (it.topic.isNotEmpty()) {
toolbarSubtitleView.visibility = View.VISIBLE toolbarSubtitleView.visibility = View.VISIBLE
toolbarSubtitleView.text = it.topic toolbarSubtitleView.text = it.topic

View file

@ -17,7 +17,7 @@ class RoomListViewModel(initialState: RoomListViewState,
@JvmStatic @JvmStatic
override fun create(activity: FragmentActivity, state: RoomListViewState): RoomListViewModel { override fun create(activity: FragmentActivity, state: RoomListViewState): RoomListViewModel {
val matrix = activity.get<Matrix>() val matrix = activity.get<Matrix>()
val currentSession = matrix.currentSession!! val currentSession = matrix.currentSession
return RoomListViewModel(state, currentSession) return RoomListViewModel(state, currentSession)
} }
} }

View file

@ -38,7 +38,8 @@ class LoginActivity : RiotActivity() {
authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback<Session> { authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback<Session> {
override fun onSuccess(data: Session) { override fun onSuccess(data: Session) {
openSessionAndGoToHome(data) matrix.currentSession = data
goToHome()
} }
override fun onFailure(failure: Failure) { override fun onFailure(failure: Failure) {
@ -50,16 +51,11 @@ class LoginActivity : RiotActivity() {
private fun checkActiveSessions() { private fun checkActiveSessions() {
if (authenticator.hasActiveSessions()) { if (authenticator.hasActiveSessions()) {
val session = authenticator.getLastActiveSession() goToHome()
session?.let {
openSessionAndGoToHome(it)
}
} }
} }
private fun openSessionAndGoToHome(session: Session) { private fun goToHome() {
matrix.currentSession = session
session.open()
val intent = HomeActivity.newIntent(this) val intent = HomeActivity.newIntent(this)
startActivity(intent) startActivity(intent)
finish() finish()

View file

@ -19,7 +19,7 @@ class Matrix(matrixOptions: MatrixOptions) : KoinComponent {
private val authenticator by inject<Authenticator>() private val authenticator by inject<Authenticator>()
private val backgroundDetectionObserver by inject<BackgroundDetectionObserver>() private val backgroundDetectionObserver by inject<BackgroundDetectionObserver>()
var currentSession: Session? = null lateinit var currentSession: Session
init { init {
Monarchy.init(matrixOptions.context) Monarchy.init(matrixOptions.context)
@ -28,6 +28,11 @@ class Matrix(matrixOptions: MatrixOptions) : KoinComponent {
val authModule = AuthModule() val authModule = AuthModule()
loadKoinModules(listOf(matrixModule, networkModule, authModule)) loadKoinModules(listOf(matrixModule, networkModule, authModule))
ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver) ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver)
val lastActiveSession = authenticator.getLastActiveSession()
if (lastActiveSession != null) {
currentSession = lastActiveSession
currentSession.open()
}
} }
fun authenticator(): Authenticator { fun authenticator(): Authenticator {

View file

@ -54,6 +54,7 @@ class DefaultTimelineHolder(private val roomId: String,
val pagedListConfig = PagedList.Config.Builder() val pagedListConfig = PagedList.Config.Builder()
.setEnablePlaceholders(false) .setEnablePlaceholders(false)
.setPageSize(PAGE_SIZE) .setPageSize(PAGE_SIZE)
.setInitialLoadSizeHint(PAGE_SIZE)
.setPrefetchDistance(10) .setPrefetchDistance(10)
.build() .build()