use of us.koller.cameraroll.data.models.File_POJO in project Camera-Roll-Android-App by kollerlukas.
the class AlbumActivity method deleteAlbumItems.
public void deleteAlbumItems(final AlbumItem[] selected_items, final int[] indices) {
File_POJO[] filesToDelete = new File_POJO[selected_items.length];
for (int i = 0; i < filesToDelete.length; i++) {
filesToDelete[i] = new File_POJO(selected_items[i].getPath(), true);
}
registerLocalBroadcastReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
switch(intent.getAction()) {
case FileOperation.RESULT_DONE:
unregisterLocalBroadcastReceiver(this);
break;
case FileOperation.FAILED:
String path = intent.getStringExtra(FileOperation.FILES);
for (int i = 0; i < selected_items.length; i++) {
if (selected_items[i].getPath().equals(path)) {
int index = indices[i];
if (index < album.getAlbumItems().size()) {
album.getAlbumItems().add(index, selected_items[i]);
} else {
album.getAlbumItems().add(selected_items[i]);
}
recyclerViewAdapter.notifyItemInserted(indices[i]);
break;
}
}
break;
default:
break;
}
}
});
startService(FileOperation.getDefaultIntent(this, FileOperation.DELETE, filesToDelete));
}
use of us.koller.cameraroll.data.models.File_POJO in project Camera-Roll-Android-App by kollerlukas.
the class ExcludePathsActivity method loadDirectory.
public void loadDirectory(final String path) {
final Snackbar snackbar = Snackbar.make(findViewById(R.id.root_view), getString(R.string.loading), Snackbar.LENGTH_INDEFINITE);
Util.showSnackbar(snackbar);
filesProvider = new FilesProvider(this);
final FilesProvider.Callback callback = new FilesProvider.Callback() {
@Override
public void onDirLoaded(final File_POJO dir) {
runOnUiThread(new Runnable() {
@Override
public void run() {
filesProvider.onDestroy();
snackbar.dismiss();
if (dir == null) {
return;
}
File_POJO currentDir = removeFiles(dir);
if (currentDir == null) {
return;
}
ExcludePathsActivity.this.currentDir = currentDir;
if (recyclerViewAdapter != null) {
recyclerViewAdapter.setFiles(currentDir);
recyclerViewAdapter.notifyDataSetChanged();
onPathChanged();
}
}
});
}
@Override
public void timeout() {
runOnUiThread(new Runnable() {
@Override
public void run() {
finish();
}
});
}
@Override
public void needPermission() {
runOnUiThread(new Runnable() {
@Override
public void run() {
finish();
}
});
}
};
filesProvider.loadDir(this, path, callback);
}
use of us.koller.cameraroll.data.models.File_POJO in project Camera-Roll-Android-App by kollerlukas.
the class FileExplorerAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
final File_POJO file = files.getChildren().get(position);
((FileHolder) holder).setFile(file);
((FileHolder) holder).setSelected(selected_items[position]);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mode == SELECTOR_MODE) {
onItemSelect(file);
} else if (file.isMedia) {
int index = file.getPath().lastIndexOf("/");
String path = file.getPath().substring(0, index);
// load Album
final Album album = new Album().setPath(path);
AlbumItem albumItem = AlbumItem.getInstance(file.getPath());
if (albumItem != null) {
album.getAlbumItems().add(albumItem);
}
if (albumItem != null) {
// create intent
Intent intent = new Intent(holder.itemView.getContext(), IntentReceiver.class).setAction(Intent.ACTION_VIEW).setData(albumItem.getUri(holder.itemView.getContext()));
holder.itemView.getContext().startActivity(intent);
}
} else {
// to keep the ripple animation
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
directoryChangeCallback.changeDir(file.getPath());
}
}, 300);
}
}
});
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
onItemSelect(file);
return true;
}
});
// clicking on folder icons also selects this item
holder.itemView.findViewById(R.id.folder_indicator).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onItemSelect(file);
}
});
}
use of us.koller.cameraroll.data.models.File_POJO in project Camera-Roll-Android-App by kollerlukas.
the class FileLoader method onFile.
@Override
public void onFile(Context context, File file) {
File_POJO file_pojo = new File_POJO(file.getPath(), MediaType.isMedia(file.getPath()));
dir_pojo.addChild(file_pojo);
}
use of us.koller.cameraroll.data.models.File_POJO in project Camera-Roll-Android-App by kollerlukas.
the class Copy method execute.
@Override
public void execute(Intent workIntent) {
File_POJO[] files = getFiles(workIntent);
File_POJO target = workIntent.getParcelableExtra(TARGET);
if (target == null) {
return;
}
int success_count = 0;
onProgress(success_count, files.length);
boolean copyingOntoRemovableStorage = Util.isOnRemovableStorage(target.getPath());
Uri treeUri = null;
if (copyingOntoRemovableStorage) {
treeUri = getTreeUri(workIntent, target.getPath());
if (treeUri == null) {
return;
}
}
for (int i = files.length - 1; i >= 0; i--) {
boolean result = copyFilesRecursively(getApplicationContext(), treeUri, files[i].getPath(), target.getPath(), true);
success_count += result ? 1 : 0;
onProgress(success_count, files.length);
}
if (success_count == 0) {
onProgress(success_count, files.length);
}
}
Aggregations