From f3913ed3648cb70ab39615b5afd5d2f25b3fc8e2 Mon Sep 17 00:00:00 2001
From: Ye feng <597231656@qq.com>
Date: Fri, 6 Apr 2018 13:49:50 +0200
Subject: [PATCH] migrate the RecyclerView
---
build.gradle | 1 -
libs/EnhancedListView/build.gradle | 33 -
.../src/main/AndroidManifest.xml | 6 -
.../android/listview/EnhancedListView.java | 969 ------------------
.../src/main/res/anim/elv_popup_hide.xml | 7 -
.../src/main/res/anim/elv_popup_show.xml | 7 -
.../res/drawable-hdpi/elv_ic_action_undo.png | Bin 813 -> 0 bytes
.../res/drawable-hdpi/elv_toast_frame.9.png | Bin 1249 -> 0 bytes
.../res/drawable-ldpi/elv_ic_action_undo.png | Bin 3104 -> 0 bytes
.../res/drawable-ldpi/elv_toast_frame.9.png | Bin 420 -> 0 bytes
.../res/drawable-mdpi/elv_ic_action_undo.png | Bin 545 -> 0 bytes
.../res/drawable-mdpi/elv_toast_frame.9.png | Bin 562 -> 0 bytes
.../res/drawable-xhdpi/elv_ic_action_undo.png | Bin 1068 -> 0 bytes
.../res/drawable-xhdpi/elv_toast_frame.9.png | Bin 1462 -> 0 bytes
.../drawable-xxhdpi/elv_ic_action_undo.png | Bin 1687 -> 0 bytes
.../res/drawable-xxhdpi/elv_toast_frame.9.png | Bin 1979 -> 0 bytes
.../src/main/res/drawable/elv_popup_bg.xml | 5 -
.../src/main/res/drawable/elv_undo_btn_bg.xml | 6 -
.../res/drawable/elv_undo_btn_bg_focused.xml | 5 -
.../res/drawable/elv_undo_btn_bg_pressed.xml | 5 -
.../main/res/layout-v19/elv_undo_popup.xml | 43 -
.../src/main/res/layout/elv_undo_popup.xml | 35 -
.../src/main/res/values-v19/colors.xml | 4 -
.../src/main/res/values/colors.xml | 10 -
.../src/main/res/values/dimens.xml | 7 -
.../src/main/res/values/strings.xml | 7 -
.../src/main/res/values/styles.xml | 7 -
.../ui/ConversationFragment.java | 57 +-
.../ui/ConversationsOverviewFragment.java | 190 ++--
.../conversations/ui/ShareWithActivity.java | 18 +-
.../ui/adapter/ConversationAdapter.java | 98 +-
.../ui/util/PendingActionHelper.java | 29 +
src/main/res/layout/activity_share_with.xml | 2 +-
src/main/res/layout/conversation_list_row.xml | 8 +-
.../fragment_conversations_overview.xml | 13 +-
src/main/res/values/strings.xml | 1 +
36 files changed, 250 insertions(+), 1323 deletions(-)
delete mode 100644 libs/EnhancedListView/build.gradle
delete mode 100644 libs/EnhancedListView/src/main/AndroidManifest.xml
delete mode 100644 libs/EnhancedListView/src/main/java/de/timroes/android/listview/EnhancedListView.java
delete mode 100644 libs/EnhancedListView/src/main/res/anim/elv_popup_hide.xml
delete mode 100644 libs/EnhancedListView/src/main/res/anim/elv_popup_show.xml
delete mode 100644 libs/EnhancedListView/src/main/res/drawable-hdpi/elv_ic_action_undo.png
delete mode 100644 libs/EnhancedListView/src/main/res/drawable-hdpi/elv_toast_frame.9.png
delete mode 100644 libs/EnhancedListView/src/main/res/drawable-ldpi/elv_ic_action_undo.png
delete mode 100644 libs/EnhancedListView/src/main/res/drawable-ldpi/elv_toast_frame.9.png
delete mode 100644 libs/EnhancedListView/src/main/res/drawable-mdpi/elv_ic_action_undo.png
delete mode 100644 libs/EnhancedListView/src/main/res/drawable-mdpi/elv_toast_frame.9.png
delete mode 100644 libs/EnhancedListView/src/main/res/drawable-xhdpi/elv_ic_action_undo.png
delete mode 100644 libs/EnhancedListView/src/main/res/drawable-xhdpi/elv_toast_frame.9.png
delete mode 100644 libs/EnhancedListView/src/main/res/drawable-xxhdpi/elv_ic_action_undo.png
delete mode 100644 libs/EnhancedListView/src/main/res/drawable-xxhdpi/elv_toast_frame.9.png
delete mode 100644 libs/EnhancedListView/src/main/res/drawable/elv_popup_bg.xml
delete mode 100644 libs/EnhancedListView/src/main/res/drawable/elv_undo_btn_bg.xml
delete mode 100644 libs/EnhancedListView/src/main/res/drawable/elv_undo_btn_bg_focused.xml
delete mode 100644 libs/EnhancedListView/src/main/res/drawable/elv_undo_btn_bg_pressed.xml
delete mode 100644 libs/EnhancedListView/src/main/res/layout-v19/elv_undo_popup.xml
delete mode 100644 libs/EnhancedListView/src/main/res/layout/elv_undo_popup.xml
delete mode 100644 libs/EnhancedListView/src/main/res/values-v19/colors.xml
delete mode 100644 libs/EnhancedListView/src/main/res/values/colors.xml
delete mode 100644 libs/EnhancedListView/src/main/res/values/dimens.xml
delete mode 100644 libs/EnhancedListView/src/main/res/values/strings.xml
delete mode 100644 libs/EnhancedListView/src/main/res/values/styles.xml
create mode 100644 src/main/java/eu/siacs/conversations/ui/util/PendingActionHelper.java
diff --git a/build.gradle b/build.gradle
index ea48488f2..41ed6e668 100644
--- a/build.gradle
+++ b/build.gradle
@@ -33,7 +33,6 @@ ext {
}
dependencies {
- implementation project(':libs:EnhancedListView')
playstoreImplementation 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'org.sufficientlysecure:openpgp-api:10.0'
implementation 'com.soundcloud.android:android-crop:1.0.1@aar'
diff --git a/libs/EnhancedListView/build.gradle b/libs/EnhancedListView/build.gradle
deleted file mode 100644
index b43eedae8..000000000
--- a/libs/EnhancedListView/build.gradle
+++ /dev/null
@@ -1,33 +0,0 @@
-apply plugin: 'com.android.library'
-
-repositories {
- mavenCentral()
- google()
-}
-
-dependencies {
- implementation 'com.android.support:support-v4:27.0.2'
- implementation 'com.nineoldandroids:library:2.4.0'
-}
-
-android {
- compileSdkVersion 27
- buildToolsVersion "27.0.3"
-
- defaultConfig {
- minSdkVersion 14
- targetSdkVersion 25
- versionName "0.3.4"
- versionCode 9
- }
-
- lintOptions {
- abortOnError false
- }
-}
-
-apply plugin: 'maven'
-apply plugin: 'signing'
-
-version = android.defaultConfig.versionName
-group = "de.timroes.android"
diff --git a/libs/EnhancedListView/src/main/AndroidManifest.xml b/libs/EnhancedListView/src/main/AndroidManifest.xml
deleted file mode 100644
index 5f9f17429..000000000
--- a/libs/EnhancedListView/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/libs/EnhancedListView/src/main/java/de/timroes/android/listview/EnhancedListView.java b/libs/EnhancedListView/src/main/java/de/timroes/android/listview/EnhancedListView.java
deleted file mode 100644
index 45222f968..000000000
--- a/libs/EnhancedListView/src/main/java/de/timroes/android/listview/EnhancedListView.java
+++ /dev/null
@@ -1,969 +0,0 @@
-/*
- * Copyright 2012 - 2013 Roman Nurik, Jake Wharton, Tim Roes
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package de.timroes.android.listview;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.os.Build;
-import android.os.Handler;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.VelocityTracker;
-import android.view.View;
-import android.view.ViewConfiguration;
-import android.view.ViewGroup;
-import android.view.ViewParent;
-import android.widget.AbsListView;
-import android.widget.Button;
-import android.widget.ListView;
-import android.widget.PopupWindow;
-import android.widget.TextView;
-
-import com.nineoldandroids.animation.Animator;
-import com.nineoldandroids.animation.AnimatorListenerAdapter;
-import com.nineoldandroids.animation.ValueAnimator;
-import com.nineoldandroids.view.ViewHelper;
-import com.nineoldandroids.view.ViewPropertyAnimator;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-/**
- * A {@link android.widget.ListView} offering enhanced features like Swipe To Dismiss and an
- * undo functionality. See the documentation on GitHub for more information.
- *
- * @author Tim Roes
- */
-public class EnhancedListView extends ListView {
-
- /**
- * Defines the style in which undos should be displayed and handled in the list.
- * Pass this to {@link #setUndoStyle(de.timroes.android.listview.EnhancedListView.UndoStyle)}
- * to change the default behavior from {@link #SINGLE_POPUP}.
- */
- public enum UndoStyle {
-
- /**
- * Shows a popup window, that allows the user to undo the last
- * dismiss. If another element is deleted, the undo popup will undo that deletion.
- * The user is only able to undo the last deletion.
- */
- SINGLE_POPUP,
-
- /**
- * Shows a popup window, that allows the user to undo the last dismiss.
- * If another item is deleted, this will be added to the chain of undos. So pressing
- * undo will undo the last deletion, pressing it again will undo the deletion before that,
- * and so on. As soon as the popup vanished (e.g. because {@link #setUndoHideDelay(int) autoHideDelay}
- * is over) all saved undos will be discarded.
- */
- MULTILEVEL_POPUP,
-
- /**
- * Shows a popup window, that allows the user to undo the last dismisses.
- * If another item is deleted, while there is still an undo popup visible, the label
- * of the button changes to Undo all and a press on the button, will discard
- * all stored undos. As soon as the popup vanished (e.g. because {@link #setUndoHideDelay(int) autoHideDelay}
- * is over) all saved undos will be discarded.
- */
- COLLAPSED_POPUP
-
- }
-
- /**
- * Defines the direction in which list items can be swiped out to delete them.
- * Use {@link #setSwipeDirection(de.timroes.android.listview.EnhancedListView.SwipeDirection)}
- * to change the default behavior.
- *
- * Note: This method requires the Swipe to Dismiss feature enabled. Use
- * {@link #enableSwipeToDismiss()}
- * to enable the feature.
- */
- public enum SwipeDirection {
-
- /**
- * The user can swipe each item into both directions (left and right) to delete it.
- */
- BOTH,
-
- /**
- * The user can only swipe the items to the beginning of the item to
- * delete it. The start of an item is in Left-To-Right languages the left
- * side and in Right-To-Left languages the right side. Before API level
- * 17 this is always the left side.
- */
- START,
-
- /**
- * The user can only swipe the items to the end of the item to delete it.
- * This is in Left-To-Right languages the right side in Right-To-Left
- * languages the left side. Before API level 17 this will always be the
- * right side.
- */
- END
-
- }
-
- /**
- * The callback interface used by {@link #setShouldSwipeCallback(EnhancedListView.OnShouldSwipeCallback)}
- * to inform its client that a list item is going to be swiped and check whether is
- * should or not. Implement this to prevent some items from be swiped.
- */
- public interface OnShouldSwipeCallback {
-
- /**
- * Called when the user is swiping an item from the list.
- *
- * If the user should get the possibility to swipe the item, return true.
- * Otherwise, return false to disable swiping for this item.
- *
- * @param listView The {@link EnhancedListView} the item is wiping from.
- * @param position The position of the item to swipe in your adapter.
- * @return Whether the item should be swiped or not.
- */
- boolean onShouldSwipe(EnhancedListView listView, int position);
-
- }
-
- /**
- * The callback interface used by {@link #setDismissCallback(EnhancedListView.OnDismissCallback)}
- * to inform its client about a successful dismissal of one or more list item positions.
- * Implement this to remove items from your adapter, that has been swiped from the list.
- */
- public interface OnDismissCallback {
-
- /**
- * Called when the user has deleted an item from the list. The item has been deleted from
- * the {@code listView} at {@code position}. Delete this item from your adapter.
- *
- * Don't return from this method, before your item has been deleted from the adapter, meaning
- * if you delete the item in another thread, you have to make sure, you don't return from
- * this method, before the item has been deleted. Since the way how you delete your item
- * depends on your data and adapter, the {@link de.timroes.android.listview.EnhancedListView}
- * cannot handle that synchronizing for you. If you return from this method before you removed
- * the view from the adapter, you will most likely get errors like exceptions and flashing
- * items in the list.
- *
- * If the user should get the possibility to undo this deletion, return an implementation
- * of {@link de.timroes.android.listview.EnhancedListView.Undoable} from this method.
- * If you return {@code null} no undo will be possible. You are free to return an {@code Undoable}
- * for some items, and {@code null} for others, though it might be a horrible user experience.
- *
- * @param listView The {@link EnhancedListView} the item has been deleted from.
- * @param position The position of the item to delete from your adapter.
- * @return An {@link de.timroes.android.listview.EnhancedListView.Undoable}, if you want
- * to give the user the possibility to undo the deletion.
- */
- Undoable onDismiss(EnhancedListView listView, int position);
-
- }
-
- /**
- * Extend this abstract class and return it from
- * {@link EnhancedListView.OnDismissCallback#onDismiss(EnhancedListView, int)}
- * to let the user undo the deletion you've done with your {@link EnhancedListView.OnDismissCallback}.
- * You have at least to implement the {@link #undo()} method, and can override {@link #discard()}
- * and {@link #getTitle()} to offer more functionality. See the README file for example implementations.
- */
- public abstract static class Undoable {
-
- /**
- * This method must undo the deletion you've done in
- * {@link EnhancedListView.OnDismissCallback#onDismiss(EnhancedListView, int)} and reinsert
- * the element into the adapter.
- *
- * In the most implementations, you will only remove the list item from your adapter
- * in the {@code onDismiss} method and delete it from the database (or your permanent
- * storage) in {@link #discard()}. In that case you only need to reinsert the item
- * to the adapter.
- */
- public abstract void undo();
-
- /**
- * Returns the individual undo message for this undo. This will be displayed in the undo
- * window, beside the undo button. The default implementation returns {@code null},
- * what will lead in a default message to be displayed in the undo window.
- * Don't call the super method, when overriding this method.
- *
- * @return The title for a special string.
- */
- public String getTitle() {
- return null;
- }
-
- /**
- * Discard the undo, meaning the user has no longer the possibility to undo the deletion.
- * Implement this, to finally delete your stuff from permanent storages like databases
- * (whereas in {@link de.timroes.android.listview.EnhancedListView.OnDismissCallback#onKeyDown(int, android.view.KeyEvent)}
- * you should only remove it from the list adapter).
- */
- public void discard() { }
-
- }
-
- private class PendingDismissData implements Comparable {
-
- public int position;
- /**
- * The view that should get swiped out.
- */
- public View view;
- /**
- * The whole list item view.
- */
- public View childView;
-
- PendingDismissData(int position, View view, View childView) {
- this.position = position;
- this.view = view;
- this.childView = childView;
- }
-
- @Override
- public int compareTo(PendingDismissData other) {
- // Sort by descending position
- return other.position - position;
- }
-
- }
-
- private class UndoClickListener implements OnClickListener {
-
- /**
- * Called when a view has been clicked.
- *
- * @param v The view that was clicked.
- */
- @Override
- public void onClick(View v) {
- if(!mUndoActions.isEmpty()) {
- switch(mUndoStyle) {
- case SINGLE_POPUP:
- mUndoActions.get(0).undo();
- mUndoActions.clear();
- break;
- case COLLAPSED_POPUP:
- Collections.reverse(mUndoActions);
- for(Undoable undo : mUndoActions) {
- undo.undo();
- }
- mUndoActions.clear();
- break;
- case MULTILEVEL_POPUP:
- mUndoActions.get(mUndoActions.size() - 1).undo();
- mUndoActions.remove(mUndoActions.size() - 1);
- break;
- }
- }
-
- // Dismiss dialog or change text
- if(mUndoActions.isEmpty()) {
- if(mUndoPopup.isShowing()) {
- mUndoPopup.dismiss();
- }
- } else {
- changePopupText();
- changeButtonLabel();
- }
-
- mValidDelayedMsgId++;
- }
- }
-
- private class HideUndoPopupHandler extends Handler {
-
- /**
- * Subclasses must implement this to receive messages.
- */
- @Override
- public void handleMessage(Message msg) {
- if(msg.what == mValidDelayedMsgId) {
- discardUndo();
- }
- }
- }
-
- // Cached ViewConfiguration and system-wide constant values
- private float mSlop;
- private int mMinFlingVelocity;
- private int mMaxFlingVelocity;
- private long mAnimationTime;
-
- private final Object[] mAnimationLock = new Object[0];
-
- // Swipe-To-Dismiss
- private boolean mSwipeEnabled;
- private OnDismissCallback mDismissCallback;
- private OnShouldSwipeCallback mShouldSwipeCallback;
- private UndoStyle mUndoStyle = UndoStyle.SINGLE_POPUP;
- private boolean mTouchBeforeAutoHide = true;
- private SwipeDirection mSwipeDirection = SwipeDirection.BOTH;
- private int mUndoHideDelay = 5000;
- private int mSwipingLayout;
-
- private List mUndoActions = new ArrayList();
- private SortedSet mPendingDismisses = new TreeSet();
- private List mAnimatedViews = new LinkedList();
- private int mDismissAnimationRefCount;
-
- private boolean mSwipePaused;
- private boolean mSwiping;
- private int mViewWidth = 1; // 1 and not 0 to prevent dividing by zero
- private View mSwipeDownView;
- private View mSwipeDownChild;
- private TextView mUndoPopupTextView;
- private VelocityTracker mVelocityTracker;
- private float mDownX;
- private int mDownPosition;
- private float mScreenDensity;
-
- private PopupWindow mUndoPopup;
- private int mValidDelayedMsgId;
- private Handler mHideUndoHandler = new HideUndoPopupHandler();
- private Button mUndoButton;
- // END Swipe-To-Dismiss
-
- /**
- * {@inheritDoc}
- */
- public EnhancedListView(Context context) {
- super(context);
- init(context);
- }
-
- /**
- * {@inheritDoc}
- */
- public EnhancedListView(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context);
- }
-
- /**
- * {@inheritDoc}
- */
- public EnhancedListView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- init(context);
- }
-
- private void init(Context ctx) {
-
- if(isInEditMode()) {
- // Skip initializing when in edit mode (IDE preview).
- return;
- }
- ViewConfiguration vc =ViewConfiguration.get(ctx);
- mSlop = getResources().getDimension(R.dimen.elv_touch_slop);
- mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
- mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
- mAnimationTime = ctx.getResources().getInteger(
- android.R.integer.config_shortAnimTime);
-
- // Initialize undo popup
- LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View undoView = inflater.inflate(R.layout.elv_undo_popup, null);
- mUndoButton = (Button)undoView.findViewById(R.id.undo);
- mUndoButton.setOnClickListener(new UndoClickListener());
- mUndoButton.setOnTouchListener(new OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- // If the user touches the screen invalidate the current running delay by incrementing
- // the valid message id. So this delay won't hide the undo popup anymore
- mValidDelayedMsgId++;
- return false;
- }
- });
- mUndoPopupTextView = (TextView)undoView.findViewById(R.id.text);
-
- mUndoPopup = new PopupWindow(undoView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, false);
- mUndoPopup.setAnimationStyle(R.style.elv_fade_animation);
-
- mScreenDensity = getResources().getDisplayMetrics().density;
- // END initialize undo popup
-
- setOnScrollListener(makeScrollListener());
-
- }
-
- /**
- * Enables the Swipe to Dismiss feature for this list. This allows users to swipe out
- * an list item element to delete it from the list. Every time the user swipes out an element
- * {@link de.timroes.android.listview.EnhancedListView.OnDismissCallback#onDismiss(EnhancedListView, int)}
- * of the given {@link de.timroes.android.listview.EnhancedListView} will be called. To enable
- * undo of the deletion, return an {@link de.timroes.android.listview.EnhancedListView.Undoable}
- * from {@link de.timroes.android.listview.EnhancedListView.OnDismissCallback#onDismiss(EnhancedListView, int)}.
- * Return {@code null}, if you don't want the undo feature enabled. Read the README file
- * or the demo project for more detailed samples.
- *
- * @return The {@link de.timroes.android.listview.EnhancedListView}
- * @throws java.lang.IllegalStateException when you haven't passed an {@link EnhancedListView.OnDismissCallback}
- * to {@link #setDismissCallback(EnhancedListView.OnDismissCallback)} before calling this
- * method.
- */
- public EnhancedListView enableSwipeToDismiss() {
-
- if(mDismissCallback == null) {
- throw new IllegalStateException("You must pass an OnDismissCallback to the list before enabling Swipe to Dismiss.");
- }
-
- mSwipeEnabled = true;
-
- return this;
- }
-
- /**
- * Disables the Swipe to Dismiss feature for this list.
- *
- * @return This {@link de.timroes.android.listview.EnhancedListView}
- */
- public EnhancedListView disableSwipeToDismiss() {
- mSwipeEnabled = false;
- return this;
- }
-
- /**
- * Sets the callback to be called when the user dismissed an item from the list (either by
- * swiping it out - with Swipe to Dismiss enabled - or by deleting it with
- * {@link #delete(int)}). You must call this, before you call {@link #delete(int)} or
- * {@link #enableSwipeToDismiss()} otherwise you will get an {@link java.lang.IllegalStateException}.
- *
- * @param dismissCallback The callback used to handle dismisses of list items.
- * @return This {@link de.timroes.android.listview.EnhancedListView}
- */
- public EnhancedListView setDismissCallback(OnDismissCallback dismissCallback) {
- mDismissCallback = dismissCallback;
- return this;
- }
-
- /**
- * Sets the callback to be called when the user is swiping an item from the list.
- *
- * @param shouldSwipeCallback The callback used to handle swipes of list items.
- * @return This {@link de.timroes.android.listview.EnhancedListView}
- */
- public EnhancedListView setShouldSwipeCallback(OnShouldSwipeCallback shouldSwipeCallback) {
- mShouldSwipeCallback = shouldSwipeCallback;
- return this;
- }
-
- /**
- * Sets the undo style of this list. See the javadoc of {@link de.timroes.android.listview.EnhancedListView.UndoStyle}
- * for a detailed explanation of the different styles. The default style (if you never call this
- * method) is {@link de.timroes.android.listview.EnhancedListView.UndoStyle#SINGLE_POPUP}.
- *
- * @param undoStyle The style of this listview.
- * @return This {@link de.timroes.android.listview.EnhancedListView}
- */
- public EnhancedListView setUndoStyle(UndoStyle undoStyle) {
- mUndoStyle = undoStyle;
- return this;
- }
-
- /**
- * Sets the time in milliseconds after which the undo popup automatically disappears.
- * The countdown will start when the user touches the screen. If you want to start the countdown
- * immediately when the popups appears, call {@link #setRequireTouchBeforeDismiss(boolean)} with
- * {@code false}.
- *
- * @param hideDelay The delay in milliseconds.
- * @return This {@link de.timroes.android.listview.EnhancedListView}
- */
- public EnhancedListView setUndoHideDelay(int hideDelay) {
- mUndoHideDelay = hideDelay;
- return this;
- }
-
- /**
- * Sets whether another touch on the view is required before the popup counts down to dismiss
- * the undo popup. By default this is set to {@code true}.
- *
- * @param touchBeforeDismiss Whether the screen needs to be touched before the countdown starts.
- * @return This {@link de.timroes.android.listview.EnhancedListView}
- *
- * @see #setUndoHideDelay(int)
- */
- public EnhancedListView setRequireTouchBeforeDismiss(boolean touchBeforeDismiss) {
- mTouchBeforeAutoHide = touchBeforeDismiss;
- return this;
- }
-
- /**
- * Sets the directions in which a list item can be swiped to delete.
- * By default this is set to {@link SwipeDirection#BOTH} so that an item
- * can be swiped into both directions.
- *
- * Note: This method requires the Swipe to Dismiss feature enabled. Use
- * {@link #enableSwipeToDismiss()} to enable the feature.
- *
- * @param direction The direction to which the swipe should be limited.
- * @return This {@link de.timroes.android.listview.EnhancedListView}
- */
- public EnhancedListView setSwipeDirection(SwipeDirection direction) {
- mSwipeDirection = direction;
- return this;
- }
-
- /**
- * Sets the id of the view, that should be moved, when the user swipes an item.
- * Only the view with the specified id will move, while all other views in the list item, will
- * stay where they are. This might be usefull to have a background behind the view that is swiped
- * out, to stay where it is (and maybe explain that the item is going to be deleted).
- * If you never call this method (or call it with 0), the whole view will be swiped. Also if there
- * is no view in a list item, with the given id, the whole view will be swiped.
- *
- * Note: This method requires the Swipe to Dismiss feature enabled. Use
- * {@link #enableSwipeToDismiss()} to enable the feature.
- *
- * @param swipingLayoutId The id (from R.id) of the view, that should be swiped.
- * @return This {@link de.timroes.android.listview.EnhancedListView}
- */
- public EnhancedListView setSwipingLayout(int swipingLayoutId) {
- mSwipingLayout = swipingLayoutId;
- return this;
- }
-
- /**
- * Discard all stored undos and hide the undo popup dialog.
- * This method must be called in {@link android.app.Activity#onStop()}. Otherwise
- * {@link EnhancedListView.Undoable#discard()} might not be called for several items, what might
- * break your data consistency.
- */
- public void discardUndo() {
- for(Undoable undoable : mUndoActions) {
- undoable.discard();
- }
- mUndoActions.clear();
- if(mUndoPopup.isShowing()) {
- mUndoPopup.dismiss();
- }
- }
-
- /**
- * Delete the list item at the specified position. This will animate the item sliding out of the
- * list and then collapsing until it vanished (same as if the user slides out an item).
- *