aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java4
3 files changed, 18 insertions, 16 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
index bdfb619f..19080f65 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
@@ -934,8 +934,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
Post.Preview preview = getSuitablePreview(mPost.getPreviews());
if (preview != null) {
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
+ int height = (int) (400 * mScale);
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
- ((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getLayoutParams().height = (int) (400 * mScale);
+ ((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getLayoutParams().height = height;
+ preview.setPreviewWidth(mImageViewWidth);
+ preview.setPreviewHeight(height);
} else {
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setRatio((float) preview.getPreviewHeight() / (float) preview.getPreviewWidth());
}
@@ -1475,29 +1478,29 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
previewIndex = 0;
}
preview = previews.get(previewIndex);
- if (preview.getPreviewWidth() * preview.getPreviewHeight() > 35_000_000) {
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) {
for (int i = previews.size() - 1; i >= 1; i--) {
preview = previews.get(i);
if (mImageViewWidth >= preview.getPreviewWidth()) {
- if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 35_000_000) {
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 10_000_000) {
return preview;
}
} else {
int height = mImageViewWidth / preview.getPreviewWidth() * preview.getPreviewHeight();
- if (mImageViewWidth * height <= 35_000_000) {
+ if (mImageViewWidth * height <= 10_000_000) {
return preview;
}
}
}
}
- if (preview.getPreviewWidth() * preview.getPreviewHeight() > 35_000_000) {
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) {
int divisor = 2;
do {
preview.setPreviewWidth(preview.getPreviewWidth() / divisor);
preview.setPreviewHeight(preview.getPreviewHeight() / divisor);
divisor *= 2;
- } while (preview.getPreviewWidth() * preview.getPreviewHeight() / divisor / divisor > 35_000_000);
+ } while (preview.getPreviewWidth() * preview.getPreviewHeight() / divisor / divisor > 10_000_000);
}
return preview;
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 15faf972..8064779f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -696,8 +696,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (preview != null) {
((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.VISIBLE);
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
+ int height = (int) (400 * mScale);
((PostWithPreviewTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
- ((PostWithPreviewTypeViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale);
+ ((PostWithPreviewTypeViewHolder) holder).imageView.getLayoutParams().height = height;
+ preview.setPreviewWidth(mImageViewWidth);
+ preview.setPreviewHeight(height);
} else {
((PostWithPreviewTypeViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
@@ -1047,29 +1050,29 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
previewIndex = 0;
}
preview = previews.get(previewIndex);
- if (preview.getPreviewWidth() * preview.getPreviewHeight() > 35_000_000) {
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) {
for (int i = previews.size() - 1; i >= 1; i--) {
preview = previews.get(i);
if (mImageViewWidth >= preview.getPreviewWidth()) {
- if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 35_000_000) {
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 10_000_000) {
return preview;
}
} else {
int height = mImageViewWidth / preview.getPreviewWidth() * preview.getPreviewHeight();
- if (mImageViewWidth * height <= 35_000_000) {
+ if (mImageViewWidth * height <= 10_000_000) {
return preview;
}
}
}
}
- if (preview.getPreviewWidth() * preview.getPreviewHeight() > 35_000_000) {
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) {
int divisor = 2;
do {
preview.setPreviewWidth(preview.getPreviewWidth() / divisor);
preview.setPreviewHeight(preview.getPreviewHeight() / divisor);
divisor *= 2;
- } while (preview.getPreviewWidth() * preview.getPreviewHeight() / divisor / divisor > 35_000_000);
+ } while (preview.getPreviewWidth() * preview.getPreviewHeight() / divisor / divisor > 10_000_000);
}
return preview;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
index c5aa3990..d6bced34 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
@@ -3,7 +3,6 @@ package ml.docilealligator.infinityforreddit.post;
import android.net.Uri;
import android.os.AsyncTask;
import android.text.Html;
-import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
@@ -242,9 +241,6 @@ public class ParsePost {
//Video post
JSONObject redditVideoObject = data.getJSONObject(JSONUtils.MEDIA_KEY).getJSONObject(JSONUtils.REDDIT_VIDEO_KEY);
int postType = Post.VIDEO_TYPE;
- if (!redditVideoObject.has(JSONUtils.HLS_URL_KEY)) {
- Log.i("afasd", "s " + redditVideoObject);
- }
String videoUrl = Html.fromHtml(redditVideoObject.getString(JSONUtils.HLS_URL_KEY)).toString();
String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY);