Unverified Commit 5964f871 authored by Rafael Kellermann Streit's avatar Rafael Kellermann Streit Committed by GitHub

Merge pull request #1509 from RocketChat/fix/fix-crashes-2.5.0-beta

[FIX] fix crashes 2.5.0 beta
parents c3d08b98 63e2da00
...@@ -3,7 +3,6 @@ package chat.rocket.android.chatrooms.domain ...@@ -3,7 +3,6 @@ package chat.rocket.android.chatrooms.domain
import chat.rocket.android.db.DatabaseManager import chat.rocket.android.db.DatabaseManager
import chat.rocket.android.db.model.ChatRoomEntity import chat.rocket.android.db.model.ChatRoomEntity
import chat.rocket.android.db.model.UserEntity import chat.rocket.android.db.model.UserEntity
import chat.rocket.android.infrastructure.LocalRepository
import chat.rocket.android.util.retryIO import chat.rocket.android.util.retryIO
import chat.rocket.core.RocketChatClient import chat.rocket.core.RocketChatClient
import chat.rocket.core.internal.rest.chatRooms import chat.rocket.core.internal.rest.chatRooms
......
...@@ -154,14 +154,14 @@ class DatabaseManager(val context: Application, ...@@ -154,14 +154,14 @@ class DatabaseManager(val context: Application,
val chatRoom = current.chatRoom val chatRoom = current.chatRoom
lastMessage?.sender?.let { user -> lastMessage?.sender?.let { user ->
if (findUser(user.id!!) == null) { if (findUser(user.id) == null) {
Timber.d("Missing last message user, inserting: ${user.id}") Timber.d("Missing last message user, inserting: ${user.id}")
insert(UserEntity(user.id!!, user.username, user.name)) insert(UserEntity(user.id!!, user.username, user.name))
} }
} }
user?.let { user -> user?.let { user ->
if (findUser(user.id!!) == null) { if (findUser(user.id) == null) {
Timber.d("Missing owner user, inserting: ${user.id}") Timber.d("Missing owner user, inserting: ${user.id}")
insert(UserEntity(user.id!!, user.username, user.name)) insert(UserEntity(user.id!!, user.username, user.name))
} }
...@@ -260,15 +260,16 @@ class DatabaseManager(val context: Application, ...@@ -260,15 +260,16 @@ class DatabaseManager(val context: Application,
Timber.d("Missing user, inserting: $userId") Timber.d("Missing user, inserting: $userId")
insert(UserEntity(userId)) insert(UserEntity(userId))
} }
room.lastMessage?.sender?.let { user -> room.lastMessage?.sender?.let { user ->
if (findUser(user.id!!) == null) { if (findUser(user.id) == null) {
Timber.d("Missing last message user, inserting: ${user.id}") Timber.d("Missing last message user, inserting: ${user.id}")
insert(UserEntity(user.id!!, user.username, user.name)) insert(UserEntity(user.id!!, user.username, user.name))
} }
} }
room.user?.let { user -> room.user?.let { user ->
if (findUser(user.id!!) == null) { if (findUser(user.id) == null) {
Timber.d("Missing owner user, inserting: ${user.id}") Timber.d("Missing owner user, inserting: ${user.id}")
insert(UserEntity(user.id!!, user.username, user.name)) insert(UserEntity(user.id!!, user.username, user.name))
} }
...@@ -312,13 +313,13 @@ class DatabaseManager(val context: Application, ...@@ -312,13 +313,13 @@ class DatabaseManager(val context: Application,
} }
} }
fun findUser(userId: String): String? = userDao().findUser(userId) fun findUser(userId: String?): String? = if (userId != null) userDao().findUser(userId) else null
} }
fun User.toEntity(): BaseUserEntity? { fun User.toEntity(): BaseUserEntity? {
return if (name == null && username == null && utcOffset == null && status != null) { return if (name == null && username == null && utcOffset == null && status != null) {
UserStatus(id = id, status = status.toString()) UserStatus(id = id, status = status.toString())
} else if (username != null){ } else if (username != null) {
UserEntity(id, username, name, status?.toString() ?: "offline", utcOffset) UserEntity(id, username, name, status?.toString() ?: "offline", utcOffset)
} else { } else {
null null
......
...@@ -14,6 +14,7 @@ import chat.rocket.android.profile.presentation.ProfileView ...@@ -14,6 +14,7 @@ import chat.rocket.android.profile.presentation.ProfileView
import chat.rocket.android.util.extension.asObservable import chat.rocket.android.util.extension.asObservable
import chat.rocket.android.util.extensions.* import chat.rocket.android.util.extensions.*
import dagger.android.support.AndroidSupportInjection import dagger.android.support.AndroidSupportInjection
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.rxkotlin.Observables import io.reactivex.rxkotlin.Observables
import kotlinx.android.synthetic.main.avatar_profile.* import kotlinx.android.synthetic.main.avatar_profile.*
...@@ -28,7 +29,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback { ...@@ -28,7 +29,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
private lateinit var currentEmail: String private lateinit var currentEmail: String
private lateinit var currentAvatar: String private lateinit var currentAvatar: String
private var actionMode: ActionMode? = null private var actionMode: ActionMode? = null
private lateinit var editTextsDisposable: Disposable private val editTextsDisposable = CompositeDisposable()
companion object { companion object {
fun newInstance() = ProfileFragment() fun newInstance() = ProfileFragment()
...@@ -170,7 +171,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback { ...@@ -170,7 +171,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
} }
private fun subscribeEditTexts() { private fun subscribeEditTexts() {
editTextsDisposable = Observables.combineLatest( editTextsDisposable.add(Observables.combineLatest(
text_name.asObservable(), text_name.asObservable(),
text_username.asObservable(), text_username.asObservable(),
text_email.asObservable(), text_email.asObservable(),
...@@ -186,11 +187,11 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback { ...@@ -186,11 +187,11 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
} else { } else {
finishActionMode() finishActionMode()
} }
} })
} }
private fun unsubscribeEditTexts() { private fun unsubscribeEditTexts() {
editTextsDisposable.dispose() editTextsDisposable.clear()
} }
private fun startActionMode() { private fun startActionMode() {
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_container" android:id="@+id/layout_container"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar_layout"> app:layout_constraintTop_toBottomOf="@id/toolbar_layout">
<android.support.design.chip.ChipGroup <com.google.android.material.chip.ChipGroup
android:id="@+id/members_chips" android:id="@+id/members_chips"
style="@style/Widget.MaterialComponents.Chip.Entry" style="@style/Widget.MaterialComponents.Chip.Entry"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
</android.support.design.chip.ChipGroup> </com.google.android.material.chip.ChipGroup>
<com.wang.avi.AVLoadingIndicatorView <com.wang.avi.AVLoadingIndicatorView
android:id="@+id/view_loading" android:id="@+id/view_loading"
...@@ -63,12 +63,12 @@ ...@@ -63,12 +63,12 @@
android:background="@color/colorDividerMessageComposer" android:background="@color/colorDividerMessageComposer"
app:layout_constraintTop_toBottomOf="@id/text_search_member" /> app:layout_constraintTop_toBottomOf="@id/text_search_member" />
<android.support.v7.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:scrollbars="vertical" android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/separator_1" /> app:layout_constraintTop_toBottomOf="@id/separator_1" />
</android.support.constraint.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</android.support.constraint.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -41,4 +41,4 @@ ...@@ -41,4 +41,4 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:text="04/06/2018 14:18:36" /> tools:text="04/06/2018 14:18:36" />
</android.support.constraint.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_container" android:id="@+id/toolbar_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<android.support.v7.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height" android:layout_height="@dimen/toolbar_height"
...@@ -29,6 +29,6 @@ ...@@ -29,6 +29,6 @@
android:gravity="end" android:gravity="end"
android:textSize="14sp" /> android:textSize="14sp" />
</android.support.v7.widget.Toolbar> </androidx.appcompat.widget.Toolbar>
</android.support.constraint.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment