swipe dismiss: set article back to unread if it was before
This commit is contained in:
parent
9b16a179e8
commit
f6162a8d72
@ -372,26 +372,38 @@ public class HeadlinesFragment extends Fragment {
|
||||
|
||||
try {
|
||||
final Article article = getArticleAtPosition(position);
|
||||
final boolean wasUnread;
|
||||
|
||||
if (article != null) {
|
||||
if (article.unread) {
|
||||
wasUnread = true;
|
||||
|
||||
article.unread = false;
|
||||
m_activity.saveArticleUnread(article);
|
||||
} else {
|
||||
wasUnread = false;
|
||||
}
|
||||
|
||||
m_articles.remove(position);
|
||||
m_adapter.notifyDataSetChanged();
|
||||
|
||||
Snackbar.make(m_list, R.string.headline_undo_row_prompt, Snackbar.LENGTH_LONG)
|
||||
.setAction(getString(R.string.headline_undo_row_button), new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (wasUnread) {
|
||||
article.unread = true;
|
||||
m_activity.saveArticleUnread(article);
|
||||
}
|
||||
|
||||
m_articles.add(position, article);
|
||||
m_adapter.notifyDataSetChanged();
|
||||
}
|
||||
}).show();
|
||||
|
||||
}
|
||||
|
||||
m_articles.remove(position);
|
||||
m_adapter.notifyDataSetChanged();
|
||||
|
||||
Snackbar.make(m_list, R.string.headline_undo_row_prompt, Snackbar.LENGTH_LONG)
|
||||
.setAction(getString(R.string.headline_undo_row_button), new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
m_articles.add(position, article);
|
||||
m_adapter.notifyDataSetChanged();
|
||||
}
|
||||
}).show();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user