java类android.view.ViewConfiguration的实例源码

FoldingLayoutActivity.java 文件源码 项目:buildAPKsSamples 阅读 29 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_fold);

    mImageView = (ImageView)findViewById(R.id.image_view);
    mImageView.setPadding(ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING,
            ANTIALIAS_PADDING);
    mImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    mImageView.setImageDrawable(getResources().getDrawable(R.drawable.image));

    mTextureView = new TextureView(this);
    mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);

    mAnchorSeekBar = (SeekBar)findViewById(R.id.anchor_seek_bar);
    mFoldLayout = (FoldingLayout)findViewById(R.id.fold_view);
    mFoldLayout.setBackgroundColor(Color.BLACK);
    mFoldLayout.setFoldListener(mOnFoldListener);

    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();

    mAnchorSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener);

    mScrollGestureDetector = new GestureDetector(this, new ScrollGestureDetector());
    mItemSelectedListener = new ItemSelectedListener();

    mDefaultPaint = new Paint();
    mSepiaPaint = new Paint();

    ColorMatrix m1 = new ColorMatrix();
    ColorMatrix m2 = new ColorMatrix();
    m1.setSaturation(0);
    m2.setScale(1f, .95f, .82f, 1.0f);
    m1.setConcat(m2, m1);
    mSepiaPaint.setColorFilter(new ColorMatrixColorFilter(m1));
}
KeyButtonView.java 文件源码 项目:GravityBox 阅读 27 收藏 0 点赞 0 评论 0
public void run() {
    if (isPressed()) {
        if (mCode != 0) {
            if (mCode == KeyEvent.KEYCODE_DPAD_LEFT || mCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
                sendEvent(KeyEvent.ACTION_UP, KeyEvent.FLAG_SOFT_KEYBOARD |
                        KeyEvent.FLAG_KEEP_TOUCH_MODE, System.currentTimeMillis(), false);
                sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_SOFT_KEYBOARD |
                        KeyEvent.FLAG_KEEP_TOUCH_MODE, System.currentTimeMillis(), false);
                removeCallbacks(mCheckLongPress);
                postDelayed(mCheckLongPress, ViewConfiguration.getKeyRepeatDelay());
            } else {
                sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS);
                sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
            }
        } else {
            mLongPressConsumed = performLongClick();
        }
    }
}
PullToZoomBase.java 文件源码 项目:letv 阅读 17 收藏 0 点赞 0 评论 0
@SuppressLint({"NewApi"})
private void init(Context context, AttributeSet attrs) {
    setGravity(17);
    this.mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    DisplayMetrics localDisplayMetrics = new DisplayMetrics();
    ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
    this.mScreenHeight = localDisplayMetrics.heightPixels;
    this.mScreenWidth = localDisplayMetrics.widthPixels;
    this.mRootView = createRootView(context, attrs);
    if (attrs != null) {
        LayoutInflater mLayoutInflater = LayoutInflater.from(getContext());
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.PullToZoomView);
        int zoomViewResId = a.getResourceId(2, 0);
        if (zoomViewResId > 0) {
            this.mZoomView = mLayoutInflater.inflate(zoomViewResId, null, false);
        }
        int headerViewResId = a.getResourceId(0, 0);
        if (headerViewResId > 0) {
            this.mHeaderView = mLayoutInflater.inflate(headerViewResId, null, false);
        }
        this.isParallax = a.getBoolean(1, true);
        handleStyledAttributes(a);
        a.recycle();
    }
    addView(this.mRootView, -1, -1);
}
ViewDragHelper.java 文件源码 项目:Hello-Music-droid 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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);
}
CoreBaseActivity.java 文件源码 项目:quickblox-android 阅读 29 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    actionBar = getSupportActionBar();

    // Hack. Forcing overflow button on actionbar on devices with hardware menu button
    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }
}
GooglePhotosGestureDetector.java 文件源码 项目:XphotoView 阅读 23 收藏 0 点赞 0 评论 0
public GooglePhotosGestureDetector(@Nullable Context context, @NonNull GooglePhotosGestureListener listener) {
    this.gestureListener = listener;
    gestureHandler = new GestureHandler();
    if (context == null) {
        MIN_FLING_VELOCITY = ViewConfiguration.getMinimumFlingVelocity();
        MAX_FLING_VELOCITY = ViewConfiguration.getMaximumFlingVelocity();
        DOUBLE_TAP_SLOP = 100;
        SCALE_SPAN_SLOP = 16;
    } else {
        ViewConfiguration config = ViewConfiguration.get(context);
        MIN_FLING_VELOCITY = config.getScaledMinimumFlingVelocity();
        MAX_FLING_VELOCITY = config.getScaledMaximumFlingVelocity();
        DOUBLE_TAP_SLOP = config.getScaledDoubleTapSlop();
        SCALE_SPAN_SLOP = config.getScaledTouchSlop() * 2;
    }
}
RepeatableImageKey.java 文件源码 项目:Nird2 阅读 26 收藏 0 点赞 0 评论 0
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    switch (motionEvent.getAction()) {
        case ACTION_DOWN:
            view.postDelayed(repeater,
                    ViewConfiguration.getKeyRepeatTimeout());
            performHapticFeedback(KEYBOARD_TAP);
            return false;
        case ACTION_CANCEL:
        case ACTION_UP:
            view.removeCallbacks(repeater);
            return false;
        default:
            return false;
    }
}
RecyclerView.java 文件源码 项目:PlusGram 阅读 29 收藏 0 点赞 0 评论 0
/**
 * Configure the scrolling touch slop for a specific use case.
 *
 * Set up the RecyclerView's scrolling motion threshold based on common usages.
 * Valid arguments are {@link #TOUCH_SLOP_DEFAULT} and {@link #TOUCH_SLOP_PAGING}.
 *
 * @param slopConstant One of the <code>TOUCH_SLOP_</code> constants representing
 *                     the intended usage of this RecyclerView
 */
public void setScrollingTouchSlop(int slopConstant) {
    final ViewConfiguration vc = ViewConfiguration.get(getContext());
    switch (slopConstant) {
        default:
            Log.w(TAG, "setScrollingTouchSlop(): bad argument constant "
                    + slopConstant + "; using default value");
            // fall-through
        case TOUCH_SLOP_DEFAULT:
            mTouchSlop = vc.getScaledTouchSlop();
            break;

        case TOUCH_SLOP_PAGING:
            mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(vc);
            break;
    }
}
SystemBarTintManager.java 文件源码 项目:GitHub 阅读 33 收藏 0 点赞 0 评论 0
@TargetApi(14)
private boolean hasNavBar(Context context) {
    Resources res = context.getResources();
    int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android");
    if (resourceId != 0) {
        boolean hasNav = res.getBoolean(resourceId);
        // check override flag (see static block)
        if ("1".equals(sNavBarOverride)) {
            hasNav = false;
        } else if ("0".equals(sNavBarOverride)) {
            hasNav = true;
        }
        return hasNav;
    } else { // fallback
        return !ViewConfiguration.get(context).hasPermanentMenuKey();
    }
}
ViewDragHelper.java 文件源码 项目:boohee_v5.6 阅读 22 收藏 0 点赞 0 评论 0
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    } else if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    } else {
        this.mParentView = forParent;
        this.mCallback = cb;
        ViewConfiguration vc = ViewConfiguration.get(context);
        this.mEdgeSize = (int) ((20.0f * context.getResources().getDisplayMetrics().density) + 0.5f);
        this.mTouchSlop = vc.getScaledTouchSlop();
        this.mMaxVelocity = (float) vc.getScaledMaximumFlingVelocity();
        this.mMinVelocity = (float) vc.getScaledMinimumFlingVelocity();
        this.mScroller = ScrollerCompat.create(context, sInterpolator);
    }
}
SystemBarTintManager.java 文件源码 项目:LiuAGeAndroid 阅读 27 收藏 0 点赞 0 评论 0
@TargetApi(14)
private boolean hasNavBar(Context context) {
    Resources res = context.getResources();
    int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android");
    if (resourceId != 0) {
        boolean hasNav = res.getBoolean(resourceId);
        // check override flag (see static block)
        if ("1".equals(sNavBarOverride)) {
            hasNav = false;
        } else if ("0".equals(sNavBarOverride)) {
            hasNav = true;
        }
        return hasNav;
    } else { // fallback
        return !ViewConfiguration.get(context).hasPermanentMenuKey();
    }
}
LatinKeyboard.java 文件源码 项目:keepass2android 阅读 23 收藏 0 点赞 0 评论 0
@SuppressLint("ResourceAsColor")
public SlidingLocaleDrawable(Drawable background, int width, int height) {
          mBackground = background;
          setDefaultBounds(mBackground);
          mWidth = width;
          mHeight = height;
          mTextPaint = new TextPaint();
          mTextPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18));

          mTextPaint.setColor(R.color.latinkeyboard_transparent);
          mTextPaint.setTextAlign(Align.CENTER);
          mTextPaint.setAlpha(OPACITY_FULLY_OPAQUE);
          mTextPaint.setAntiAlias(true);
          mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2;
          mLeftDrawable =
                  mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_left);
          mRightDrawable =
                  mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_right);
          mThreshold = ViewConfiguration.get(mContext).getScaledTouchSlop();
      }
StackLayout.java 文件源码 项目:chromium-for-android-56-debug-video 阅读 22 收藏 0 点赞 0 评论 0
/**
 * @param context     The current Android's context.
 * @param updateHost  The {@link LayoutUpdateHost} view for this layout.
 * @param renderHost  The {@link LayoutRenderHost} view for this layout.
 * @param eventFilter The {@link EventFilter} that is needed for this view.
 */
public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost,
        EventFilter eventFilter) {
    super(context, updateHost, renderHost, eventFilter);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mMinDirectionThreshold = configuration.getScaledTouchSlop();
    mMinShortPressThresholdSqr =
            configuration.getScaledPagingTouchSlop() * configuration.getScaledPagingTouchSlop();

    mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5);
    mFlingSpeed = FLING_SPEED_DP;
    mStacks = new Stack[2];
    mStacks[0] = new Stack(context, this);
    mStacks[1] = new Stack(context, this);
    mStackRects = new RectF[2];
    mStackRects[0] = new RectF();
    mStackRects[1] = new RectF();

    mViewContainer = new FrameLayout(getContext());
    mSceneLayer = new TabListSceneLayer();
}
DraggableSquareView.java 文件源码 项目:Tribe 阅读 25 收藏 0 点赞 0 评论 0
public DraggableSquareView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mDragHelper = ViewDragHelper
            .create(this, 10f, new DragHelperCallback());
    moveDetector = new GestureDetectorCompat(context,
            new MoveDetector());
    moveDetector.setIsLongpressEnabled(false); // 不能处理长按事件,否则违背最初设计的初衷
    spaceInterval = (int) getResources().getDimension(R.dimen.drag_square_interval); // 小方块之间的间隔

    // 滑动的距离阈值由系统提供
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();

    anchorHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (draggingView != null) {
                // 开始移动重心的动画
                draggingView.startAnchorAnimation();
            }
        }
    };
}
DragController.java 文件源码 项目:FlickLauncher 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Determines whether the user flung the current item to delete it.
 *
 * @return the vector at which the item was flung, or null if no fling was detected.
 */
private PointF isFlingingToDelete(DragSource source) {
    if (mFlingToDeleteDropTarget == null) return null;
    if (!source.supportsFlingToDelete()) return null;

    ViewConfiguration config = ViewConfiguration.get(mLauncher);
    mVelocityTracker.computeCurrentVelocity(1000, config.getScaledMaximumFlingVelocity());
    PointF vel = new PointF(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity());
    float theta = MAX_FLING_DEGREES + 1;
    if (mVelocityTracker.getYVelocity() < mFlingToDeleteThresholdVelocity) {
        // Do a quick dot product test to ensure that we are flinging upwards
        PointF upVec = new PointF(0f, -1f);
        theta = getAngleBetweenVectors(vel, upVec);
    } else if (mLauncher.getDeviceProfile().isVerticalBarLayout() &&
            mVelocityTracker.getXVelocity() < mFlingToDeleteThresholdVelocity) {
        // Remove icon is on left side instead of top, so check if we are flinging to the left.
        PointF leftVec = new PointF(-1f, 0f);
        theta = getAngleBetweenVectors(vel, leftVec);
    }
    if (theta <= Math.toRadians(MAX_FLING_DEGREES)) {
        return vel;
    }
    return null;
}
ViewDragHelper.java 文件源码 项目:letv 阅读 23 收藏 0 点赞 0 评论 0
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    } else if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    } else {
        this.mParentView = forParent;
        this.mCallback = cb;
        ViewConfiguration vc = ViewConfiguration.get(context);
        this.mEdgeSize = (int) ((TitleBar.BACKBTN_LEFT_MARGIN * context.getResources().getDisplayMetrics().density) + 0.5f);
        this.mTouchSlop = vc.getScaledTouchSlop();
        this.mMaxVelocity = (float) vc.getScaledMaximumFlingVelocity();
        this.mMinVelocity = (float) vc.getScaledMinimumFlingVelocity();
        this.mScroller = ScrollerCompat.create(context, sInterpolator);
    }
}
SystemBarTintManager.java 文件源码 项目:KUtils-master 阅读 40 收藏 0 点赞 0 评论 0
@TargetApi(14)
private boolean hasNavBar(Context context) {
    Resources res = context.getResources();
    int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android");
    if (resourceId != 0) {
        boolean hasNav = res.getBoolean(resourceId);
        // check override flag (see static block)
        if ("1".equals(sNavBarOverride)) {
            hasNav = false;
        } else if ("0".equals(sNavBarOverride)) {
            hasNav = true;
        }
        return hasNav;
    } else { // fallback
        return !ViewConfiguration.get(context).hasPermanentMenuKey();
    }
}
RepeatableImageKey.java 文件源码 项目:Cable-Android 阅读 25 收藏 0 点赞 0 评论 0
@TargetApi(VERSION_CODES.HONEYCOMB_MR1)
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
  switch (motionEvent.getAction()) {
  case MotionEvent.ACTION_DOWN:
    view.postDelayed(repeater, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1
                               ? ViewConfiguration.getKeyRepeatTimeout()
                               : ViewConfiguration.getLongPressTimeout());
    performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
    return false;
  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    view.removeCallbacks(repeater);
    return false;
  default:
    return false;
  }
}
SystemBarTintManager.java 文件源码 项目:head 阅读 48 收藏 0 点赞 0 评论 0
@TargetApi(14)
private boolean hasNavBar(Context context) {
    Resources res = context.getResources();
    int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android");
    if (resourceId != 0) {
        boolean hasNav = res.getBoolean(resourceId);
        // check override flag (see static block)
        if ("1".equals(sNavBarOverride)) {
            hasNav = false;
        } else if ("0".equals(sNavBarOverride)) {
            hasNav = true;
        }
        return hasNav;
    } else { // fallback
        return !ViewConfiguration.get(context).hasPermanentMenuKey();
    }
}
CustomViewPager.java 文件源码 项目:WebPager 阅读 28 收藏 0 点赞 0 评论 0
void initViewPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this,
            ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}
SuperSwipeRefreshLayout.java 文件源码 项目:AutoRecycleView 阅读 28 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
public SuperSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    /**
     * getScaledTouchSlop是一个距离,表示滑动的时候,手的移动要大于这个距离才开始移动控件。如果小于这个距离就不触发移动控件
     */
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(
            android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(
            DECELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context
            .obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    WindowManager wm = (WindowManager) context
            .getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mHeaderViewWidth = (int) display.getWidth();
    mFooterViewWidth = (int) display.getWidth();
    mHeaderViewHeight = (int) (HEADER_VIEW_HEIGHT * metrics.density);
    mFooterViewHeight = (int) (HEADER_VIEW_HEIGHT * metrics.density);
    defaultProgressView = new CircleProgressView(getContext());
    createHeaderViewContainer();
    createFooterViewContainer();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    density = metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
}
PullRefreshLayout.java 文件源码 项目:Android-PullRefresh 阅读 28 收藏 0 点赞 0 评论 0
public PullRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.refresh_PullRefreshLayout);
    final int colorsId = a.getResourceId(R.styleable.refresh_PullRefreshLayout_refreshColors, 0);
    final int colorId = a.getResourceId(R.styleable.refresh_PullRefreshLayout_refreshColor, 0);
    a.recycle();
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    int defaultDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
    mDurationToStartPosition = defaultDuration;
    mDurationToCorrectPosition = defaultDuration;
    mSpinnerFinalOffset = mTotalDragDistance = dp2px(DRAG_MAX_DISTANCE);
    mRefreshView = new ImageView(context);
    if (colorsId > 0) {
        mColorSchemeColors = context.getResources().getIntArray(colorsId);
    } else {
        mColorSchemeColors = new int[]{Color.rgb(0xC9, 0x34, 0x37), Color.rgb(0x37, 0x5B, 0xF1), Color.rgb(0xF7, 0xD2, 0x3E), Color.rgb(0x34, 0xA3, 0x50)};
    }

    if (colorId > 0) {
        mColorSchemeColors = new int[]{ContextCompat.getColor(context, colorId)};
    }
    setDefaultRefreshStyle();
    mRefreshView.setVisibility(View.GONE);

    setWillNotDraw(false);
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
}
NoteMainActivity.java 文件源码 项目:SuperNote 阅读 19 收藏 0 点赞 0 评论 0
@Override
protected void initViews() {

    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();

    mPresenter.initDataBase();
    initDrawer();
    initAdapter();

    mRvNoteList.setAdapter(mAdapter);
    mRvNoteList.setOnTouchListener(this);

    mPresenter.initNoteRvLayoutManager();
}
NumberPicker.java 文件源码 项目:airgram 阅读 26 收藏 0 点赞 0 评论 0
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    if (!isEnabled()) {
        return false;
    }
    final int action = event.getActionMasked();
    switch (action) {
        case MotionEvent.ACTION_DOWN: {
            removeAllCallbacks();
            mInputText.setVisibility(View.INVISIBLE);
            mLastDownOrMoveEventY = mLastDownEventY = event.getY();
            mLastDownEventTime = event.getEventTime();
            mIngonreMoveEvents = false;
            if (mLastDownEventY < mTopSelectionDividerTop) {
                if (mScrollState == OnScrollListener.SCROLL_STATE_IDLE) {
                    mPressedStateHelper.buttonPressDelayed(PressedStateHelper.BUTTON_DECREMENT);
                }
            } else if (mLastDownEventY > mBottomSelectionDividerBottom) {
                if (mScrollState == OnScrollListener.SCROLL_STATE_IDLE) {
                    mPressedStateHelper.buttonPressDelayed(PressedStateHelper.BUTTON_INCREMENT);
                }
            }
            getParent().requestDisallowInterceptTouchEvent(true);
            if (!mFlingScroller.isFinished()) {
                mFlingScroller.forceFinished(true);
                mAdjustScroller.forceFinished(true);
                onScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
            } else if (!mAdjustScroller.isFinished()) {
                mFlingScroller.forceFinished(true);
                mAdjustScroller.forceFinished(true);
            } else if (mLastDownEventY < mTopSelectionDividerTop) {
                postChangeCurrentByOneFromLongPress(false, ViewConfiguration.getLongPressTimeout());
            } else if (mLastDownEventY > mBottomSelectionDividerBottom) {
                postChangeCurrentByOneFromLongPress(true, ViewConfiguration.getLongPressTimeout());
            }
            return true;
        }
    }
    return false;
}
Utils.java 文件源码 项目:GitHub 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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();
}
CirclePageIndicator.java 文件源码 项目:scab 阅读 24 收藏 0 点赞 0 评论 0
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
      setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
RecyclerView.java 文件源码 项目:PlusGram 阅读 29 收藏 0 点赞 0 评论 0
public RecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setScrollContainer(true);
    setFocusableInTouchMode(true);
    final int version = Build.VERSION.SDK_INT;
    mPostUpdatesOnAnimation = version >= 16;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    setWillNotDraw(ViewCompat.getOverScrollMode(this) == ViewCompat.OVER_SCROLL_NEVER);

    mItemAnimator.setListener(mItemAnimatorListener);
    initAdapterManager();
    initChildrenHelper();
    // If not explicitly specified this view is important for accessibility.
    if (ViewCompat.getImportantForAccessibility(this)
            == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this,
                ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
    mAccessibilityManager = (AccessibilityManager) getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    setAccessibilityDelegateCompat(new RecyclerViewAccessibilityDelegate(this));
    // Create the layoutManager if specified.

    // Re-set whether nested scrolling is enabled so that it is set on all API levels
    setNestedScrollingEnabled(true);
}
SuperSwipeRefreshLayout.java 文件源码 项目:MultiSelecter 阅读 41 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
public SuperSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    /**
     * getScaledTouchSlop是一个距离,表示滑动的时候,手的移动要大于这个距离才开始移动控件。如果小于这个距离就不触发移动控件
     */
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(
            android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(
            DECELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context
            .obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    WindowManager wm = (WindowManager) context
            .getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mHeaderViewWidth = (int) display.getWidth();
    mFooterViewWidth = (int) display.getWidth();
    mHeaderViewHeight = (int) (HEADER_VIEW_HEIGHT * metrics.density);
    mFooterViewHeight = (int) (HEADER_VIEW_HEIGHT * metrics.density);
    defaultProgressView = new CircleProgressView(getContext());
    createHeaderViewContainer();
    createFooterViewContainer();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    density = metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
}
CirclePageIndicator.java 文件源码 项目:GitHub 阅读 27 收藏 0 点赞 0 评论 0
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
      setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
BaseDialog.java 文件源码 项目:anyRTC-RTCP-Android 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 判断当前用户触摸是否超出了Dialog的显示区域
 *
 * @param context
 * @param event
 * @return
 */
private boolean isOutOfBounds(Context context, MotionEvent event) {
    final int x = (int) event.getX();
    final int y = (int) event.getY();
    final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
    final View decorView = getWindow().getDecorView();
    return (x < -slop) || (y < -slop) || (x > (decorView.getWidth() + slop))
            || (y > (decorView.getHeight() + slop));
}


问题


面经


文章

微信
公众号

扫码关注公众号