List of usage examples for android.view ViewConfiguration getScaledTouchSlop
public int getScaledTouchSlop()
From source file:com.todotxt.todotxttouch.TodoTxtTouch.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); currentActivityPointer = this; setContentView(R.layout.main);//from w ww. j a v a 2 s .co m m_app = (TodoApplication) getApplication(); m_app.m_prefs.registerOnSharedPreferenceChangeListener(this); this.taskBag = m_app.getTaskBag(); m_adapter = new TaskAdapter(this, R.layout.list_item, taskBag.getTasks(), getLayoutInflater()); // listen to the ACTION_LOGOUT intent, if heard display LoginScreen // and finish() current activity IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constants.INTENT_ACTION_ARCHIVE); intentFilter.addAction(Constants.INTENT_SYNC_CONFLICT); intentFilter.addAction(Constants.INTENT_ACTION_LOGOUT); intentFilter.addAction(Constants.INTENT_UPDATE_UI); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); m_broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equalsIgnoreCase(Constants.INTENT_ACTION_ARCHIVE)) { // archive // refresh screen to remove completed tasks // push to remote //archiveTasks(); } else if (intent.getAction().equalsIgnoreCase(Constants.INTENT_ACTION_LOGOUT)) { taskBag.clear(); m_app.broadcastWidgetUpdate(); // Intent i = new Intent(context, LoginScreen.class); // startActivity(i); // finish(); } else if (intent.getAction().equalsIgnoreCase(Constants.INTENT_UPDATE_UI)) { updateSyncUI(intent.getBooleanExtra("redrawList", false)); } else if (intent.getAction().equalsIgnoreCase(Constants.INTENT_SYNC_CONFLICT)) { handleSyncConflict(); } else if (intent.getAction().equalsIgnoreCase(ConnectivityManager.CONNECTIVITY_ACTION)) { handleConnectivityChange(context); } // Taskbag might have changed, update drawer adapter // to reflect new/removed contexts and projects updateNavigationDrawer(); } }; registerReceiver(m_broadcastReceiver, intentFilter); setListAdapter(this.m_adapter); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); // Setup Navigation drawer m_drawerList = (ListView) findViewById(R.id.left_drawer); m_drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // Set the adapter for the list view updateNavigationDrawer(); SwipeDismissList.OnDismissCallback callback = new SwipeDismissList.OnDismissCallback() { // Gets called whenever the user deletes an item. public SwipeDismissList.Undoable onDismiss(AbsListView listView, final int position) { m_swipeList.setEnabled(false); final Task task = m_adapter.getItem(position); m_adapter.remove(task); ArrayList<Task> tasks = new ArrayList<Task>(); tasks.add(task); final boolean wasComplete = task.isCompleted(); final String popupTitle = listView.getResources() .getString(wasComplete ? R.string.swipe_action_unComplete : R.string.swipe_action_complete); if (wasComplete) { undoCompleteTasks(tasks, false); } else { completeTasks(tasks, false); } // Return an Undoable implementing every method return new SwipeDismissList.Undoable() { // Method is called when user undoes this deletion public void undo() { // Reinsert item to list ArrayList<Task> tasks = new ArrayList<Task>(); tasks.add(task); if (wasComplete) { completeTasks(tasks, false); } else { undoCompleteTasks(tasks, false); } } @Override public String getTitle() { return popupTitle; } }; } }; m_swipeList = new SwipeDismissList(lv, callback, SwipeDismissList.UndoMode.SINGLE_UNDO); m_swipeList.setPopupYOffset(56); m_swipeList.setAutoHideDelay(250); m_swipeList.setSwipeLayout(R.id.swipe_view); m_pullToRefreshAttacher = PullToRefreshAttacher.get(this); DefaultHeaderTransformer ht = (DefaultHeaderTransformer) m_pullToRefreshAttacher.getHeaderTransformer(); ht.setPullText(getString(R.string.pull_to_refresh)); ht.setRefreshingText(getString(R.string.syncing)); m_pullToRefreshAttacher.addRefreshableView(lv, this); // Delegate OnTouch calls to both libraries that want to receive them // Don't forward swipes when swiping on the left lv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { // Don't listen to gestures on the left area of the list // to prevent interference with the DrawerLayout ViewConfiguration vc = ViewConfiguration.get(view.getContext()); int deadZoneX = vc.getScaledTouchSlop(); if (motionEvent.getX() < deadZoneX) { return false; } m_pullToRefreshAttacher.onTouch(view, motionEvent); // Only listen to item swipes if we are not scrolling the // listview if (!mListScrolling && m_swipeList.onTouch(view, motionEvent)) { return false; } return false; } }); // We must set the scrollListener after the onTouchListener, // otherwise it will not fire lv.setOnScrollListener(this); initializeTasks(false); // Show search results Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { m_app.m_search = intent.getStringExtra(SearchManager.QUERY); Log.v(TAG, "Searched for " + m_app.m_search); m_app.storeFilters(); setFilteredTasks(false); } }
From source file:net.simonvt.staggeredgridview.StaggeredGridView.java
public StaggeredGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StaggeredGridView, defStyle, 0); colCount = a.getInt(R.styleable.StaggeredGridView_android_numColumns, 1); verticalItemMargin = a.getDimensionPixelSize(R.styleable.StaggeredGridView_verticalItemMargin, 0); horizontalItemMargin = a.getDimensionPixelSize(R.styleable.StaggeredGridView_horizontalItemMargin, 0); selector = a.getDrawable(R.styleable.StaggeredGridView_android_listChoiceBackgroundIndicator); if (selector != null) { selector.setCallback(this); }//from w w w . j ava 2 s. c om a.recycle(); final ViewConfiguration vc = ViewConfiguration.get(context); touchSlop = vc.getScaledTouchSlop(); maximumVelocity = vc.getScaledMaximumFlingVelocity(); flingVelocity = vc.getScaledMinimumFlingVelocity(); scroller = new Scroller(context); topEdge = new EdgeEffect(context); bottomEdge = new EdgeEffect(context); setWillNotDraw(false); setClipToPadding(false); setVerticalScrollBarEnabled(true); }
From source file:com.hxqc.mall.core.views.CustomScrollView.java
private void initScrollView() { mScroller = ScrollerCompat.create(getContext(), null); setFocusable(true);/*from w w w.j a va2 s . c o m*/ setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setWillNotDraw(false); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:com.doubleTwist.drawerlib.ADrawerLayout.java
public ADrawerLayout(Context ctx, AttributeSet attrs, int defStyle) { super(ctx, attrs, defStyle); ViewConfiguration vc = ViewConfiguration.get(ctx); mTouchSlop = vc.getScaledTouchSlop(); mVelocityTracker = VelocityTracker.obtain(); // Read the attributes passed in the XML view declaration TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.ADrawerLayout); try {/*from w ww.j ava2s . c om*/ Rect innerMargins = new Rect(); innerMargins.left = a.getDimensionPixelSize(R.styleable.ADrawerLayout_innerMarginLeft, 0); innerMargins.top = a.getDimensionPixelSize(R.styleable.ADrawerLayout_innerMarginTop, 0); innerMargins.right = a.getDimensionPixelSize(R.styleable.ADrawerLayout_innerMarginRight, 0); innerMargins.bottom = a.getDimensionPixelSize(R.styleable.ADrawerLayout_innerMarginBottom, 0); setInnerMargins(innerMargins); boolean innerIsGlobalLeft = a.getBoolean(R.styleable.ADrawerLayout_innerMarginIsGlobalLeft, false); boolean innerIsGlobalTop = a.getBoolean(R.styleable.ADrawerLayout_innerMarginIsGlobalTop, false); boolean innerIsGlobalRight = a.getBoolean(R.styleable.ADrawerLayout_innerMarginIsGlobalRight, false); boolean innerIsGlobalBottom = a.getBoolean(R.styleable.ADrawerLayout_innerMarginIsGlobalBottom, false); setInnerIsGlobal(innerIsGlobalLeft, innerIsGlobalTop, innerIsGlobalRight, innerIsGlobalBottom); Rect peekSize = new Rect(); peekSize.left = a.getDimensionPixelSize(R.styleable.ADrawerLayout_peekSizeLeft, 0); peekSize.top = a.getDimensionPixelSize(R.styleable.ADrawerLayout_peekSizeTop, 0); peekSize.right = a.getDimensionPixelSize(R.styleable.ADrawerLayout_peekSizeRight, 0); peekSize.bottom = a.getDimensionPixelSize(R.styleable.ADrawerLayout_peekSizeBottom, 0); setPeekSize(peekSize); boolean restrictToPeekLeft = a.getBoolean(R.styleable.ADrawerLayout_restrictToPeekLeft, true); boolean restrictToPeekTop = a.getBoolean(R.styleable.ADrawerLayout_restrictToPeekTop, true); boolean restrictToPeekRight = a.getBoolean(R.styleable.ADrawerLayout_restrictToPeekRight, true); boolean restrictToPeekBottom = a.getBoolean(R.styleable.ADrawerLayout_restrictToPeekBottom, true); setRestrictTouchesToPeekArea(restrictToPeekLeft, restrictToPeekTop, restrictToPeekRight, restrictToPeekBottom); } finally { a.recycle(); } }
From source file:com.apptentive.android.sdk.view.ApptentiveNestedScrollView.java
private void initScrollView() { //mScroller = new ScrollerCompat(getContext(), null); mScroller = ScrollerCompat.create(getContext(), null); setFocusable(true);/* w ww .j a v a 2s . c om*/ setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setWillNotDraw(false); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:com.comcast.freeflow.core.FreeFlowContainer.java
@Override protected void init(Context context) { // usedViews = new HashMap<Object, FreeFlowItem>(); // usedHeaderViews = new HashMap<Object, FreeFlowItem>(); setWillNotDraw(false);/*from w w w .j a v a 2 s . co m*/ viewpool = new ViewPool(); frames = new HashMap<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); mLeftEdge = new EdgeEffect(context); mRightEdge = new EdgeEffect(context); mTopEdge = new EdgeEffect(context); mBottomEdge = new EdgeEffect(context); }
From source file:com.cmbb.smartkids.widget.NestedScrollView.java
private void initScrollView() { mScroller = ScrollerCompat.create(getContext(), null); setFocusable(true);//from w w w . ja v a2s . c o m setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setWillNotDraw(false); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:com.android.launcher2.PagedView.java
/** * Initializes various states for this workspace. *///w w w.java 2s. co m protected void init() { mDirtyPageContent = new ArrayList<Boolean>(); mDirtyPageContent.ensureCapacity(32); mScroller = new Scroller(getContext(), new ScrollInterpolator()); mCurrentPage = 0; mCenterPagesVertically = true; final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mPagingTouchSlop = configuration.getScaledPagingTouchSlop(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mDensity = getResources().getDisplayMetrics().density; mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity); mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * mDensity); mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * mDensity); setOnHierarchyChangeListener(this); }
From source file:com.skurro.pricesnapp1.customviews.swipeback.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./*from www . j av a 2 s. com*/ * * @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().widthPixels; // final float density = context.getResources().getDisplayMetrics().density; // int pixel = context.getWindowManager().getDefaultDisplay().getWidth(); // mEdgeSize = (int) (density); mEdgeSize = (int) (EDGE_SIZE * density + 0.5f); mTouchSlop = vc.getScaledTouchSlop(); mMaxVelocity = vc.getScaledMaximumFlingVelocity(); mMinVelocity = vc.getScaledMinimumFlingVelocity(); mScroller = ScrollerCompat.create(context, sInterpolator); }
From source file:freeflow.core.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);/* w w w .j a v a 2 s .c o m*/ }