mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-14 06:22:50 +01:00
Maybe fix Canvas: drawing too large bitmap again.
This commit is contained in:
parent
6c3a8c9340
commit
c2abe90ba2
@ -934,8 +934,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
Post.Preview preview = getSuitablePreview(mPost.getPreviews());
|
Post.Preview preview = getSuitablePreview(mPost.getPreviews());
|
||||||
if (preview != null) {
|
if (preview != null) {
|
||||||
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
|
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
|
||||||
|
int height = (int) (400 * mScale);
|
||||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
((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 {
|
} else {
|
||||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setRatio((float) preview.getPreviewHeight() / (float) preview.getPreviewWidth());
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setRatio((float) preview.getPreviewHeight() / (float) preview.getPreviewWidth());
|
||||||
}
|
}
|
||||||
@ -1475,29 +1478,29 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
previewIndex = 0;
|
previewIndex = 0;
|
||||||
}
|
}
|
||||||
preview = previews.get(previewIndex);
|
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--) {
|
for (int i = previews.size() - 1; i >= 1; i--) {
|
||||||
preview = previews.get(i);
|
preview = previews.get(i);
|
||||||
if (mImageViewWidth >= preview.getPreviewWidth()) {
|
if (mImageViewWidth >= preview.getPreviewWidth()) {
|
||||||
if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 35_000_000) {
|
if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 10_000_000) {
|
||||||
return preview;
|
return preview;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int height = mImageViewWidth / preview.getPreviewWidth() * preview.getPreviewHeight();
|
int height = mImageViewWidth / preview.getPreviewWidth() * preview.getPreviewHeight();
|
||||||
if (mImageViewWidth * height <= 35_000_000) {
|
if (mImageViewWidth * height <= 10_000_000) {
|
||||||
return preview;
|
return preview;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preview.getPreviewWidth() * preview.getPreviewHeight() > 35_000_000) {
|
if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) {
|
||||||
int divisor = 2;
|
int divisor = 2;
|
||||||
do {
|
do {
|
||||||
preview.setPreviewWidth(preview.getPreviewWidth() / divisor);
|
preview.setPreviewWidth(preview.getPreviewWidth() / divisor);
|
||||||
preview.setPreviewHeight(preview.getPreviewHeight() / divisor);
|
preview.setPreviewHeight(preview.getPreviewHeight() / divisor);
|
||||||
divisor *= 2;
|
divisor *= 2;
|
||||||
} while (preview.getPreviewWidth() * preview.getPreviewHeight() / divisor / divisor > 35_000_000);
|
} while (preview.getPreviewWidth() * preview.getPreviewHeight() / divisor / divisor > 10_000_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return preview;
|
return preview;
|
||||||
|
@ -696,8 +696,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
if (preview != null) {
|
if (preview != null) {
|
||||||
((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.VISIBLE);
|
((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.VISIBLE);
|
||||||
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
|
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
|
||||||
|
int height = (int) (400 * mScale);
|
||||||
((PostWithPreviewTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
((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 {
|
} else {
|
||||||
((PostWithPreviewTypeViewHolder) holder).imageView
|
((PostWithPreviewTypeViewHolder) holder).imageView
|
||||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||||
@ -1047,29 +1050,29 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
previewIndex = 0;
|
previewIndex = 0;
|
||||||
}
|
}
|
||||||
preview = previews.get(previewIndex);
|
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--) {
|
for (int i = previews.size() - 1; i >= 1; i--) {
|
||||||
preview = previews.get(i);
|
preview = previews.get(i);
|
||||||
if (mImageViewWidth >= preview.getPreviewWidth()) {
|
if (mImageViewWidth >= preview.getPreviewWidth()) {
|
||||||
if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 35_000_000) {
|
if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 10_000_000) {
|
||||||
return preview;
|
return preview;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int height = mImageViewWidth / preview.getPreviewWidth() * preview.getPreviewHeight();
|
int height = mImageViewWidth / preview.getPreviewWidth() * preview.getPreviewHeight();
|
||||||
if (mImageViewWidth * height <= 35_000_000) {
|
if (mImageViewWidth * height <= 10_000_000) {
|
||||||
return preview;
|
return preview;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preview.getPreviewWidth() * preview.getPreviewHeight() > 35_000_000) {
|
if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) {
|
||||||
int divisor = 2;
|
int divisor = 2;
|
||||||
do {
|
do {
|
||||||
preview.setPreviewWidth(preview.getPreviewWidth() / divisor);
|
preview.setPreviewWidth(preview.getPreviewWidth() / divisor);
|
||||||
preview.setPreviewHeight(preview.getPreviewHeight() / divisor);
|
preview.setPreviewHeight(preview.getPreviewHeight() / divisor);
|
||||||
divisor *= 2;
|
divisor *= 2;
|
||||||
} while (preview.getPreviewWidth() * preview.getPreviewHeight() / divisor / divisor > 35_000_000);
|
} while (preview.getPreviewWidth() * preview.getPreviewHeight() / divisor / divisor > 10_000_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return preview;
|
return preview;
|
||||||
|
@ -3,7 +3,6 @@ package ml.docilealligator.infinityforreddit.post;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -242,9 +241,6 @@ public class ParsePost {
|
|||||||
//Video post
|
//Video post
|
||||||
JSONObject redditVideoObject = data.getJSONObject(JSONUtils.MEDIA_KEY).getJSONObject(JSONUtils.REDDIT_VIDEO_KEY);
|
JSONObject redditVideoObject = data.getJSONObject(JSONUtils.MEDIA_KEY).getJSONObject(JSONUtils.REDDIT_VIDEO_KEY);
|
||||||
int postType = Post.VIDEO_TYPE;
|
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 videoUrl = Html.fromHtml(redditVideoObject.getString(JSONUtils.HLS_URL_KEY)).toString();
|
||||||
String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY);
|
String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user