Local Media Provider
The library is providing an easy way to fetch media files (photo and video) from media storage.
Requirements
Android API 21+
Usage
Add a dependency:
implementation 'com.rosberry.android:LocalMediaProvider:0.1.0'
Query files
val mediaList = MediaProvider(context).getLocalMedia(
folderId = NO_FOLDER_ID,
limit = NO_LIMIT,
filterMode = FilterMode.ALL,
sortingMode = SortingMode.DATE,
sortingOrder = SortingOrder.DESCENDING
)
Use getLocalMedia
method to query files, which return a list of LocalMedia
. You can customize your query with arguments:
- folderId - id of the folder in which to query (default is
NO_FOLDER_ID
) - limit - limit of the query (default is
NO_LIMIT
) - filterMode - can be
ALL
,VIDEO
orIMAGE
(default isALL
) - sortingMode - can be
NAME
,DATE
,SIZE
,TYPE
orNUMERIC
(default isDATE
) - sortingOrder - can be
ASCENDING
orDESCENDING
(default isDESCENDING
)
Listen media updates
interface MediaUpdatesCallback {
fun onChange(selfChange: Boolean)
}
Register callback with MediaProvider.registerMediaUpdatesCallback
. MediaUpdatesCallback.onChange
method will be invoked whenever content change occurs. Don't forget to unregister callback with MediaProvider.unregisterMediaCallback
when it isn't using.
MediaUpdateCallback
is publishing the events on the main thread.
About
This project is owned and maintained by Rosberry. We build mobile apps for users worldwide
Check out our open source projects, read our blog or give us a high-five on
License
Image Cropper is available under the Apache License 2.0. See the LICENSE file for more info.