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.

This commit is contained in:
Alex Ning 2018-10-05 14:28:14 +08:00
parent b4a3e8b822
commit 11ac14a3f1
11 changed files with 332 additions and 270 deletions

View File

@ -3,6 +3,11 @@
<component name="WizardSettings"> <component name="WizardSettings">
<option name="children"> <option name="children">
<map> <map>
<entry key="imageWizard">
<value>
<PersistentState />
</value>
</entry>
<entry key="vectorWizard"> <entry key="vectorWizard">
<value> <value>
<PersistentState> <PersistentState>

View File

@ -33,14 +33,13 @@ import de.hdodenhof.circleimageview.CircleImageView;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private static final String FRAGMENT_OUT_STATE_KEY = "FOSK"; private static final String FRAGMENT_OUT_STATE = "FOS";
private static final String NAME_STATE = "NS";
private String nameState = "NS"; private static final String PROFILE_IMAGE_URL_STATE = "PIUS";
private String profileImageUrlState = "PIUS"; private static final String BANNER_IMAGE_URL_STATE = "BIUS";
private String bannerImageUrlState = "BIUS"; private static final String KARMA_STATE = "KS";
private String karmaState = "KS"; private static final String FETCH_USER_INFO_STATE = "FUIS";
private String fetchUserInfoState = "FUIS"; private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS";
private String insertSubscribedSubredditState = "ISSS";
private TextView mNameTextView; private TextView mNameTextView;
private TextView mKarmaTextView; private TextView mKarmaTextView;
@ -87,7 +86,7 @@ public class MainActivity extends AppCompatActivity {
mFragment.setArguments(bundle); mFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_content_main, mFragment).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_content_main, mFragment).commit();
} else { } 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(); 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) { protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
if(mFragment != null) { if(mFragment != null) {
getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE_KEY, mFragment); getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment);
} }
outState.putString(nameState, mName); outState.putString(NAME_STATE, mName);
outState.putString(profileImageUrlState, mProfileImageUrl); outState.putString(PROFILE_IMAGE_URL_STATE, mProfileImageUrl);
outState.putString(bannerImageUrlState, mBannerImageUrl); outState.putString(BANNER_IMAGE_URL_STATE, mBannerImageUrl);
outState.putString(karmaState, mKarma); outState.putString(KARMA_STATE, mKarma);
outState.putBoolean(fetchUserInfoState, mFetchUserInfoSuccess); outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
outState.putBoolean(insertSubscribedSubredditState, mInsertSuccess); outState.putBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE, mInsertSuccess);
} }
@Override @Override
protected void onRestoreInstanceState(Bundle savedInstanceState) { protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState); super.onRestoreInstanceState(savedInstanceState);
mName = savedInstanceState.getString(nameState); mName = savedInstanceState.getString(NAME_STATE);
mProfileImageUrl = savedInstanceState.getString(profileImageUrlState); mProfileImageUrl = savedInstanceState.getString(PROFILE_IMAGE_URL_STATE);
mBannerImageUrl = savedInstanceState.getString(bannerImageUrlState); mBannerImageUrl = savedInstanceState.getString(BANNER_IMAGE_URL_STATE);
mKarma = savedInstanceState.getString(karmaState); mKarma = savedInstanceState.getString(KARMA_STATE);
mFetchUserInfoSuccess = savedInstanceState.getBoolean(fetchUserInfoState); mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
mInsertSuccess = savedInstanceState.getBoolean(insertSubscribedSubredditState); mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE);
mNameTextView.setText(mName); mNameTextView.setText(mName);
mKarmaTextView.setText(mKarma); mKarmaTextView.setText(mKarma);
if(!mProfileImageUrl.equals("")) { if(!mProfileImageUrl.equals("")) {

View File

@ -91,10 +91,10 @@ class ParsePost {
//Cross post //Cross post
data = data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0); data = data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0);
parseData(data, permalink, newPostData, id, fullName, subredditNamePrefixed, 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 { } else {
parseData(data, permalink, newPostData, id, fullName, subredditNamePrefixed, 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) { } catch (JSONException e) {
@ -118,7 +118,7 @@ class ParsePost {
private static void parseData(JSONObject data, String permalink, ArrayList<PostData> bestPostData, private static void parseData(JSONObject data, String permalink, ArrayList<PostData> bestPostData,
String id, String fullName, String subredditNamePrefixed, String formattedPostTime, String id, String fullName, String subredditNamePrefixed, String formattedPostTime,
String title, String previewUrl, int score, int voteType, int gilded, 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); boolean isVideo = data.getBoolean(JSONUtils.IS_VIDEO_KEY);
String url = data.getString(JSONUtils.URL_KEY); String url = data.getString(JSONUtils.URL_KEY);
@ -128,7 +128,7 @@ class ParsePost {
Log.i("text", Integer.toString(i)); Log.i("text", Integer.toString(i));
int postType = PostData.TEXT_TYPE; int postType = PostData.TEXT_TYPE;
PostData postData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, 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)) { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
postData.setSelfText(""); postData.setSelfText("");
} else { } else {
@ -140,7 +140,7 @@ class ParsePost {
Log.i("no preview link", Integer.toString(i)); Log.i("no preview link", Integer.toString(i));
int postType = PostData.NO_PREVIEW_LINK_TYPE; int postType = PostData.NO_PREVIEW_LINK_TYPE;
PostData linkPostData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, 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)) { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
linkPostData.setSelfText(""); linkPostData.setSelfText("");
} else { } else {
@ -156,7 +156,7 @@ class ParsePost {
String videoUrl = redditVideoObject.getString(JSONUtils.DASH_URL_KEY); String videoUrl = redditVideoObject.getString(JSONUtils.DASH_URL_KEY);
PostData videoPostData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, 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.setVideoUrl(videoUrl);
videoPostData.setDownloadableGifOrVideo(false); 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 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); 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, 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.setVideoUrl(videoUrl);
post.setDownloadableGifOrVideo(true); post.setDownloadableGifOrVideo(true);
@ -186,7 +186,7 @@ class ParsePost {
.getJSONObject(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY).getString(JSONUtils.DASH_URL_KEY); .getJSONObject(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY).getString(JSONUtils.DASH_URL_KEY);
PostData post = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, title, 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.setVideoUrl(videoUrl);
post.setDownloadableGifOrVideo(false); post.setDownloadableGifOrVideo(false);
@ -198,13 +198,13 @@ class ParsePost {
Log.i("image", Integer.toString(i)); Log.i("image", Integer.toString(i));
int postType = PostData.IMAGE_TYPE; int postType = PostData.IMAGE_TYPE;
bestPostData.add(new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, 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 { } else {
//Link post //Link post
Log.i("link", Integer.toString(i)); Log.i("link", Integer.toString(i));
int postType = PostData.LINK_TYPE; int postType = PostData.LINK_TYPE;
PostData linkPostData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, 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)) { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
linkPostData.setSelfText(""); linkPostData.setSelfText("");
} else { } else {
@ -219,13 +219,13 @@ class ParsePost {
Log.i("CP no preview image", Integer.toString(i)); Log.i("CP no preview image", Integer.toString(i));
int postType = PostData.IMAGE_TYPE; int postType = PostData.IMAGE_TYPE;
bestPostData.add(new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, title, 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 { } else {
//Link post //Link post
Log.i("CP no preview link", Integer.toString(i)); Log.i("CP no preview link", Integer.toString(i));
int postType = PostData.LINK_TYPE; int postType = PostData.LINK_TYPE;
PostData linkPostData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime, 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); bestPostData.add(linkPostData);
} }
} }

View File

@ -33,12 +33,14 @@ class PostData implements Parcelable {
private int gilded; private int gilded;
private boolean nsfw; private boolean nsfw;
private boolean stickied; private boolean stickied;
private boolean isCrosspost;
private boolean isDashVideo; private boolean isDashVideo;
private boolean isDownloadableGifOrVideo; private boolean isDownloadableGifOrVideo;
private PostData crosspostParentPostData;
PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title, PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title,
String previewUrl, String permalink, int score, int postType, int voteType, int gilded, 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.id = id;
this.fullName = fullName; this.fullName = fullName;
this.subredditNamePrefixed = subredditNamePrefixed; this.subredditNamePrefixed = subredditNamePrefixed;
@ -52,12 +54,13 @@ class PostData implements Parcelable {
this.gilded = gilded; this.gilded = gilded;
this.nsfw = nsfw; this.nsfw = nsfw;
this.stickied = stickied; this.stickied = stickied;
this.isCrosspost = isCrosspost;
this.isDashVideo = isDashVideo; this.isDashVideo = isDashVideo;
} }
PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title, PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title,
String previewUrl, String url, String permalink, int score, int postType, int voteType, 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.id = id;
this.fullName = fullName; this.fullName = fullName;
this.subredditNamePrefixed = subredditNamePrefixed; this.subredditNamePrefixed = subredditNamePrefixed;
@ -72,11 +75,12 @@ class PostData implements Parcelable {
this.gilded = gilded; this.gilded = gilded;
this.nsfw = nsfw; this.nsfw = nsfw;
this.stickied = stickied; this.stickied = stickied;
this.isCrosspost = isCrosspost;
} }
PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title, PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title,
String permalink, int score, int postType, int voteType, int gilded, boolean nsfw, String permalink, int score, int postType, int voteType, int gilded, boolean nsfw,
boolean stickied) { boolean stickied, boolean isCrosspost) {
this.id = id; this.id = id;
this.fullName = fullName; this.fullName = fullName;
this.subredditNamePrefixed = subredditNamePrefixed; this.subredditNamePrefixed = subredditNamePrefixed;
@ -89,6 +93,7 @@ class PostData implements Parcelable {
this.gilded = gilded; this.gilded = gilded;
this.nsfw = nsfw; this.nsfw = nsfw;
this.stickied = stickied; this.stickied = stickied;
this.isCrosspost= isCrosspost;
} }
protected PostData(Parcel in) { protected PostData(Parcel in) {
@ -110,6 +115,7 @@ class PostData implements Parcelable {
gilded = in.readInt(); gilded = in.readInt();
nsfw = in.readByte() != 0; nsfw = in.readByte() != 0;
stickied = in.readByte() != 0; stickied = in.readByte() != 0;
isCrosspost = in.readByte() != 0;
isDashVideo = in.readByte() != 0; isDashVideo = in.readByte() != 0;
isDownloadableGifOrVideo = in.readByte() != 0; isDownloadableGifOrVideo = in.readByte() != 0;
} }
@ -243,6 +249,10 @@ class PostData implements Parcelable {
return stickied; return stickied;
} }
public boolean isCrosspost() {
return isCrosspost;
}
@Override @Override
public void writeToParcel(Parcel parcel, int i) { public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(id); parcel.writeString(id);
@ -263,6 +273,7 @@ class PostData implements Parcelable {
parcel.writeInt(gilded); parcel.writeInt(gilded);
parcel.writeByte((byte) (nsfw ? 1 : 0)); parcel.writeByte((byte) (nsfw ? 1 : 0));
parcel.writeByte((byte) (stickied ? 1 : 0)); parcel.writeByte((byte) (stickied ? 1 : 0));
parcel.writeByte((byte) (isCrosspost ? 1 : 0));
parcel.writeByte((byte) (isDashVideo ? 1 : 0)); parcel.writeByte((byte) (isDashVideo ? 1 : 0));
parcel.writeByte((byte) (isDownloadableGifOrVideo ? 1 : 0)); parcel.writeByte((byte) (isDownloadableGifOrVideo ? 1 : 0));
} }

View File

@ -127,7 +127,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}); });
mPaginationSynchronizer.setLoadSuccess(savedInstanceState.getBoolean(LOAD_SUCCESS_STATE)); mPaginationSynchronizer.setLoadSuccess(savedInstanceState.getBoolean(LOAD_SUCCESS_STATE));
mPaginationSynchronizer.setLoadingState(savedInstanceState.getBoolean(LOADING_STATE_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.setAdapter(adapter);
mPostRecyclerView.addOnScrollListener(new PostPaginationScrollListener( mPostRecyclerView.addOnScrollListener(new PostPaginationScrollListener(
getActivity(), mLinearLayoutManager, adapter, mLastItem, mPostData, getActivity(), mLinearLayoutManager, adapter, mLastItem, mPostData,
@ -187,7 +187,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if(isAdded() && getActivity() != null) { if(isAdded() && getActivity() != null) {
mPostData = postData; mPostData = postData;
mLastItem = lastItem; mLastItem = lastItem;
PostRecyclerViewAdapter adapter = new PostRecyclerViewAdapter(getActivity(), postData, mPaginationSynchronizer); PostRecyclerViewAdapter adapter = new PostRecyclerViewAdapter(getActivity(), postData, mPaginationSynchronizer, mIsBestPost);
mPostRecyclerView.setAdapter(adapter); mPostRecyclerView.setAdapter(adapter);
mPostRecyclerView.addOnScrollListener(new PostPaginationScrollListener( mPostRecyclerView.addOnScrollListener(new PostPaginationScrollListener(
@ -259,7 +259,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if(isAdded() && getActivity() != null) { if(isAdded() && getActivity() != null) {
mPostData = postData; mPostData = postData;
mLastItem = lastItem; mLastItem = lastItem;
PostRecyclerViewAdapter adapter = new PostRecyclerViewAdapter(getActivity(), postData, mPaginationSynchronizer); PostRecyclerViewAdapter adapter = new PostRecyclerViewAdapter(getActivity(), postData, mPaginationSynchronizer, mIsBestPost);
mPostRecyclerView.setAdapter(adapter); mPostRecyclerView.setAdapter(adapter);
mPostRecyclerView.addOnScrollListener(new PostPaginationScrollListener( mPostRecyclerView.addOnScrollListener(new PostPaginationScrollListener(

View File

@ -9,6 +9,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.customtabs.CustomTabsIntent; import android.support.customtabs.CustomTabsIntent;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -46,20 +47,20 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
private PaginationSynchronizer mPaginationSynchronizer; private PaginationSynchronizer mPaginationSynchronizer;
private RequestManager glide; private RequestManager glide;
private SubredditDao subredditDao; private SubredditDao subredditDao;
private boolean isLoadingMorePostSuccess; private boolean isLoadingMorePostSuccess = true;
private boolean canStartActivity; private boolean canStartActivity = true;
private boolean hasMultipleSubreddits;
private static final int VIEW_TYPE_DATA = 0; private static final int VIEW_TYPE_DATA = 0;
private static final int VIEW_TYPE_LOADING = 1; 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) { if(context != null) {
mContext = context; mContext = context;
mPostData = postData; mPostData = postData;
mPaginationSynchronizer = paginationSynchronizer; mPaginationSynchronizer = paginationSynchronizer;
isLoadingMorePostSuccess = true; this.hasMultipleSubreddits = hasMultipleSubreddits;
canStartActivity = true;
glide = Glide.with(mContext); glide = Glide.with(mContext);
subredditDao = SubredditRoomDatabase.getDatabase(mContext).subredditDao(); subredditDao = SubredditRoomDatabase.getDatabase(mContext).subredditDao();
} }
@ -73,8 +74,8 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
@Override @Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if(viewType == VIEW_TYPE_DATA) { if(viewType == VIEW_TYPE_DATA) {
LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post, parent, false); CardView cardView = (CardView) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post, parent, false);
return new DataViewHolder(linearLayout); return new DataViewHolder(cardView);
} else { } else {
LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_progress_bar, parent, false); LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_progress_bar, parent, false);
return new LoadingViewHolder(linearLayout); 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); 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 @Override
public void onClick(View view) { public void onClick(View view) {
if(canStartActivity) { if(canStartActivity) {
@ -201,11 +202,15 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
loadImage(holder, mPostData.get(holder.getAdapterPosition())); loadImage(holder, mPostData.get(holder.getAdapterPosition()));
} }
if(mPostData.get(position).isStickied()) { if(!hasMultipleSubreddits && mPostData.get(position).isStickied()) {
((DataViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE); ((DataViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE);
glide.load(R.drawable.thumbtack).into(((DataViewHolder) holder).stickiedPostImageView); 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()) { switch (mPostData.get(position).getPostType()) {
case PostData.IMAGE_TYPE: case PostData.IMAGE_TYPE:
((DataViewHolder) holder).typeTextView.setText("IMAGE"); ((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).scoreTextView.setText(Integer.toString(mPostData.get(position).getScore()));
((DataViewHolder) holder).downvoteButton.setColorFilter(downvoteButtonColorFilter); ((DataViewHolder) holder).downvoteButton.setColorFilter(downvoteButtonColorFilter);
} }
}, id, RedditUtils.DIR_UPVOTE, ((DataViewHolder) holder).getAdapterPosition(), 1); }, id, RedditUtils.DIR_UPVOTE, holder.getAdapterPosition(), 1);
} else { } else {
//Upvoted before //Upvoted before
((DataViewHolder) holder).upvoteButton.clearColorFilter(); ((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); ((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); 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 { class DataViewHolder extends RecyclerView.ViewHolder {
private LinearLayout linearLayout; private CardView cardView;
private CircleImageView subredditIconCircleImageView; private CircleImageView subredditIconCircleImageView;
private TextView subredditNameTextView; private TextView subredditNameTextView;
private ImageView stickiedPostImageView; private ImageView stickiedPostImageView;
@ -516,6 +521,7 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
private TextView typeTextView; private TextView typeTextView;
private ImageView gildedImageView; private ImageView gildedImageView;
private TextView gildedNumberTextView; private TextView gildedNumberTextView;
private ImageView crosspostImageView;
private TextView nsfwTextView; private TextView nsfwTextView;
private RelativeLayout relativeLayout; private RelativeLayout relativeLayout;
private ProgressBar progressBar; private ProgressBar progressBar;
@ -527,9 +533,9 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
private ImageView downvoteButton; private ImageView downvoteButton;
private ImageView shareButton; private ImageView shareButton;
DataViewHolder(LinearLayout itemView) { DataViewHolder(View itemView) {
super(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); subredditIconCircleImageView = itemView.findViewById(R.id.subreddit_icon_circle_image_view_best_post_item);
subredditNameTextView = itemView.findViewById(R.id.subreddit_text_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); 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); typeTextView = itemView.findViewById(R.id.type_text_view_item_best_post);
gildedImageView = itemView.findViewById(R.id.gilded_image_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); 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); nsfwTextView = itemView.findViewById(R.id.nsfw_text_view_item_best_post);
relativeLayout = itemView.findViewById(R.id.image_view_wrapper_item_best_post); relativeLayout = itemView.findViewById(R.id.image_view_wrapper_item_best_post);
progressBar = itemView.findViewById(R.id.progress_bar_best_post_item); 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); glide.clear(((DataViewHolder) holder).subredditIconCircleImageView);
((DataViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE); ((DataViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE);
((DataViewHolder) holder).relativeLayout.setVisibility(View.GONE); ((DataViewHolder) holder).relativeLayout.setVisibility(View.GONE);
((DataViewHolder) holder).gildedImageView.setVisibility(View.GONE);
((DataViewHolder) holder).gildedNumberTextView.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).nsfwTextView.setVisibility(View.GONE);
((DataViewHolder) holder).progressBar.setVisibility(View.GONE); ((DataViewHolder) holder).progressBar.setVisibility(View.GONE);
((DataViewHolder) holder).imageView.setVisibility(View.GONE); ((DataViewHolder) holder).imageView.setVisibility(View.GONE);

View File

@ -87,6 +87,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
TextView typeTextView = findViewById(R.id.type_text_view_view_post_detail); TextView typeTextView = findViewById(R.id.type_text_view_view_post_detail);
ImageView gildedImageView = findViewById(R.id.gilded_image_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); 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); TextView nsfwTextView = findViewById(R.id.nsfw_text_view_view_post_detail);
RelativeLayout relativeLayout = findViewById(R.id.image_view_wrapper_view_post_detail); RelativeLayout relativeLayout = findViewById(R.id.image_view_wrapper_view_post_detail);
mLoadWrapper = findViewById(R.id.load_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.setNestedScrollingEnabled(false);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
@ -242,7 +247,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
break; break;
case PostData.LINK_TYPE: case PostData.LINK_TYPE:
typeTextView.setText("LINK"); typeTextView.setText("LINK");
if(!mPostData.getSelfText().equals("")) { if(mPostData.getSelfText() != null && !mPostData.getSelfText().equals("")) {
contentTextView.setVisibility(View.VISIBLE); contentTextView.setVisibility(View.VISIBLE);
contentTextView.setHtml(mPostData.getSelfText()); contentTextView.setHtml(mPostData.getSelfText());
} }
@ -260,7 +265,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
}); });
break; break;
case PostData.GIF_VIDEO_TYPE: case PostData.GIF_VIDEO_TYPE:
typeTextView.setText("VIDEO"); typeTextView.setText("GIF");
final Uri gifVideoUri = Uri.parse(mPostData.getVideoUrl()); final Uri gifVideoUri = Uri.parse(mPostData.getVideoUrl());
mImageView.setOnClickListener(new View.OnClickListener() { mImageView.setOnClickListener(new View.OnClickListener() {

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="27.963dp"
android:height="27.963dp"
android:viewportWidth="27.963"
android:viewportHeight="27.963">
<path
android:fillColor="#030104"
android:pathData="M7.254,12.923c-0.117,0-0.234-0.043-0.324-0.125c-0.316-0.295-0.588-0.533-0.834-0.73 c-1.076-0.887-1.9-1.195-2.312-1.195H0.475C0.213,10.872,0,10.655,0,10.395V6.763c0-0.256,0.213-0.471,0.475-0.471h3.268 c1.352,0.004,2.695,0.457,4.104,1.385c0.701,0.463,1.404,1.029,2.207,1.779c0.092,0.084,0.148,0.209,0.15,0.334 c0.004,0.125-0.045,0.25-0.131,0.342c-0.459,0.48-0.91,0.963-1.355,1.438c-0.386,0.419-0.757,0.818-1.122,1.204 C7.504,12.874,7.379,12.923,7.254,12.923z" />
<path
android:fillColor="#030104"
android:pathData="M21.818,24.675c-0.068,0-0.133-0.012-0.199-0.043c-0.166-0.078-0.275-0.244-0.275-0.426v-2.402 h-2.342c-1.363-0.006-2.723-0.453-4.143-1.379c-0.703-0.459-1.406-1.02-2.213-1.764c-0.096-0.086-0.146-0.207-0.15-0.336 c-0.006-0.127,0.039-0.248,0.131-0.344c0.488-0.506,0.969-1.021,1.439-1.531c0.355-0.383,0.697-0.752,1.035-1.109 c0.18-0.186,0.475-0.197,0.67-0.023c0.301,0.281,0.564,0.51,0.805,0.697c0.932,0.762,1.822,1.211,2.389,1.211h2.379V14.65 c0-0.184,0.109-0.355,0.275-0.432s0.367-0.053,0.508,0.064l5.662,4.787c0.109,0.092,0.174,0.223,0.174,0.363 s-0.064,0.273-0.174,0.363l-5.662,4.768C22.039,24.64,21.93,24.675,21.818,24.675z" />
<path
android:fillColor="#030104"
android:pathData="M3.689,21.804H0.475C0.213,21.804,0,21.591,0,21.327V17.7c0-0.262,0.213-0.475,0.475-0.475H3.69 c0.436,0,1.016-0.229,1.648-0.641c0.682-0.443,1.523-1.16,2.492-2.143c0.613-0.609,1.221-1.271,1.867-1.965 c1.27-1.377,2.588-2.801,4.016-3.963c1.27-1.023,3.014-2.199,5.23-2.223h2.4V3.763c0-0.186,0.109-0.354,0.275-0.432 c0.166-0.074,0.367-0.051,0.508,0.066l5.662,4.785c0.109,0.09,0.174,0.225,0.174,0.365c0,0.14-0.066,0.271-0.174,0.363 l-5.662,4.768c-0.141,0.117-0.342,0.146-0.508,0.07c-0.166-0.078-0.275-0.25-0.275-0.432v-2.444h-2.396 c-0.246,0-0.756,0.078-1.586,0.629c-0.676,0.441-1.506,1.164-2.475,2.146c-0.588,0.596-1.174,1.229-1.797,1.904 c-1.301,1.398-2.643,2.854-4.109,4.035c-1.289,1.023-3.045,2.195-5.289,2.217C3.691,21.804,3.691,21.804,3.689,21.804z" />
</vector>

View File

@ -98,7 +98,7 @@
android:id="@+id/type_text_view_view_post_detail" android:id="@+id/type_text_view_view_post_detail"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="16dp" android:layout_marginEnd="8dp"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:background="@drawable/rounded_corner" android:background="@drawable/rounded_corner"
android:textColor="@android:color/white" /> android:textColor="@android:color/white" />
@ -118,12 +118,24 @@
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_toEndOf="@id/gilded_image_view_view_post_detail" android:layout_toEndOf="@id/gilded_image_view_view_post_detail"
android:layout_toStartOf="@id/nsfw_text_view_view_post_detail"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:visibility="gone" android:visibility="gone"
android:textSize="20sp" android:textSize="20sp"
android:textColor="@color/gold"/> android:textColor="@color/gold"/>
<ImageView
android:id="@+id/crosspost_image_view_view_post_detail"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_toStartOf="@id/nsfw_text_view_item_best_post"
android:layout_toEndOf="@id/gilded_number_text_view_view_post_detail"
android:layout_centerVertical="true"
android:src="@drawable/crosspost"
android:tint="@color/colorAccent"
android:visibility="gone"/>
<TextView <TextView
android:id="@+id/nsfw_text_view_view_post_detail" android:id="@+id/nsfw_text_view_view_post_detail"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -10,7 +10,7 @@
android:id="@+id/progress_bar_footer_progress_bar_item" android:id="@+id/progress_bar_footer_progress_bar_item"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="8dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:layout_gravity="center" /> android:layout_gravity="center" />
@ -18,11 +18,9 @@
android:id="@+id/relative_layout_footer_progress_bar_item" android:id="@+id/relative_layout_footer_progress_bar_item"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="8dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:visibility="gone"> android:visibility="gone">

View File

@ -1,233 +1,240 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!--
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:id="@+id/card_view_view_post_detail"> android:id="@+id/card_view_view_post_detail">
</android.support.v7.widget.CardView>-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#FFFFFF"
android:id="@+id/linear_layout_view_post_detail">
<RelativeLayout <LinearLayout
android:id="@+id/relative_view_item_best_post"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:orientation="vertical"
android:layout_marginStart="16dp" android:background="#FFFFFF">
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp">
<de.hdodenhof.circleimageview.CircleImageView <RelativeLayout
android:id="@+id/subreddit_icon_circle_image_view_best_post_item" android:id="@+id/relative_view_item_best_post"
android:layout_width="24dp" android:layout_width="match_parent"
android:layout_height="24dp" android:layout_height="wrap_content"
android:layout_alignParentStart="true" android:layout_marginBottom="8dp"
android:layout_centerVertical="true"/>
<TextView
android:id="@+id/subreddit_text_view_best_post_item"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="16dp"
android:layout_toStartOf="@id/stickied_post_image_view_best_post_item" android:layout_marginTop="16dp">
android:layout_toEndOf="@id/subreddit_icon_circle_image_view_best_post_item"
android:layout_centerVertical="true"
android:textColor="#E91E63"/>
<ImageView <de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/stickied_post_image_view_best_post_item" android:id="@+id/subreddit_icon_circle_image_view_best_post_item"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_toStartOf="@id/post_time_text_view_best_post_item" android:layout_alignParentStart="true"
android:layout_marginStart="8dp" android:layout_centerVertical="true"/>
android:layout_marginEnd="8dp"
android:tint="@color/colorPrimary"
android:visibility="gone"/>
<TextView
android:id="@+id/post_time_text_view_best_post_item"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:gravity="center_vertical"/>
</RelativeLayout>
<TextView
android:id="@+id/title_text_view_best_post_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:textSize="18sp"
android:textColor="#000000"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp">
<TextView
android:id="@+id/type_text_view_item_best_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corner"
android:layout_marginEnd="8dp"
android:layout_centerVertical="true"
android:textColor="@android:color/white"/>
<ImageView
android:id="@+id/gilded_image_view_item_best_post"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_toEndOf="@id/type_text_view_item_best_post"
android:layout_centerVertical="true"
android:layout_marginStart="8dp"
android:visibility="gone"/>
<TextView
android:id="@+id/gilded_number_text_view_item_best_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:layout_toEndOf="@id/gilded_image_view_item_best_post"
android:layout_toStartOf="@id/nsfw_text_view_item_best_post"
android:layout_centerVertical="true"
android:visibility="gone"
android:textSize="20sp"
android:textColor="@color/gold"/>
<TextView
android:id="@+id/nsfw_text_view_item_best_post"
android:text="@string/nsfw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/nsfw_rounded_corner"
android:layout_alignParentEnd="true"
android:layout_marginStart="8dp"
android:layout_centerVertical="true"
android:textColor="@android:color/white"
android:visibility="gone"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/image_view_wrapper_item_best_post"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_marginTop="16dp"
android:visibility="gone">
<ProgressBar
android:id="@+id/progress_bar_best_post_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<ImageView
android:id="@+id/image_view_best_post_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<LinearLayout
android:id="@+id/load_image_error_linear_layout_best_post_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<TextView <TextView
android:layout_width="match_parent" android:id="@+id/subreddit_text_view_best_post_item"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:drawableTop="@drawable/ic_error_outline_black_24dp" android:layout_height="match_parent"
android:layout_gravity="center" android:layout_marginStart="16dp"
android:gravity="center" android:layout_marginEnd="8dp"
android:text="@string/tap_to_retry" /> android:layout_toStartOf="@id/stickied_post_image_view_best_post_item"
android:layout_toEndOf="@id/subreddit_icon_circle_image_view_best_post_item"
android:layout_centerVertical="true"
android:textColor="#E91E63"/>
</LinearLayout> <ImageView
android:id="@+id/stickied_post_image_view_best_post_item"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_toStartOf="@id/post_time_text_view_best_post_item"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:tint="@color/colorPrimary"
android:visibility="gone"/>
</RelativeLayout> <TextView
android:id="@+id/post_time_text_view_best_post_item"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:gravity="center_vertical"/>
<ImageView </RelativeLayout>
android:id="@+id/image_view_no_preview_link_best_post_item"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginTop="16dp"
android:scaleType="center"
android:src="@drawable/ic_link"
android:background="#E0E0E0"
android:visibility="gone"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/plus_button_item_best_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:padding="16dp"
android:src="@drawable/ic_arrow_upward_black_24dp"
android:layout_centerVertical="true"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"/>
<TextView <TextView
android:id="@+id/score_text_view_item_best_post" android:id="@+id/title_text_view_best_post_item"
android:layout_width="64dp" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_toEndOf="@id/plus_button_item_best_post" android:layout_marginLeft="16dp"
android:layout_alignBottom="@id/plus_button_item_best_post" android:layout_marginStart="16dp"
android:layout_alignParentTop="true" android:layout_marginRight="16dp"
android:gravity="center"/> android:layout_marginEnd="16dp"
android:textSize="18sp"
android:textColor="#000000"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp">
<TextView
android:id="@+id/type_text_view_item_best_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corner"
android:layout_marginEnd="8dp"
android:layout_centerVertical="true"
android:textColor="@android:color/white"/>
<ImageView
android:id="@+id/gilded_image_view_item_best_post"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_toEndOf="@id/type_text_view_item_best_post"
android:layout_centerVertical="true"
android:layout_marginStart="8dp"
android:visibility="gone"/>
<TextView
android:id="@+id/gilded_number_text_view_item_best_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:layout_toEndOf="@id/gilded_image_view_item_best_post"
android:layout_centerVertical="true"
android:visibility="gone"
android:textSize="20sp"
android:textColor="@color/gold"/>
<ImageView
android:id="@+id/crosspost_image_view_item_best_post"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_toStartOf="@id/nsfw_text_view_item_best_post"
android:layout_toEndOf="@id/gilded_number_text_view_item_best_post"
android:layout_centerVertical="true"
android:src="@drawable/crosspost"
android:tint="@color/colorAccent"
android:visibility="gone"/>
<TextView
android:id="@+id/nsfw_text_view_item_best_post"
android:text="@string/nsfw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/nsfw_rounded_corner"
android:layout_alignParentEnd="true"
android:layout_marginStart="8dp"
android:layout_centerVertical="true"
android:textColor="@android:color/white"
android:visibility="gone"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/image_view_wrapper_item_best_post"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_marginTop="16dp"
android:visibility="gone">
<ProgressBar
android:id="@+id/progress_bar_best_post_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<ImageView
android:id="@+id/image_view_best_post_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<LinearLayout
android:id="@+id/load_image_error_linear_layout_best_post_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_error_outline_black_24dp"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/tap_to_retry" />
</LinearLayout>
</RelativeLayout>
<ImageView <ImageView
android:id="@+id/minus_button_item_best_post" android:id="@+id/image_view_no_preview_link_best_post_item"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="150dp"
android:layout_centerVertical="true" android:layout_marginTop="16dp"
android:layout_toEndOf="@id/score_text_view_item_best_post" android:scaleType="center"
android:padding="16dp" android:src="@drawable/ic_link"
android:src="@drawable/ic_arrow_downward_black_24dp" android:background="#E0E0E0"
android:tint="@android:color/tab_indicator_text" android:visibility="gone"/>
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"/>
<ImageView <RelativeLayout
android:id="@+id/share_button_item_best_post" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:padding="16dp"
android:src="@drawable/ic_share_black_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true" />
</RelativeLayout> <ImageView
android:id="@+id/plus_button_item_best_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:padding="16dp"
android:src="@drawable/ic_arrow_upward_black_24dp"
android:layout_centerVertical="true"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"/>
<View <TextView
android:layout_width="match_parent" android:id="@+id/score_text_view_item_best_post"
android:layout_height="1dp" android:layout_width="64dp"
android:background="#F0F0F0"/> android:layout_height="match_parent"
android:layout_toEndOf="@id/plus_button_item_best_post"
android:layout_alignBottom="@id/plus_button_item_best_post"
android:layout_alignParentTop="true"
android:gravity="center"/>
</LinearLayout> <ImageView
android:id="@+id/minus_button_item_best_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/score_text_view_item_best_post"
android:padding="16dp"
android:src="@drawable/ic_arrow_downward_black_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"/>
<ImageView
android:id="@+id/share_button_item_best_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:padding="16dp"
android:src="@drawable/ic_share_black_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true" />
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>