Skip to content

Commit

Permalink
Added "no comments yet" message
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumBadger committed Jul 2, 2016
1 parent 005103c commit fa4d993
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class CommentListingManager {
private final GroupedRecyclerViewAdapter mAdapter = new GroupedRecyclerViewAdapter(6);
private LinearLayoutManager mLayoutManager;

private int mCommentCount = 0;

private static final int
GROUP_POST_HEADER = 0,
GROUP_NOTIFICATIONS = 1,
Expand Down Expand Up @@ -90,6 +92,12 @@ public void addComments(final Collection<RedditCommentListItem> comments) {
mAdapter.appendToGroup(
GROUP_COMMENTS,
Collections.<GroupedRecyclerViewAdapter.Item>unmodifiableCollection(comments));
mCommentCount += comments.size();
doWorkaround();
}

public void addViewToComments(final View view) {
mAdapter.appendToGroup(GROUP_COMMENTS, new GroupedRecyclerViewItemFrameLayout(view));
doWorkaround();
}

Expand All @@ -113,4 +121,8 @@ public void notifyCommentChanged(final RedditCommentListItem item) {
public int getItemCount() {
return mAdapter.getItemCount();
}

public int getCommentCount() {
return mCommentCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,17 @@ public void onCommentListingRequestAllItemsDownloaded(final ArrayList<RedditComm
}

if(mUrlsToDownload.isEmpty()) {

if(mCommentListingManager.getCommentCount() == 0) {

final View noCommentsYet = LayoutInflater.from(getContext()).inflate(
R.layout.no_comments_yet,
mRecyclerView,
false);

mCommentListingManager.addViewToComments(noCommentsYet);
}

mCommentListingManager.setLoadingVisible(false);

} else {
Expand Down
37 changes: 37 additions & 0 deletions src/main/res/layout/no_comments_yet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
~ This file is part of RedReader.
~
~ RedReader is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ RedReader is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with RedReader. If not, see <http://www.gnu.org/licenses/>.
-->


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="25dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAlignment="center"
android:textSize="18sp"
android:textColor="?rrSubTextCol"
android:text="@string/no_comments_yet"/>

</FrameLayout>

1 change: 1 addition & 0 deletions src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<attr name="rrCommentSpecificThreadHeaderTextCol" format="color" />

<attr name="rrMainTextCol" format="color" />
<attr name="rrSubTextCol" format="color" />

<!-- icons -->

Expand Down
2 changes: 2 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -813,4 +813,6 @@
<string name="pref_behaviour_actions_comment_longclick_key">pref_behaviour_actions_comment_longclick</string>
<string name="pref_behaviour_actions_comment_longclick_title">Comment Long Click Action</string>

<string name="no_comments_yet">No comments yet.</string>

</resources>
2 changes: 2 additions & 0 deletions src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<item name="colorAccent">#99DDDD</item>

<item name="rrMainTextCol">#FFFFFF</item>
<item name="rrSubTextCol">#AAAAAA</item>

<item name="android:windowBackground">@color/darkWindowBackground</item>

Expand Down Expand Up @@ -123,6 +124,7 @@
<item name="colorAccent">?colorPrimaryDark</item>

<item name="rrMainTextCol">#000000</item>
<item name="rrSubTextCol">#777777</item>

<item name="android:textColorPrimary">#000000</item>
<item name="android:textColorSecondary">#000000</item>
Expand Down

0 comments on commit fa4d993

Please sign in to comment.