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() {
}
}
val ircFormatDeserializer = IrcFormatDeserializer(context!!)
val renderingSettings = RenderingSettings(
private var ircFormatDeserializer: IrcFormatDeserializer? = null
private val renderingSettings = RenderingSettings(
showPrefix = RenderingSettings.ShowPrefixMode.FIRST,
colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE,
colorizeMirc = true,
......@@ -134,9 +134,9 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
away -> BufferListAdapter.BufferStatus.AWAY
else -> BufferListAdapter.BufferStatus.ONLINE
},
description = ircFormatDeserializer.formatString(
description = ircFormatDeserializer?.formatString(
realName, renderingSettings.colorizeMirc
),
) ?: realName,
activity = activity
)
}
......@@ -155,9 +155,9 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
IrcChannel.NULL -> BufferListAdapter.BufferStatus.OFFLINE
else -> BufferListAdapter.BufferStatus.ONLINE
},
description = ircFormatDeserializer.formatString(
description = ircFormatDeserializer?.formatString(
topic, renderingSettings.colorizeMirc
),
) ?: topic,
activity = activity
)
}
......@@ -210,6 +210,10 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
handlerThread.onCreate()
super.onCreate(savedInstanceState)
if (ircFormatDeserializer == null) {
ircFormatDeserializer = IrcFormatDeserializer(context!!)
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
......
......@@ -34,8 +34,8 @@ class NickListFragment : ServiceBoundFragment() {
@BindView(R.id.nickList)
lateinit var nickList: RecyclerView
val ircFormatDeserializer = IrcFormatDeserializer(context!!)
val renderingSettings = RenderingSettings(
private var ircFormatDeserializer: IrcFormatDeserializer? = null
private val renderingSettings = RenderingSettings(
showPrefix = RenderingSettings.ShowPrefixMode.FIRST,
colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE,
colorizeMirc = true,
......@@ -74,7 +74,9 @@ class NickListFragment : ServiceBoundFragment() {
user.nick(),
network.modesToPrefixes(userModes),
lowestMode,
ircFormatDeserializer.formatString(realName, renderingSettings.colorizeMirc),
ircFormatDeserializer?.formatString(
realName, renderingSettings.colorizeMirc
) ?: realName,
away,
network.support("CASEMAPPING")
)
......@@ -97,6 +99,10 @@ class NickListFragment : ServiceBoundFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
handlerThread.onCreate()
super.onCreate(savedInstanceState)
if (ircFormatDeserializer == null) {
ircFormatDeserializer = IrcFormatDeserializer(context!!)
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
......
......@@ -210,7 +210,7 @@ class QuasselMessageRenderer(
Message_Type.Error -> FormattedMessage(
message.messageId,
timeFormatter.format(message.time.atZone(zoneId)),
message.content
formatContent(message.content)
)
Message_Type.Topic -> FormattedMessage(
message.messageId,
......
......@@ -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.irc.format.IrcFormatDeserializer
import de.kuschku.quasseldroid_ng.util.service.ServiceBoundFragment
import de.kuschku.quasseldroid_ng.util.ui.SpanFormatter
import io.reactivex.Observable
class ToolbarFragment : ServiceBoundFragment() {
......@@ -45,8 +46,8 @@ class ToolbarFragment : ServiceBoundFragment() {
showLag = true
)
val ircFormatDeserializer = IrcFormatDeserializer(context!!)
val renderingSettings = RenderingSettings(
private var ircFormatDeserializer: IrcFormatDeserializer? = null
private val renderingSettings = RenderingSettings(
showPrefix = RenderingSettings.ShowPrefixMode.FIRST,
colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE,
colorizeMirc = true,
......@@ -81,9 +82,9 @@ class ToolbarFragment : ServiceBoundFragment() {
BufferData(
info = info,
network = network.networkInfo(),
description = ircFormatDeserializer.formatString(
description = ircFormatDeserializer?.formatString(
realName, renderingSettings.colorizeMirc
)
) ?: realName
)
}
}
......@@ -96,9 +97,9 @@ class ToolbarFragment : ServiceBoundFragment() {
BufferData(
info = info,
network = network.networkInfo(),
description = ircFormatDeserializer.formatString(
description = ircFormatDeserializer?.formatString(
topic, renderingSettings.colorizeMirc
)
) ?: topic
)
}
}
......@@ -154,6 +155,13 @@ class ToolbarFragment : ServiceBoundFragment() {
toolbarSubtitle.visibleIf(value?.isNotEmpty() == true)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (ircFormatDeserializer == null) {
ircFormatDeserializer = IrcFormatDeserializer(context!!)
}
}
override fun onCreateView(inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?): View? {
......@@ -177,7 +185,7 @@ class ToolbarFragment : ServiceBoundFragment() {
if (description.isNullOrBlank()) {
this.subtitle = "Lag: ${lag}ms"
} 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