Skip to content

Commit 5a0722f

Browse files
refactor file reading logic
1 parent bf8737f commit 5a0722f

File tree

6 files changed

+19578
-74
lines changed

6 files changed

+19578
-74
lines changed

app/build.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Build Properties
2-
#Mon Dec 29 09:07:23 EST 2025
3-
version_build=39
2+
#Mon Dec 29 11:24:27 EST 2025
3+
version_build=40
44
version_major=3
55
version_minor=2
66
version_patch=1

app/src/main/kotlin/com/vrem/util/FileUtils.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package com.vrem.util
1919

2020
import android.content.res.Resources
2121
import androidx.annotation.RawRes
22-
import java.util.zip.ZipInputStream
2322

2423
fun readFile(
2524
resources: Resources,
@@ -32,16 +31,3 @@ fun readFile(
3231
.use { it.readText() }
3332
.replace("\r", String.EMPTY)
3433
}.getOrDefault(String.EMPTY)
35-
36-
fun readZipFile(
37-
resources: Resources,
38-
@RawRes id: Int,
39-
): List<String> =
40-
runCatching {
41-
resources.openRawResource(id).use { inputStream ->
42-
ZipInputStream(inputStream).use { zipInputStream ->
43-
zipInputStream.nextEntry
44-
zipInputStream.bufferedReader().readLines()
45-
}
46-
}
47-
}.getOrDefault(emptyList())

app/src/main/kotlin/com/vrem/wifianalyzer/vendor/model/VendorService.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package com.vrem.wifianalyzer.vendor.model
2020
import android.content.res.Resources
2121
import com.vrem.annotation.OpenClass
2222
import com.vrem.util.EMPTY
23-
import com.vrem.util.readZipFile
23+
import com.vrem.util.readFile
2424
import com.vrem.wifianalyzer.R
2525
import java.util.Locale
2626
import java.util.TreeMap
@@ -59,7 +59,9 @@ class VendorService(
5959
private fun load(resources: Resources): VendorData {
6060
val macs: MutableMap<String, String> = TreeMap()
6161
val vendors: MutableMap<String, List<String>> = TreeMap()
62-
readZipFile(resources, R.raw.data)
62+
readFile(resources, R.raw.data)
63+
.split("\n")
64+
.filter { it.isNotBlank() }
6365
.map { it.split("|").toTypedArray() }
6466
.forEach {
6567
val name = it[0]

0 commit comments

Comments
 (0)