-
-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated post list to a RecyclerView
- Loading branch information
1 parent
f058a4e
commit 32795fe
Showing
36 changed files
with
903 additions
and
1,264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/org/quantumbadger/redreader/adapters/FilteredCommentListingManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/******************************************************************************* | ||
* 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/>. | ||
******************************************************************************/ | ||
|
||
package org.quantumbadger.redreader.adapters; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.Nullable; | ||
import org.quantumbadger.redreader.reddit.RedditCommentListItem; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
public class FilteredCommentListingManager extends RedditListingManager { | ||
|
||
@Nullable | ||
private final String mSearchString; | ||
|
||
public FilteredCommentListingManager( | ||
final Context context, | ||
@Nullable final String searchString) { | ||
|
||
super(context); | ||
mSearchString = searchString; | ||
} | ||
|
||
public void addComments(final Collection<RedditCommentListItem> comments) { | ||
addItems(filter(comments)); | ||
} | ||
|
||
private Collection<GroupedRecyclerViewAdapter.Item> filter(Collection<RedditCommentListItem> comments) { | ||
|
||
final Collection<RedditCommentListItem> searchComments; | ||
|
||
if (mSearchString == null) { | ||
searchComments = comments; | ||
|
||
} else { | ||
searchComments = new ArrayList<>(); | ||
for (RedditCommentListItem comment : comments) { | ||
if (!comment.isComment()) continue; | ||
String commentStr = comment.asComment().getParsedComment().getRawComment().body; | ||
if (commentStr != null) { | ||
commentStr = commentStr.toLowerCase(); | ||
if (commentStr.contains(mSearchString)) { | ||
searchComments.add(comment); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return Collections.<GroupedRecyclerViewAdapter.Item>unmodifiableCollection(searchComments); | ||
} | ||
|
||
public boolean isSearchListing() { | ||
return mSearchString != null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 0 additions & 127 deletions
127
src/main/java/org/quantumbadger/redreader/adapters/PostListingAdapter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.