use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.
the class SingleMediaActivity method loadUri.
private void loadUri(Uri uri) {
album = new Album(uri.toString(), uri.getPath());
album.settings = AlbumSettings.getDefaults();
try {
InputStream inputStream = getContentResolver().openInputStream(uri);
if (inputStream != null)
inputStream.close();
} catch (Exception ex) {
boolean showEasterEgg = Prefs.showEasterEgg();
((TextView) findViewById(R.id.nothing_to_show_text_emoji_easter_egg)).setText(R.string.error_occured_open_media);
findViewById(R.id.nothing_to_show_placeholder).setVisibility(!showEasterEgg ? View.VISIBLE : View.GONE);
findViewById(R.id.ll_emoji_easter_egg).setVisibility(showEasterEgg ? View.VISIBLE : View.GONE);
}
media = new ArrayList<>(Collections.singletonList(new Media(uri)));
position = 0;
customUri = true;
}
use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.
the class SelectAlbumBottomSheet method toggleExplorerMode.
private void toggleExplorerMode(boolean enabled) {
folders = new ArrayList<File>();
setExploreMode(enabled);
if (enabled) {
displayContentFolder(Environment.getExternalStorageDirectory());
imgExploreMode.setIcon(theme.getIcon(CommunityMaterial.Icon.cmd_folder));
exploreModePanel.setVisibility(View.VISIBLE);
} else {
currentFolderPath.setText(R.string.local_folder);
for (Album album : ((MyApplication) getActivity().getApplicationContext()).getAlbums().dispAlbums) {
folders.add(new File(album.getPath()));
}
imgExploreMode.setIcon(theme.getIcon(CommunityMaterial.Icon.cmd_compass_outline));
exploreModePanel.setVisibility(View.GONE);
}
adapter.notifyDataSetChanged();
}
use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.
the class MediaStoreProvider method getHiddenAlbums.
private static ArrayList<Album> getHiddenAlbums(Context context) {
ArrayList<Album> list = new ArrayList<Album>();
String[] projection = new String[] { MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.PARENT };
String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "=" + MediaStore.Files.FileColumns.MEDIA_TYPE_NONE + " and " + MediaStore.Files.FileColumns.DATA + " LIKE '%.nomedia'";
Cursor cur = context.getContentResolver().query(MediaStore.Files.getContentUri("external"), projection, selection, null, null);
if (cur != null && cur.moveToFirst()) {
do {
File folder = new File(cur.getString(0)).getParentFile();
File[] files = folder.listFiles(new ImageFileFilter(true));
if (files != null && files.length > 0) {
Album album = new Album(context, folder.getAbsolutePath(), -1, folder.getName(), files.length);
// TODO: 21/08/16 sort and find?
long lastMod = Long.MIN_VALUE;
File f = null;
for (File file : files) {
if (file.lastModified() > lastMod) {
f = file;
lastMod = file.lastModified();
}
}
if (f != null && !isExcluded(f.getPath())) {
album.addMedia(new Media(f.getPath(), f.lastModified()));
list.add(album);
}
}
} while (cur.moveToNext());
cur.close();
}
return list;
}
use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.
the class AlbumsFragment method onPrepareOptionsMenu.
@Override
public void onPrepareOptionsMenu(Menu menu) {
boolean editMode = editMode();
boolean oneSelected = getSelectedCount() == 1;
menu.setGroupVisible(R.id.general_album_items, !editMode);
menu.setGroupVisible(R.id.edit_mode_items, editMode);
menu.setGroupVisible(R.id.one_selected_items, oneSelected);
menu.findItem(R.id.select_all).setTitle(getSelectedCount() == getCount() ? R.string.clear_selected : R.string.select_all);
if (editMode) {
menu.findItem(R.id.hide).setTitle(hidden ? R.string.unhide : R.string.hide);
} else {
menu.findItem(R.id.ascending_sort_order).setChecked(sortingOrder() == SortingOrder.ASCENDING);
switch(sortingMode()) {
case NAME:
menu.findItem(R.id.name_sort_mode).setChecked(true);
break;
case SIZE:
menu.findItem(R.id.size_sort_mode).setChecked(true);
break;
case DATE:
default:
menu.findItem(R.id.date_taken_sort_mode).setChecked(true);
break;
case NUMERIC:
menu.findItem(R.id.numeric_sort_mode).setChecked(true);
break;
}
}
if (oneSelected) {
Album selectedAlbum = adapter.getFirstSelectedAlbum();
menu.findItem(R.id.pin_album).setTitle(selectedAlbum.isPinned() ? getString(R.string.un_pin) : getString(R.string.pin));
menu.findItem(R.id.clear_album_cover).setVisible(selectedAlbum.hasCover());
}
super.onPrepareOptionsMenu(menu);
}
use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.
the class AlbumsAdapter method removeSelectedAlbums.
public void removeSelectedAlbums() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
albums.removeIf(Album::isSelected);
else {
Iterator<Album> iter = albums.iterator();
while (iter.hasNext()) {
Album album = iter.next();
if (album.isSelected())
iter.remove();
}
}
selectedCount = 0;
notifyDataSetChanged();
}
Aggregations