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

feat: improve asset loading

parent 422ba9ba
Branches
No related tags found
Loading
/* /*
* Quasseldroid - Quassel client for Android * Quasseldroid - Quassel client for Android
* *
* Copyright (c) 2020 Janne Mareike Koschinski * Copyright (c) 2023 Janne Mareike Koschinski
* Copyright (c) 2020 The Quassel Project * Copyright (c) 2023 The Quassel Project
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published * under the terms of the GNU General Public License version 3 as published
...@@ -21,7 +21,7 @@ package de.kuschku.quasseldroid.defaults ...@@ -21,7 +21,7 @@ package de.kuschku.quasseldroid.defaults
import android.content.Context import android.content.Context
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.reflect.TypeToken import de.kuschku.quasseldroid.util.helper.fromJson
import java.io.IOException import java.io.IOException
import javax.inject.Inject import javax.inject.Inject
...@@ -29,10 +29,7 @@ class DefaultNetworks @Inject constructor(context: Context, gson: Gson) { ...@@ -29,10 +29,7 @@ class DefaultNetworks @Inject constructor(context: Context, gson: Gson) {
val networks: List<DefaultNetwork> by lazy { val networks: List<DefaultNetwork> by lazy {
try { try {
context.assets.open("networks.json").use { context.assets.open("networks.json").use {
gson.fromJson<List<DefaultNetwork>>( gson.fromJson(it.bufferedReader(Charsets.UTF_8))
it.bufferedReader(Charsets.UTF_8),
object : TypeToken<List<DefaultNetwork>>() {}.type
)
} }
} catch (e: IOException) { } catch (e: IOException) {
throw IllegalStateException("networks.json missing from assets.", e) throw IllegalStateException("networks.json missing from assets.", e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment