This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun isExternalStorageDocument(uri: Uri) = "com.android.externalstorage.documents" == uri.authority | |
fun isDownloadsDocument(uri: Uri) = "com.android.providers.downloads.documents" == uri.authority | |
fun isMediaDocument(uri: Uri) = "com.android.providers.media.documents" == uri.authority | |
/** | |
* Get a file path from a Uri. This will get the the path for Storage Access | |
* Framework Documents, as well as the _data field for the MediaStore and | |
* other file-based ContentProviders. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Suppress("UNCHECKED_CAST") | |
class ArrayListAdapter<T>(private val adapter: JsonAdapter<T>) : JsonAdapter<ArrayList<T>>() { | |
@Throws(IOException::class) | |
override fun fromJson(reader: JsonReader): ArrayList<T>? { | |
val arrayList = arrayListOf<T>() | |
reader.beginArray() | |
while (reader.hasNext()) { | |
(adapter.fromJson(reader))?.let { arrayList.add(it) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AwsDataFetcher(private val s3Client: AmazonS3Client, private val awsImage: AwsImage) : DataFetcher<InputStream> { | |
override fun getDataClass() = InputStream::class.java | |
override fun loadData(priority: Priority, callback: DataFetcher.DataCallback<in InputStream>) { | |
callback.onDataReady( | |
s3Client.getObject( | |
GetObjectRequest( | |
awsImage.bucket, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias NetworkCall<R> = suspend () -> Response<R> | |
typealias DbCall<R> = suspend () -> R | |
typealias DbSave<R> = suspend (R) -> Unit | |
open class BaseRepo { | |
suspend inline fun <R : Any, reified E> loadData( | |
noinline dbCall: DbCall<R>? = null, | |
noinline dbSave: DbSave<R>? = null, | |
noinline networkCall: NetworkCall<R>? = null |