Last active
August 5, 2018 18:42
-
-
Save ShaishavGandhi/20cd928557b2ce8e46fa4a0f8c9217a3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package com.shaishavgandhi.rxreplayingsharesample | |
import android.content.res.Resources | |
import android.graphics.Bitmap | |
import android.graphics.BitmapFactory | |
import androidx.annotation.RawRes | |
import io.reactivex.Observable | |
class ImageRepository(private val resources: Resources) { | |
fun loadImage(@RawRes imageId: Int): Observable<Bitmap> { | |
return Observable.fromCallable { | |
// Use BitmapFactory to get Bitmap from a raw resource | |
return@fromCallable BitmapFactory.decodeStream(resources.openRawResource(imageId)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment