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
plugins { | |
id("com.android.application") | |
id("kotlin-android") | |
id("kotlin-android-extensions") | |
} | |
android { | |
compileSdkVersion(Versions.Android.sdk) | |
defaultConfig { | |
applicationId = Versions.App.id |
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
object Versions { | |
const val kotlin = "1.3.50" | |
const val androidX = "1.1.0" | |
const val junit = "4.12" | |
const val espresso = "3.2.0" | |
object Android { | |
const val sdk = 29 | |
const val minSdk = 23 | |
} |
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
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
buildscript { | |
- ext.kotlin_version = "1.3.50" | |
repositories { | |
google() | |
jcenter() | |
} | |
dependencies { |
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
-apply plugin: "com.android.application" | |
-apply plugin: "kotlin-android" | |
-apply plugin: "kotlin-android-extensions" | |
+plugins { | |
+ id("com.android.application") | |
+ id("kotlin-android") | |
+ id("kotlin-android-extensions") | |
+} | |
android { |
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
class GalleryViewModel : ViewModel(), KoinComponent { | |
var setting: AlbumSetting? = null | |
val multipleSelectMedia = BehaviorSubject.createDefault<MutableList<Media>>(mutableListOf()) | |
val singleSelectMedia = PublishSubject.create<Media>() | |
val currentAlbumItem = BehaviorSubject.create<AlbumItem>() | |
private val albumRepo: AlbumRepo by inject() | |
fun loadAlbums(): Completable { | |
return albumRepo.fetchAlbums(setting) |
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
class AlbumRepoImpl(private val context: Context) : AlbumRepo { | |
private val albumSubject = BehaviorSubject.create<List<AlbumItem>>() | |
private val albumItemMapping = mutableMapOf<String, AlbumItem>() | |
override fun fetchAlbums(setting: AlbumSetting?): Completable { | |
return Completable.fromAction { | |
fetchAlbumSync(setting) | |
} | |
} |
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
interface AlbumRepo { | |
fun fetchAlbums(setting: AlbumSetting? = null): Completable | |
fun getAlbums(setting: AlbumSetting? = null): BehaviorSubject<List<AlbumItem>> | |
fun getAlbumItem(name: String, setting: AlbumSetting? = null): Observable<AlbumItem> | |
fun getAlbumItemSync(name: String, settings: AlbumSetting? = null): AlbumItem? | |
} |
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
const val ALL_MEDIA_ALBUM_NAME = "ALL_MEDIA_ALBUM_NAME" | |
const val KEY_MEDIA_LIST = "mediaList" | |
data class AlbumItem( | |
val name: String, | |
val folder: String, | |
val coverImagePath: String | |
) { | |
val mediaList = mutableListOf<Media>() | |
} |
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
<manifest package="com.enginebai.gallery" | |
xmlns:android="http://schemas.android.com/apk/res/android"> | |
<!-- Remember to add this line --> | |
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | |
<application | |
... |
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
interface PostRepository { | |
fun getFeeds(): Observable<PagedList<Post>> | |
} | |
class PostRepositoryImpl : PostRepository { | |
private val remoteDataSource: PostApiService by inject() | |
private val localDataSource: PostDao by inject() | |
private val postBoundaryCallback: postBoundaryCallback by inject() |