Search in sources :

Example 1 with GalleryImage

use of me.ccrama.redditslide.Activities.GalleryImage in project Slide by ccrama.

the class RedditGalleryView method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder2, int i) {
    if (holder2 instanceof AlbumViewHolder) {
        final int position = paddingBottom ? i : i - 1;
        AlbumViewHolder holder = (AlbumViewHolder) holder2;
        final GalleryImage image = images.get(position);
        ((Reddit) main.getApplicationContext()).getImageLoader().displayImage(image.url, holder.image, ImageGridAdapter.options);
        holder.body.setVisibility(View.VISIBLE);
        holder.text.setVisibility(View.VISIBLE);
        View imageView = holder.image;
        if (imageView.getWidth() == 0) {
            holder.image.setLayoutParams(new LinearLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
        } else {
            holder.image.setLayoutParams(new LinearLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, (int) getHeightFromAspectRatio(image.height, image.width, imageView.getWidth())));
        }
        {
            int type = new FontPreferences(holder.body.getContext()).getFontTypeComment().getTypeface();
            Typeface typeface;
            if (type >= 0) {
                typeface = RobotoTypefaces.obtainTypeface(holder.body.getContext(), type);
            } else {
                typeface = Typeface.DEFAULT;
            }
            holder.body.setTypeface(typeface);
        }
        {
            int type = new FontPreferences(holder.body.getContext()).getFontTypeTitle().getTypeface();
            Typeface typeface;
            if (type >= 0) {
                typeface = RobotoTypefaces.obtainTypeface(holder.body.getContext(), type);
            } else {
                typeface = Typeface.DEFAULT;
            }
            holder.text.setTypeface(typeface);
        }
        holder.text.setVisibility(View.GONE);
        holder.body.setVisibility(View.GONE);
        View.OnClickListener onGifImageClickListener = new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                if (SettingValues.image) {
                    Intent myIntent = new Intent(main, MediaView.class);
                    myIntent.putExtra(MediaView.EXTRA_URL, image.url);
                    myIntent.putExtra(MediaView.SUBREDDIT, subreddit);
                    if (submissionTitle != null) {
                        myIntent.putExtra(EXTRA_SUBMISSION_TITLE, submissionTitle);
                    }
                    myIntent.putExtra("index", position);
                    main.startActivity(myIntent);
                } else {
                    LinkUtil.openExternally(image.url);
                }
            }
        };
        holder.itemView.setOnClickListener(onGifImageClickListener);
    } else if (holder2 instanceof SpacerViewHolder) {
        holder2.itemView.findViewById(R.id.height).setLayoutParams(new LinearLayout.LayoutParams(holder2.itemView.getWidth(), paddingBottom ? height : main.findViewById(R.id.toolbar).getHeight()));
    }
}
Also used : Typeface(android.graphics.Typeface) Intent(android.content.Intent) GridView(android.widget.GridView) MediaView(me.ccrama.redditslide.Activities.MediaView) ImageView(android.widget.ImageView) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) FontPreferences(me.ccrama.redditslide.Visuals.FontPreferences) LinearLayout(android.widget.LinearLayout) GalleryImage(me.ccrama.redditslide.Activities.GalleryImage)

Aggregations

Intent (android.content.Intent)1 Typeface (android.graphics.Typeface)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 GalleryImage (me.ccrama.redditslide.Activities.GalleryImage)1 MediaView (me.ccrama.redditslide.Activities.MediaView)1 SpoilerRobotoTextView (me.ccrama.redditslide.SpoilerRobotoTextView)1 FontPreferences (me.ccrama.redditslide.Visuals.FontPreferences)1