-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #244 from ouchadam/tech/gallery-tests
Tech/Image Gallery Tests
- Loading branch information
Showing
12 changed files
with
471 additions
and
65 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
domains/android/core/src/main/kotlin/app/dapk/st/core/ContentResolverExtensions.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package app.dapk.st.core | ||
|
||
import android.content.ContentResolver | ||
import android.database.Cursor | ||
import android.net.Uri | ||
|
||
data class ContentResolverQuery( | ||
val uri: Uri, | ||
val projection: List<String>, | ||
val selection: String, | ||
val selectionArgs: List<String>, | ||
val sortBy: String, | ||
) | ||
|
||
inline fun <T> ContentResolver.reduce(query: ContentResolverQuery, operation: (Cursor) -> T): List<T> { | ||
return this.reduce(query, mutableListOf<T>()) { acc, cursor -> | ||
acc.add(operation(cursor)) | ||
acc | ||
} | ||
} | ||
|
||
inline fun <T> ContentResolver.reduce(query: ContentResolverQuery, initial: T, operation: (T, Cursor) -> T): T { | ||
var accumulator: T = initial | ||
this.query(query.uri, query.projection.toTypedArray(), query.selection, query.selectionArgs.toTypedArray(), query.sortBy).use { cursor -> | ||
while (cursor != null && cursor.moveToNext()) { | ||
accumulator = operation(accumulator, cursor) | ||
} | ||
} | ||
return accumulator | ||
} |
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
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
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
40 changes: 21 additions & 19 deletions
40
features/messenger/src/main/kotlin/app/dapk/st/messenger/gallery/FetchMediaFoldersUseCase.kt
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
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
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
8 changes: 8 additions & 0 deletions
8
features/messenger/src/main/kotlin/app/dapk/st/messenger/gallery/MediaUriAvoidance.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package app.dapk.st.messenger.gallery | ||
|
||
import android.net.Uri | ||
|
||
class MediaUriAvoidance( | ||
val uriAppender: (Uri, Long) -> Uri, | ||
val externalContentUri: Uri, | ||
) |
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
Oops, something went wrong.