use of us.koller.cameraroll.data.provider.retriever.MediaStoreRetriever in project Camera-Roll-Android-App by kollerlukas.
the class MediaProvider method loadAlbums.
public void loadAlbums(final Activity context, final boolean hiddenFolders, OnMediaLoadedCallback callback) {
if (!MediaProvider.checkPermission(context)) {
callback.needPermission();
return;
}
int mode = getMode(context);
switch(mode) {
case MODE_STORAGE:
retriever = new StorageRetriever();
break;
case MODE_MEDIASTORE:
retriever = new MediaStoreRetriever();
break;
default:
break;
}
if (retriever != null) {
setCallback(callback);
retriever.loadAlbums(context, hiddenFolders, new OnMediaLoadedCallback() {
@Override
public void onMediaLoaded(ArrayList<Album> albums) {
// remove excluded albums
for (int i = albums.size() - 1; i >= 0; i--) {
if (albums.get(i) == null || albums.get(i).excluded) {
albums.remove(i);
}
}
SortUtil.sortAlbums(context, albums);
setAlbums(albums);
OnMediaLoadedCallback callback = getCallback();
if (callback != null) {
callback.onMediaLoaded(albums);
}
}
@Override
public void timeout() {
OnMediaLoadedCallback callback = getCallback();
if (callback != null) {
callback.timeout();
}
}
@Override
public void needPermission() {
OnMediaLoadedCallback callback = getCallback();
if (callback != null) {
callback.needPermission();
}
}
});
} else {
if (callback != null) {
callback.onMediaLoaded(null);
}
}
}
Aggregations