Search in sources :

Example 1 with Gif

use of us.koller.cameraroll.data.models.Gif in project Camera-Roll-Android-App by kollerlukas.

the class ItemAdapter method instantiateItem.

@NonNull
@Override
public Object instantiateItem(@NonNull final ViewGroup container, int position) {
    AlbumItem albumItem = album.getAlbumItems().get(position);
    ViewHolder viewHolder;
    if (albumItem instanceof Video) {
        viewHolder = new VideoViewHolder(albumItem, position);
    } else if (albumItem instanceof Gif) {
        viewHolder = new GifViewHolder(albumItem, position);
    } else if (albumItem instanceof RAWImage) {
        viewHolder = new RAWImageViewHolder(albumItem, position);
    } else {
        viewHolder = new PhotoViewHolder(albumItem, position);
    }
    viewHolders.add(viewHolder);
    View v = viewHolder.getView(container);
    container.addView(v);
    if (callback != null) {
        boolean b = callback.onInstantiateItem(viewHolder);
        if (!b) {
            callback = null;
        }
    }
    return v;
}
Also used : RAWImage(us.koller.cameraroll.data.models.RAWImage) PhotoViewHolder(us.koller.cameraroll.adapter.item.viewHolder.PhotoViewHolder) VideoViewHolder(us.koller.cameraroll.adapter.item.viewHolder.VideoViewHolder) RAWImageViewHolder(us.koller.cameraroll.adapter.item.viewHolder.RAWImageViewHolder) ViewHolder(us.koller.cameraroll.adapter.item.viewHolder.ViewHolder) GifViewHolder(us.koller.cameraroll.adapter.item.viewHolder.GifViewHolder) Gif(us.koller.cameraroll.data.models.Gif) Video(us.koller.cameraroll.data.models.Video) AlbumItem(us.koller.cameraroll.data.models.AlbumItem) RAWImageViewHolder(us.koller.cameraroll.adapter.item.viewHolder.RAWImageViewHolder) PhotoViewHolder(us.koller.cameraroll.adapter.item.viewHolder.PhotoViewHolder) VideoViewHolder(us.koller.cameraroll.adapter.item.viewHolder.VideoViewHolder) GifViewHolder(us.koller.cameraroll.adapter.item.viewHolder.GifViewHolder) View(android.view.View) NonNull(android.support.annotation.NonNull)

Example 2 with Gif

use of us.koller.cameraroll.data.models.Gif in project Camera-Roll-Android-App by kollerlukas.

the class ItemActivity method showInfoDialog.

public void showInfoDialog() {
    final InfoRecyclerViewAdapter adapter = new InfoRecyclerViewAdapter();
    boolean exifSupported = adapter.exifSupported(this, albumItem);
    final View rootView = LayoutInflater.from(this).inflate(R.layout.info_dialog_layout, (ViewGroup) findViewById(R.id.root_view), false);
    final View loadingBar = rootView.findViewById(R.id.progress_bar);
    loadingBar.setVisibility(View.VISIBLE);
    final View dialogLayout = rootView.findViewById(R.id.dialog_layout);
    dialogLayout.setVisibility(View.GONE);
    AlertDialog.Builder builder = new AlertDialog.Builder(this, theme.getDialogThemeRes()).setTitle(getString(R.string.info)).setView(rootView).setPositiveButton(R.string.done, null).setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            infoDialog = null;
        }
    });
    if (exifSupported && !view_only) {
        builder.setNeutralButton(R.string.edit_exif, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Intent intent = new Intent(ItemActivity.this, ExifEditorActivity.class);
                intent.putExtra(ExifEditorActivity.ALBUM_ITEM, albumItem);
                startActivity(intent);
            }
        });
    }
    infoDialog = builder.create();
    infoDialog.show();
    // noinspection ConstantConditions
    /*infoDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);*/
    boolean showColors = (albumItem instanceof Photo || albumItem instanceof Gif) && !view_only;
    adapter.retrieveData(albumItem, showColors, new InfoRecyclerViewAdapter.OnDataRetrievedCallback() {

        @Override
        public void onDataRetrieved() {
            ItemActivity.this.runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    RecyclerView recyclerView = rootView.findViewById(R.id.recyclerView);
                    LinearLayoutManager layoutManager = new LinearLayoutManager(ItemActivity.this);
                    recyclerView.setLayoutManager(layoutManager);
                    recyclerView.setAdapter(adapter);
                    final View scrollIndicatorTop = rootView.findViewById(R.id.scroll_indicator_top);
                    final View scrollIndicatorBottom = rootView.findViewById(R.id.scroll_indicator_bottom);
                    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

                        @Override
                        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                            super.onScrolled(recyclerView, dx, dy);
                            scrollIndicatorTop.setVisibility(recyclerView.canScrollVertically(-1) ? View.VISIBLE : View.INVISIBLE);
                            scrollIndicatorBottom.setVisibility(recyclerView.canScrollVertically(1) ? View.VISIBLE : View.INVISIBLE);
                        }
                    });
                    loadingBar.setVisibility(View.GONE);
                    dialogLayout.setVisibility(View.VISIBLE);
                }
            });
        }

        @Override
        public void failed() {
            Toast.makeText(getContext(), R.string.error, Toast.LENGTH_SHORT).show();
        }

        @Override
        public Context getContext() {
            return ItemActivity.this;
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Context(android.content.Context) InfoRecyclerViewAdapter(us.koller.cameraroll.adapter.item.InfoRecyclerViewAdapter) DialogInterface(android.content.DialogInterface) Gif(us.koller.cameraroll.data.models.Gif) Intent(android.content.Intent) Photo(us.koller.cameraroll.data.models.Photo) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

View (android.view.View)2 Gif (us.koller.cameraroll.data.models.Gif)2 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 NonNull (android.support.annotation.NonNull)1 AlertDialog (android.support.v7.app.AlertDialog)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ImageView (android.widget.ImageView)1 SubsamplingScaleImageView (com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView)1 InfoRecyclerViewAdapter (us.koller.cameraroll.adapter.item.InfoRecyclerViewAdapter)1 GifViewHolder (us.koller.cameraroll.adapter.item.viewHolder.GifViewHolder)1 PhotoViewHolder (us.koller.cameraroll.adapter.item.viewHolder.PhotoViewHolder)1 RAWImageViewHolder (us.koller.cameraroll.adapter.item.viewHolder.RAWImageViewHolder)1 VideoViewHolder (us.koller.cameraroll.adapter.item.viewHolder.VideoViewHolder)1 ViewHolder (us.koller.cameraroll.adapter.item.viewHolder.ViewHolder)1 AlbumItem (us.koller.cameraroll.data.models.AlbumItem)1 Photo (us.koller.cameraroll.data.models.Photo)1 RAWImage (us.koller.cameraroll.data.models.RAWImage)1