aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java65
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java21
-rw-r--r--app/src/main/res/layout/item_post_detail_gallery.xml3
-rw-r--r--app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml3
-rw-r--r--app/src/main/res/layout/item_post_detail_link.xml3
-rw-r--r--app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml3
-rw-r--r--app/src/main/res/layout/item_post_detail_video_autoplay.xml1
7 files changed, 78 insertions, 21 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index 7c9814f0..d929aa0d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -15,7 +15,6 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -40,6 +39,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.load.DataSource;
+import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
@@ -816,7 +816,13 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostWithPreviewTypeViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder);
+ ((PostWithPreviewTypeViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ ((PostWithPreviewTypeViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
+ loadImage(holder);
+ }
+ });
} else {
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE);
if (post.getPostType() == Post.VIDEO_TYPE) {
@@ -970,7 +976,13 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCard2WithPreviewViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder);
+ ((PostCard2WithPreviewViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ ((PostCard2WithPreviewViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
+ loadImage(holder);
+ }
+ });
} else {
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
@@ -1348,7 +1360,13 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder);
+ ((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ ((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
+ loadImage(holder);
+ }
+ });
} else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
if (post.getPostType() == Post.VIDEO_TYPE) {
@@ -1382,7 +1400,13 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder);
+ ((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ ((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
+ loadImage(holder);
+ }
+ });
} else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
@@ -1406,7 +1430,13 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder);
+ ((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ ((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
+ loadImage(holder);
+ }
+ });
} else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_outline_video_24dp);
@@ -1430,7 +1460,13 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder);
+ ((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ ((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
+ loadImage(holder);
+ }
+ });
} else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
@@ -1464,7 +1500,13 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder);
+ ((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ ((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
+ loadImage(holder);
+ }
+ });
} else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp);
@@ -1514,12 +1556,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
url = preview.getPreviewUrl();
}
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(((PostWithPreviewTypeViewHolder) holder).glideRequestListener);
-
+ if (post.getAuthor().startsWith("GLIBG10")) {
+ Log.i("sssssaffd", "s " + url + " " + ((PostWithPreviewTypeViewHolder) holder).imageView.getRatio());
+ }
if (blurImage) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostWithPreviewTypeViewHolder) holder).imageView);
} else {
- imageRequestBuilder.downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostWithPreviewTypeViewHolder) holder).imageView);
+ imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostWithPreviewTypeViewHolder) holder).imageView);
}
}
} else if (holder instanceof PostCompactBaseViewHolder) {
@@ -1756,7 +1800,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
- super.onViewRecycled(holder);
if (holder instanceof PostBaseViewHolder) {
if (mMarkPostsAsReadOnScroll) {
int position = ((PostBaseViewHolder) holder).currentPosition;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java
index 499e92b2..ff7df783 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java
@@ -34,7 +34,6 @@ public class AspectRatioGifImageView extends GifImageView {
this.ratio = a.getFloat(com.santalu.aspectratioimageview.R.styleable.AspectRatioImageView_ari_ratio, 1.0F);
a.recycle();
}
-
}
@Override
@@ -52,4 +51,24 @@ public class AspectRatioGifImageView extends GifImageView {
this.setMeasuredDimension(width, height);
}
}
+
+ /*@Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+ int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+ int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+
+ int desiredHeight = (int) (widthSize * ratio);
+ int selectedHeight;
+
+ if(heightMode == MeasureSpec.EXACTLY) {
+ selectedHeight = heightSize;
+ } else if(heightMode == MeasureSpec.AT_MOST) {
+ selectedHeight = Math.min(heightSize, desiredHeight);
+ } else {
+ selectedHeight = desiredHeight;
+ }
+ super.onMeasure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(selectedHeight, MeasureSpec.EXACTLY));
+ }*/
}
diff --git a/app/src/main/res/layout/item_post_detail_gallery.xml b/app/src/main/res/layout/item_post_detail_gallery.xml
index 2b3ed1ef..a73e1965 100644
--- a/app/src/main/res/layout/item_post_detail_gallery.xml
+++ b/app/src/main/res/layout/item_post_detail_gallery.xml
@@ -216,8 +216,7 @@
android:id="@+id/image_view_item_post_detail_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:adjustViewBounds="true"
- android:scaleType="fitStart" />
+ android:adjustViewBounds="true" />
<ImageView
android:id="@+id/video_or_gif_indicator_image_view_item_post_detail"
diff --git a/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml b/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml
index fa135603..3f40a6e4 100644
--- a/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml
+++ b/app/src/main/res/layout/item_post_detail_image_and_gif_autoplay.xml
@@ -211,8 +211,7 @@
android:id="@+id/image_view_item_post_detail_image_and_gif_autoplay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:adjustViewBounds="true"
- android:scaleType="fitStart" />
+ android:adjustViewBounds="true" />
<RelativeLayout
android:id="@+id/load_wrapper_item_post_detail_image_and_gif_autoplay"
diff --git a/app/src/main/res/layout/item_post_detail_link.xml b/app/src/main/res/layout/item_post_detail_link.xml
index 076766d0..26d4479d 100644
--- a/app/src/main/res/layout/item_post_detail_link.xml
+++ b/app/src/main/res/layout/item_post_detail_link.xml
@@ -221,8 +221,7 @@
android:id="@+id/image_view_item_post_detail_link"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:adjustViewBounds="true"
- android:scaleType="fitStart" />
+ android:adjustViewBounds="true" />
<RelativeLayout
android:id="@+id/load_wrapper_item_post_detail_link"
diff --git a/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml b/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml
index 846a2c10..44197b8d 100644
--- a/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml
+++ b/app/src/main/res/layout/item_post_detail_video_and_gif_preview.xml
@@ -213,8 +213,7 @@
android:id="@+id/image_view_item_post_detail_video_and_gif_preview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:adjustViewBounds="true"
- android:scaleType="fitStart" />
+ android:adjustViewBounds="true" />
<ImageView
android:id="@+id/video_or_gif_indicator_image_view_item_post_detail"
diff --git a/app/src/main/res/layout/item_post_detail_video_autoplay.xml b/app/src/main/res/layout/item_post_detail_video_autoplay.xml
index aa3a3662..c23d3af8 100644
--- a/app/src/main/res/layout/item_post_detail_video_autoplay.xml
+++ b/app/src/main/res/layout/item_post_detail_video_autoplay.xml
@@ -221,7 +221,6 @@
android:id="@+id/preview_image_view_item_post_detail_video_autoplay"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:scaleType="fitStart"
android:visibility="gone" />
<ImageView