Search in sources :

Example 1 with ViewConfiguration

use of android.view.ViewConfiguration in project Android-ObservableScrollView by ksoichiro.

the class ViewPagerTab2Activity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_viewpagertab2);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    ViewCompat.setElevation(findViewById(R.id.header), getResources().getDimension(R.dimen.toolbar_elevation));
    mToolbarView = findViewById(R.id.toolbar);
    mPagerAdapter = new NavigationAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    // Padding for ViewPager must be set outside the ViewPager itself
    // because with padding, EdgeEffect of ViewPager become strange.
    final int tabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
    findViewById(R.id.pager_wrapper).setPadding(0, getActionBarSize() + tabHeight, 0, 0);
    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);
    ViewConfiguration vc = ViewConfiguration.get(this);
    mSlop = vc.getScaledTouchSlop();
    mInterceptionLayout = (TouchInterceptionFrameLayout) findViewById(R.id.container);
    mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);
}
Also used : ViewConfiguration(android.view.ViewConfiguration) SlidingTabLayout(com.google.samples.apps.iosched.ui.widget.SlidingTabLayout)

Example 2 with ViewConfiguration

use of android.view.ViewConfiguration in project CurtainView by aicaprio.

the class CurtainView method init.

private void init(Context context) {
    ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mTouchSlop = viewConfiguration.getScaledTouchSlop();
    mScroller = new Scroller(context);
    mContext = context;
}
Also used : ViewConfiguration(android.view.ViewConfiguration) Scroller(android.widget.Scroller)

Example 3 with ViewConfiguration

use of android.view.ViewConfiguration in project actor-platform by actorapp.

the class VerticalViewPager method initViewPager.

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();
    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = 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);
    }
}
Also used : Context(android.content.Context) ViewConfiguration(android.view.ViewConfiguration) EdgeEffectCompat(android.support.v4.widget.EdgeEffectCompat) Scroller(android.widget.Scroller)

Example 4 with ViewConfiguration

use of android.view.ViewConfiguration in project android_frameworks_base by ParanoidAndroid.

the class PagedView method isFlingingToDelete.

/*
     * Flinging to delete - IN PROGRESS
     */
private PointF isFlingingToDelete() {
    ViewConfiguration config = ViewConfiguration.get(getContext());
    mVelocityTracker.computeCurrentVelocity(1000, config.getScaledMaximumFlingVelocity());
    if (mVelocityTracker.getYVelocity() < mFlingToDeleteThresholdVelocity) {
        // Do a quick dot product test to ensure that we are flinging upwards
        PointF vel = new PointF(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity());
        PointF upVec = new PointF(0f, -1f);
        float theta = (float) Math.acos(((vel.x * upVec.x) + (vel.y * upVec.y)) / (vel.length() * upVec.length()));
        if (theta <= Math.toRadians(FLING_TO_DELETE_MAX_FLING_DEGREES)) {
            return vel;
        }
    }
    return null;
}
Also used : ViewConfiguration(android.view.ViewConfiguration) PointF(android.graphics.PointF)

Example 5 with ViewConfiguration

use of android.view.ViewConfiguration in project android_frameworks_base by ParanoidAndroid.

the class PagedView method init.

/**
     * Initializes various states for this workspace.
     */
protected void init() {
    mDirtyPageContent = new ArrayList<Boolean>();
    mDirtyPageContent.ensureCapacity(32);
    mScroller = new Scroller(getContext(), new ScrollInterpolator());
    mCurrentPage = 0;
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mPagingTouchSlop = configuration.getScaledPagingTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mDensity = getResources().getDisplayMetrics().density;
    // Scale the fling-to-delete threshold by the density
    mFlingToDeleteThresholdVelocity = (int) (mFlingToDeleteThresholdVelocity * mDensity);
    mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
    mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * mDensity);
    mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * mDensity);
    setOnHierarchyChangeListener(this);
}
Also used : ViewConfiguration(android.view.ViewConfiguration) Scroller(android.widget.Scroller)

Aggregations

ViewConfiguration (android.view.ViewConfiguration)233 Scroller (android.widget.Scroller)53 Context (android.content.Context)36 TypedArray (android.content.res.TypedArray)28 Field (java.lang.reflect.Field)20 EdgeEffectCompat (android.support.v4.widget.EdgeEffectCompat)18 View (android.view.View)15 Point (android.graphics.Point)14 OverScroller (android.widget.OverScroller)12 Drawable (android.graphics.drawable.Drawable)10 Paint (android.graphics.Paint)8 DisplayMetrics (android.util.DisplayMetrics)8 Resources (android.content.res.Resources)7 RectF (android.graphics.RectF)7 GestureDetector (android.view.GestureDetector)7 ImageView (android.widget.ImageView)6 PointF (android.graphics.PointF)5 FlingAnimationUtils (com.android.systemui.statusbar.FlingAnimationUtils)5 Rect (android.graphics.Rect)4 SlidingTabLayout (com.google.samples.apps.iosched.ui.widget.SlidingTabLayout)4