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 currentSession = matrix.currentSession!!
private val currentSession = matrix.currentSession
private var roomId by FragmentArgumentDelegate<String>()
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

View File

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

View File

@ -38,7 +38,8 @@ class LoginActivity : RiotActivity() {

authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback<Session> {
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()

View File

@ -19,7 +19,7 @@ class Matrix(matrixOptions: MatrixOptions) : KoinComponent {
private val authenticator by inject<Authenticator>()
private val backgroundDetectionObserver by inject<BackgroundDetectionObserver>()

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 {

View File

@ -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()