use of us.koller.cameraroll.adapter.fileExplorer.viewHolder.FileHolder 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);
}
});
}
Aggregations