aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-08-04 03:11:52 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-08-04 03:11:52 +0000
commit44e2987a848ec07fd866f8ed76bb29c66b03e60a (patch)
treefb8511bf13475f6d19cc5e0a6994f191f1c5dfc0 /app/src/main/java
parent70e65565ae14792b4bbb93f5b4468e7a60d6ba98 (diff)
downloadinfinity-for-reddit-44e2987a848ec07fd866f8ed76bb29c66b03e60a.tar
infinity-for-reddit-44e2987a848ec07fd866f8ed76bb29c66b03e60a.tar.gz
infinity-for-reddit-44e2987a848ec07fd866f8ed76bb29c66b03e60a.tar.bz2
infinity-for-reddit-44e2987a848ec07fd866f8ed76bb29c66b03e60a.tar.lz
infinity-for-reddit-44e2987a848ec07fd866f8ed76bb29c66b03e60a.tar.xz
infinity-for-reddit-44e2987a848ec07fd866f8ed76bb29c66b03e60a.tar.zst
infinity-for-reddit-44e2987a848ec07fd866f8ed76bb29c66b03e60a.zip
Fixed UI in dark theme. Minor bugs fixed.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java74
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java29
3 files changed, 65 insertions, 58 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
index 26776df0..3d3769d1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
@@ -166,15 +166,15 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
if(mPost.getAuthorIconUrl() == null) {
new LoadUserDataAsyncTask(UserRoomDatabase.getDatabase(mActivity).userDao(), mPost.getAuthor(), mOauthRetrofit, iconImageUrl -> {
if(mActivity != null && getItemCount() > 0) {
- if(!iconImageUrl.equals("")) {
- mGlide.load(iconImageUrl)
+ if(iconImageUrl == null || iconImageUrl.equals("")) {
+ mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .error(mGlide.load(R.drawable.subreddit_default_icon)
- .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
.into(((PostDetailViewHolder) holder).mIconGifImageView);
} else {
- mGlide.load(R.drawable.subreddit_default_icon)
+ mGlide.load(iconImageUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
+ .error(mGlide.load(R.drawable.subreddit_default_icon)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
.into(((PostDetailViewHolder) holder).mIconGifImageView);
}
@@ -202,15 +202,15 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
mLoadSubredditIconAsyncTask = new LoadSubredditIconAsyncTask(
SubredditRoomDatabase.getDatabase(mActivity).subredditDao(), mPost.getSubredditNamePrefixed().substring(2),
mRetrofit, iconImageUrl -> {
- if(!iconImageUrl.equals("")) {
- mGlide.load(iconImageUrl)
+ if(iconImageUrl == null || iconImageUrl.equals("")) {
+ mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .error(mGlide.load(R.drawable.subreddit_default_icon)
- .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
.into(((PostDetailViewHolder) holder).mIconGifImageView);
} else {
- mGlide.load(R.drawable.subreddit_default_icon)
+ mGlide.load(iconImageUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
+ .error(mGlide.load(R.drawable.subreddit_default_icon)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
.into(((PostDetailViewHolder) holder).mIconGifImageView);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
index 724b00ba..e5c8a896 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
@@ -138,7 +138,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
final String id = post.getFullName();
final String subredditNamePrefixed = post.getSubredditNamePrefixed();
String subredditName = subredditNamePrefixed.substring(2);
- String author = "u/" + post.getAuthor();
+ String authorPrefixed = "u/" + post.getAuthor();
final String postTime = post.getPostTime();
final String title = post.getTitle();
final String permalink = post.getPermalink();
@@ -161,20 +161,20 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
});
if(displaySubredditName) {
- if(author.equals(subredditNamePrefixed)) {
+ if(authorPrefixed.equals(subredditNamePrefixed)) {
if(post.getAuthorIconUrl() == null) {
new LoadUserDataAsyncTask(userDao, post.getAuthor(), mRetrofit, iconImageUrl -> {
if(mContext != null && getItemCount() > 0) {
- if(!iconImageUrl.equals("")) {
+ if(iconImageUrl == null || iconImageUrl.equals("")) {
+ glide.load(R.drawable.subreddit_default_icon)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
+ .into(((DataViewHolder) holder).iconGifImageView);
+ } else {
glide.load(iconImageUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
- } else {
- glide.load(R.drawable.subreddit_default_icon)
- .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
+ .into(((DataViewHolder) holder).iconGifImageView);
}
if(holder.getAdapterPosition() >= 0) {
@@ -187,29 +187,27 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
+ .into(((DataViewHolder) holder).iconGifImageView);
} else {
glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
+ .into(((DataViewHolder) holder).iconGifImageView);
}
} else {
if(post.getSubredditIconUrl() == null) {
new LoadSubredditIconAsyncTask(subredditDao, subredditName, mRetrofit,
iconImageUrl -> {
if(mContext != null && getItemCount() > 0) {
- if(iconImageUrl == null) {
-
- } else if(!iconImageUrl.equals("")) {
+ if(iconImageUrl == null || iconImageUrl.equals("")) {
+ glide.load(R.drawable.subreddit_default_icon)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
+ .into(((DataViewHolder) holder).iconGifImageView);
+ } else {
glide.load(iconImageUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
- } else {
- glide.load(R.drawable.subreddit_default_icon)
- .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
+ .into(((DataViewHolder) holder).iconGifImageView);
}
if(holder.getAdapterPosition() >= 0) {
@@ -222,18 +220,18 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
+ .into(((DataViewHolder) holder).iconGifImageView);
} else {
glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
+ .into(((DataViewHolder) holder).iconGifImageView);
}
}
- ((DataViewHolder) holder).subredditNameTextView.setTextColor(mContext.getResources().getColor(R.color.colorAccent));
- ((DataViewHolder) holder).subredditNameTextView.setText(subredditNamePrefixed);
+ ((DataViewHolder) holder).nameTextView.setTextColor(mContext.getResources().getColor(R.color.colorAccent));
+ ((DataViewHolder) holder).nameTextView.setText(subredditNamePrefixed);
- ((DataViewHolder) holder).subredditIconNameLinearLayout.setOnClickListener(view -> {
+ ((DataViewHolder) holder).iconNameLinearLayout.setOnClickListener(view -> {
if(canStartActivity) {
canStartActivity = false;
if(post.getSubredditNamePrefixed().startsWith("u/")) {
@@ -253,16 +251,16 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
if(post.getAuthorIconUrl() == null) {
new LoadUserDataAsyncTask(userDao, post.getAuthor(), mRetrofit, iconImageUrl -> {
if(mContext != null && getItemCount() > 0) {
- if(!iconImageUrl.equals("")) {
+ if(iconImageUrl == null || iconImageUrl.equals("")) {
+ glide.load(R.drawable.subreddit_default_icon)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
+ .into(((DataViewHolder) holder).iconGifImageView);
+ } else {
glide.load(iconImageUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
- } else {
- glide.load(R.drawable.subreddit_default_icon)
- .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
+ .into(((DataViewHolder) holder).iconGifImageView);
}
if(holder.getAdapterPosition() >= 0) {
@@ -275,17 +273,17 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
+ .into(((DataViewHolder) holder).iconGifImageView);
} else {
glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((DataViewHolder) holder).subredditIconGifImageView);
+ .into(((DataViewHolder) holder).iconGifImageView);
}
- ((DataViewHolder) holder).subredditNameTextView.setTextColor(mContext.getResources().getColor(R.color.textColorPrimaryDark));
- ((DataViewHolder) holder).subredditNameTextView.setText(author);
+ ((DataViewHolder) holder).nameTextView.setTextColor(mContext.getResources().getColor(R.color.textColorPrimaryDark));
+ ((DataViewHolder) holder).nameTextView.setText(authorPrefixed);
- ((DataViewHolder) holder).subredditIconNameLinearLayout.setOnClickListener(view -> {
+ ((DataViewHolder) holder).iconNameLinearLayout.setOnClickListener(view -> {
if(canStartActivity) {
canStartActivity = false;
Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
@@ -652,9 +650,9 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
class DataViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.card_view_item_post) MaterialCardView cardView;
- @BindView(R.id.subreddit_icon_name_linear_layout_view_item_post) LinearLayout subredditIconNameLinearLayout;
- @BindView(R.id.subreddit_icon_gif_image_view_item_post) AspectRatioGifImageView subredditIconGifImageView;
- @BindView(R.id.subreddit_text_view_item_post) TextView subredditNameTextView;
+ @BindView(R.id.icon_name_linear_layout_view_item_post) LinearLayout iconNameLinearLayout;
+ @BindView(R.id.icon_gif_image_view_item_post) AspectRatioGifImageView iconGifImageView;
+ @BindView(R.id.name_text_view_item_post) TextView nameTextView;
@BindView(R.id.stickied_post_image_view_item_post) ImageView stickiedPostImageView;
@BindView(R.id.post_time_text_view_best_item_post) TextView postTimeTextView;
@BindView(R.id.title_text_view_best_item_post) TextView titleTextView;
@@ -709,7 +707,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if(holder instanceof DataViewHolder) {
glide.clear(((DataViewHolder) holder).imageView);
- glide.clear(((DataViewHolder) holder).subredditIconGifImageView);
+ glide.clear(((DataViewHolder) holder).iconGifImageView);
((DataViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE);
((DataViewHolder) holder).relativeLayout.setVisibility(View.GONE);
((DataViewHolder) holder).gildedImageView.setVisibility(View.GONE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
index cc1edbad..b5c11f1c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
@@ -73,8 +73,12 @@ public class ViewUserDetailActivity extends AppCompatActivity {
private String userName;
private boolean subscriptionReady = false;
private boolean isInLazyMode = false;
- private int colorPrimary;
- private int white;
+ private int expandedTabTextColor;
+ private int expandedTabBackgroundColor;
+ private int expandedTabIndicatorColor;
+ private int collapsedTabTextColor;
+ private int collapsedTabBackgroundColor;
+ private int collapsedTabIndicatorColor;
@Inject
@Named("no_oauth")
@@ -122,20 +126,25 @@ public class ViewUserDetailActivity extends AppCompatActivity {
viewPager.setOffscreenPageLimit(2);
tabLayout.setupWithViewPager(viewPager);
- colorPrimary = getResources().getColor(R.color.colorPrimary);
- white = getResources().getColor(android.R.color.white);
+ expandedTabTextColor = getResources().getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTextColor);
+ expandedTabBackgroundColor = getResources().getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabBackground);
+ expandedTabIndicatorColor = getResources().getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabIndicator);
+
+ collapsedTabTextColor = getResources().getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTextColor);
+ collapsedTabBackgroundColor = getResources().getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabBackground);
+ collapsedTabIndicatorColor = getResources().getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabIndicator);
appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() {
@Override
void onStateChanged(AppBarLayout appBarLayout, State state) {
if(state == State.EXPANDED) {
- tabLayout.setTabTextColors(colorPrimary, colorPrimary);
- tabLayout.setSelectedTabIndicatorColor(colorPrimary);
- tabLayout.setBackgroundColor(white);
+ tabLayout.setTabTextColors(expandedTabTextColor, expandedTabTextColor);
+ tabLayout.setSelectedTabIndicatorColor(expandedTabIndicatorColor);
+ tabLayout.setBackgroundColor(expandedTabBackgroundColor);
} else if(state == State.COLLAPSED) {
- tabLayout.setTabTextColors(white, white);
- tabLayout.setSelectedTabIndicatorColor(white);
- tabLayout.setBackgroundColor(colorPrimary);
+ tabLayout.setTabTextColors(collapsedTabTextColor, collapsedTabTextColor);
+ tabLayout.setSelectedTabIndicatorColor(collapsedTabIndicatorColor);
+ tabLayout.setBackgroundColor(collapsedTabBackgroundColor);
}
}
});