public class

NearestInTouchBoundsChildViewFinder

extends Object
implements ChildViewFinder
java.lang.Object
   ↳ com.shinobicontrols.grids.supplement.NearestInTouchBoundsChildViewFinder

Class Overview

This ChildViewFinder searches for the nearest child View to some given X and Y co-ordinates that is within some specified bounds. Thus, it includes the space taken up by gridlines and other android.support.v7.widget.RecyclerView.ItemDecorations in its search.

The check for the X and Y co-ordinates being within bounds is performed in the isWithinTouchBounds(GridRecyclerView, float, float) method. By default, the bounds are that of the parent ShinobiGridView. Override this method to define different touch bounds.

If no child View is found, null is returned.

Summary

Public Constructors
NearestInTouchBoundsChildViewFinder()
Public Methods
View findChildViewUnder(GridRecyclerView gridRecyclerView, float x, float y)

Returns the child View of the RecyclerView that corresponds to the given X and Y co-ordinates.

Protected Methods
boolean isWithinTouchBounds(GridRecyclerView gridRecyclerView, float x, float y)

Returns whether or not the given X and Y co-ordinates are considered to be within some valid bounds for touch events.

[Expand]
Inherited Methods
From class java.lang.Object
From interface com.shinobicontrols.grids.supplement.ChildViewFinder

Public Constructors

public NearestInTouchBoundsChildViewFinder ()

Public Methods

public View findChildViewUnder (GridRecyclerView gridRecyclerView, float x, float y)

Returns the child View of the RecyclerView that corresponds to the given X and Y co-ordinates. If no child View is found null should be returned.

This method defines the way in which the child View is searched for and particular implementations will search for child views in different ways.

Parameters
gridRecyclerView the GridRecyclerView in which to search for a child View for the given X and Y co-ordinates
x the X co-ordinate at which to search for a child View
y the Y co-ordinate at which to search for a child View
Returns
  • the child View of recyclerView that corresponds to the X and Y co-ordinates, or null if no child is found.

Protected Methods

protected boolean isWithinTouchBounds (GridRecyclerView gridRecyclerView, float x, float y)

Returns whether or not the given X and Y co-ordinates are considered to be within some valid bounds for touch events.

By default, this method uses the parent ShinobiGridView's bounds as the area considered valid. This allows, for example, a row to be dragged to and released on the header row, and will be considered as a valid row reorder putting the dragged row at the top of the data items.

Parameters
gridRecyclerView the RecyclerView to which the X and Y co-ordinates are relative to
x the X co-ordinate to check for being within the touch bounds
y the Y co-ordinate to check for being within the touch bounds
Returns
  • whether the given MotionEvent's X and Y co-ordinates are considered to be within the valid bounds for touch events