Java Code Examples for android.view.ViewConfiguration#getMinimumFlingVelocity()

The following examples show how to use android.view.ViewConfiguration#getMinimumFlingVelocity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method.
 *
 * @param context
 */
@SuppressWarnings("deprecation")
public static void init(Context context) {

    if (context == null) {
        // noinspection deprecation
        mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
        // noinspection deprecation
        mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();

        Log.e("MPChartLib-Utils"
                , "Utils.init(...) PROVIDED CONTEXT OBJECT IS NULL");

    } else {
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
        mMaximumFlingVelocity = viewConfiguration.getScaledMaximumFlingVelocity();

        Resources res = context.getResources();
        mMetrics = res.getDisplayMetrics();
    }
}
 
Example 2
Source File: GestureDetector2.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void init(Context context) {
    if (mListener == null) {
        throw new NullPointerException("OnGestureListener must not be null");
    }
    mIsLongpressEnabled = true;

    int touchSlop, doubleTapSlop, doubleTapTouchSlop;
    if (context == null) {
        touchSlop = ViewConfiguration.getTouchSlop();
        doubleTapTouchSlop = touchSlop;
        doubleTapSlop = 100;
        mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
        mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
    } else {
        final ViewConfiguration configuration = ViewConfiguration.get(context);
        touchSlop = configuration.getScaledTouchSlop();
        doubleTapTouchSlop = configuration.getScaledTouchSlop();
        doubleTapSlop = configuration.getScaledDoubleTapSlop();
        mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
        mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity();
    }
    mTouchSlopSquare = touchSlop * touchSlop;
    mDoubleTapTouchSlopSquare = doubleTapTouchSlop * doubleTapTouchSlop;
    mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
}
 
Example 3
Source File: GestureDetector2.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void init(Context context) {
    if (mListener == null) {
        throw new NullPointerException("OnGestureListener must not be null");
    }
    mIsLongpressEnabled = true;

    int touchSlop, doubleTapSlop, doubleTapTouchSlop;
    if (context == null) {
        touchSlop = ViewConfiguration.getTouchSlop();
        doubleTapTouchSlop = touchSlop;
        doubleTapSlop = 100;
        mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
        mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
    } else {
        final ViewConfiguration configuration = ViewConfiguration.get(context);
        touchSlop = configuration.getScaledTouchSlop();
        doubleTapTouchSlop = configuration.getScaledTouchSlop();
        doubleTapSlop = configuration.getScaledDoubleTapSlop();
        mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
        mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity();
    }
    mTouchSlopSquare = touchSlop * touchSlop;
    mDoubleTapTouchSlopSquare = doubleTapTouchSlop * doubleTapTouchSlop;
    mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
}
 
Example 4
Source File: Utils.java    From JNChartDemo with Apache License 2.0 6 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method.
 *
 * @param context
 */
@SuppressWarnings("deprecation")
public static void init(Context context) {

    if (context == null) {
        // noinspection deprecation
        mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
        // noinspection deprecation
        mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();

        Log.e("MPChartLib-Utils"
                , "Utils.init(...) PROVIDED CONTEXT OBJECT IS NULL");

    } else {
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
        mMaximumFlingVelocity = viewConfiguration.getScaledMaximumFlingVelocity();

        Resources res = context.getResources();
        mMetrics = res.getDisplayMetrics();
    }
}
 
Example 5
Source File: Utils.java    From NetKnight with Apache License 2.0 6 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method.
 *
 * @param context
 */
@SuppressWarnings("deprecation")
public static void init(Context context) {

    if (context == null) {
        // noinspection deprecation
        mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
        // noinspection deprecation
        mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();

        Log.e("MPChartLib-Utils"
                , "Utils.init(...) PROVIDED CONTEXT OBJECT IS NULL");

    } else {
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
        mMaximumFlingVelocity = viewConfiguration.getScaledMaximumFlingVelocity();

        Resources res = context.getResources();
        mMetrics = res.getDisplayMetrics();
    }
}
 
Example 6
Source File: Utils.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method.
 *
 * @param context
 */
@SuppressWarnings("deprecation")
public static void init(Context context) {

    if (context == null) {
        // noinspection deprecation
        mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
        // noinspection deprecation
        mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();

        Log.e("MPChartLib-Utils"
                , "Utils.init(...) PROVIDED CONTEXT OBJECT IS NULL");

    } else {
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
        mMaximumFlingVelocity = viewConfiguration.getScaledMaximumFlingVelocity();

        Resources res = context.getResources();
        mMetrics = res.getDisplayMetrics();
    }
}
 
Example 7
Source File: Utils.java    From iMoney with Apache License 2.0 6 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method.
 * 
 * @param res
 */
@SuppressWarnings("deprecation")
public static void init(Context context) {

    if (context == null) {
        // noinspection deprecation
        mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
        // noinspection deprecation
        mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();

        Log.e("MPAndroidChart, Utils.init(...)", "PROVIDED CONTEXT OBJECT IS NULL");

    } else {
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
        mMaximumFlingVelocity = viewConfiguration.getScaledMaximumFlingVelocity();

        Resources res = context.getResources();
        mMetrics = res.getDisplayMetrics();
    }
}
 
Example 8
Source File: Utils.java    From android-kline with Apache License 2.0 6 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method.
 *
 * @param context
 */
@SuppressWarnings("deprecation")
public static void init(Context context) {

    if (context == null) {
        // noinspection deprecation
        mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
        // noinspection deprecation
        mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();

        Log.e("MPChartLib-Utils"
                , "Utils.init(...) PROVIDED CONTEXT OBJECT IS NULL");

    } else {
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
        mMaximumFlingVelocity = viewConfiguration.getScaledMaximumFlingVelocity();

        Resources res = context.getResources();
        mMetrics = res.getDisplayMetrics();
    }
}
 
Example 9
Source File: Utils.java    From Ticket-Analysis with MIT License 6 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method.
 *
 * @param context
 */
@SuppressWarnings("deprecation")
public static void init(Context context) {

    if (context == null) {
        // noinspection deprecation
        mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
        // noinspection deprecation
        mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();

        Log.e("MPChartLib-Utils"
                , "Utils.init(...) PROVIDED CONTEXT OBJECT IS NULL");

    } else {
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
        mMaximumFlingVelocity = viewConfiguration.getScaledMaximumFlingVelocity();

        Resources res = context.getResources();
        mMetrics = res.getDisplayMetrics();
    }
}
 
Example 10
Source File: Utils.java    From android-kline with Apache License 2.0 5 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method. backwards
 * compatibility - to not break existing code
 *
 * @param res
 */
@Deprecated
public static void init(Resources res) {

    mMetrics = res.getDisplayMetrics();

    // noinspection deprecation
    mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
    // noinspection deprecation
    mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
}
 
Example 11
Source File: Utils.java    From iMoney with Apache License 2.0 5 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method. backwards
 * compatibility - to not break existing code
 *
 * @param res
 */
@Deprecated
public static void init(Resources res) {

    mMetrics = res.getDisplayMetrics();

    // noinspection deprecation
    mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
    // noinspection deprecation
    mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
}
 
Example 12
Source File: Utils.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method. backwards
 * compatibility - to not break existing code
 *
 * @param res
 */
@Deprecated
public static void init(Resources res) {

    mMetrics = res.getDisplayMetrics();

    // noinspection deprecation
    mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
    // noinspection deprecation
    mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
}
 
Example 13
Source File: Utils.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method. backwards
 * compatibility - to not break existing code
 *
 * @param res
 */
@Deprecated
public static void init(Resources res) {

    mMetrics = res.getDisplayMetrics();

    // noinspection deprecation
    mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
    // noinspection deprecation
    mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
}
 
Example 14
Source File: Utils.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method. backwards
 * compatibility - to not break existing code
 *
 * @param res
 */
@Deprecated
public static void init(Resources res) {

    mMetrics = res.getDisplayMetrics();

    // noinspection deprecation
    mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
    // noinspection deprecation
    mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
}
 
Example 15
Source File: Utils.java    From JNChartDemo with Apache License 2.0 5 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method. backwards
 * compatibility - to not break existing code
 *
 * @param res
 */
@Deprecated
public static void init(Resources res) {

    mMetrics = res.getDisplayMetrics();

    // noinspection deprecation
    mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
    // noinspection deprecation
    mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
}
 
Example 16
Source File: GestureDetector.java    From remoteyourcam-usb with Apache License 2.0 5 votes vote down vote up
public GestureDetector(Context context, GestureHandler gestureHandler) {
    this.gestureHandler = gestureHandler;
    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    pixelScaling = metrics.density;
    minimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
    maximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
}
 
Example 17
Source File: GestureDetector.java    From remoteyourcam-usb with Apache License 2.0 5 votes vote down vote up
public GestureDetector(Context context, GestureHandler gestureHandler) {
    this.gestureHandler = gestureHandler;
    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    pixelScaling = metrics.density;
    minimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
    maximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
}
 
Example 18
Source File: Utils.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
/**
 * initialize method, called inside the Chart.init() method. backwards
 * compatibility - to not break existing code
 *
 * @param res
 */
@Deprecated
public static void init(Resources res) {

    mMetrics = res.getDisplayMetrics();

    // noinspection deprecation
    mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
    // noinspection deprecation
    mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
}
 
Example 19
Source File: ChartView.java    From mytracks with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
  if (velocityTracker == null) {
    velocityTracker = VelocityTracker.obtain();
  }
  velocityTracker.addMovement(event);
  float x = event.getX();
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      // Stop the fling
      if (!scroller.isFinished()) {
        scroller.abortAnimation();
      }
      lastMotionEventX = x;
      break;
    case MotionEvent.ACTION_MOVE:
      if (lastMotionEventX == -1) {
        break;
      }
      // Scroll to follow the motion event
      int deltaX = (int) (lastMotionEventX - x);
      lastMotionEventX = x;
      if (deltaX < 0) {
        if (getScrollX() > 0) {
          scrollBy(deltaX);
        }
      } else if (deltaX > 0) {
        int availableToScroll = effectiveWidth * (zoomLevel - 1) - getScrollX();
        if (availableToScroll > 0) {
          scrollBy(Math.min(availableToScroll, deltaX));
        }
      }
      break;
    case MotionEvent.ACTION_UP:
      // Check if the y event is within markerHeight of the marker center
      if (Math.abs(event.getY() - topBorder - spacer - markerHeight / 2) < markerHeight) {
        int minDistance = Integer.MAX_VALUE;
        Waypoint nearestWaypoint = null;
        synchronized (waypoints) {
          for (int i = 0; i < waypoints.size(); i++) {
            Waypoint waypoint = waypoints.get(i);
            int distance = Math.abs(
                getX(getWaypointXValue(waypoint)) - (int) event.getX() - getScrollX());
            if (distance < minDistance) {
              minDistance = distance;
              nearestWaypoint = waypoint;
            }
          }
        }
        if (nearestWaypoint != null && minDistance < markerWidth) {
          Intent intent = IntentUtils.newIntent(getContext(), MarkerDetailActivity.class)
              .putExtra(MarkerDetailActivity.EXTRA_MARKER_ID, nearestWaypoint.getId());
          getContext().startActivity(intent);
          return true;
        }
      }

      VelocityTracker myVelocityTracker = velocityTracker;
      myVelocityTracker.computeCurrentVelocity(1000);
      int initialVelocity = (int) myVelocityTracker.getXVelocity();
      if (Math.abs(initialVelocity) > ViewConfiguration.getMinimumFlingVelocity()) {
        fling(-initialVelocity);
      }
      if (velocityTracker != null) {
        velocityTracker.recycle();
        velocityTracker = null;
      }
      break;
  }
  return true;
}