getScaledTouchSlop ( )源码实例Demo

android.view.ViewConfiguration#getScaledTouchSlop ( )源码实例Demo

下面列出了android.view.ViewConfiguration#getScaledTouchSlop ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CoreModule   文件: ViewDragHelper.java
/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context   Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
源代码2 项目: Slide   文件: ViewDragHelper.java
/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context   Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
源代码3 项目: UltimateSwipeTool   文件: ViewDragHelper.java
/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context   Context to init config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
源代码4 项目: ting   文件: ViewDragHelper.java
/**
 * Apps should use ViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
源代码5 项目: Klyph   文件: ScrollableViewGroup.java
public ScrollableViewGroup(Context paramContext, AttributeSet paramAttributeSet)
{
  super(paramContext, paramAttributeSet);
  Context localContext = getContext();
  setFocusable(false);
  ViewConfiguration localViewConfiguration = ViewConfiguration.get(localContext);
  this.mTouchSlop = localViewConfiguration.getScaledTouchSlop();
  this.mMinimumVelocity = localViewConfiguration.getScaledMinimumFlingVelocity();
  this.mMaximumVelocity = localViewConfiguration.getScaledMaximumFlingVelocity();
  this.mScroller = new Scroller(localContext, sInterpolator);
}
 
源代码6 项目: AndroidQuick   文件: TwoDScrollView.java
private void initTwoDScrollView() {
    mScroller = new Scroller(getContext());
    setFocusable(true);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setWillNotDraw(false);
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}
 
public void initView() {
	if (hasHeader) {
		mListHeaderView = new PullHeadView(mContext);
		mListHeaderView.setStateListener(this);
		setHeaderDividersEnabled(false);
		setFooterDividersEnabled(false);
		addHeaderView(mListHeaderView, null, false);
		mState = STATE_NORMAL;
		final ViewConfiguration configuration = ViewConfiguration
				.get(mContext);
		mTouchSlop = configuration.getScaledTouchSlop();
	}
	
	super.setOnScrollListener(this);
}
 
源代码8 项目: WaveForm   文件: ScaleDragDetector.java
public ScaleDragDetector(Context context, OnScaleDragGestureListener scaleDragGestureListener) {
    mScaleDetector = new ScaleGestureDetector(context, this);
    mScaleDragGestureListener = scaleDragGestureListener;

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mTouchSlop = configuration.getScaledTouchSlop();
}
 
源代码9 项目: DanDanPlayForAndroid   文件: ScrollableLayout.java
private void init(Context context) {
    mHelper = new ScrollableHelper();
    mScroller = new Scroller(context);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}
 
源代码10 项目: UCDMediaPlayer_Android   文件: UVideoMainView.java
void init() {
    x1 = -1;
    y1 = -1;
    ViewConfiguration mViewConfiguration = ViewConfiguration.get(getContext());
    minSlideDistance = mViewConfiguration.getScaledTouchSlop();
    minHorizontalSlideDistance = minVerticalSlideDistance = minSlideDistance;
}
 
源代码11 项目: umeng_community_android   文件: SwitchButton.java
/**
 * 初始化
 * 
 * @param attrs 属性
 */
private void init(AttributeSet attrs) {
    setGravity(Gravity.CENTER_VERTICAL);
    paint = new Paint();
    paint.setColor(Color.RED);
    porterDuffXfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
    switchScroller = new SwitchScroller(getContext(), new AccelerateDecelerateInterpolator());
    buttonRectF = new RectF();

    setDrawables();
    ViewConfiguration config = ViewConfiguration.get(getContext());
    touchSlop = config.getScaledTouchSlop();
    setChecked(isChecked());
    setClickable(true); // 设置允许点击,当用户点击在按钮其它区域的时候就会切换状态
}
 
源代码12 项目: PicKing   文件: ScaleDragDetector.java
public ScaleDragDetector(Context context, OnScaleDragGestureListener scaleDragGestureListener) {
    mScaleDetector = new ScaleGestureDetector(context, this);
    mScaleDragGestureListener = scaleDragGestureListener;

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mTouchSlop = configuration.getScaledTouchSlop();
}
 
源代码13 项目: PreferenceFragment   文件: Switch.java
/**
     * Construct a new Switch with a default style determined by the given theme attribute,
     * overriding specific style attributes as requested.
     *
     * @param context The Context that will determine this widget's theming.
     * @param attrs Specification of attributes that should deviate from the default styling.
     * @param defStyle An attribute ID within the active theme containing a reference to the
     *                 default style for this widget. e.g. android.R.attr.switchStyle.
     */
    public Switch(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        Resources res = getResources();
        mTextPaint.density = res.getDisplayMetrics().density;
//        mTextPaint.setCompatibilityScaling(res.getCompatibilityInfo().applicationScale);

        TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.Switch, defStyle, 0);

        mThumbDrawable = a.getDrawable(R.styleable.Switch_thumb);
        mTrackDrawable = a.getDrawable(R.styleable.Switch_track);
        mTextOn = a.getText(R.styleable.Switch_textOn);
        mTextOff = a.getText(R.styleable.Switch_textOff);
        mThumbTextPadding = a.getDimensionPixelSize(
                R.styleable.Switch_thumbTextPadding, 0);
        mSwitchMinWidth = a.getDimensionPixelSize(
                R.styleable.Switch_switchMinWidth, 0);
        mSwitchPadding = a.getDimensionPixelSize(
                R.styleable.Switch_switchPadding, 0);

        int appearance = a.getResourceId(
                R.styleable.Switch_switchTextAppearance, 0);
        if (appearance != 0) {
            setSwitchTextAppearance(context, appearance);
        }
        a.recycle();

        ViewConfiguration config = ViewConfiguration.get(context);
        mTouchSlop = config.getScaledTouchSlop();
        mMinFlingVelocity = config.getScaledMinimumFlingVelocity();

        // Refresh display with current params
        refreshDrawableState();
        setChecked(isChecked());
    }
 
源代码14 项目: Telegram   文件: NumberPicker.java
private void init() {
    mSolidColor = 0;
    mSelectionDivider = new Paint();
    mSelectionDivider.setColor(Theme.getColor(Theme.key_dialogButton));

    mSelectionDividerHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDER_HEIGHT, getResources().getDisplayMetrics());
    mSelectionDividersDistance = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDERS_DISTANCE, getResources().getDisplayMetrics());

    mMinHeight = SIZE_UNSPECIFIED;

    mMaxHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, getResources().getDisplayMetrics());
    if (mMinHeight != SIZE_UNSPECIFIED && mMaxHeight != SIZE_UNSPECIFIED && mMinHeight > mMaxHeight) {
        throw new IllegalArgumentException("minHeight > maxHeight");
    }

    mMinWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, getResources().getDisplayMetrics());

    mMaxWidth = SIZE_UNSPECIFIED;
    if (mMinWidth != SIZE_UNSPECIFIED && mMaxWidth != SIZE_UNSPECIFIED && mMinWidth > mMaxWidth) {
        throw new IllegalArgumentException("minWidth > maxWidth");
    }

    mComputeMaxWidth = (mMaxWidth == SIZE_UNSPECIFIED);

    mPressedStateHelper = new PressedStateHelper();

    setWillNotDraw(false);

    mInputText = new TextView(getContext());
    mInputText.setGravity(Gravity.CENTER);
    mInputText.setSingleLine(true);
    mInputText.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    mInputText.setBackgroundResource(0);
    mInputText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    mInputText.setVisibility(INVISIBLE);
    addView(mInputText, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity() / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT;
    mTextSize = (int) mInputText.getTextSize();

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(mTextSize);
    paint.setTypeface(mInputText.getTypeface());
    ColorStateList colors = mInputText.getTextColors();
    int color = colors.getColorForState(ENABLED_STATE_SET, Color.WHITE);
    paint.setColor(color);
    mSelectorWheelPaint = paint;

    mFlingScroller = new Scroller(getContext(), null, true);
    mAdjustScroller = new Scroller(getContext(), new DecelerateInterpolator(2.5f));

    updateInputTextView();
}
 
源代码15 项目: UltimateAndroid   文件: FreeFlowContainer.java
@Override
protected void init(Context context) {

	viewpool = new ViewPool();
	frames = new LinkedHashMap<Object, FreeFlowItem>();

	ViewConfiguration configuration = ViewConfiguration.get(context);
	maxFlingVelocity = configuration.getScaledMaximumFlingVelocity();
	minFlingVelocity = configuration.getScaledMinimumFlingVelocity();
	overflingDistance = configuration.getScaledOverflingDistance();
	/*overscrollDistance = configuration.getScaledOverscrollDistance();*/

	touchSlop = configuration.getScaledTouchSlop();

	scroller = new OverScroller(context);

	setEdgeEffectsEnabled(true);

}
 
public CupcakeGestureDetector(Context context) {
    final ViewConfiguration configuration = ViewConfiguration
            .get(context);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mTouchSlop = configuration.getScaledTouchSlop();
}
 
源代码17 项目: cathode   文件: RadialPickerLayout.java
public RadialPickerLayout(Context context, AttributeSet attrs) {
  super(context, attrs);

  setOnTouchListener(this);
  ViewConfiguration vc = ViewConfiguration.get(context);
  TOUCH_SLOP = vc.getScaledTouchSlop();
  TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
  mDoingMove = false;

  mCircleView = new CircleView(context);
  addView(mCircleView);

  mAmPmCirclesView = new AmPmCirclesView(context);
  addView(mAmPmCirclesView);

  mHourRadialTextsView = new RadialTextsView(context);
  addView(mHourRadialTextsView);
  mMinuteRadialTextsView = new RadialTextsView(context);
  addView(mMinuteRadialTextsView);

  mHourRadialSelectorView = new RadialSelectorView(context);
  addView(mHourRadialSelectorView);
  mMinuteRadialSelectorView = new RadialSelectorView(context);
  addView(mMinuteRadialSelectorView);

  // Prepare mapping to snap touchable degrees to selectable degrees.
  preparePrefer30sMap();

  mLastValueSelected = -1;

  mInputEnabled = true;
  mGrayBox = new View(context);
  mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
      ViewGroup.LayoutParams.MATCH_PARENT));
  mGrayBox.setBackgroundColor(getResources().getColor(R.color.transparent_black));
  mGrayBox.setVisibility(View.INVISIBLE);
  addView(mGrayBox);

  mAccessibilityManager =
      (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

  mTimeInitialized = false;
}
 
源代码18 项目: RotatePhotoView   文件: CupcakeGestureDetector.java
public CupcakeGestureDetector(Context context) {
    final ViewConfiguration configuration = ViewConfiguration
            .get(context);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mTouchSlop = configuration.getScaledTouchSlop();
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flexiblespacewithimagewithviewpagertab2);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    ViewCompat.setElevation(findViewById(R.id.header), getResources().getDimension(R.dimen.toolbar_elevation));
    mPagerAdapter = new NavigationAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mImageView = findViewById(R.id.image);
    mOverlayView = findViewById(R.id.overlay);
    // Padding for ViewPager must be set outside the ViewPager itself
    // because with padding, EdgeEffect of ViewPager become strange.
    mFlexibleSpaceHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    mTabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
    findViewById(R.id.pager_wrapper).setPadding(0, mFlexibleSpaceHeight, 0, 0);
    mTitleView = (TextView) findViewById(R.id.title);
    mTitleView.setText(getTitle());
    setTitle(null);

    SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent));
    slidingTabLayout.setDistributeEvenly(true);
    slidingTabLayout.setViewPager(mPager);
    ((FrameLayout.LayoutParams) slidingTabLayout.getLayoutParams()).topMargin = mFlexibleSpaceHeight - mTabHeight;

    ViewConfiguration vc = ViewConfiguration.get(this);
    mSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mInterceptionLayout = (TouchInterceptionFrameLayout) findViewById(R.id.container);
    mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);
    mScroller = new OverScroller(getApplicationContext());
    ScrollUtils.addOnGlobalLayoutListener(mInterceptionLayout, new Runnable() {
        @Override
        public void run() {
            // Extra space is required to move mInterceptionLayout when it's scrolled.
            // It's better to adjust its height when it's laid out
            // than to adjust the height when scroll events (onMoveMotionEvent) occur
            // because it causes lagging.
            // See #87: https://github.com/ksoichiro/Android-ObservableScrollView/issues/87
            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
            lp.height = getScreenHeight() + mFlexibleSpaceHeight;
            mInterceptionLayout.requestLayout();

            updateFlexibleSpace();
        }
    });
}
 
源代码20 项目: ExpressHelper   文件: ViewDragHelper.java
/**
 * Sets the sensitivity of the dragger.
 *
 * @param context     The application context.
 * @param sensitivity value between 0 and 1, the final value for touchSlop =
 *                    ViewConfiguration.getScaledTouchSlop * (1 / s);
 */
public void setSensitivity(Context context, float sensitivity) {
    float s = Math.max(0f, Math.min(1.0f, sensitivity));
    ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mTouchSlop = (int) (viewConfiguration.getScaledTouchSlop() * (1 / s));
}