Skip to content

Commit

Permalink
Resolved #384 - Ability to Recognize Child View Click
Browse files Browse the repository at this point in the history
  • Loading branch information
davideas committed Feb 4, 2018
1 parent 8f9714c commit 3dabac7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ This library is configurable and it guides the developers to create a better use
### Main features
* Simple, Single & Multi selection mode with [ActionModeHelper](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-ActionModeHelper).
* Auto mapping multi view types with [Item interfaces](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-Item-Interfaces).
* Predefined [ViewHolders](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-ViewHolders) with click listeners and others callbacks.
* Predefined [ViewHolders](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-ViewHolders) with (**NEW!** child) click listeners and others callbacks.
* Customizable [FastScroller](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-FastScroller) with new features.
* Customizable [Scrolling Animations](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-Adapter-Animations) based on adapter position and beyond.
* Customizable [Animations](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-Adapter-Animations#item-animations-when-items-are-notified) when adding and removing items.
* [Advanced item decoration](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-Flexible-Item-Decoration) (customizable dividers, sections gap and item offsets).
* Restore deleted items with [UndoHelper](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-UndoHelper); Works with Expandable items too!
* **NEW!** EmptyView handling with [EmptyViewHelper](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-EmptyViewHelper).
* Async [Filter](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-Search-Filter) with Spannable text; Result list is animated; With optional original list; Works with sub items too!
* [High performance](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-Search-Filter#performance-result-when-animations-are-active) updates and filter on big list (far better than _DiffUtil_).
* [Headers and Sections](https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-Headers-and-Sections) with sticky behaviour fully clickable and collapsible, elevation, transparency and automatic linkage!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ public void onTitleModified(int position, String newTitle) {
* ======================================================================== */

@Override
public boolean onItemClick(int position) {
public boolean onItemClick(View view, int position) {
IFlexible flexibleItem = mAdapter.getItem(position);
if (flexibleItem instanceof OverallItem) {
OverallItem overallItem = (OverallItem) flexibleItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public class FlexibleAdapter<T extends IFlexible>
* Simple Constructor with NO listeners!
*
* @param items items to display.
* @see #FlexibleAdapter(List, Object)
* @see #FlexibleAdapter(List, Object, boolean)
* @see FlexibleAdapter(List, Object)
* @see FlexibleAdapter(List, Object, boolean)
* @since 4.2.0 Created
* <br>5.0.0-rc2 Copy of the Original List is done internally
*/
Expand All @@ -206,8 +206,8 @@ public FlexibleAdapter(@Nullable List<T> items) {
* <li>{@link OnStickyHeaderChangeListener}
* <li>{@link OnUpdateListener}
* </ul>
* @see #FlexibleAdapter(List)
* @see #FlexibleAdapter(List, Object, boolean)
* @see FlexibleAdapter(List)
* @see FlexibleAdapter(List, Object, boolean)
* @see #addListener(Object)
* @since 5.0.0-b1 Created
* <br>5.0.0-rc2 Copy of the Original List is done internally
Expand All @@ -217,16 +217,16 @@ public FlexibleAdapter(@Nullable List<T> items, @Nullable Object listeners) {
}

/**
* Same as {@link #FlexibleAdapter(List, Object)} with possibility to set stableIds.
* Same as {@link FlexibleAdapter(List, Object)} with possibility to set stableIds.
* <p><b>Tip:</b> Setting {@code true} allows the RecyclerView to rebind only items really
* changed after a refresh with {@link #notifyDataSetChanged()} or after swapping Adapter.
* This increases performance.<br>
* Set {@code true} only if items implement {@link Object#hashCode()} and have unique ids.
* The method {@link #setHasStableIds(boolean)} will be called.</p>
*
* @param stableIds set {@code true} if item implements {@code hashcode()} and have unique ids.
* @see #FlexibleAdapter(List)
* @see #FlexibleAdapter(List, Object)
* @see FlexibleAdapter(List)
* @see FlexibleAdapter(List, Object)
* @see #addListener(Object)
* @since 5.0.0-b8 Created
* <br>5.0.0-rc2 Copy of the Original List is done internally
Expand Down Expand Up @@ -4984,17 +4984,19 @@ public interface OnDeleteCompleteListener {
public interface OnItemClickListener {
/**
* Called when single tap occurs.
* <p>This method receives the click event generated from the itemView to check if one
* of the selection mode ({@code SINGLE or MULTI}) is enabled in order to activate the
* itemView.</p>
* For Expandable Views it will toggle the Expansion if configured so.
* <p>The click event is generated from the itemView or any view inside it (if registered).</p>
* Here, we check if one of the selection mode ({@code SINGLE or MULTI}) is enabled in order
* to activate the itemView.</p>
* To register the click event to any subview, just assign the ViewHolder instance as click
* listener to that view.
*
* @param view the view that generated the event
* @param position the adapter position of the item clicked
* @return true if the click should activate the itemView according to the selection mode,
* false for no change to the itemView.
* @since 5.0.0-b1
*/
boolean onItemClick(int position);
boolean onItemClick(View view, int position);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void onClick(View view) {
if (mAdapter.mItemClickListener != null && mActionState == ItemTouchHelper.ACTION_STATE_IDLE) {
Log.v("onClick on position %s mode=%s", position, LayoutUtils.getModeName(mAdapter.getMode()));
// Get the permission to activate the View from user
if (mAdapter.mItemClickListener.onItemClick(position)) {
if (mAdapter.mItemClickListener.onItemClick(view, position)) {
// Now toggle the activation
toggleActivation();
}
Expand Down

0 comments on commit 3dabac7

Please sign in to comment.