fix multidefined swipe problem in history page
This commit is contained in:
parent
65a6488e44
commit
02d986fc89
3 changed files with 21 additions and 7 deletions
|
@ -55,7 +55,7 @@ public abstract class HistoryFragment<E extends HistoryEntry> extends BaseFragme
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private HistoryEntryAdapter<E, ? extends RecyclerView.ViewHolder> mHistoryAdapter;
|
private HistoryEntryAdapter<E, ? extends RecyclerView.ViewHolder> mHistoryAdapter;
|
||||||
private ItemTouchHelper.SimpleCallback mHistoryItemSwipeCallback;
|
private ItemTouchHelper.SimpleCallback mHistoryItemSwipeCallback;
|
||||||
private int allowedSwipeToDeleteDirections = ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
|
// private int allowedSwipeToDeleteDirections = ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
|
||||||
|
|
||||||
private HistoryDAO<E> mHistoryDataSource;
|
private HistoryDAO<E> mHistoryDataSource;
|
||||||
private PublishSubject<Collection<E>> mHistoryEntryDeleteSubject;
|
private PublishSubject<Collection<E>> mHistoryEntryDeleteSubject;
|
||||||
|
@ -99,7 +99,11 @@ public abstract class HistoryFragment<E extends HistoryEntry> extends BaseFragme
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mHistoryItemSwipeCallback = new ItemTouchHelper.SimpleCallback(0, allowedSwipeToDeleteDirections) {
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void historyItemSwipeCallback(int swipeDirection) {
|
||||||
|
mHistoryItemSwipeCallback = new ItemTouchHelper.SimpleCallback(0, swipeDirection) {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
|
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -265,10 +269,6 @@ public abstract class HistoryFragment<E extends HistoryEntry> extends BaseFragme
|
||||||
mRecyclerViewState = mRecyclerView.getLayoutManager().onSaveInstanceState();
|
mRecyclerViewState = mRecyclerView.getLayoutManager().onSaveInstanceState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAllowedSwipeToDeleteDirections(int allowedSwipeToDeleteDirections) {
|
|
||||||
this.allowedSwipeToDeleteDirections = allowedSwipeToDeleteDirections;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when history enabled flag is changed.
|
* Called when history enabled flag is changed.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package org.schabi.newpipe.history;
|
package org.schabi.newpipe.history;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -17,11 +20,19 @@ import org.schabi.newpipe.util.NavigationHelper;
|
||||||
|
|
||||||
public class SearchHistoryFragment extends HistoryFragment<SearchHistoryEntry> {
|
public class SearchHistoryFragment extends HistoryFragment<SearchHistoryEntry> {
|
||||||
|
|
||||||
|
private static int allowedSwipeToDeleteDirections = ItemTouchHelper.RIGHT;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static SearchHistoryFragment newInstance() {
|
public static SearchHistoryFragment newInstance() {
|
||||||
return new SearchHistoryFragment();
|
return new SearchHistoryFragment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
historyItemSwipeCallback(allowedSwipeToDeleteDirections);
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected SearchHistoryAdapter createAdapter() {
|
protected SearchHistoryAdapter createAdapter() {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -26,6 +27,8 @@ import org.schabi.newpipe.util.NavigationHelper;
|
||||||
|
|
||||||
public class WatchedHistoryFragment extends HistoryFragment<WatchHistoryEntry> {
|
public class WatchedHistoryFragment extends HistoryFragment<WatchHistoryEntry> {
|
||||||
|
|
||||||
|
private static int allowedSwipeToDeleteDirections = ItemTouchHelper.LEFT;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static WatchedHistoryFragment newInstance() {
|
public static WatchedHistoryFragment newInstance() {
|
||||||
return new WatchedHistoryFragment();
|
return new WatchedHistoryFragment();
|
||||||
|
@ -34,7 +37,7 @@ public class WatchedHistoryFragment extends HistoryFragment<WatchHistoryEntry> {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
historyItemSwipeCallback(allowedSwipeToDeleteDirections);
|
||||||
}
|
}
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
|
|
Loading…
Reference in a new issue