snackbar-based undo for swipe to dismiss
This commit is contained in:
parent
5d3f580de4
commit
b043d6acb7
@ -37,6 +37,7 @@ dependencies {
|
||||
compile 'com.android.support:support-v4:25.3.1'
|
||||
compile 'com.android.support:appcompat-v7:25.3.1'
|
||||
compile 'com.android.support:customtabs:25.3.1'
|
||||
compile 'com.android.support:design:25.3.1'
|
||||
compile 'com.google.code.gson:gson:2.7'
|
||||
compile 'com.shamanland:fab:0.0.8'
|
||||
compile 'ch.acra:acra:4.9.1'
|
||||
|
@ -16,7 +16,9 @@ import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.ActivityOptionsCompat;
|
||||
import android.support.v4.app.Fragment;
|
||||
@ -366,10 +368,10 @@ public class HeadlinesFragment extends Fragment {
|
||||
@Override
|
||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
|
||||
int position = viewHolder.getAdapterPosition() - m_adapter.getHeaderCount();
|
||||
final int position = viewHolder.getAdapterPosition() - m_adapter.getHeaderCount();
|
||||
|
||||
try {
|
||||
Article article = getArticleAtPosition(position);
|
||||
final Article article = getArticleAtPosition(position);
|
||||
|
||||
if (article != null) {
|
||||
if (article.unread) {
|
||||
@ -380,6 +382,16 @@ public class HeadlinesFragment extends Fragment {
|
||||
|
||||
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