public MultiCardMenu(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mContext = context; ViewConfiguration vc = ViewConfiguration.get(context); mMaxVelocity = vc.getScaledMaximumFlingVelocity(); mMinVelocity = vc.getScaledMinimumFlingVelocity() * 8; mTouchSlop = vc.getScaledTouchSlop(); mDensity = context.getResources().getDisplayMetrics().density; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MultiCardMenu, defStyleAttr, 0); MAX_CLICK_DISTANCE = mTitleBarHeightNoDisplay = a.getDimension( R.styleable.MultiCardMenu_title_bar_height_no_display, dip2px(DEFAULT_TITLE_BAR_HEIGHT_NO_DISPLAY)); mTitleBarHeightDisplay = a.getDimension( R.styleable.MultiCardMenu_title_bar_height_display, dip2px(DEFAULT_TITLE_BAR_HEIGHT_DISPLAY)); mMarginTop = a.getDimension(R.styleable.MultiCardMenu_margin_top, dip2px(DEFAULT_CARD_MARGIN_TOP)); mMoveDistanceToTrigger = a.getDimension( R.styleable.MultiCardMenu_move_distance_to_trigger, dip2px(DEFAULT_MOVE_DISTANCE_TO_TRIGGER)); mBackgroundRid = a.getResourceId(R.styleable.MultiCardMenu_background_layout, -1); mDuration = a.getInt(R.styleable.MultiCardMenu_animator_duration, DEFAULT_DURATION); isFade = a.getBoolean(R.styleable.MultiCardMenu_fade, true); mBoundary = a.getBoolean(R.styleable.MultiCardMenu_boundary, false); a.recycle(); initBackgroundView(); }
/** * Constructor that is called when inflating a view from XML. This is called when a view is being * constructed from an XML file, supplying attributes that were specified in the XML file. This * version uses a default style of 0, so the only attribute values applied are those in the * Context's Theme and the given AttributeSet. * * <p>The method onFinishInflate() will be called after all children have been added. * * @param context The Context the view is running in, through which it can access the current * theme, resources, etc. * @param attrs The attributes of the XML tag that is inflating the view. */ public TableFixHeaders(Context context, AttributeSet attrs) { super(context, attrs); this.headView = null; this.rowViewList = new ArrayList<View>(); this.columnViewList = new ArrayList<View>(); this.bodyViewTable = new ArrayList<List<View>>(); this.needRelayout = true; this.shadows = new ImageView[4]; this.shadows[0] = new ImageView(context); this.shadows[0].setImageResource(R.drawable.shadow_left); this.shadows[1] = new ImageView(context); this.shadows[1].setImageResource(R.drawable.shadow_top); this.shadows[2] = new ImageView(context); this.shadows[2].setImageResource(R.drawable.shadow_right); this.shadows[3] = new ImageView(context); this.shadows[3].setImageResource(R.drawable.shadow_bottom); // this.lineView = new View(context); // this.lineView.setTag(R.id.tag_row, -2); this.shadowSize = getResources().getDimensionPixelSize(R.dimen.shadow_size); this.flinger = new Flinger(context); final ViewConfiguration configuration = ViewConfiguration.get(context); this.touchSlop = configuration.getScaledTouchSlop(); this.minimumVelocity = configuration.getScaledMinimumFlingVelocity(); this.maximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
public ListViewSwipeGesture(ListView listView, TouchCallbacks Callbacks, Activity context) { ViewConfiguration vc = ViewConfiguration.get(listView.getContext()); mSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mListView = listView; activity = context; tcallbacks = Callbacks; SwipeType = Double; GetResourcesValues(); mListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick( AdapterView<?> arg0, View arg1, int arg2, long arg3) { // Invokes OnClick Functionality if (!moptionsDisplay && DeltaX == 0.0) { tcallbacks.OnClickListView(temp_position); } else { if (old_mDownView != null && mDownView != old_mDownView) { ResetListItem(old_mDownView); old_mDownView = null; mDownView = null; } } } }); }
void initCustomViewAbove() { // setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setDescendantFocusability(FOCUS_BEFORE_DESCENDANTS); setClickable(true); setFocusable(true); setWillNotDraw(false); final Context context = getContext(); mScroller = new Scroller(context, sInterpolator); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); setInternalPageChangeListener( new SimpleOnPageChangeListener() { public void onPageSelected(int position) { if (mViewBehind != null) { switch (position) { case 0: case 2: mViewBehind.setChildrenEnabled(true); break; case 1: mViewBehind.setChildrenEnabled(false); break; } } } }); final float density = context.getResources().getDisplayMetrics().density; mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density); }
/** * Constructs a new swipe touch listener for the given {@link RecyclerView} * * @param recyclerView The recycler view whose items should be dismissable by swiping. * @param listener The listener for the swipe events. */ public SwipeableRecyclerViewTouchListener(RecyclerView recyclerView, SwipeListener listener) { ViewConfiguration vc = ViewConfiguration.get(recyclerView.getContext()); mSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mAnimationTime = recyclerView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime); mRecyclerView = recyclerView; mSwipeListener = listener; /** * This will ensure that this SwipeableRecyclerViewTouchListener is paused during list view * scrolling. If a scroll listener is already assigned, the caller should still pass scroll * changes through to this listener. */ mRecyclerView.setOnScrollListener( new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { setEnabled(newState != RecyclerView.SCROLL_STATE_DRAGGING); } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) {} }); }
private void initWorkspace(Context context, AttributeSet attrs, int defStyle) { Theme theme = context.getTheme(); TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.AviaryWorkspace, defStyle, 0); mDefaultScreen = a.getInt(R.styleable.AviaryWorkspace_aviary_defaultScreen, 0); int overscrollMode = a.getInt(R.styleable.AviaryWorkspace_aviary_overscroll, 0); a.recycle(); setHapticFeedbackEnabled(false); mScrollInterpolator = new DecelerateInterpolator(1.0f); mScroller = new Scroller(context, mScrollInterpolator); mPreviousScreen = INVALID_SCREEN; final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mPaddingTop = getPaddingTop(); mPaddingBottom = getPaddingBottom(); mPaddingLeft = getPaddingLeft(); mPaddingRight = getPaddingRight(); setOverScroll(overscrollMode); }
/** Initializes various states for this workspace. */ private void init(Context context) { mScroller = new Scroller(getContext(), new DecelerateInterpolator()); mCurrentPage = 0; final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
public ResizeManager(@NonNull CollapseCalendarView calendarView) { mCalendarView = calendarView; mScroller = new Scroller(calendarView.getContext()); ViewConfiguration viewConfig = ViewConfiguration.get(mCalendarView.getContext()); mTouchSlop = viewConfig.getScaledTouchSlop(); mMinFlingVelocity = viewConfig.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = viewConfig.getScaledMaximumFlingVelocity(); }
private void init(Context context) { setOrientation(VERTICAL); mOverScroller = new OverScroller(context); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); }
private void initScrollView() { this.mScroller = new ScrollerCompat(this.getContext(), (Interpolator) null); this.setFocusable(true); this.setDescendantFocusability(262144); this.setWillNotDraw(false); ViewConfiguration var1 = ViewConfiguration.get(this.getContext()); this.mTouchSlop = var1.getScaledTouchSlop(); this.mMinimumVelocity = var1.getScaledMinimumFlingVelocity(); this.mMaximumVelocity = var1.getScaledMaximumFlingVelocity(); }
public OnSwipeGestureTouchListener(Context context, boolean isLongPressEnabled) { super(context, isLongPressEnabled); ViewConfiguration configuration = ViewConfiguration.get(context); // We think a swipe flings a full page. // mMinSwipeDelta = configuration.getScaledTouchSlop(); mMinSwipeDelta = configuration.getScaledPagingTouchSlop(); mMinSwipeVelocity = configuration.getScaledMinimumFlingVelocity(); mMaxSwipeVelocity = configuration.getScaledMaximumFlingVelocity(); }
/** * Constructs a new swipe-to-dismiss touch listener for the given list view. * * @param listView The list view whose items should be dismissable. * @param callback The callback to trigger when the user has indicated that she would like to * dismiss one or more list items. */ public SwipeDismissListViewTouchListener(ListView listView, OnDismissCallback callback) { ViewConfiguration vc = ViewConfiguration.get(listView.getContext()); mSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mAnimationTime = listView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime); mListView = listView; mCallback = callback; }
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(); }
/** * Constructs a new swipe-to-dismiss OnItemTouchListener for RecyclerView * * @param recyclerView RecyclerView * @param callbacks The callback to trigger when the user has indicated that she would like to * dismiss this view. */ public SwipeToDismissTouchListener(RecyclerView recyclerView, DismissCallbacks callbacks) { ViewConfiguration vc = ViewConfiguration.get(recyclerView.getContext()); mSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 4; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mAnimationTime = recyclerView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime); mRecyclerView = recyclerView; mCallbacks = callbacks; }
public ItemSlideHelper(Context context, Callback callback) { this.mCallback = callback; // 手势用于处理fling mGestureDetector = new GestureDetectorCompat(context, this); ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mMaxVelocity = configuration.getScaledMaximumFlingVelocity(); mMinVelocity = configuration.getScaledMinimumFlingVelocity(); }
/** * Constructs a new swipe-to-dismiss touch listener for the given view. * * @param view The view to make dismissable. * @param token An optional token/cookie object to be passed through to the callback. * @param callbacks The callback to trigger when the user has indicated that she would like to * dismiss this view. */ public SwipeDismissTouchListener(View view, Object token, DismissCallbacks callbacks) { ViewConfiguration vc = ViewConfiguration.get(view.getContext()); mSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mAnimationTime = view.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime); mView = view; mToken = token; mCallbacks = callbacks; }
public PlaylistContainerWrapper(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mDetector = new GestureDetectorCompat(context, this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); }
private void init(Context context) { ViewConfiguration vc = ViewConfiguration.get(context); mSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 8; // 获取滑动的最小速度 mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); // 获取滑动的最大速度 // 获取分辨率 DisplayMetrics dm = context.getApplicationContext().getResources().getDisplayMetrics(); mWidth = dm.widthPixels; mFlaggingWidth = mWidth / 4; }
@SuppressLint("NewApi") public ExcelView(Context context) { super(context); scroller = new Scroller(context); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); minimumVelocity = configuration.getScaledMinimumFlingVelocity(); maximumVelocity = configuration.getScaledMaximumFlingVelocity(); touchSlop = configuration.getScaledTouchSlop(); if (Integer.valueOf(Build.VERSION.SDK) >= 11) this.setLayerType(View.LAYER_TYPE_SOFTWARE, painter); dp = context.getResources().getDisplayMetrics().density; }
/** * Constructs a new swipe-to-dismiss touch listener for the given list view. * * @param listView The list view whose items should be dismissable. * @param callbacks The callback to trigger when the user has indicated that she would like to * dismiss one or more list items. */ public SwipeDismissListViewTouchListener(ListView listView, DismissCallbacks callbacks) { ViewConfiguration vc = ViewConfiguration.get(listView.getContext()); mSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mAnimationTime = listView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime); mListView = listView; mCallbacks = callbacks; swipeDistanceDivisor = listView.getContext().getResources().getInteger(R.integer.list_card_swipe_distance_divisor); }
@SuppressLint("NewApi") private void initScrollView() { mScroller = new OverScroller(getContext()); setFocusable(true); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setWillNotDraw(false); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mOverscrollDistance = configuration.getScaledOverscrollDistance(); mOverflingDistance = configuration.getScaledOverflingDistance(); }
@Override protected void init(Context context, AttributeSet attrs, int defStyle) { super.init(context, attrs, defStyle); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mMaxVelocity = configuration.getScaledMaximumFlingVelocity(); mScroller = new Scroller(context, SwipeBack.SMOOTH_INTERPOLATOR); mPeekScroller = new Scroller(context, DraggableSwipeBack.PEEK_INTERPOLATOR); mCloseEnough = dpToPx(DraggableSwipeBack.CLOSE_ENOUGH); }
/** Inits the scroll view. */ private void initScrollView() { mScroller = new OverScroller(getContext(), new DecelerateInterpolator()); setFocusable(true); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setWillNotDraw(false); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mOverscrollDistance = configuration.getScaledOverscrollDistance(); mOverflingDistance = configuration.getScaledOverflingDistance(); mScrollMarginTop = getResources().getDimensionPixelSize(R.dimen.gn_recent_info_zone_height); }
/** Sets up the scroller and touch/fling sensitivity parameters for the pager. */ private void init() { mScroller = new Scroller(getContext()); // Calculate the density-dependent snap velocity in pixels DisplayMetrics displayMetrics = new DisplayMetrics(); ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay() .getMetrics(displayMetrics); mDensityAdjustedSnapVelocity = (int) (displayMetrics.density * SNAP_VELOCITY_DIP_PER_SECOND); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
private void init() { final Context context = getContext(); mScroller = new Scroller(context, flipInterpolator); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledPagingTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mShadowPaint.setColor(Color.BLACK); mShadowPaint.setStyle(Style.FILL); mShadePaint.setColor(Color.BLACK); mShadePaint.setStyle(Style.FILL); mShinePaint.setColor(Color.WHITE); mShinePaint.setStyle(Style.FILL); }
/** * @param context * @param attrs */ public ViewFlow(Context context, AttributeSet attrs) { super(context, attrs); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ViewFlow); setAutoScrollDuration(typedArray.getInt(R.styleable.ViewFlow_autoScrollDuration, 1000)); setBufferedItemCount(typedArray.getInt(R.styleable.ViewFlow_bufferedItemCount, 3)); typedArray.recycle(); mLoadedViews = new LinkedList<View>(); mRecycledViews = new LinkedList<View>(); mScroller = new Scroller(getContext()); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); TOUCH_SLOP = configuration.getScaledTouchSlop(); MAX_VELOCITY = configuration.getScaledMaximumFlingVelocity(); scrollMode = ScrollMode.MANUAL; runTask(); }
/** * Constructor that is called when inflating a view from XML. This is called when a view is being * constructed from an XML file, supplying attributes that were specified in the XML file. This * version uses a default style of 0, so the only attribute values applied are those in the * Context's Theme and the given AttributeSet. * * <p>The method onFinishInflate() will be called after all children have been added. * * @param context The Context the view is running in, through which it can access the current * theme, resources, etc. * @param attrs The attributes of the XML tag that is inflating the view. */ public TableFixHeaders(Context context, AttributeSet attrs) { super(context, attrs); this.headView = null; this.rowViewList = new ArrayList<View>(); this.columnViewList = new ArrayList<View>(); this.bodyViewTable = new ArrayList<List<View>>(); this.needRelayout = true; this.shadows = new ImageView[4]; this.shadows[0] = new ImageView(context); this.shadows[0].setImageResource(R.drawable.datagrid_shadow_left); this.shadows[1] = new ImageView(context); this.shadows[1].setImageResource(R.drawable.datagrid_shadow_top); this.shadows[2] = new ImageView(context); this.shadows[2].setImageResource(R.drawable.datagrid_shadow_right); this.shadows[3] = new ImageView(context); this.shadows[3].setImageResource(R.drawable.datagrid_shadow_bottom); this.shadowSize = getResources().getDimensionPixelSize(R.dimen.datagrid_shadow_size); this.flinger = new Flinger(context); final ViewConfiguration configuration = ViewConfiguration.get(context); this.touchSlop = configuration.getScaledTouchSlop(); this.minimumVelocity = configuration.getScaledMinimumFlingVelocity(); this.maximumVelocity = configuration.getScaledMaximumFlingVelocity(); this.setWillNotDraw(false); final TypedArray a = context.obtainStyledAttributes(R.styleable.View); try { // TODO fix initializeScrollbars // initializeScrollbars(a); } finally { if (a != null) { a.recycle(); } } this.setHorizontalScrollBarEnabled(true); this.setVerticalScrollBarEnabled(true); this.rowSelectable = true; if (context instanceof OnDataGridRowSelectedListener) { mRowSelectedListener = (OnDataGridRowSelectedListener) context; } }
// TODO 需要研究 private void init() { setWillNotDraw(false); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setFocusable(true); final Context context = getContext(); mScroller = new Scroller(context, sMenuInterpolator); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); final float density = context.getResources().getDisplayMetrics().density; mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density); mRandom = new Random(); }
@Test public void methodsShouldReturnScaledAndroidConstantsDependingOnPixelDensity() { Activity context = new Activity(); shadowOf(context.getResources()).setDensity(1.5f); ViewConfiguration viewConfiguration = ViewConfiguration.get(context); assertEquals(15, viewConfiguration.getScaledScrollBarSize()); assertEquals(18, viewConfiguration.getScaledFadingEdgeLength()); assertEquals(18, viewConfiguration.getScaledEdgeSlop()); assertEquals(24, viewConfiguration.getScaledTouchSlop()); assertEquals(48, viewConfiguration.getScaledPagingTouchSlop()); assertEquals(150, viewConfiguration.getScaledDoubleTapSlop()); assertEquals(24, viewConfiguration.getScaledWindowTouchSlop()); assertEquals(75, viewConfiguration.getScaledMinimumFlingVelocity()); assertEquals(6000, viewConfiguration.getScaledMaximumFlingVelocity()); }
/** * Constructor * * @param swipeListView SwipeListView * @param swipeFrontView front view Identifier * @param swipeBackView back view Identifier */ public SwipeListViewTouchListener( SwipeListView swipeListView, int swipeFrontView, int swipeBackView) { this.swipeFrontView = swipeFrontView; this.swipeBackView = swipeBackView; ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext()); slop = vc.getScaledTouchSlop(); minFlingVelocity = vc.getScaledMinimumFlingVelocity(); maxFlingVelocity = vc.getScaledMaximumFlingVelocity(); configShortAnimationTime = swipeListView .getContext() .getResources() .getInteger(android.R.integer.config_shortAnimTime); animationTime = configShortAnimationTime; this.swipeListView = swipeListView; }