Skip to content
Snippets Groups Projects
Commit 9090d941 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fix a crashing bug due to the context not being available yet

parent 7678abff
Branches
Tags
No related merge requests found
...@@ -74,8 +74,8 @@ class BufferViewConfigFragment : ServiceBoundFragment() { ...@@ -74,8 +74,8 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
} }
} }
val ircFormatDeserializer = IrcFormatDeserializer(context!!) private var ircFormatDeserializer: IrcFormatDeserializer? = null
val renderingSettings = RenderingSettings( private val renderingSettings = RenderingSettings(
showPrefix = RenderingSettings.ShowPrefixMode.FIRST, showPrefix = RenderingSettings.ShowPrefixMode.FIRST,
colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE, colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE,
colorizeMirc = true, colorizeMirc = true,
...@@ -134,9 +134,9 @@ class BufferViewConfigFragment : ServiceBoundFragment() { ...@@ -134,9 +134,9 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
away -> BufferListAdapter.BufferStatus.AWAY away -> BufferListAdapter.BufferStatus.AWAY
else -> BufferListAdapter.BufferStatus.ONLINE else -> BufferListAdapter.BufferStatus.ONLINE
}, },
description = ircFormatDeserializer.formatString( description = ircFormatDeserializer?.formatString(
realName, renderingSettings.colorizeMirc realName, renderingSettings.colorizeMirc
), ) ?: realName,
activity = activity activity = activity
) )
} }
...@@ -155,9 +155,9 @@ class BufferViewConfigFragment : ServiceBoundFragment() { ...@@ -155,9 +155,9 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
IrcChannel.NULL -> BufferListAdapter.BufferStatus.OFFLINE IrcChannel.NULL -> BufferListAdapter.BufferStatus.OFFLINE
else -> BufferListAdapter.BufferStatus.ONLINE else -> BufferListAdapter.BufferStatus.ONLINE
}, },
description = ircFormatDeserializer.formatString( description = ircFormatDeserializer?.formatString(
topic, renderingSettings.colorizeMirc topic, renderingSettings.colorizeMirc
), ) ?: topic,
activity = activity activity = activity
) )
} }
...@@ -210,6 +210,10 @@ class BufferViewConfigFragment : ServiceBoundFragment() { ...@@ -210,6 +210,10 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
handlerThread.onCreate() handlerThread.onCreate()
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
if (ircFormatDeserializer == null) {
ircFormatDeserializer = IrcFormatDeserializer(context!!)
}
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
......
...@@ -34,8 +34,8 @@ class NickListFragment : ServiceBoundFragment() { ...@@ -34,8 +34,8 @@ class NickListFragment : ServiceBoundFragment() {
@BindView(R.id.nickList) @BindView(R.id.nickList)
lateinit var nickList: RecyclerView lateinit var nickList: RecyclerView
val ircFormatDeserializer = IrcFormatDeserializer(context!!) private var ircFormatDeserializer: IrcFormatDeserializer? = null
val renderingSettings = RenderingSettings( private val renderingSettings = RenderingSettings(
showPrefix = RenderingSettings.ShowPrefixMode.FIRST, showPrefix = RenderingSettings.ShowPrefixMode.FIRST,
colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE, colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE,
colorizeMirc = true, colorizeMirc = true,
...@@ -74,7 +74,9 @@ class NickListFragment : ServiceBoundFragment() { ...@@ -74,7 +74,9 @@ class NickListFragment : ServiceBoundFragment() {
user.nick(), user.nick(),
network.modesToPrefixes(userModes), network.modesToPrefixes(userModes),
lowestMode, lowestMode,
ircFormatDeserializer.formatString(realName, renderingSettings.colorizeMirc), ircFormatDeserializer?.formatString(
realName, renderingSettings.colorizeMirc
) ?: realName,
away, away,
network.support("CASEMAPPING") network.support("CASEMAPPING")
) )
...@@ -97,6 +99,10 @@ class NickListFragment : ServiceBoundFragment() { ...@@ -97,6 +99,10 @@ class NickListFragment : ServiceBoundFragment() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
handlerThread.onCreate() handlerThread.onCreate()
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
if (ircFormatDeserializer == null) {
ircFormatDeserializer = IrcFormatDeserializer(context!!)
}
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
......
...@@ -210,7 +210,7 @@ class QuasselMessageRenderer( ...@@ -210,7 +210,7 @@ class QuasselMessageRenderer(
Message_Type.Error -> FormattedMessage( Message_Type.Error -> FormattedMessage(
message.messageId, message.messageId,
timeFormatter.format(message.time.atZone(zoneId)), timeFormatter.format(message.time.atZone(zoneId)),
message.content formatContent(message.content)
) )
Message_Type.Topic -> FormattedMessage( Message_Type.Topic -> FormattedMessage(
message.messageId, message.messageId,
......
...@@ -23,6 +23,7 @@ import de.kuschku.quasseldroid_ng.ui.settings.data.RenderingSettings ...@@ -23,6 +23,7 @@ import de.kuschku.quasseldroid_ng.ui.settings.data.RenderingSettings
import de.kuschku.quasseldroid_ng.util.helper.* import de.kuschku.quasseldroid_ng.util.helper.*
import de.kuschku.quasseldroid_ng.util.irc.format.IrcFormatDeserializer import de.kuschku.quasseldroid_ng.util.irc.format.IrcFormatDeserializer
import de.kuschku.quasseldroid_ng.util.service.ServiceBoundFragment import de.kuschku.quasseldroid_ng.util.service.ServiceBoundFragment
import de.kuschku.quasseldroid_ng.util.ui.SpanFormatter
import io.reactivex.Observable import io.reactivex.Observable
class ToolbarFragment : ServiceBoundFragment() { class ToolbarFragment : ServiceBoundFragment() {
...@@ -45,8 +46,8 @@ class ToolbarFragment : ServiceBoundFragment() { ...@@ -45,8 +46,8 @@ class ToolbarFragment : ServiceBoundFragment() {
showLag = true showLag = true
) )
val ircFormatDeserializer = IrcFormatDeserializer(context!!) private var ircFormatDeserializer: IrcFormatDeserializer? = null
val renderingSettings = RenderingSettings( private val renderingSettings = RenderingSettings(
showPrefix = RenderingSettings.ShowPrefixMode.FIRST, showPrefix = RenderingSettings.ShowPrefixMode.FIRST,
colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE, colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE,
colorizeMirc = true, colorizeMirc = true,
...@@ -81,9 +82,9 @@ class ToolbarFragment : ServiceBoundFragment() { ...@@ -81,9 +82,9 @@ class ToolbarFragment : ServiceBoundFragment() {
BufferData( BufferData(
info = info, info = info,
network = network.networkInfo(), network = network.networkInfo(),
description = ircFormatDeserializer.formatString( description = ircFormatDeserializer?.formatString(
realName, renderingSettings.colorizeMirc realName, renderingSettings.colorizeMirc
) ) ?: realName
) )
} }
} }
...@@ -96,9 +97,9 @@ class ToolbarFragment : ServiceBoundFragment() { ...@@ -96,9 +97,9 @@ class ToolbarFragment : ServiceBoundFragment() {
BufferData( BufferData(
info = info, info = info,
network = network.networkInfo(), network = network.networkInfo(),
description = ircFormatDeserializer.formatString( description = ircFormatDeserializer?.formatString(
topic, renderingSettings.colorizeMirc topic, renderingSettings.colorizeMirc
) ) ?: topic
) )
} }
} }
...@@ -154,6 +155,13 @@ class ToolbarFragment : ServiceBoundFragment() { ...@@ -154,6 +155,13 @@ class ToolbarFragment : ServiceBoundFragment() {
toolbarSubtitle.visibleIf(value?.isNotEmpty() == true) toolbarSubtitle.visibleIf(value?.isNotEmpty() == true)
} }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (ircFormatDeserializer == null) {
ircFormatDeserializer = IrcFormatDeserializer(context!!)
}
}
override fun onCreateView(inflater: LayoutInflater, override fun onCreateView(inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?): View? {
...@@ -177,7 +185,7 @@ class ToolbarFragment : ServiceBoundFragment() { ...@@ -177,7 +185,7 @@ class ToolbarFragment : ServiceBoundFragment() {
if (description.isNullOrBlank()) { if (description.isNullOrBlank()) {
this.subtitle = "Lag: ${lag}ms" this.subtitle = "Lag: ${lag}ms"
} else { } else {
this.subtitle = "Lag: ${lag}ms | $description" this.subtitle = SpanFormatter.format("Lag: %dms | %s", lag, description)
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment