added remove handler for list view.

Not working yet because dslv.startDrag returns false unless the list view supports dragging. I'm not sure we want dragging, just fling remove.
This commit is contained in:
Tom Hennen 2015-03-29 15:12:20 -04:00
parent f104bc5b9b
commit 1a63f26de4
2 changed files with 32 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v7.widget.SearchView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@ -43,6 +44,7 @@ import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.DownloadRequester;
import de.danoeh.antennapod.core.util.QueueAccess;
import de.danoeh.antennapod.core.util.gui.FeedItemUndoToken;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
@ -242,6 +244,34 @@ public class NewEpisodesFragment extends Fragment {
}
});
listView.setDragSortListener(new DragSortListView.DragSortListener() {
@Override
public void drag(int from, int to) {
// no drag
}
@Override
public void drop(int from, int to) {
// no drop
}
@Override
public void remove(int which) {
Log.d(TAG, "remove("+which+")");
stopItemLoader();
FeedItem item = (FeedItem) listView.getAdapter().getItem(which);
DBWriter.markItemRead(getActivity(), item.getId(), true);
// TODO: provide undo?
/*
undoBarController.showUndoBar(false,
getString(R.string.removed_from_queue), new FeedItemUndoToken(item,
which)
);
*/
}
});
final int secondColor = (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) ? R.color.swipe_refresh_secondary_color_dark : R.color.swipe_refresh_secondary_color_light;
if (!itemsLoaded) {

View File

@ -236,7 +236,8 @@ public class DragSortController extends SimpleFloatViewManager implements View.O
@Override
public boolean onTouch(View v, MotionEvent ev) {
if (!mDslv.isDragEnabled() || mDslv.listViewIntercepted()) {
if (!(mDslv.isDragEnabled() || mRemoveEnabled)
|| mDslv.listViewIntercepted()) {
return false;
}