Glimpse: Share common projections

Change-Id: I362799adb1200c46bcbbaed31fb9d537ef21e565
This commit is contained in:
Luca Stefani 2023-08-07 18:58:31 +02:00 committed by Sebastiano Barezzi
parent 1cb30ec8bb
commit 79a420286d
5 changed files with 27 additions and 34 deletions

View File

@ -132,14 +132,7 @@ class AlbumFragment : Fragment(R.layout.fragment_album), LoaderManager.LoaderCal
override fun onCreateLoader(id: Int, args: Bundle?) = when (id) {
MediaStoreRequests.MEDIA_STORE_REELS_LOADER_ID.ordinal -> {
val projection = arrayOf(
MediaStore.Files.FileColumns._ID,
MediaStore.Files.FileColumns.IS_FAVORITE,
MediaStore.Files.FileColumns.IS_TRASHED,
MediaStore.Files.FileColumns.DATE_ADDED,
MediaStore.Files.FileColumns.MEDIA_TYPE,
MediaStore.Files.FileColumns.MIME_TYPE,
)
val projection = MediaQuery.MediaProjection
val imageOrVideo =
(MediaStore.Files.FileColumns.MEDIA_TYPE eq MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE) or
(MediaStore.Files.FileColumns.MEDIA_TYPE eq MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO)

View File

@ -90,16 +90,7 @@ class AlbumsFragment : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
override fun onCreateLoader(id: Int, args: Bundle?) = when (id) {
MediaStoreRequests.MEDIA_STORE_ALBUMS_LOADER_ID.ordinal -> {
val projection = arrayOf(
MediaStore.Files.FileColumns.BUCKET_ID,
MediaStore.Files.FileColumns.BUCKET_DISPLAY_NAME,
MediaStore.Files.FileColumns._ID,
MediaStore.Files.FileColumns.IS_FAVORITE,
MediaStore.Files.FileColumns.IS_TRASHED,
MediaStore.Files.FileColumns.DATE_ADDED,
MediaStore.Files.FileColumns.MEDIA_TYPE,
MediaStore.Files.FileColumns.MIME_TYPE,
)
val projection = MediaQuery.AlbumsProjection
val imageOrVideo =
(MediaStore.Files.FileColumns.MEDIA_TYPE eq MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE) or
(MediaStore.Files.FileColumns.MEDIA_TYPE eq MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO)

View File

@ -321,14 +321,7 @@ class MediaViewerFragment : Fragment(
override fun onCreateLoader(id: Int, args: Bundle?) = when (id) {
MediaStoreRequests.MEDIA_STORE_REELS_LOADER_ID.ordinal -> {
val projection = arrayOf(
MediaStore.Files.FileColumns._ID,
MediaStore.Files.FileColumns.IS_FAVORITE,
MediaStore.Files.FileColumns.IS_TRASHED,
MediaStore.Files.FileColumns.DATE_ADDED,
MediaStore.Files.FileColumns.MEDIA_TYPE,
MediaStore.Files.FileColumns.MIME_TYPE,
)
val projection = MediaQuery.MediaProjection
val imageOrVideo =
(MediaStore.Files.FileColumns.MEDIA_TYPE eq MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE) or
(MediaStore.Files.FileColumns.MEDIA_TYPE eq MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO)

View File

@ -114,14 +114,7 @@ class ReelsFragment : Fragment(R.layout.fragment_reels), LoaderManager.LoaderCal
override fun onCreateLoader(id: Int, args: Bundle?) = when (id) {
MediaStoreRequests.MEDIA_STORE_REELS_LOADER_ID.ordinal -> {
val projection = arrayOf(
MediaStore.Files.FileColumns._ID,
MediaStore.Files.FileColumns.IS_FAVORITE,
MediaStore.Files.FileColumns.IS_TRASHED,
MediaStore.Files.FileColumns.DATE_ADDED,
MediaStore.Files.FileColumns.MEDIA_TYPE,
MediaStore.Files.FileColumns.MIME_TYPE,
)
val projection = MediaQuery.MediaProjection
val imageOrVideo =
(MediaStore.Files.FileColumns.MEDIA_TYPE eq MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE) or
(MediaStore.Files.FileColumns.MEDIA_TYPE eq MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO)

View File

@ -0,0 +1,23 @@
/*
* SPDX-FileCopyrightText: 2023 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
package org.lineageos.glimpse.query
import android.provider.MediaStore
object MediaQuery {
val MediaProjection = arrayOf(
MediaStore.Files.FileColumns._ID,
MediaStore.Files.FileColumns.IS_FAVORITE,
MediaStore.Files.FileColumns.IS_TRASHED,
MediaStore.Files.FileColumns.MEDIA_TYPE,
MediaStore.Files.FileColumns.MIME_TYPE,
MediaStore.Files.FileColumns.DATE_ADDED,
)
val AlbumsProjection = arrayOf(
MediaStore.Files.FileColumns.BUCKET_ID,
MediaStore.Files.FileColumns.BUCKET_DISPLAY_NAME,
) + MediaProjection
}