Commit e2ce221d authored by Lucio Maciel's avatar Lucio Maciel

Fix error message on rotating and change server

parent a4213242
...@@ -36,6 +36,8 @@ import chat.rocket.android.helper.SharedPreferenceHelper ...@@ -36,6 +36,8 @@ import chat.rocket.android.helper.SharedPreferenceHelper
import chat.rocket.android.util.extension.onQueryTextListener import chat.rocket.android.util.extension.onQueryTextListener
import chat.rocket.android.util.extensions.fadeIn import chat.rocket.android.util.extensions.fadeIn
import chat.rocket.android.util.extensions.fadeOut import chat.rocket.android.util.extensions.fadeOut
import chat.rocket.android.util.extensions.ifNotNullNorEmpty
import chat.rocket.android.util.extensions.ifNotNullNotEmpty
import chat.rocket.android.util.extensions.inflate import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.showToast import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.ui import chat.rocket.android.util.extensions.ui
...@@ -83,8 +85,8 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView { ...@@ -83,8 +85,8 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
val bundle = arguments val bundle = arguments
if (bundle != null) { if (bundle != null) {
chatRoomId = bundle.getString(BUNDLE_CHAT_ROOM_ID) chatRoomId = bundle.getString(BUNDLE_CHAT_ROOM_ID)
chatRoomId?.let { chatRoomId.ifNotNullNotEmpty { roomId ->
presenter.loadChatRoom(it) presenter.loadChatRoom(roomId)
chatRoomId = null chatRoomId = null
} }
} }
......
...@@ -64,6 +64,7 @@ import chat.rocket.common.internal.ISO8601Date ...@@ -64,6 +64,7 @@ import chat.rocket.common.internal.ISO8601Date
import chat.rocket.common.model.TimestampAdapter import chat.rocket.common.model.TimestampAdapter
import chat.rocket.common.util.CalendarISO8601Converter import chat.rocket.common.util.CalendarISO8601Converter
import chat.rocket.common.util.Logger import chat.rocket.common.util.Logger
import chat.rocket.common.util.NoOpLogger
import chat.rocket.common.util.PlatformLogger import chat.rocket.common.util.PlatformLogger
import chat.rocket.core.internal.AttachmentAdapterFactory import chat.rocket.core.internal.AttachmentAdapterFactory
import chat.rocket.core.internal.ReactionsAdapter import chat.rocket.core.internal.ReactionsAdapter
...@@ -231,7 +232,7 @@ class AppModule { ...@@ -231,7 +232,7 @@ class AppModule {
return Moshi.Builder() return Moshi.Builder()
.add(FallbackSealedClassJsonAdapter.ADAPTER_FACTORY) .add(FallbackSealedClassJsonAdapter.ADAPTER_FACTORY)
.add(AppJsonAdapterFactory.INSTANCE) .add(AppJsonAdapterFactory.INSTANCE)
.add(AttachmentAdapterFactory(Logger(logger, url))) .add(AttachmentAdapterFactory(NoOpLogger))
.add( .add(
java.lang.Long::class.java, java.lang.Long::class.java,
ISO8601Date::class.java, ISO8601Date::class.java,
......
...@@ -14,6 +14,7 @@ import chat.rocket.common.internal.ISO8601Date ...@@ -14,6 +14,7 @@ import chat.rocket.common.internal.ISO8601Date
import chat.rocket.common.model.TimestampAdapter import chat.rocket.common.model.TimestampAdapter
import chat.rocket.common.util.CalendarISO8601Converter import chat.rocket.common.util.CalendarISO8601Converter
import chat.rocket.common.util.Logger import chat.rocket.common.util.Logger
import chat.rocket.common.util.NoOpLogger
import chat.rocket.common.util.PlatformLogger import chat.rocket.common.util.PlatformLogger
import chat.rocket.core.internal.AttachmentAdapterFactory import chat.rocket.core.internal.AttachmentAdapterFactory
import chat.rocket.core.internal.ReactionsAdapter import chat.rocket.core.internal.ReactionsAdapter
...@@ -47,7 +48,7 @@ class LocalModule { ...@@ -47,7 +48,7 @@ class LocalModule {
return Moshi.Builder() return Moshi.Builder()
.add(FallbackSealedClassJsonAdapter.ADAPTER_FACTORY) .add(FallbackSealedClassJsonAdapter.ADAPTER_FACTORY)
.add(AppJsonAdapterFactory.INSTANCE) .add(AppJsonAdapterFactory.INSTANCE)
.add(AttachmentAdapterFactory(Logger(logger, url))) .add(AttachmentAdapterFactory(NoOpLogger))
.add( .add(
java.lang.Long::class.java, java.lang.Long::class.java,
ISO8601Date::class.java, ISO8601Date::class.java,
...@@ -67,8 +68,6 @@ class LocalModule { ...@@ -67,8 +68,6 @@ class LocalModule {
return context.getSharedPreferences("rocket.chat", Context.MODE_PRIVATE) return context.getSharedPreferences("rocket.chat", Context.MODE_PRIVATE)
} }
@Provides @Provides
@Singleton @Singleton
fun provideLocalRepository(sharedPreferences: SharedPreferences, moshi: Moshi): LocalRepository { fun provideLocalRepository(sharedPreferences: SharedPreferences, moshi: Moshi): LocalRepository {
......
...@@ -110,6 +110,7 @@ class MainPresenter @Inject constructor( ...@@ -110,6 +110,7 @@ class MainPresenter @Inject constructor(
} }
fun loadCurrentInfo() { fun loadCurrentInfo() {
setupConnectionInfo(currentServer)
checkServerInfo(currentServer) checkServerInfo(currentServer)
launchUI(strategy) { launchUI(strategy) {
try { try {
......
...@@ -30,6 +30,7 @@ class RocketChatClientFactory @Inject constructor( ...@@ -30,6 +30,7 @@ class RocketChatClientFactory @Inject constructor(
userAgent = "RC Mobile; Android ${Build.VERSION.RELEASE}; v${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})" userAgent = "RC Mobile; Android ${Build.VERSION.RELEASE}; v${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
tokenRepository = repository tokenRepository = repository
platformLogger = logger platformLogger = logger
enableLogger = false
} }
Timber.d("Returning NEW client for: $url") Timber.d("Returning NEW client for: $url")
......
...@@ -76,4 +76,10 @@ fun String.lowercaseUrl(): String? { ...@@ -76,4 +76,10 @@ fun String.lowercaseUrl(): String? {
return httpUrl?.newBuilder()?.scheme(newScheme)?.build()?.toString() return httpUrl?.newBuilder()?.scheme(newScheme)?.build()?.toString()
} }
fun String?.isNotNullNorEmpty(): Boolean = this != null && this.isNotEmpty() fun String?.isNotNullNorEmpty(): Boolean = this != null && this.isNotEmpty()
\ No newline at end of file
inline fun String?.ifNotNullNotEmpty(block: (String) -> Unit) {
if (this != null && this.isNotEmpty()) {
block(this)
}
}
\ 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