diff options
author | Alex Ning <chineseperson5@gmail.com> | 2018-10-05 06:28:14 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2018-10-05 06:28:14 +0000 |
commit | 11ac14a3f13c893ff9cd98d01abe586a3c794bd9 (patch) | |
tree | cc023d25648ad015f7dbdb85a42e4ec6333c92d5 /app/src/main/java/ml | |
parent | b4a3e8b82250762b810889db5197800054507d7a (diff) | |
download | infinity-for-reddit-11ac14a3f13c893ff9cd98d01abe586a3c794bd9.tar infinity-for-reddit-11ac14a3f13c893ff9cd98d01abe586a3c794bd9.tar.gz infinity-for-reddit-11ac14a3f13c893ff9cd98d01abe586a3c794bd9.tar.bz2 infinity-for-reddit-11ac14a3f13c893ff9cd98d01abe586a3c794bd9.tar.lz infinity-for-reddit-11ac14a3f13c893ff9cd98d01abe586a3c794bd9.tar.xz infinity-for-reddit-11ac14a3f13c893ff9cd98d01abe586a3c794bd9.tar.zst infinity-for-reddit-11ac14a3f13c893ff9cd98d01abe586a3c794bd9.zip |
Display a crosspost icon if the post is a crosspost. Hide the thumbtack icon if the post is not viewed in its subreddit. Tweak the post layout. Minor bugs fixed.
Diffstat (limited to 'app/src/main/java/ml')
6 files changed, 80 insertions, 57 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index 606126fe..e6f705a8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -33,14 +33,13 @@ import de.hdodenhof.circleimageview.CircleImageView; public class MainActivity extends AppCompatActivity { - private static final String FRAGMENT_OUT_STATE_KEY = "FOSK"; - - private String nameState = "NS"; - private String profileImageUrlState = "PIUS"; - private String bannerImageUrlState = "BIUS"; - private String karmaState = "KS"; - private String fetchUserInfoState = "FUIS"; - private String insertSubscribedSubredditState = "ISSS"; + private static final String FRAGMENT_OUT_STATE = "FOS"; + private static final String NAME_STATE = "NS"; + private static final String PROFILE_IMAGE_URL_STATE = "PIUS"; + private static final String BANNER_IMAGE_URL_STATE = "BIUS"; + private static final String KARMA_STATE = "KS"; + private static final String FETCH_USER_INFO_STATE = "FUIS"; + private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS"; private TextView mNameTextView; private TextView mKarmaTextView; @@ -87,7 +86,7 @@ public class MainActivity extends AppCompatActivity { mFragment.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_content_main, mFragment).commit(); } else { - mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE_KEY); + mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_content_main, mFragment).commit(); } @@ -290,25 +289,25 @@ public class MainActivity extends AppCompatActivity { protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if(mFragment != null) { - getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE_KEY, mFragment); + getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment); } - outState.putString(nameState, mName); - outState.putString(profileImageUrlState, mProfileImageUrl); - outState.putString(bannerImageUrlState, mBannerImageUrl); - outState.putString(karmaState, mKarma); - outState.putBoolean(fetchUserInfoState, mFetchUserInfoSuccess); - outState.putBoolean(insertSubscribedSubredditState, mInsertSuccess); + outState.putString(NAME_STATE, mName); + outState.putString(PROFILE_IMAGE_URL_STATE, mProfileImageUrl); + outState.putString(BANNER_IMAGE_URL_STATE, mBannerImageUrl); + outState.putString(KARMA_STATE, mKarma); + outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess); + outState.putBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE, mInsertSuccess); } @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); - mName = savedInstanceState.getString(nameState); - mProfileImageUrl = savedInstanceState.getString(profileImageUrlState); - mBannerImageUrl = savedInstanceState.getString(bannerImageUrlState); - mKarma = savedInstanceState.getString(karmaState); - mFetchUserInfoSuccess = savedInstanceState.getBoolean(fetchUserInfoState); - mInsertSuccess = savedInstanceState.getBoolean(insertSubscribedSubredditState); + mName = savedInstanceState.getString(NAME_STATE); + mProfileImageUrl = savedInstanceState.getString(PROFILE_IMAGE_URL_STATE); + mBannerImageUrl = savedInstanceState.getString(BANNER_IMAGE_URL_STATE); + mKarma = savedInstanceState.getString(KARMA_STATE); + mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE); + mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE); mNameTextView.setText(mName); mKarmaTextView.setText(mKarma); if(!mProfileImageUrl.equals("")) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java index 381f8044..4330afe3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java @@ -91,10 +91,10 @@ class ParsePost { //Cross post data = data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0); parseData(data, permalink, newPostData, id, fullName, subredditNamePrefixed, - formattedPostTime, title, previewUrl, score, voteType, gilded, nsfw, stickied, i); + formattedPostTime, title, previewUrl, score, voteType, gilded, nsfw, stickied, true, i); } else { parseData(data, permalink, newPostData, id, fullName, subredditNamePrefixed, - formattedPostTime, title, previewUrl, score, voteType, gilded, nsfw, stickied, i); + formattedPostTime, title, previewUrl, score, voteType, gilded, nsfw, stickied, false, i); } } } catch (JSONException e) { @@ -118,7 +118,7 @@ class ParsePost { private static void parseData(JSONObject data, String permalink, ArrayList<PostData> bestPostData, String id, String fullName, String subredditNamePrefixed, String formattedPostTime, String title, String previewUrl, int score, int voteType, int gilded, - boolean nsfw, boolean stickied, int i) throws JSONException { + boolean nsfw, boolean stickied, boolean isCrosspost, int i) throws JSONException { boolean isVideo = data.getBoolean(JSONUtils.IS_VIDEO_KEY); String url = data.getString(JSONUtils.URL_KEY); @@ -128,7 +128,7 @@ class ParsePost { Log.i("text", Integer.toString(i)); int postType = PostData.TEXT_TYPE; PostData postData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, - title, permalink, score, postType, voteType, gilded, nsfw, stickied); + title, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost); if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { postData.setSelfText(""); } else { @@ -140,7 +140,7 @@ class ParsePost { Log.i("no preview link", Integer.toString(i)); int postType = PostData.NO_PREVIEW_LINK_TYPE; PostData linkPostData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, - title, previewUrl, url, permalink, score, postType, voteType, gilded, nsfw, stickied); + title, previewUrl, url, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost); if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { linkPostData.setSelfText(""); } else { @@ -156,7 +156,7 @@ class ParsePost { String videoUrl = redditVideoObject.getString(JSONUtils.DASH_URL_KEY); PostData videoPostData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, - title, previewUrl, permalink, score, postType, voteType, gilded, nsfw, stickied, true); + title, previewUrl, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost, true); videoPostData.setVideoUrl(videoUrl); videoPostData.setDownloadableGifOrVideo(false); @@ -171,7 +171,7 @@ class ParsePost { String videoUrl = variations.getJSONObject(JSONUtils.VARIANTS_KEY).getJSONObject(JSONUtils.MP4_KEY).getJSONObject(JSONUtils.SOURCE_KEY).getString(JSONUtils.URL_KEY); String gifDownloadUrl = variations.getJSONObject(JSONUtils.VARIANTS_KEY).getJSONObject(JSONUtils.GIF_KEY).getJSONObject(JSONUtils.SOURCE_KEY).getString(JSONUtils.URL_KEY); PostData post = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, title, - previewUrl, permalink, score, postType, voteType, gilded, nsfw, stickied, false); + previewUrl, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost, false); post.setVideoUrl(videoUrl); post.setDownloadableGifOrVideo(true); @@ -186,7 +186,7 @@ class ParsePost { .getJSONObject(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY).getString(JSONUtils.DASH_URL_KEY); PostData post = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, title, - previewUrl, permalink, score, postType, voteType, gilded, nsfw, stickied, true); + previewUrl, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost, true); post.setVideoUrl(videoUrl); post.setDownloadableGifOrVideo(false); @@ -198,13 +198,13 @@ class ParsePost { Log.i("image", Integer.toString(i)); int postType = PostData.IMAGE_TYPE; bestPostData.add(new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, - title, url, url, permalink, score, postType, voteType, gilded, nsfw, stickied)); + title, url, url, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost)); } else { //Link post Log.i("link", Integer.toString(i)); int postType = PostData.LINK_TYPE; PostData linkPostData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, - title, previewUrl, url, permalink, score, postType, voteType, gilded, nsfw, stickied); + title, previewUrl, url, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost); if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { linkPostData.setSelfText(""); } else { @@ -219,13 +219,13 @@ class ParsePost { Log.i("CP no preview image", Integer.toString(i)); int postType = PostData.IMAGE_TYPE; bestPostData.add(new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, title, - url, url, permalink, score, postType, voteType, gilded, nsfw, stickied)); + url, url, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost)); } else { //Link post Log.i("CP no preview link", Integer.toString(i)); int postType = PostData.LINK_TYPE; PostData linkPostData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, - title, previewUrl, url, permalink, score, postType, voteType, gilded, nsfw, stickied); + title, previewUrl, url, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost); bestPostData.add(linkPostData); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostData.java index 93b8d832..289ca083 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostData.java @@ -33,12 +33,14 @@ class PostData implements Parcelable { private int gilded; private boolean nsfw; private boolean stickied; + private boolean isCrosspost; private boolean isDashVideo; private boolean isDownloadableGifOrVideo; + private PostData crosspostParentPostData; PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title, String previewUrl, String permalink, int score, int postType, int voteType, int gilded, - boolean nsfw, boolean stickied, boolean isDashVideo) { + boolean nsfw, boolean stickied, boolean isCrosspost, boolean isDashVideo) { this.id = id; this.fullName = fullName; this.subredditNamePrefixed = subredditNamePrefixed; @@ -52,12 +54,13 @@ class PostData implements Parcelable { this.gilded = gilded; this.nsfw = nsfw; this.stickied = stickied; + this.isCrosspost = isCrosspost; this.isDashVideo = isDashVideo; } PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title, String previewUrl, String url, String permalink, int score, int postType, int voteType, - int gilded, boolean nsfw, boolean stickied) { + int gilded, boolean nsfw, boolean stickied, boolean isCrosspost) { this.id = id; this.fullName = fullName; this.subredditNamePrefixed = subredditNamePrefixed; @@ -72,11 +75,12 @@ class PostData implements Parcelable { this.gilded = gilded; this.nsfw = nsfw; this.stickied = stickied; + this.isCrosspost = isCrosspost; } PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title, String permalink, int score, int postType, int voteType, int gilded, boolean nsfw, - boolean stickied) { + boolean stickied, boolean isCrosspost) { this.id = id; this.fullName = fullName; this.subredditNamePrefixed = subredditNamePrefixed; @@ -89,6 +93,7 @@ class PostData implements Parcelable { this.gilded = gilded; this.nsfw = nsfw; this.stickied = stickied; + this.isCrosspost= isCrosspost; } protected PostData(Parcel in) { @@ -110,6 +115,7 @@ class PostData implements Parcelable { gilded = in.readInt(); nsfw = in.readByte() != 0; stickied = in.readByte() != 0; + isCrosspost = in.readByte() != 0; isDashVideo = in.readByte() != 0; isDownloadableGifOrVideo = in.readByte() != 0; } @@ -243,6 +249,10 @@ class PostData implements Parcelable { return stickied; } + public boolean isCrosspost() { + return isCrosspost; + } + @Override public void writeToParcel(Parcel parcel, int i) { parcel.writeString(id); @@ -263,6 +273,7 @@ class PostData implements Parcelable { parcel.writeInt(gilded); parcel.writeByte((byte) (nsfw ? 1 : 0)); parcel.writeByte((byte) (stickied ? 1 : 0)); + parcel.writeByte((byte) (isCrosspost ? 1 : 0)); parcel.writeByte((byte) (isDashVideo ? 1 : 0)); parcel.writeByte((byte) (isDownloadableGifOrVideo ? 1 : 0)); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java index afad78ca..0dd4b50f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java @@ -127,7 +127,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { }); mPaginationSynchronizer.setLoadSuccess(savedInstanceState.getBoolean(LOAD_SUCCESS_STATE)); mPaginationSynchronizer.setLoadingState(savedInstanceState.getBoolean(LOADING_STATE_STATE)); - PostRecyclerViewAdapter adapter = new PostRecyclerViewAdapter(getActivity(), mPostData, mPaginationSynchronizer); + PostRecyclerViewAdapter adapter = new PostRecyclerViewAdapter(getActivity(), mPostData, mPaginationSynchronizer, mIsBestPost); mPostRecyclerView.setAdapter(adapter); mPostRecyclerView.addOnScrollListener(new PostPaginationScrollListener( getActivity(), mLinearLayoutManager, adapter, mLastItem, mPostData, @@ -187,7 +187,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if(isAdded() && getActivity() != null) { mPostData = postData; mLastItem = lastItem; - PostRecyclerViewAdapter adapter = new PostRecyclerViewAdapter(getActivity(), postData, mPaginationSynchronizer); + PostRecyclerViewAdapter adapter = new PostRecyclerViewAdapter(getActivity(), postData, mPaginationSynchronizer, mIsBestPost); mPostRecyclerView.setAdapter(adapter); mPostRecyclerView.addOnScrollListener(new PostPaginationScrollListener( @@ -259,7 +259,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if(isAdded() && getActivity() != null) { mPostData = postData; mLastItem = lastItem; - PostRecyclerViewAdapter adapter = new PostRecyclerViewAdapter(getActivity(), postData, mPaginationSynchronizer); + PostRecyclerViewAdapter adapter = new PostRecyclerViewAdapter(getActivity(), postData, mPaginationSynchronizer, mIsBestPost); mPostRecyclerView.setAdapter(adapter); mPostRecyclerView.addOnScrollListener(new PostPaginationScrollListener( diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java index d9b6c146..d3075ee0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java @@ -9,6 +9,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.customtabs.CustomTabsIntent; import android.support.v4.content.ContextCompat; +import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; @@ -46,20 +47,20 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold private PaginationSynchronizer mPaginationSynchronizer; private RequestManager glide; private SubredditDao subredditDao; - private boolean isLoadingMorePostSuccess; - private boolean canStartActivity; + private boolean isLoadingMorePostSuccess = true; + private boolean canStartActivity = true; + private boolean hasMultipleSubreddits; private static final int VIEW_TYPE_DATA = 0; private static final int VIEW_TYPE_LOADING = 1; - PostRecyclerViewAdapter(Context context, ArrayList<PostData> postData, PaginationSynchronizer paginationSynchronizer) { + PostRecyclerViewAdapter(Context context, ArrayList<PostData> postData, PaginationSynchronizer paginationSynchronizer, boolean hasMultipleSubreddits) { if(context != null) { mContext = context; mPostData = postData; mPaginationSynchronizer = paginationSynchronizer; - isLoadingMorePostSuccess = true; - canStartActivity = true; + this.hasMultipleSubreddits = hasMultipleSubreddits; glide = Glide.with(mContext); subredditDao = SubredditRoomDatabase.getDatabase(mContext).subredditDao(); } @@ -73,8 +74,8 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { if(viewType == VIEW_TYPE_DATA) { - LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post, parent, false); - return new DataViewHolder(linearLayout); + CardView cardView = (CardView) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post, parent, false); + return new DataViewHolder(cardView); } else { LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_progress_bar, parent, false); return new LoadingViewHolder(linearLayout); @@ -121,7 +122,7 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold glide.load(R.drawable.subreddit_default_icon).into(((DataViewHolder) holder).subredditIconCircleImageView); } - ((DataViewHolder) holder).linearLayout.setOnClickListener(new View.OnClickListener() { + ((DataViewHolder) holder).cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(canStartActivity) { @@ -201,11 +202,15 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold loadImage(holder, mPostData.get(holder.getAdapterPosition())); } - if(mPostData.get(position).isStickied()) { + if(!hasMultipleSubreddits && mPostData.get(position).isStickied()) { ((DataViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE); glide.load(R.drawable.thumbtack).into(((DataViewHolder) holder).stickiedPostImageView); } + if(mPostData.get(holder.getAdapterPosition()).isCrosspost()) { + ((DataViewHolder) holder).crosspostImageView.setVisibility(View.VISIBLE); + } + switch (mPostData.get(position).getPostType()) { case PostData.IMAGE_TYPE: ((DataViewHolder) holder).typeTextView.setText("IMAGE"); @@ -334,7 +339,7 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold ((DataViewHolder) holder).scoreTextView.setText(Integer.toString(mPostData.get(position).getScore())); ((DataViewHolder) holder).downvoteButton.setColorFilter(downvoteButtonColorFilter); } - }, id, RedditUtils.DIR_UPVOTE, ((DataViewHolder) holder).getAdapterPosition(), 1); + }, id, RedditUtils.DIR_UPVOTE, holder.getAdapterPosition(), 1); } else { //Upvoted before ((DataViewHolder) holder).upvoteButton.clearColorFilter(); @@ -354,7 +359,7 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold ((DataViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN); mPostData.get(position).setScore(mPostData.get(position).getScore() + 1); } - }, id, RedditUtils.DIR_UNVOTE, ((DataViewHolder) holder).getAdapterPosition(), 1); + }, id, RedditUtils.DIR_UNVOTE, holder.getAdapterPosition(), 1); } } }); @@ -507,7 +512,7 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold } class DataViewHolder extends RecyclerView.ViewHolder { - private LinearLayout linearLayout; + private CardView cardView; private CircleImageView subredditIconCircleImageView; private TextView subredditNameTextView; private ImageView stickiedPostImageView; @@ -516,6 +521,7 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold private TextView typeTextView; private ImageView gildedImageView; private TextView gildedNumberTextView; + private ImageView crosspostImageView; private TextView nsfwTextView; private RelativeLayout relativeLayout; private ProgressBar progressBar; @@ -527,9 +533,9 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold private ImageView downvoteButton; private ImageView shareButton; - DataViewHolder(LinearLayout itemView) { + DataViewHolder(View itemView) { super(itemView); - linearLayout = itemView.findViewById(R.id.linear_layout_view_post_detail); + cardView = itemView.findViewById(R.id.card_view_view_post_detail); subredditIconCircleImageView = itemView.findViewById(R.id.subreddit_icon_circle_image_view_best_post_item); subredditNameTextView = itemView.findViewById(R.id.subreddit_text_view_best_post_item); stickiedPostImageView = itemView.findViewById(R.id.stickied_post_image_view_best_post_item); @@ -538,6 +544,7 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold typeTextView = itemView.findViewById(R.id.type_text_view_item_best_post); gildedImageView = itemView.findViewById(R.id.gilded_image_view_item_best_post); gildedNumberTextView = itemView.findViewById(R.id.gilded_number_text_view_item_best_post); + crosspostImageView = itemView.findViewById(R.id.crosspost_image_view_item_best_post); nsfwTextView = itemView.findViewById(R.id.nsfw_text_view_item_best_post); relativeLayout = itemView.findViewById(R.id.image_view_wrapper_item_best_post); progressBar = itemView.findViewById(R.id.progress_bar_best_post_item); @@ -572,8 +579,9 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold glide.clear(((DataViewHolder) holder).subredditIconCircleImageView); ((DataViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE); ((DataViewHolder) holder).relativeLayout.setVisibility(View.GONE); + ((DataViewHolder) holder).gildedImageView.setVisibility(View.GONE); ((DataViewHolder) holder).gildedNumberTextView.setVisibility(View.GONE); - glide.clear(((DataViewHolder) holder).gildedImageView); + ((DataViewHolder) holder).crosspostImageView.setVisibility(View.GONE); ((DataViewHolder) holder).nsfwTextView.setVisibility(View.GONE); ((DataViewHolder) holder).progressBar.setVisibility(View.GONE); ((DataViewHolder) holder).imageView.setVisibility(View.GONE); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java index d5f401d1..b6195a11 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java @@ -87,6 +87,7 @@ public class ViewPostDetailActivity extends AppCompatActivity { TextView typeTextView = findViewById(R.id.type_text_view_view_post_detail); ImageView gildedImageView = findViewById(R.id.gilded_image_view_view_post_detail); TextView gildedNumberTextView = findViewById(R.id.gilded_number_text_view_view_post_detail); + ImageView crosspostImageView = findViewById(R.id.crosspost_image_view_view_post_detail); TextView nsfwTextView = findViewById(R.id.nsfw_text_view_view_post_detail); RelativeLayout relativeLayout = findViewById(R.id.image_view_wrapper_view_post_detail); mLoadWrapper = findViewById(R.id.load_wrapper_view_post_detail); @@ -181,6 +182,10 @@ public class ViewPostDetailActivity extends AppCompatActivity { }*/ } + if(mPostData.isCrosspost()) { + crosspostImageView.setVisibility(View.VISIBLE); + } + mRecyclerView.setNestedScrollingEnabled(false); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); @@ -242,7 +247,7 @@ public class ViewPostDetailActivity extends AppCompatActivity { break; case PostData.LINK_TYPE: typeTextView.setText("LINK"); - if(!mPostData.getSelfText().equals("")) { + if(mPostData.getSelfText() != null && !mPostData.getSelfText().equals("")) { contentTextView.setVisibility(View.VISIBLE); contentTextView.setHtml(mPostData.getSelfText()); } @@ -260,7 +265,7 @@ public class ViewPostDetailActivity extends AppCompatActivity { }); break; case PostData.GIF_VIDEO_TYPE: - typeTextView.setText("VIDEO"); + typeTextView.setText("GIF"); final Uri gifVideoUri = Uri.parse(mPostData.getVideoUrl()); mImageView.setOnClickListener(new View.OnClickListener() { |