aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java29
-rw-r--r--app/src/main/res/values/strings.xml3
4 files changed, 38 insertions, 13 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
index b58c87ee..e001e632 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -125,6 +125,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private boolean mHasMoreComments;
private boolean loadMoreCommentsFailed;
private int mCommentBackgroundColor;
+ private float mScale;
private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment;
private CopyTextBottomSheetFragment mCopyTextBottomSheetFragment;
@@ -228,6 +229,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
isInitiallyLoadingFailed = false;
mHasMoreComments = false;
loadMoreCommentsFailed = false;
+ mScale = activity.getResources().getDisplayMetrics().density;
TypedValue typedValue = new TypedValue();
mActivity.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true);
@@ -498,6 +500,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
+ "-" + mPost.getId().substring(3) + ".jpg");
mActivity.startActivity(intent);
});
+
+ if (mPost.getPreviewWidth() <= 0 || mPost.getPreviewHeight() <= 0) {
+ ((PostDetailViewHolder) holder).mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ ((PostDetailViewHolder) holder).mImageView.getLayoutParams().height = (int) (400 * mScale);
+ }
break;
case Post.LINK_TYPE:
((PostDetailViewHolder) holder).mTypeTextView.setText("LINK");
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index ad9c215d..12d6ac8e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -9,6 +9,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
+import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
@@ -97,6 +98,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean canStartActivity = true;
private int mPostType;
private int mPostLayout;
+ private float mScale;
private boolean mDisplaySubredditName;
private boolean mVoteButtonsOnTheRight;
private boolean mNeedBlurNSFW;
@@ -126,6 +128,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mShowElapsedTime = showElapsedTime;
mShowDividerInCompactLayout = showDividerInCompactLayout;
mPostLayout = postLayout;
+ mScale = activity.getResources().getDisplayMetrics().density;
mGlide = Glide.with(mActivity.getApplicationContext());
mRedditDataRoomDatabase = redditDataRoomDatabase;
mUserDao = redditDataRoomDatabase.userDao();
@@ -170,7 +173,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
String authorPrefixed = "u/" + post.getAuthor();
final String postTime = post.getPostTime();
final String title = post.getTitle();
- final String permalink = post.getPermalink();
int voteType = post.getVoteType();
int gilded = post.getGilded();
boolean nsfw = post.isNSFW();
@@ -439,6 +441,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
+ "-" + id + ".jpg");
mActivity.startActivity(intent);
});
+
+ if (post.getPreviewWidth() <= 0 || post.getPreviewHeight() <= 0) {
+ ((PostViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ ((PostViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale);
+ }
break;
case Post.LINK_TYPE:
((PostViewHolder) holder).typeTextView.setText(R.string.link);
@@ -727,7 +734,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
String authorPrefixed = "u/" + post.getAuthor();
final String postTime = post.getPostTime();
final String title = post.getTitle();
- final String permalink = post.getPermalink();
int voteType = post.getVoteType();
int gilded = post.getGilded();
boolean nsfw = post.isNSFW();
@@ -1433,6 +1439,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).flairTextView.setVisibility(View.GONE);
((PostViewHolder) holder).linkTextView.setVisibility(View.GONE);
((PostViewHolder) holder).progressBar.setVisibility(View.GONE);
+ ((PostViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START);
+ ((PostViewHolder) holder).imageView.getLayoutParams().height = FrameLayout.LayoutParams.WRAP_CONTENT;
((PostViewHolder) holder).imageView.setVisibility(View.GONE);
((PostViewHolder) holder).playButtonImageView.setVisibility(View.GONE);
((PostViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java
index 435cce53..1d2e2e6f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java
@@ -141,15 +141,28 @@ public class ParsePost {
}
}
} else {
- //No preview link post
- int postType = Post.NO_PREVIEW_LINK_TYPE;
- post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis,
- title, previewUrl, thumbnailPreviewUrl, url, permalink, score, postType, voteType,
- gilded, nComments, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
- if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
- post.setSelfText("");
+ if (url.endsWith("jpg") || url.endsWith("png")) {
+ //Image post
+ int postType = Post.IMAGE_TYPE;
+
+ post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
+ formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink,
+ score, postType, voteType, gilded, nComments, flair, hidden, spoiler,
+ nsfw, stickied, archived, locked, saved, isCrosspost);
+
+ post.setPreviewWidth(previewWidth);
+ post.setPreviewHeight(previewHeight);
} else {
- post.setSelfText(Utils.modifyMarkdown(data.getString(JSONUtils.SELFTEXT_KEY).trim()));
+ //No preview link post
+ int postType = Post.NO_PREVIEW_LINK_TYPE;
+ post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis,
+ title, previewUrl, thumbnailPreviewUrl, url, permalink, score, postType, voteType,
+ gilded, nComments, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
+ post.setSelfText("");
+ } else {
+ post.setSelfText(Utils.modifyMarkdown(data.getString(JSONUtils.SELFTEXT_KEY).trim()));
+ }
}
}
} else {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 8ca45ac6..d95e7be9 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -419,7 +419,4 @@
<string name="save_comment">Save comment</string>
<string name="unsave_comment">Unsave comment</string>
-
- <!-- TODO: Remove or change this placeholder text -->
- <string name="hello_blank_fragment">Hello blank fragment</string>
</resources>