use of android.view.GestureDetector in project android_frameworks_base by DirtyUnicorns.
the class DividerView method onFinishInflate.
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mHandle = (DividerHandleView) findViewById(R.id.docked_divider_handle);
mBackground = findViewById(R.id.docked_divider_background);
mMinimizedShadow = (MinimizedDockShadow) findViewById(R.id.minimized_dock_shadow);
mHandle.setOnTouchListener(this);
mDividerWindowWidth = getResources().getDimensionPixelSize(com.android.internal.R.dimen.docked_stack_divider_thickness);
mDividerInsets = getResources().getDimensionPixelSize(com.android.internal.R.dimen.docked_stack_divider_insets);
mDividerSize = mDividerWindowWidth - 2 * mDividerInsets;
mTouchElevation = getResources().getDimensionPixelSize(R.dimen.docked_stack_divider_lift_elevation);
mLongPressEntraceAnimDuration = getResources().getInteger(R.integer.long_press_dock_anim_duration);
mGrowRecents = getResources().getBoolean(R.bool.recents_grow_in_multiwindow);
mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop();
mFlingAnimationUtils = new FlingAnimationUtils(getContext(), 0.3f);
updateDisplayInfo();
boolean landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
mHandle.setPointerIcon(PointerIcon.getSystemIcon(getContext(), landscape ? TYPE_HORIZONTAL_DOUBLE_ARROW : TYPE_VERTICAL_DOUBLE_ARROW));
getViewTreeObserver().addOnComputeInternalInsetsListener(this);
mHandle.setAccessibilityDelegate(mHandleDelegate);
mGestureDetector = new GestureDetector(mContext, new SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (SWAPPING_ENABLED) {
updateDockSide();
SystemServicesProxy ssp = Recents.getSystemServices();
if (mDockSide != WindowManager.DOCKED_INVALID && !ssp.isRecentsActivityVisible()) {
mWindowManagerProxy.swapTasks();
return true;
}
}
return false;
}
});
}
use of android.view.GestureDetector in project instructure-android by instructure.
the class BaseLoginLandingPageActivity method setupGesture.
private void setupGesture() {
mGesture = new GestureDetector(getApplicationContext(), new GestureDetector.SimpleOnGestureListener() {
public boolean onDown(MotionEvent event) {
return true;
}
});
findViewById(R.id.rootView).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return mGesture.onTouchEvent(event);
}
});
}
use of android.view.GestureDetector in project instructure-android by instructure.
the class URLSignIn method onCreate.
// /////////////////////////////////////////////////////////////////////////
// LifeCycle
// /////////////////////////////////////////////////////////////////////////
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getRootLayout());
mTopDivider = findViewById(R.id.topDivider);
listView = (ListView) findViewById(R.id.listview);
mConnect = (ImageView) findViewById(R.id.connect);
mRightHelpIcon = findViewById(R.id.help_button);
mCanvasLogo = findViewById(R.id.canvas_logo);
SoftKeyboardUtil.observeSoftKeyBoard(this, this);
// Log to GA.
trackAppFlow(URLSignIn.this);
setupUrlEnter();
// Handle Intent. This will set the URLEnter if it was passed in. So it has to be AFTER it's initialized and set.
handleIntent();
// Handle the Crouton if it exists.
if (messageToUser != null && messageToUser.length() > 1) {
displayMessage(messageToUser, MESSAGE_TYPE_WARNING);
}
if (mConnect != null) {
mConnect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
connectToURL();
}
});
}
if (getErrorDelegate() != null) {
// Set Retrofit Error Handling Delegate
APIHelpers.setDefaultErrorDelegateClass(URLSignIn.this, getErrorDelegate().getClass().getName());
}
// Start crashlytics
startCrashlytics();
// Set our user agent for CanvasKit.
APIHelpers.setUserAgent(URLSignIn.this, CanvasAPI.getCandroidUserAgent(getUserAgent(), URLSignIn.this));
// Start helpShift
startHelpShift();
// Delete old externally cached files
deleteCachedFiles();
// Help Layout
findViewById(R.id.help_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showHelpShiftSupport();
}
});
// Set up gesture
gesture = new GestureDetector(getApplicationContext(), new GestureDetector.SimpleOnGestureListener() {
public boolean onDown(MotionEvent event) {
return true;
}
});
// Handle canvas_login stuff.
findViewById(R.id.rootView).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return gesture.onTouchEvent(event);
}
});
setupCallbacks();
// See if the user is already signed in.
checkSignedIn(true);
beginAdapterSetupProcess();
handleNightlyBuilds();
}
use of android.view.GestureDetector in project RxTools by vondear.
the class RxScaleImageView method setGestureDetector.
private void setGestureDetector(final Context context) {
this.detector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (panEnabled && readySent && vTranslate != null && e1 != null && e2 != null && (Math.abs(e1.getX() - e2.getX()) > 50 || Math.abs(e1.getY() - e2.getY()) > 50) && (Math.abs(velocityX) > 500 || Math.abs(velocityY) > 500) && !isZooming) {
PointF vTranslateEnd = new PointF(vTranslate.x + (velocityX * 0.25f), vTranslate.y + (velocityY * 0.25f));
float sCenterXEnd = ((getWidth() / 2) - vTranslateEnd.x) / scale;
float sCenterYEnd = ((getHeight() / 2) - vTranslateEnd.y) / scale;
new AnimationBuilder(new PointF(sCenterXEnd, sCenterYEnd)).withEasing(EASE_OUT_QUAD).withPanLimited(false).withOrigin(ORIGIN_FLING).start();
return true;
}
return super.onFling(e1, e2, velocityX, velocityY);
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
performClick();
return true;
}
@Override
public boolean onDoubleTap(MotionEvent e) {
if (zoomEnabled && readySent && vTranslate != null) {
// Hacky solution for #15 - after a double tap the GestureDetector gets in a state
// where the next fling is ignored, so here we replace it with a new one.
setGestureDetector(context);
if (quickScaleEnabled) {
// Store quick scale params. This will become either a double tap zoom or a
// quick scale depending on whether the user swipes.
vCenterStart = new PointF(e.getX(), e.getY());
vTranslateStart = new PointF(vTranslate.x, vTranslate.y);
scaleStart = scale;
isQuickScaling = true;
isZooming = true;
quickScaleLastDistance = -1F;
quickScaleSCenter = viewToSourceCoord(vCenterStart);
quickScaleVStart = new PointF(e.getX(), e.getY());
quickScaleVLastPoint = new PointF(quickScaleSCenter.x, quickScaleSCenter.y);
quickScaleMoved = false;
// We need to get events in onTouchEvent after this.
return false;
} else {
// Start double tap zoom animation.
doubleTapZoom(viewToSourceCoord(new PointF(e.getX(), e.getY())), new PointF(e.getX(), e.getY()));
return true;
}
}
return super.onDoubleTapEvent(e);
}
});
}
use of android.view.GestureDetector in project CustomViews by AndroidStudy233.
the class PhotoView method init.
private void init() {
super.setScaleType(ScaleType.MATRIX);
if (mScaleType == null)
mScaleType = ScaleType.CENTER_INSIDE;
mRotateDetector = new RotateGestureDetector(mRotateListener);
mDetector = new GestureDetector(getContext(), mGestureListener);
mScaleDetector = new ScaleGestureDetector(getContext(), mScaleListener);
float density = getResources().getDisplayMetrics().density;
MAX_OVER_SCROLL = (int) (density * 30);
MAX_FLING_OVER_SCROLL = (int) (density * 30);
MAX_OVER_RESISTANCE = (int) (density * 140);
mMinRotate = MIN_ROTATE;
mAnimaDuring = ANIMA_DURING;
mMaxScale = MAX_SCALE;
}
Aggregations