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