diff options
Diffstat (limited to 'app/src/main')
10 files changed, 314 insertions, 257 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() { diff --git a/app/src/main/res/drawable/crosspost.xml b/app/src/main/res/drawable/crosspost.xml new file mode 100644 index 00000000..c8b43c52 --- /dev/null +++ b/app/src/main/res/drawable/crosspost.xml @@ -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>
\ No newline at end of file diff --git a/app/src/main/res/layout/activity_view_post_detail.xml b/app/src/main/res/layout/activity_view_post_detail.xml index 025f8ef1..b9c13bcb 100644 --- a/app/src/main/res/layout/activity_view_post_detail.xml +++ b/app/src/main/res/layout/activity_view_post_detail.xml @@ -98,7 +98,7 @@ android:id="@+id/type_text_view_view_post_detail" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginEnd="16dp" + android:layout_marginEnd="8dp" android:layout_centerVertical="true" android:background="@drawable/rounded_corner" android:textColor="@android:color/white" /> @@ -118,12 +118,24 @@ android:layout_marginStart="4dp" android:layout_marginEnd="8dp" 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:visibility="gone" android:textSize="20sp" 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 android:id="@+id/nsfw_text_view_view_post_detail" android:layout_width="wrap_content" diff --git a/app/src/main/res/layout/item_footer_progress_bar.xml b/app/src/main/res/layout/item_footer_progress_bar.xml index a84af3bc..270fc6ef 100644 --- a/app/src/main/res/layout/item_footer_progress_bar.xml +++ b/app/src/main/res/layout/item_footer_progress_bar.xml @@ -10,7 +10,7 @@ android:id="@+id/progress_bar_footer_progress_bar_item" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="16dp" + android:layout_marginTop="8dp" android:layout_marginBottom="16dp" android:layout_gravity="center" /> @@ -18,11 +18,9 @@ android:id="@+id/relative_layout_footer_progress_bar_item" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="16dp" + android:layout_marginTop="8dp" android:layout_marginBottom="16dp" - android:layout_marginLeft="16dp" android:layout_marginStart="16dp" - android:layout_marginRight="16dp" android:layout_marginEnd="16dp" android:visibility="gone"> diff --git a/app/src/main/res/layout/item_post.xml b/app/src/main/res/layout/item_post.xml index 8549d735..900e9817 100644 --- a/app/src/main/res/layout/item_post.xml +++ b/app/src/main/res/layout/item_post.xml @@ -1,233 +1,240 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" 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 - android:id="@+id/relative_view_item_best_post" + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="8dp" - android:layout_marginStart="16dp" - android:layout_marginEnd="16dp" - android:layout_marginTop="16dp"> - - <de.hdodenhof.circleimageview.CircleImageView - android:id="@+id/subreddit_icon_circle_image_view_best_post_item" - android:layout_width="24dp" - android:layout_height="24dp" - android:layout_alignParentStart="true" - android:layout_centerVertical="true"/> + android:orientation="vertical" + android:background="#FFFFFF"> - <TextView - android:id="@+id/subreddit_text_view_best_post_item" - android:layout_width="wrap_content" - android:layout_height="match_parent" + <RelativeLayout + android:id="@+id/relative_view_item_best_post" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="8dp" android:layout_marginStart="16dp" - android:layout_marginEnd="8dp" - 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"/> + android:layout_marginEnd="16dp" + android:layout_marginTop="16dp"> - <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"/> + <de.hdodenhof.circleimageview.CircleImageView + android:id="@+id/subreddit_icon_circle_image_view_best_post_item" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_alignParentStart="true" + android:layout_centerVertical="true"/> - <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/subreddit_text_view_best_post_item" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_marginStart="16dp" + android:layout_marginEnd="8dp" + 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"/> + + <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"/> - <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"/> + <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 - 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"/> + </RelativeLayout> <TextView - android:id="@+id/gilded_number_text_view_item_best_post" - android:layout_width="wrap_content" + android:id="@+id/title_text_view_best_post_item" + android:layout_width="match_parent" 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"/> + android:layout_marginLeft="16dp" + android:layout_marginStart="16dp" + android:layout_marginRight="16dp" + android:layout_marginEnd="16dp" + android:textSize="18sp" + android:textColor="#000000"/> - <TextView - android:id="@+id/nsfw_text_view_item_best_post" - android:text="@string/nsfw" - android:layout_width="wrap_content" + <RelativeLayout + android:layout_width="match_parent" 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"/> + android:layout_marginTop="8dp" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp"> - </RelativeLayout> + <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"/> - <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"> + <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"/> - <ProgressBar - android:id="@+id/progress_bar_best_post_item" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerInParent="true" /> + <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"/> - <ImageView - android:id="@+id/image_view_best_post_item" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:scaleType="centerCrop" /> + </RelativeLayout> - <LinearLayout - android:id="@+id/load_image_error_linear_layout_best_post_item" + <RelativeLayout + android:id="@+id/image_view_wrapper_item_best_post" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="350dp" + android:layout_marginTop="16dp" android:visibility="gone"> - <TextView - android:layout_width="match_parent" + <ProgressBar + android:id="@+id/progress_bar_best_post_item" + android:layout_width="wrap_content" 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" /> + android:layout_centerInParent="true" /> - </LinearLayout> + <ImageView + android:id="@+id/image_view_best_post_item" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:scaleType="centerCrop" /> - </RelativeLayout> + <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"> - <ImageView - 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"> + <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" /> - <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"/> + </LinearLayout> - <TextView - android:id="@+id/score_text_view_item_best_post" - android:layout_width="64dp" - 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"/> + </RelativeLayout> <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"/> + 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"/> - <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> - - <View - android:layout_width="match_parent" - android:layout_height="1dp" - android:background="#F0F0F0"/> + <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 + android:id="@+id/score_text_view_item_best_post" + android:layout_width="64dp" + 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"/> + + <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> -</LinearLayout>
\ No newline at end of file +</android.support.v7.widget.CardView>
\ No newline at end of file |