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()));
}
}
Aggregations