undo for new items
This commit is contained in:
parent
7489046037
commit
a02b84d2d2
|
@ -81,6 +81,7 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<AllEpisodesR
|
||||||
holder.txtvDuration = (TextView) view.findViewById(R.id.txtvDuration);
|
holder.txtvDuration = (TextView) view.findViewById(R.id.txtvDuration);
|
||||||
holder.item = null;
|
holder.item = null;
|
||||||
holder.mainActivity = mainActivity;
|
holder.mainActivity = mainActivity;
|
||||||
|
holder.position = -1;
|
||||||
|
|
||||||
return holder;
|
return holder;
|
||||||
}
|
}
|
||||||
|
@ -90,6 +91,7 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<AllEpisodesR
|
||||||
final FeedItem item = itemAccess.getItem(position);
|
final FeedItem item = itemAccess.getItem(position);
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
holder.item = item;
|
holder.item = item;
|
||||||
|
holder.position = position;
|
||||||
holder.placeholder.setVisibility(View.VISIBLE);
|
holder.placeholder.setVisibility(View.VISIBLE);
|
||||||
holder.placeholder.setText(item.getFeed().getTitle());
|
holder.placeholder.setText(item.getFeed().getTitle());
|
||||||
holder.title.setText(item.getTitle());
|
holder.title.setText(item.getTitle());
|
||||||
|
@ -241,6 +243,7 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<AllEpisodesR
|
||||||
ImageButton butSecondary;
|
ImageButton butSecondary;
|
||||||
FeedItem item;
|
FeedItem item;
|
||||||
MainActivity mainActivity;
|
MainActivity mainActivity;
|
||||||
|
int position;
|
||||||
|
|
||||||
public Holder(View itemView) {
|
public Holder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
@ -256,6 +259,8 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<AllEpisodesR
|
||||||
}
|
}
|
||||||
|
|
||||||
public FeedItem getFeedItem() { return item; }
|
public FeedItem getFeedItem() { return item; }
|
||||||
|
|
||||||
|
public int getItemPosition() { return position; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ItemAccess {
|
public interface ItemAccess {
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class FavoriteEpisodesFragment extends AllEpisodesFragment {
|
||||||
|
|
||||||
undoBarController.showUndoBar(false,
|
undoBarController.showUndoBar(false,
|
||||||
getString(R.string.removed_item), new FeedItemUndoToken(item,
|
getString(R.string.removed_item), new FeedItemUndoToken(item,
|
||||||
0)
|
holder.getItemPosition())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package de.danoeh.antennapod.fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -13,6 +15,7 @@ import com.mobeta.android.dslv.DragSortListView;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
|
import de.danoeh.antennapod.adapter.AllEpisodesRecycleAdapter;
|
||||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||||
import de.danoeh.antennapod.core.event.QueueEvent;
|
import de.danoeh.antennapod.core.event.QueueEvent;
|
||||||
|
@ -69,25 +72,31 @@ public class NewEpisodesFragment extends AllEpisodesFragment {
|
||||||
View root = super.onCreateViewHelper(inflater, container, savedInstanceState,
|
View root = super.onCreateViewHelper(inflater, container, savedInstanceState,
|
||||||
R.layout.episodes_fragment_with_undo);
|
R.layout.episodes_fragment_with_undo);
|
||||||
|
|
||||||
/** TODO!
|
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
|
||||||
listView.setRemoveListener(new DragSortListView.RemoveListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(int which) {
|
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
|
||||||
Log.d(TAG, "remove(" + which + ")");
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
|
||||||
|
AllEpisodesRecycleAdapter.Holder holder = (AllEpisodesRecycleAdapter.Holder)viewHolder;
|
||||||
|
Log.d(TAG, "remove(" + holder.getItemId() + ")");
|
||||||
if (subscription != null) {
|
if (subscription != null) {
|
||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
}
|
}
|
||||||
FeedItem item = (FeedItem) listView.getAdapter().getItem(which);
|
FeedItem item = holder.getFeedItem();
|
||||||
// we're marking it as unplayed since the user didn't actually play it
|
// we're marking it as unplayed since the user didn't actually play it
|
||||||
// but they don't want it considered 'NEW' anymore
|
// but they don't want it considered 'NEW' anymore
|
||||||
DBWriter.markItemPlayed(FeedItem.UNPLAYED, item.getId());
|
DBWriter.markItemPlayed(FeedItem.UNPLAYED, item.getId());
|
||||||
undoBarController.showUndoBar(false,
|
undoBarController.showUndoBar(false,
|
||||||
getString(R.string.marked_as_read_label), new FeedItemUndoToken(item,
|
getString(R.string.marked_as_read_label), new FeedItemUndoToken(item,
|
||||||
which)
|
holder.getItemPosition()));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
*/
|
|
||||||
|
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
|
||||||
|
itemTouchHelper.attachToRecyclerView(listView);
|
||||||
|
|
||||||
undoBarController = new UndoBarController<FeedItemUndoToken>(root.findViewById(R.id.undobar), new UndoBarController.UndoListener<FeedItemUndoToken>() {
|
undoBarController = new UndoBarController<FeedItemUndoToken>(root.findViewById(R.id.undobar), new UndoBarController.UndoListener<FeedItemUndoToken>() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue