Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3123 from YusefOuda/feature/subreddit-banner-in-s…
Browse files Browse the repository at this point in the history
…idebar

Show subreddit banner on the top of the sidebar (if exists)
  • Loading branch information
ccrama authored May 24, 2020
2 parents 96e345d + 4db2cab commit 87669e1
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2862,6 +2862,15 @@ public void onClick(View v) {
} else {
findViewById(R.id.subimage).setVisibility(View.GONE);
}
String bannerImage = subreddit.getBannerImage();
if (bannerImage != null && !bannerImage.isEmpty()) {
findViewById(R.id.sub_banner).setVisibility(View.VISIBLE);
((Reddit) getApplication()).getImageLoader()
.displayImage(bannerImage,
(ImageView) findViewById(R.id.sub_banner));
} else {
findViewById(R.id.sub_banner).setVisibility(View.GONE);
}
((TextView) findViewById(R.id.subscribers)).setText(
getString(R.string.subreddit_subscribers_string,
subreddit.getLocalizedSubscriberCount()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,15 @@ public void onCancel(
} else {
findViewById(R.id.subimage).setVisibility(View.GONE);
}
String bannerImage = subreddit.getBannerImage();
if (bannerImage != null && !bannerImage.isEmpty()) {
findViewById(R.id.sub_banner).setVisibility(View.VISIBLE);
((Reddit) getApplication()).getImageLoader()
.displayImage(bannerImage,
(ImageView) findViewById(R.id.sub_banner));
} else {
findViewById(R.id.sub_banner).setVisibility(View.GONE);
}
((TextView) findViewById(R.id.subscribers)).setText(
getString(R.string.subreddit_subscribers_string,
subreddit.getLocalizedSubscriberCount()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,15 @@ public void onClick(
} else {
sidebar.findViewById(R.id.subimage).setVisibility(View.GONE);
}
String bannerImage = baseSub.getBannerImage();
if (bannerImage != null && !bannerImage.isEmpty()) {
sidebar.findViewById(R.id.sub_banner).setVisibility(View.VISIBLE);
((Reddit) getContext().getApplicationContext()).getImageLoader()
.displayImage(bannerImage,
(ImageView) sidebar.findViewById(R.id.sub_banner));
} else {
sidebar.findViewById(R.id.sub_banner).setVisibility(View.GONE);
}
((TextView) sidebar.findViewById(R.id.subscribers)).setText(
getString(R.string.subreddit_subscribers_string,
baseSub.getLocalizedSubscriberCount()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,15 @@ private void doSidebar(Subreddit subreddit, View content) {
} else {
content.findViewById(R.id.subimage).setVisibility(View.GONE);
}
String bannerImage = subreddit.getBannerImage();
if (bannerImage != null && !bannerImage.isEmpty()) {
findViewById(R.id.sub_banner).setVisibility(View.VISIBLE);
((Reddit) ((PeekViewActivity) getContext()).getApplication()).getImageLoader()
.displayImage(bannerImage,
(ImageView) findViewById(R.id.sub_banner));
} else {
findViewById(R.id.sub_banner).setVisibility(View.GONE);
}
((TextView) content.findViewById(R.id.subscribers)).setText(
getContext().getString(R.string.subreddit_subscribers_string,
subreddit.getLocalizedSubscriberCount()));
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/subinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
android:indeterminate="true"
android:padding="0dp"/>

<ImageView
android:id="@+id/sub_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:padding="0dp"/>

<LinearLayout
android:id="@+id/header_sub"
android:layout_width="match_parent"
Expand Down

0 comments on commit 87669e1

Please sign in to comment.