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

ISwipeRefreshLayout.java 文件源码 项目:AndroidUiKit 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Constructor that is called when inflating ISwipeRefreshLayout from XML.
 *
 * @param context
 * @param attrs
 */
public ISwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

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

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

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

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mRefreshViewHeight = (int) (DEFAULT_HEADER_HEIGHT * metrics.density);
    HEADER_VIEW_MIN_HEIGHT = mRefreshViewHeight;
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    mTotalDragDistance = (int) (DEFAULT_HEADER_TARGET * metrics.density);
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);

    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);

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

    //add default refreshview
    setRefreshHeaderView(new ClassicIRefreshHeaderView(getContext()));
}
ReactionView.java 文件源码 项目:betterHotels 阅读 18 收藏 0 点赞 0 评论 0
private void init(Context context, AttributeSet attrs){
    //Initially the View is not visible until it is alerted to show at a specific position, sX and sY
    setVisibility(View.GONE);
    setLayoutTransition(new ReactionLayoutTransition());
    visibilityListeners = new ArrayList<>();
    reactionListeners = new ArrayList<>();
    vc = ViewConfiguration.get(context);
    sX = 0f;
    sY = 0f;
    //backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    //backgroundPaint.setColor(Color.parseColor("#FFFFFF"));
    //backgroundPaint.setStyle(Paint.Style.FILL);
    //backgroundPaint.setAlpha(230);
    addIcons(context);
}
GesturedListView.java 文件源码 项目:orgzly-android 阅读 15 收藏 0 点赞 0 评论 0
private void init(AttributeSet attrs) {
    maxFlingVelocity = ViewConfiguration.get(getContext()).getScaledMaximumFlingVelocity();
    minFlingVelocity = ViewConfiguration.get(getContext()).getScaledMinimumFlingVelocity();
    // touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    gestureDetector = new GestureDetector(getContext(), this);
    selector = getSelector();

    int menuContainerId = 0;
    HashMap<Gesture, Integer> gestureMenuMap = new HashMap<>();

    /* Get attributes from XML. */
    if (attrs != null) {
        TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.GesturedListView);

        menuContainerId = typedArray.getResourceId(R.styleable.GesturedListView_menu_container, 0);

        int child;

        child = typedArray.getInt(R.styleable.GesturedListView_menu_for_fling_left, -1);
        if (child != -1) {
            gestureMenuMap.put(Gesture.FLING_LEFT, child);
        }

        child = typedArray.getInt(R.styleable.GesturedListView_menu_for_fling_right, -1);
        if (child != -1) {
            gestureMenuMap.put(Gesture.FLING_RIGHT, child);
        }

        typedArray.recycle();
    }


    /* Disable selector. */
    // setSelector(android.R.color.transparent);

    itemMenus = new GesturedListViewItemMenus(this, gestureMenuMap, menuContainerId);
}
RecyclerView.java 文件源码 项目:airgram 阅读 33 收藏 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);
}
HorizontalLoopView.java 文件源码 项目:HorizontalLoopView 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 初始化一些滚动的属性
 */
private void initScroll() {
    mScroller = new Scroller(getContext());
    //水平垂直
    setGravity(Gravity.CENTER_VERTICAL);
    //水平方向
    setOrientation(HORIZONTAL);
    //视图滚动配置
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    //获取最小滚动距离
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    //最大滚动距离
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

}
DateScrollerView.java 文件源码 项目:DateScroller 阅读 17 收藏 0 点赞 0 评论 0
private void init() {

        scroller = new OverScroller(getContext());
        //the touch distance for distinguish touch event between click and scroll
        touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();

        popUpView = new PopUpView();

        dateData = new ArrayList<>();
        currentYear = calendar.get(Calendar.YEAR);
        addMoreDays();
    }
SwipeMenuLayout.java 文件源码 项目:AppFirCloud 阅读 25 收藏 0 点赞 0 评论 0
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    mScaleTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mMaxVelocity = ViewConfiguration.get(context).getScaledMaximumFlingVelocity();
    //初始化滑动帮助类对象
    //mScroller = new Scroller(context);

    //右滑删除功能的开关,默认开
    isSwipeEnable = true;
    //IOS、QQ式交互,默认开
    isIos = true;
    //左滑右滑的开关,默认左滑打开菜单
    isLeftSwipe = true;
    TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SwipeMenuLayout, defStyleAttr, 0);
    int count = ta.getIndexCount();
    for (int i = 0; i < count; i++) {
        int attr = ta.getIndex(i);
        //如果引用成AndroidLib 资源都不是常量,无法使用switch case
        if (attr == R.styleable.SwipeMenuLayout_swipeEnable) {
            isSwipeEnable = ta.getBoolean(attr, true);
        } else if (attr == R.styleable.SwipeMenuLayout_ios) {
            isIos = ta.getBoolean(attr, true);
        } else if (attr == R.styleable.SwipeMenuLayout_leftSwipe) {
            isLeftSwipe = ta.getBoolean(attr, true);
        }
    }
    ta.recycle();


}
LRecyclerView.java 文件源码 项目:UiLib 阅读 72 收藏 0 点赞 0 评论 0
private void init() {
    if (pullRefreshEnabled) {
        mRefreshHeader = new ArrowRefreshHeader(getContext());
        mRefreshHeader.setProgressStyle(mRefreshProgressStyle);
    }
    LoadingMoreFooter footView = new LoadingMoreFooter(getContext());
    footView.setProgressStyle(mLoadingMoreProgressStyle);
    mFootView = footView;
    mFootView.setVisibility(GONE);

    mScaleTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
}
DeviceUtils.java 文件源码 项目:mvparms 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 设备是否有实体菜单
 *
 * @param context
 * @return
 */
public static boolean hasHardwareMenuKey(Context context) {
    boolean flag = false;
    if (PRE_HC)
        flag = true;
    else if (GTE_ICS) {
        flag = ViewConfiguration.get(context).hasPermanentMenuKey();
    } else
        flag = false;
    return flag;
}
SwipeMenuLayout.java 文件源码 项目:RLibrary 阅读 20 收藏 0 点赞 0 评论 0
public SwipeMenuLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwipeMenuLayout);
    mLeftViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_leftViewId, mLeftViewId);
    mContentViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_contentViewId, mContentViewId);
    mRightViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_rightViewId, mRightViewId);
    typedArray.recycle();

    ViewConfiguration mViewConfig = ViewConfiguration.get(getContext());
    mScaledTouchSlop = mViewConfig.getScaledTouchSlop();
    mScroller = new OverScroller(getContext());
    mScaledMinimumFlingVelocity = mViewConfig.getScaledMinimumFlingVelocity();
    mScaledMaximumFlingVelocity = mViewConfig.getScaledMaximumFlingVelocity();
}


问题


面经


文章

微信
公众号

扫码关注公众号