Skip to content
This repository was archived by the owner on Nov 26, 2019. It is now read-only.

Commit bd2423d

Browse files
committed
# remove lateinit for ressource bundle loading
Signed-off-by: Bios-Marcel <[email protected]>
1 parent b278f50 commit bd2423d

File tree

1 file changed

+10
-20
lines changed
  • src/main/kotlin/com/msc/serverbrowser

1 file changed

+10
-20
lines changed

src/main/kotlin/com/msc/serverbrowser/Client.kt

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ import com.github.plushaze.traynotification.animations.Animations
44
import com.github.plushaze.traynotification.notification.NotificationTypeImplementations
55
import com.github.plushaze.traynotification.notification.TrayNotificationBuilder
66
import com.msc.serverbrowser.constants.PathConstants
7-
import com.msc.serverbrowser.data.properties.AutomaticUpdatesProperty
8-
import com.msc.serverbrowser.data.properties.ChangelogEnabledProperty
9-
import com.msc.serverbrowser.data.properties.ClientPropertiesController
10-
import com.msc.serverbrowser.data.properties.LanguageProperty
11-
import com.msc.serverbrowser.data.properties.MaximizedProperty
12-
import com.msc.serverbrowser.data.properties.ShowChangelogProperty
13-
import com.msc.serverbrowser.data.properties.UseDarkThemeProperty
7+
import com.msc.serverbrowser.data.properties.*
148
import com.msc.serverbrowser.gui.UncaughtExceptionHandlerController
159
import com.msc.serverbrowser.gui.UncaughtExceptionHandlerView
1610
import com.msc.serverbrowser.gui.View
@@ -39,9 +33,7 @@ import java.net.URISyntaxException
3933
import java.nio.file.Files
4034
import java.nio.file.Paths
4135
import java.nio.file.StandardCopyOption
42-
import java.util.Locale
43-
import java.util.MissingResourceException
44-
import java.util.ResourceBundle
36+
import java.util.*
4537

4638
/**
4739
* This is the main class of the client.
@@ -320,11 +312,7 @@ class Client : Application() {
320312
}
321313

322314
val javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"
323-
val command = ArrayList<String>()
324-
325-
command.add(javaBin)
326-
command.add("-jar")
327-
command.add(PathConstants.OWN_JAR.path)
315+
val command = listOf(javaBin, "-jar", PathConstants.OWN_JAR.path)
328316

329317
try {
330318
val builder = ProcessBuilder(command)
@@ -359,20 +347,22 @@ class Client : Application() {
359347

360348
/**
361349
* ResourceBundle which contains all the localized strings.
362-
*
363-
* Using `lateinit`, since a method is used to avoid code duplication.
364350
*/
365-
lateinit var languageResourceBundle: ResourceBundle
351+
var languageResourceBundle: ResourceBundle
366352

367353
init {
368354
createFolderStructure()
369-
applyCurrentLanguage()
355+
languageResourceBundle = loadChosenResourceBundle()
370356
}
371357

372358
fun applyCurrentLanguage() {
359+
languageResourceBundle = loadChosenResourceBundle()
360+
}
361+
362+
private fun loadChosenResourceBundle(): ResourceBundle {
373363
val locale = Locale(ClientPropertiesController.getProperty(LanguageProperty))
374364
Locale.setDefault(locale)
375-
languageResourceBundle = ResourceBundle.getBundle("com.msc.serverbrowser.localization.Lang", locale)
365+
return ResourceBundle.getBundle("com.msc.serverbrowser.localization.Lang", locale)
376366
}
377367

378368
/**

0 commit comments

Comments
 (0)