Search in sources :

Example 1 with AlbumHolder

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());
            }
        }
    });
}
Also used : Context(android.content.Context) AlbumActivity(us.koller.cameraroll.ui.AlbumActivity) AlbumHolder(us.koller.cameraroll.adapter.main.viewHolder.AlbumHolder) SimpleAlbumHolder(us.koller.cameraroll.adapter.main.viewHolder.SimpleAlbumHolder) NestedRecyclerViewAlbumHolder(us.koller.cameraroll.adapter.main.viewHolder.NestedRecyclerViewAlbumHolder) Album(us.koller.cameraroll.data.models.Album) MainActivity(us.koller.cameraroll.ui.MainActivity) AlbumActivity(us.koller.cameraroll.ui.AlbumActivity) ThemeableActivity(us.koller.cameraroll.ui.ThemeableActivity) Activity(android.app.Activity) Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Aggregations

Activity (android.app.Activity)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 AlbumHolder (us.koller.cameraroll.adapter.main.viewHolder.AlbumHolder)1 NestedRecyclerViewAlbumHolder (us.koller.cameraroll.adapter.main.viewHolder.NestedRecyclerViewAlbumHolder)1 SimpleAlbumHolder (us.koller.cameraroll.adapter.main.viewHolder.SimpleAlbumHolder)1 Album (us.koller.cameraroll.data.models.Album)1 AlbumActivity (us.koller.cameraroll.ui.AlbumActivity)1 MainActivity (us.koller.cameraroll.ui.MainActivity)1 ThemeableActivity (us.koller.cameraroll.ui.ThemeableActivity)1