Use RecyclerView onGenericMotionEvent

This commit is contained in:
seven332 committed 2015-05-22 22:28:07 +08:00
1 parent 27abd5f5e0
commit 0d56f13ee3
1 file changed
-40
@@ -31,9 +31,7 @@ import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.SparseBooleanArray;
import android.util.StateSet;
import android.util.TypedValue;
import android.view.HapticFeedbackConstants;
import android.view.InputDevice;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
@@ -658,44 +656,6 @@ public class EasyRecyclerView extends RecyclerView {
}
}
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
switch (event.getAction()) {
case MotionEvent.ACTION_SCROLL: {
if (getScrollState() != SCROLL_STATE_DRAGGING) {
final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
if (vscroll != 0) {
final int delta = (int) (vscroll * getVerticalScrollFactor());
scrollBy(0, -delta);
}
}
}
}
}
return super.onGenericMotionEvent(event);
}
/**
* Gets a scale factor that determines the distance the view should scroll
* vertically in response to {@link android.view.MotionEvent#ACTION_SCROLL}.
* @return The vertical scroll scale factor.
*/
@Override
protected float getVerticalScrollFactor() {
if (mVerticalScrollFactor == 0) {
TypedValue outValue = new TypedValue();
if (!getContext().getTheme().resolveAttribute(
0x0101004d, outValue, true)) {//com.android.internal.R.attr.listPreferredItemHeight
throw new IllegalStateException(
"Expected theme to define listPreferredItemHeight.");
}
mVerticalScrollFactor = outValue.getDimension(
getContext().getResources().getDisplayMetrics());
}
return mVerticalScrollFactor;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (!isEnabled()) {