Updated on 2026-08-14

This commit is contained in:
Tangem 2023-04-16 15:45:16 +03:00
parent de222c7cb7
commit 3d95481b13
2 changed files with 17 additions and 3 deletions

View file

@ -3,6 +3,7 @@ package com.tangem.datasource.asset
import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import java.io.BufferedReader
import java.io.InputStream
import javax.inject.Inject
/**
@ -15,9 +16,13 @@ internal class AndroidAssetReader @Inject constructor(
) : AssetReader {
override fun readJson(fileName: String): String {
return context.assets
.open("$fileName.json")
return openFile("$fileName.json")
.bufferedReader()
.use(BufferedReader::readText)
}
override fun openFile(fileName: String): InputStream {
return context.assets
.open(fileName)
}
}

View file

@ -1,5 +1,7 @@
package com.tangem.datasource.asset
import java.io.InputStream
/**
* Asset file reader
*
@ -7,6 +9,13 @@ package com.tangem.datasource.asset
*/
interface AssetReader {
/** Read content of json file [fileName] from asset */
/** Read content of json file from asset
* @param fileName - name of the file
* */
fun readJson(fileName: String): String
/** Read content of a file [file] from asset as InputStream
* @param file - name of the file with extension
* */
fun openFile(file: String): InputStream
}