use of us.koller.cameraroll.data.models.File_POJO in project Camera-Roll-Android-App by kollerlukas.
the class NestedRecyclerViewAlbumHolder method deleteItems.
private void deleteItems(String[] paths) {
File_POJO[] filesToDelete = new File_POJO[paths.length];
for (int i = 0; i < filesToDelete.length; i++) {
filesToDelete[i] = new File_POJO(paths[i], true);
}
getContext().startService(FileOperation.getDefaultIntent(getContext(), FileOperation.DELETE, filesToDelete));
}
use of us.koller.cameraroll.data.models.File_POJO in project Camera-Roll-Android-App by kollerlukas.
the class FileExplorerActivity method loadDirectory.
public void loadDirectory(final String path) {
Log.d("FileExplorerActivity", "loadDirectory(): " + path);
final Snackbar snackbar = Snackbar.make(findViewById(R.id.root_view), getString(R.string.loading), Snackbar.LENGTH_INDEFINITE);
Util.showSnackbar(snackbar);
final FilesProvider.Callback callback = new FilesProvider.Callback() {
@Override
public void onDirLoaded(final File_POJO dir) {
runOnUiThread(new Runnable() {
@Override
public void run() {
filesProvider.onDestroy();
filesProvider = null;
if (dir != null) {
FileExplorerActivity.this.currentDir = dir;
if (recyclerViewAdapter != null) {
recyclerViewAdapter.setFiles(currentDir);
recyclerViewAdapter.notifyDataSetChanged();
onDataChanged();
}
}
snackbar.dismiss();
}
});
}
@Override
public void timeout() {
runOnUiThread(new Runnable() {
@Override
public void run() {
snackbar.dismiss();
final Snackbar snackbar = Snackbar.make(findViewById(R.id.root_view), R.string.loading_failed, Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(getString(R.string.retry), new View.OnClickListener() {
@Override
public void onClick(View view) {
loadDirectory(path);
}
});
Util.showSnackbar(snackbar);
}
});
}
@Override
public void needPermission() {
runOnUiThread(new Runnable() {
@Override
public void run() {
snackbar.dismiss();
}
});
}
};
filesProvider = new FilesProvider(this);
filesProvider.loadDir(this, path, callback);
}
use of us.koller.cameraroll.data.models.File_POJO in project Camera-Roll-Android-App by kollerlukas.
the class FileExplorerActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case android.R.id.home:
if (recyclerViewAdapter.isModeActive() || recyclerViewAdapter.getMode() == FileExplorerAdapter.PICK_TARGET_MODE) {
recyclerViewAdapter.cancelMode();
} else {
onBackPressed();
}
break;
case R.id.exclude:
currentDir.excluded = !currentDir.excluded;
item.setChecked(currentDir.excluded);
if (currentDir.excluded) {
FilesProvider.addExcludedPath(this, currentDir.getPath());
} else {
FilesProvider.removeExcludedPath(this, currentDir.getPath());
}
break;
case R.id.scan:
AsyncTask.execute(new Runnable() {
@Override
public void run() {
ArrayList<String> paths = FileOperation.Util.getAllChildPaths(new ArrayList<String>(), currentDir.getPath());
String[] pathsArray = new String[paths.size()];
paths.toArray(pathsArray);
FileOperation.Util.scanPathsWithNotification(FileExplorerActivity.this, pathsArray);
}
});
break;
case R.id.add_to_virtual_album:
String path = currentDir.getPath();
AlertDialog dialog = VirtualAlbum.Util.getAddToVirtualAlbumDialog(this, path);
dialog.show();
break;
case R.id.paste:
if (!currentDir.getPath().equals(STORAGE_ROOTS)) {
recyclerViewAdapter.cancelMode();
if (fileOpIntent != null) {
File_POJO target = recyclerViewAdapter.getFiles();
fileOpIntent.putExtra(FileOperation.TARGET, target);
startService(fileOpIntent);
fileOpIntent = null;
}
} else {
Toast.makeText(this, R.string.paste_error, Toast.LENGTH_SHORT).show();
}
break;
case R.id.copy:
fileOpIntent = new Intent(this, Copy.class).setAction(FileOperation.Util.getActionString(this, FileOperation.COPY));
recyclerViewAdapter.cancelMode();
break;
case R.id.move:
fileOpIntent = new Intent(this, Move.class).setAction(FileOperation.Util.getActionString(this, FileOperation.MOVE));
recyclerViewAdapter.cancelMode();
break;
case R.id.delete:
fileOpIntent = new Intent(this, Delete.class).setAction(FileOperation.Util.getActionString(this, FileOperation.DELETE));
recyclerViewAdapter.cancelMode();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
use of us.koller.cameraroll.data.models.File_POJO in project Camera-Roll-Android-App by kollerlukas.
the class FileOperationDialogActivity method executeAction.
public void executeAction(File_POJO[] files, String target) {
int action = this.action.equals(ACTION_COPY) ? FileOperation.COPY : FileOperation.MOVE;
final Intent workIntent = FileOperation.getDefaultIntent(this, action, files);
workIntent.putExtra(FileOperation.TARGET, new File_POJO(target, false));
startService(workIntent);
}
use of us.koller.cameraroll.data.models.File_POJO in project Camera-Roll-Android-App by kollerlukas.
the class ItemActivity method deletePhoto.
public void deletePhoto() {
if (!MediaProvider.checkPermission(this)) {
return;
}
if (albumItem == null) {
return;
}
final File_POJO[] files = new File_POJO[] { new File_POJO(albumItem.getPath(), true) };
registerLocalBroadcastReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
unregisterLocalBroadcastReceiver(this);
switch(intent.getAction()) {
case FileOperation.RESULT_DONE:
String path = albumItem.getPath();
Intent i = new Intent(AlbumActivity.ALBUM_ITEM_REMOVED).putExtra(ALBUM_ITEM_PATH, path);
// notify AlbumActivity
LocalBroadcastManager.getInstance(ItemActivity.this).sendBroadcast(i);
/*ItemActivity.this.setResult(RESULT_OK);
finish();*/
album.getAlbumItems().remove(albumItem);
viewPager.getAdapter().notifyDataSetChanged();
if (album.getAlbumItems().size() == 0) {
ItemActivity.this.setResult(RESULT_OK);
finish();
return;
}
albumItem = album.getAlbumItems().get(viewPager.getCurrentItem());
ItemAdapter adapter = (ItemAdapter) viewPager.getAdapter();
ViewHolder viewHolder = adapter.findViewHolderByTag(albumItem.getPath());
onShowViewHolder(viewHolder);
break;
case FileOperation.FAILED:
// onBackPressed();
break;
default:
break;
}
}
});
startService(FileOperation.getDefaultIntent(this, FileOperation.DELETE, files));
}
Aggregations