diff --git a/README.md b/README.md index d90e2e77..cfbd3de2 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ public class YourAdapterClass extends FlexibleAdapter ext protected List mItems; protected List mDeletedItems; protected List mOriginalPosition; - //Searchable fields - protected static String mSearchText; //Static: It can exist only 1 searchText - + protected String mSearchText; protected Handler mHandler; - protected OnUpdateListener mUpdateListener; public FlexibleAdapter() { @@ -384,15 +381,15 @@ private void stopUndoTimer() { } } - public static boolean hasSearchText() { + public boolean hasSearchText() { return mSearchText != null && mSearchText.length() > 0; } - public static String getSearchText() { + public String getSearchText() { return mSearchText; } - public static void setSearchText(String searchText) { + public void setSearchText(String searchText) { if (searchText != null) mSearchText = searchText.trim().toLowerCase(Locale.getDefault()); else mSearchText = ""; @@ -497,9 +494,7 @@ protected void onPostExecute(Void result) { } } - /** - * This interface will contains only - */ + @Deprecated public interface OnUpdateListener { /** diff --git a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/SelectableAdapter.java b/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/SelectableAdapter.java index 224b3163..6472252a 100644 --- a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/SelectableAdapter.java +++ b/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/SelectableAdapter.java @@ -16,6 +16,7 @@ public abstract class SelectableAdapter extends RecyclerView.Adapter { private static final String TAG = SelectableAdapter.class.getSimpleName(); + /** * Default mode for selection */ @@ -36,10 +37,11 @@ public SelectableAdapter() { /** * Set the mode of the selection, MODE_SINGLE is the default: *
    - *
  • if {@link #MODE_SINGLE}, it will switch the selection position (previous selection is cleared automatically); - *
  • if {@link #MODE_MULTI}, it will add the position to the list of the items selected. + *
  • {@link #MODE_SINGLE} configures the adapter to react at the single tap over an item + * (previous selection is cleared automatically); + *
  • {@link #MODE_MULTI} configures the adapter to save the position to the list of the + * selected items. *
- * NOTE: #mModeMultiJustFinished is set true when #MODE_MULTI is finished. * * @param mode MODE_SINGLE or MODE_MULTI */ @@ -59,7 +61,7 @@ public int getMode() { } /** - * Indicates if the item at position position is selected. + * Indicates if the item, at the provided position, is selected. * * @param position Position of the item to check. * @return true if the item is selected, false otherwise. @@ -82,24 +84,26 @@ public void toggleSelection(int position) { * Toggle the selection status of the item at a given position.
* The behaviour depends on the selection mode previously set with {@link #setMode}. *

- *

* Optionally the item can be invalidated.
* However it is preferable to set false and to handle the Activated/Selected State of * the ItemView in the Click events of the ViewHolder after the selection is registered and * up to date: Very Useful if the item has views with own animation to perform! *

- *

* Usage: *

    *
  • If you don't want any item to be selected/activated at all, just don't call this method.
  • - *
  • To have actually the item visually selected you need to add a custom Selector Drawable to your layout/view of the Item. - * It's preferable: android:background="?attr/selectableItemBackground" in your layout, pointing to a custom Drawable in the style.xml - * (note: prefix ?android:attr seems to not work).
  • - *
  • In onClick, enable the Activated/Selected State of the ItemView of the ViewHolder after the listener consumed the event: + *
  • To have actually the item visually selected you need to add a custom Selector Drawable + * to your layout/view of the Item. It's preferable to set in your layout: + * android:background="?attr/selectableItemBackground", pointing to a custom Drawable + * in the style.xml (note: prefix ?android:attr doesn't work).
  • + *
  • In onClick event, enable the Activated/Selected State of the ItemView of the + * ViewHolder after the listener consumed the event: * itemView.setActivated(mAdapter.isSelected(getAdapterPosition()));
  • - *
  • In onBindViewHolder, adjust the selection status: holder.itemView.setActivated(isSelected(position));
  • - *
  • If invalidate is set true, {@link #notifyItemChanged} is called and {@link #onBindViewHolder} will be automatically called - * afterwards overriding any animation in the ItemView!
  • + *
  • In onBindViewHolder, adjust the selection status: + * holder.itemView.setActivated(isSelected(position));
  • + *
  • If invalidate is set true, {@link #notifyItemChanged} is called and + * {@link #onBindViewHolder} will be automatically called afterwards overriding any animation + * inside the ItemView!
  • *
* * @param position Position of the item to toggle the selection status for. @@ -125,16 +129,16 @@ public void toggleSelection(int position, boolean invalidate) { } /** - * Convenience method when there is nothing to skip. + * Convenience method when there is no specific view to skip. */ public void selectAll() { selectAll(-1); } /** - * Add the selection status for all items. + * Add the selection status for all items.
* The selector container is sequentially filled with All items positions. - *
Note: All items are invalidated and rebinded! + *
Note: All items are invalidated and rebound one by one! * * @param skipViewType ViewType for which we don't want selection */ @@ -150,9 +154,9 @@ public void selectAll(int skipViewType) { } /** - * Clear the selection status for all items one by one to not kill animations in the items. - *

- * Note 1: Items are invalidated and rebinded!
+ * Clear the selection status for all items one by one and it doesn't stop animations in the items. + *

+ * Note 1: Items are invalidated and rebound!
* Note 2: This method use java.util.Iterator to avoid java.util.ConcurrentModificationException. */ public void clearSelection() {