From c2abe90ba26c45173d91cbc77d80ccfd0a79bc40 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 18 Jan 2021 00:24:52 +0800 Subject: Maybe fix Canvas: drawing too large bitmap again. --- .../adapters/CommentAndPostRecyclerViewAdapter.java | 15 +++++++++------ .../adapters/PostRecyclerViewAdapter.java | 15 +++++++++------ .../docilealligator/infinityforreddit/post/ParsePost.java | 4 ---- 3 files changed, 18 insertions(+), 16 deletions(-) (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit') 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 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 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); -- cgit v1.2.3