use of us.koller.cameraroll.adapter.main.viewHolder.AlbumHolder in project Camera-Roll-Android-App by kollerlukas.
the class MainAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
final Album album = getData().get(position);
((AlbumHolder) holder).setAlbum(album);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(holder.itemView.getContext(), AlbumActivity.class);
// intent.putExtra(AlbumActivity.ALBUM, album);
intent.putExtra(AlbumActivity.ALBUM_PATH, album.getPath());
if (pickPhotos()) {
Context c = holder.itemView.getContext();
boolean allowMultiple = false;
if (c instanceof Activity) {
Activity a = (Activity) c;
allowMultiple = a.getIntent().getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false);
}
intent.setAction(MainActivity.PICK_PHOTOS);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, allowMultiple);
} else {
intent.setAction(AlbumActivity.VIEW_ALBUM);
}
ActivityOptionsCompat options;
Activity context = (Activity) holder.itemView.getContext();
if (!pickPhotos()) {
// noinspection unchecked
options = ActivityOptionsCompat.makeSceneTransitionAnimation(context);
context.startActivityForResult(intent, MainActivity.REFRESH_PHOTOS_REQUEST_CODE, options.toBundle());
} else {
View toolbar = context.findViewById(R.id.toolbar);
options = ActivityOptionsCompat.makeSceneTransitionAnimation(context, toolbar, context.getString(R.string.toolbar_transition_name));
context.startActivityForResult(intent, MainActivity.PICK_PHOTOS_REQUEST_CODE, options.toBundle());
}
}
});
}
Aggregations