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 #549 from rosenpin/fixed-dismiss-issues
Browse files Browse the repository at this point in the history
Fixed dismiss fab issues
  • Loading branch information
SlideCI committed Nov 16, 2015
2 parents d233a62 + f63426f commit 85b52b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {

@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder2, final int i) {

if (HasSeen.getSeen(dataSet.posts.get(i).getFullName())){
seen.add(dataSet.posts.get(i));
}
if (holder2 instanceof SubmissionViewHolder) {
final SubmissionViewHolder holder = (SubmissionViewHolder) holder2;

final Submission submission = dataSet.posts.get(i);
if (HasSeen.getSeen(submission.getFullName())){
seen.add(submission);
}

CreateCardView.resetColorCard(holder.itemView);
CreateCardView.colorCard(submission.getSubredditName().toLowerCase(), holder.itemView, subreddit, custom);
holder.itemView.setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,9 @@ public void onClick(View v) {
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

int i = 0;
Iterator<?> it = adapter.dataSet.posts.iterator();
while (it.hasNext()) {
i++;
if (adapter.seen.contains(it.next())) {
it.remove();
Hidden.setHidden(adapter.dataSet.posts.get(i));
adapter.notifyItemRemoved(i);
}
}
clearSeenPosts();
//Rechecking arrays, I'm note sure why is it necessary but it is.
clearSeenPosts();
}
});
}
Expand Down Expand Up @@ -202,6 +194,16 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
return v;
}

private void clearSeenPosts() {
for (int i = 0; i < adapter.dataSet.posts.size(); i++) {
if (HasSeen.getSeen(adapter.dataSet.posts.get(i).getFullName())) {
Hidden.setHidden(adapter.dataSet.posts.get(i));
adapter.dataSet.posts.remove(adapter.dataSet.posts.get(i));
adapter.notifyItemRemoved(adapter.dataSet.posts.indexOf(adapter.dataSet.posts.get(i)));
}
}
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.4+'
classpath 'com.android.tools.build:gradle:1.3.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 85b52b2

Please sign in to comment.