Glimpse: GlimpseCursorLoader: Enforce non-null queryArgs
Change-Id: I35fa64c8bd03eddc98ed15e728cd8e43d06447c7
This commit is contained in:
parent
50b56e82b8
commit
4a36f5dd5c
|
@ -25,10 +25,10 @@ class GlimpseCursorLoader(
|
||||||
selection: String?,
|
selection: String?,
|
||||||
selectionArgs: Array<out String>?,
|
selectionArgs: Array<out String>?,
|
||||||
sortOrder: String?,
|
sortOrder: String?,
|
||||||
private val queryArgs: Bundle?
|
private val queryArgs: Bundle = Bundle()
|
||||||
) : CursorLoader(context, uri, projection, selection, selectionArgs, sortOrder) {
|
) : CursorLoader(context, uri, projection, selection, selectionArgs, sortOrder) {
|
||||||
init {
|
init {
|
||||||
queryArgs?.putAll(
|
queryArgs.putAll(
|
||||||
bundleOf(
|
bundleOf(
|
||||||
ContentResolver.QUERY_ARG_SQL_SELECTION to selection,
|
ContentResolver.QUERY_ARG_SQL_SELECTION to selection,
|
||||||
ContentResolver.QUERY_ARG_SQL_SELECTION_ARGS to selectionArgs,
|
ContentResolver.QUERY_ARG_SQL_SELECTION_ARGS to selectionArgs,
|
||||||
|
|
|
@ -155,6 +155,7 @@ class AlbumFragment : Fragment(R.layout.fragment_album), LoaderManager.LoaderCal
|
||||||
}
|
}
|
||||||
val selection = albumFilter?.let { imageOrVideo and it } ?: imageOrVideo
|
val selection = albumFilter?.let { imageOrVideo and it } ?: imageOrVideo
|
||||||
val sortOrder = MediaStore.Files.FileColumns.DATE_ADDED + " DESC"
|
val sortOrder = MediaStore.Files.FileColumns.DATE_ADDED + " DESC"
|
||||||
|
val queryArgs = args ?: Bundle()
|
||||||
GlimpseCursorLoader(
|
GlimpseCursorLoader(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
MediaStore.Files.getContentUri("external"),
|
MediaStore.Files.getContentUri("external"),
|
||||||
|
@ -164,7 +165,7 @@ class AlbumFragment : Fragment(R.layout.fragment_album), LoaderManager.LoaderCal
|
||||||
MediaStoreBuckets.values().none { bucket -> it.id == bucket.id }
|
MediaStoreBuckets.values().none { bucket -> it.id == bucket.id }
|
||||||
}?.let { arrayOf(it.id.toString()) },
|
}?.let { arrayOf(it.id.toString()) },
|
||||||
sortOrder,
|
sortOrder,
|
||||||
args
|
queryArgs
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ class AlbumsFragment : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
(MediaStore.Files.FileColumns.MEDIA_TYPE eq MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE) or
|
(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)
|
(MediaStore.Files.FileColumns.MEDIA_TYPE eq MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO)
|
||||||
val sortOrder = MediaStore.Files.FileColumns.DATE_ADDED + " DESC"
|
val sortOrder = MediaStore.Files.FileColumns.DATE_ADDED + " DESC"
|
||||||
|
val queryArgs = args ?: Bundle()
|
||||||
GlimpseCursorLoader(
|
GlimpseCursorLoader(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
MediaStore.Files.getContentUri("external"),
|
MediaStore.Files.getContentUri("external"),
|
||||||
|
@ -102,7 +103,7 @@ class AlbumsFragment : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
imageOrVideo.build(),
|
imageOrVideo.build(),
|
||||||
null,
|
null,
|
||||||
sortOrder,
|
sortOrder,
|
||||||
args
|
queryArgs
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,6 +365,7 @@ class MediaViewerFragment : Fragment(
|
||||||
}
|
}
|
||||||
val selection = albumFilter?.let { imageOrVideo and it } ?: imageOrVideo
|
val selection = albumFilter?.let { imageOrVideo and it } ?: imageOrVideo
|
||||||
val sortOrder = MediaStore.Files.FileColumns.DATE_ADDED + " DESC"
|
val sortOrder = MediaStore.Files.FileColumns.DATE_ADDED + " DESC"
|
||||||
|
val queryArgs = args ?: Bundle()
|
||||||
GlimpseCursorLoader(
|
GlimpseCursorLoader(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
MediaStore.Files.getContentUri("external"),
|
MediaStore.Files.getContentUri("external"),
|
||||||
|
@ -374,7 +375,7 @@ class MediaViewerFragment : Fragment(
|
||||||
MediaStoreBuckets.values().none { bucket -> it.id == bucket.id }
|
MediaStoreBuckets.values().none { bucket -> it.id == bucket.id }
|
||||||
}?.let { arrayOf(it.id.toString()) },
|
}?.let { arrayOf(it.id.toString()) },
|
||||||
sortOrder,
|
sortOrder,
|
||||||
args
|
queryArgs
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue