Remove redundant logError method

pull/699/head
Alinson S. Xavier 5 years ago
parent f6699fbfda
commit b94a887534

@ -67,6 +67,8 @@ public interface HabitsApplicationComponent
IntentParser getIntentParser(); IntentParser getIntentParser();
Logging getLogging();
MidnightTimer getMidnightTimer(); MidnightTimer getMidnightTimer();
ModelFactory getModelFactory(); ModelFactory getModelFactory();

@ -47,14 +47,14 @@ class SyncActivity : BaseActivity(), SyncBehavior.Screen {
private val scope = CoroutineScope(Dispatchers.Main) private val scope = CoroutineScope(Dispatchers.Main)
private var styledResources = StyledResources(this) private var styledResources = StyledResources(this)
override fun onCreate(state: Bundle?) { override fun onCreate(savedInstance: Bundle?) {
super.onCreate(state) super.onCreate(savedInstance)
val component = (application as HabitsApplication).component val component = (application as HabitsApplication).component
val preferences = component.preferences val preferences = component.preferences
val server = RemoteSyncServer(preferences = preferences) val server = RemoteSyncServer(preferences = preferences)
baseScreen = BaseScreen(this) baseScreen = BaseScreen(this)
behavior = SyncBehavior(this, preferences, server) behavior = SyncBehavior(this, preferences, server, component.logging)
binding = ActivitySyncBinding.inflate(layoutInflater) binding = ActivitySyncBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
@ -125,8 +125,4 @@ class SyncActivity : BaseActivity(), SyncBehavior.Screen {
binding.syncLink.text = link binding.syncLink.text = link
showQR(link) showQR(link)
} }
override fun logError(msg: String) {
Log.e("SyncActivity", msg)
}
} }

@ -19,6 +19,7 @@
package org.isoron.uhabits.core.ui.screens.sync package org.isoron.uhabits.core.ui.screens.sync
import org.isoron.uhabits.core.io.*
import org.isoron.uhabits.core.preferences.* import org.isoron.uhabits.core.preferences.*
import org.isoron.uhabits.core.sync.* import org.isoron.uhabits.core.sync.*
@ -26,7 +27,10 @@ class SyncBehavior(
val screen: Screen, val screen: Screen,
val preferences: Preferences, val preferences: Preferences,
val server: AbstractSyncServer, val server: AbstractSyncServer,
val logging: Logging,
) { ) {
val logger = logging.getLogger("SyncBehavior")
suspend fun onResume() { suspend fun onResume() {
if (preferences.syncKey.isBlank()) { if (preferences.syncKey.isBlank()) {
register() register()
@ -47,7 +51,8 @@ class SyncBehavior(
preferences.enableSync(syncKey, encKey.base64) preferences.enableSync(syncKey, encKey.base64)
displayCurrentKey() displayCurrentKey()
} catch (e: Exception) { } catch (e: Exception) {
screen.logError("Unexpected exception $e") logger.error("Unexpected exception")
logger.error(e)
screen.showErrorScreen() screen.showErrorScreen()
} }
} }
@ -56,6 +61,5 @@ class SyncBehavior(
suspend fun showLoadingScreen() suspend fun showLoadingScreen()
suspend fun showErrorScreen() suspend fun showErrorScreen()
suspend fun showLink(link: String) suspend fun showLink(link: String)
fun logError(msg: String)
} }
} }
Loading…
Cancel
Save