public void cleanup() { if(null != this.mImageView) { ImageView imageView = (ImageView)this.mImageView.get(); if(null != imageView) { ViewTreeObserver observer = imageView.getViewTreeObserver(); if(null != observer && observer.isAlive()) { observer.removeGlobalOnLayoutListener(this); } imageView.setOnTouchListener((View.OnTouchListener)null); this.cancelFling(); } if(null != this.mGestureDetector) { this.mGestureDetector.setOnDoubleTapListener((GestureDetector.OnDoubleTapListener)null); } this.mMatrixChangeListener = null; this.mPhotoTapListener = null; this.mViewTapListener = null; this.mImageView = null; } }
private void initVideoView(Context context) { mAppContext = context.getApplicationContext(); initBackground(); initRenders(); mVideoWidth = 0; mVideoHeight = 0; // REMOVED: getHolder().addCallback(mSHCallback); // REMOVED: getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); setFocusable(true); setFocusableInTouchMode(true); requestFocus(); // REMOVED: mPendingSubtitleTracks = new Vector<Pair<InputStream, MediaFormat>>(); mCurrentState = STATE_IDLE; mTargetState = STATE_IDLE; gestureDetector = new GestureDetector(mAppContext, new PlayerGestureListener()); }
public EntityView(Context context, Point pos) { super(context); uuid = UUID.randomUUID(); position = pos; gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { public void onLongPress(MotionEvent e) { if (hasPanned || hasTransformed || hasReleased) { return; } recognizedLongPress = true; if (delegate != null) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); delegate.onEntityLongClicked(EntityView.this); } } }); }
public PhotoViewAttacher(ImageView imageView) { mImageView = new WeakReference<ImageView>(imageView); imageView.setOnTouchListener(this); mViewTreeObserver = imageView.getViewTreeObserver(); mViewTreeObserver.addOnGlobalLayoutListener(this); // Make sure we using MATRIX Scale Type setImageViewScaleTypeMatrix(imageView); if (!imageView.isInEditMode()) { // Create Gesture Detectors... mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this); mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() { // forward long click listener @Override public void onLongPress(MotionEvent e) { if(null != mLongClickListener) { mLongClickListener.onLongClick(mImageView.get()); } }}); mGestureDetector.setOnDoubleTapListener(this); // Finally, update the UI so that we're zoomable setZoomable(true); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PrefStore.setLocale(this); setContentView(R.layout.activity_profiles); // ListView Adapter listView = (ListView) findViewById(R.id.profilesView); adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_single_choice, listItems); listView.setAdapter(adapter); // Initialize the Gesture Detector listView.setOnTouchListener(this); gd = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onDoubleTap(MotionEvent e) { finish(); return false; } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fold); mImageView = (ImageView)findViewById(R.id.image_view); mImageView.setPadding(ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING); mImageView.setScaleType(ImageView.ScaleType.FIT_XY); mImageView.setImageDrawable(getResources().getDrawable(R.drawable.image)); mTextureView = new TextureView(this); mTextureView.setSurfaceTextureListener(mSurfaceTextureListener); mAnchorSeekBar = (SeekBar)findViewById(R.id.anchor_seek_bar); mFoldLayout = (FoldingLayout)findViewById(R.id.fold_view); mFoldLayout.setBackgroundColor(Color.BLACK); mFoldLayout.setFoldListener(mOnFoldListener); mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop(); mAnchorSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener); mScrollGestureDetector = new GestureDetector(this, new ScrollGestureDetector()); mItemSelectedListener = new ItemSelectedListener(); mDefaultPaint = new Paint(); mSepiaPaint = new Paint(); ColorMatrix m1 = new ColorMatrix(); ColorMatrix m2 = new ColorMatrix(); m1.setSaturation(0); m2.setScale(1f, .95f, .82f, 1.0f); m1.setConcat(m2, m1); mSepiaPaint.setColorFilter(new ColorMatrixColorFilter(m1)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 隐藏标题 requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.new_ad_media_play); sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); detector = new GestureDetector(this, new MyGesture()); initView(); initPlayHander(); initPlayInfo(); if (!isLocalPlay) { initNetworkTimerTask(); } videoId = getIntent().getStringExtra("videoId"); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gesture_detector); tvGesture = (TextView) findViewById(R.id.tvGesture); //o primeiro this é pq GestureDetectorActivity é uma Activity (óbvio!) //o segundo é pq a gente precisa de um listener, no caso OnGestureListener gestureDetector = new GestureDetector(this,this); //esse this é pq esta Activity implementa OnDoubleTapListener gestureDetector.setOnDoubleTapListener(this); //vamos monitorar longpress gestureDetector.setIsLongpressEnabled(true); }
/** * Initializes various states for this workspace. */ protected void initWorkspace() { mCurrentPage = getDefaultPage(); DeviceProfile grid = mLauncher.getDeviceProfile(); setWillNotDraw(false); setClipChildren(false); setClipToPadding(false); setMinScale(mOverviewModeShrinkFactor); setupLayoutTransition(); mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx); // Set the wallpaper dimensions when Launcher starts up setWallpaperDimension(); setEdgeGlowColor(getResources().getColor(R.color.workspace_edge_effect_color)); mGestureDetector = new GestureDetector(mLauncher,new SimpleGestureDetector(mLauncher)); for (CellLayout cellLayout: mWorkspaceScreens) { initGestureDetector(cellLayout); } }
public PhotoViewAttacher(ImageView imageView) { mImageView = new WeakReference<ImageView>(imageView); imageView.setOnTouchListener(this); mViewTreeObserver = imageView.getViewTreeObserver(); mViewTreeObserver.addOnGlobalLayoutListener(this); // Make sure we using MATRIX Scale Type setImageViewScaleTypeMatrix(imageView); if (!imageView.isInEditMode()) { // Create Gesture Detectors... mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this); mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() { // forward long click listener @Override public void onLongPress(MotionEvent e) { if (null != mLongClickListener) { mLongClickListener.onLongClick(mImageView.get()); } } }); mGestureDetector.setOnDoubleTapListener(this); // Finally, update the UI so that we're zoomable setZoomable(true); } }
private void sharedConstructing(Context context) { super.setClickable(true); this.context = context; this.mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); this.mGestureDetector = new GestureDetector(context, new GestureListener()); this.matrix = new Matrix(); this.prevMatrix = new Matrix(); this.m = new float[9]; this.normalizedScale = 1.0f; if (this.mScaleType == null) { this.mScaleType = ScaleType.FIT_CENTER; } this.minScale = 1.0f; this.maxScale = IPhotoView.DEFAULT_MAX_SCALE; this.superMinScale = 0.75f * this.minScale; this.superMaxScale = SUPER_MAX_MULTIPLIER * this.maxScale; setImageMatrix(this.matrix); setScaleType(ScaleType.MATRIX); setState(State.NONE); this.onDrawReady = false; super.setOnTouchListener(new PrivateOnTouchListener()); }
private void sharedConstructing(Context context) { super.setClickable(true); this.context = context; mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); mGestureDetector = new GestureDetector(context, new GestureListener()); matrix = new Matrix(); prevMatrix = new Matrix(); m = new float[9]; normalizedScale = 1; if (mScaleType == null) { mScaleType = ScaleType.FIT_CENTER; } minScale = 1; maxScale = 3; superMinScale = SUPER_MIN_MULTIPLIER * minScale; superMaxScale = SUPER_MAX_MULTIPLIER * maxScale; setImageMatrix(matrix); setScaleType(ScaleType.MATRIX); setState(State.NONE); onDrawReady = false; super.setOnTouchListener(new PrivateOnTouchListener()); }
private void initLayout() { mOverScroller = new OverScroller(getContext()); mGestureDetectorCompat = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, final float velocityY) { if (Math.abs(velocityX) > Math.abs(velocityY)) { return false; } if (isFloat() /*&& velocityY < 0*/) { return false; } fling(velocityY); return true; } }); }
/**设置该Activity界面布局,并设置底部左右滑动手势监听 * @param layoutResID * @param listener * @use 在子类中 * *1.onCreate中super.onCreate后setContentView(layoutResID, this); * *2.重写onDragBottom方法并实现滑动事件处理 * *3.在导航栏左右按钮的onClick事件中调用onDragBottom方法 */ public void setContentView(int layoutResID, OnBottomDragListener listener) { setContentView(layoutResID); onBottomDragListener = listener; gestureDetector = new GestureDetector(this, this);//初始化手势监听类 view = inflater.inflate(layoutResID, null); view.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }); }
private void addTabDoubleTapListener(final int position, View tab) { final GestureDetector gd = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onDoubleTap(MotionEvent e) { if (onTabDoubleTapListener != null) onTabDoubleTapListener.onCurrentTabDoubleTap(position); return true; } }); tab.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return gd.onTouchEvent(event); } }); }
/** * Creates a {@link GestureEventFilter} with offset touch events. * @param context The {@link Context} for Android. * @param host The {@link EventFilterHost} for this event filter. * @param panelManager The {@link OverlayPanelManager} responsible for showing panels. */ public OverlayPanelEventFilter(Context context, EventFilterHost host, OverlayPanel panel) { super(context, host, panel, false, false); mGestureDetector = new GestureDetector(context, new InternalGestureDetector()); mPanel = panel; mSwipeRecognizer = new SwipeRecognizerImpl(context); // Store the square of the platform touch slop in pixels to use in the scroll detection. // See {@link OverlayPanelEventFilter#isDistanceGreaterThanTouchSlop}. float touchSlopPx = ViewConfiguration.get(context).getScaledTouchSlop(); mTouchSlopSquarePx = touchSlopPx * touchSlopPx; reset(); }
private void sharedConstructing(Context context) { super.setClickable(true); mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); mGestureDetector = new GestureDetector(context, new GestureListener()); matrix = new Matrix(); prevMatrix = new Matrix(); m = new float[9]; normalizedScale = 1; if (mScaleType == null) { mScaleType = ScaleType.FIT_CENTER; } minScale = 1; maxScale = 3; superMinScale = SUPER_MIN_MULTIPLIER * minScale; superMaxScale = SUPER_MAX_MULTIPLIER * maxScale; setImageMatrix(matrix); setScaleType(ScaleType.MATRIX); setState(State.NONE); onDrawReady = false; super.setOnTouchListener(new PrivateOnTouchListener()); }
/** * Initializes class data * * @param context * the context */ private void initData(Context context) { gestureDetector = new GestureDetector(context, gestureListener); gestureDetector.setIsLongpressEnabled(false); scroller = new Scroller(context); }
private synchronized void initView() { this.mLeftViewIndex = -1; this.mRightViewIndex = 0; this.mDisplayOffset = 0; this.mCurrentX = 0; this.mNextX = 0; this.mMaxX = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED; this.mScroller = new Scroller(getContext()); this.mGesture = new GestureDetector(getContext(), this.mOnGesture); }
protected void init() { Context context = getContext(); mApp = (MainApplication) ((MainActivity) getContext()).getApplication(); mGestureDetector = new GestureDetector(context, this); mScaleGestureDetector = new ScaleGestureDetector(context, this); mScroller = new Scroller(context); mStartDragLocation = new PointF(); mCurrentDragOffset = new PointF(); mCurrentFocusLocation = new PointF(); // mCurrentFocusOffset = new PointF(); mDrawingState = DRAW_STATE_none; setEGLConfigChooser(new ConfigChooser(8, 8, 8, 0, 0, 0)); setEGLContextFactory(new ContextFactory()); setEGLWindowSurfaceFactory(new SurfaceFactory()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setPreserveEGLContextOnPause(true); // TODO: may be preserved, none guaranty, see docs } if (DEBUG) { setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR | GLSurfaceView.DEBUG_LOG_GL_CALLS); } setRenderer(new MapRenderer()); setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // update with requestRender() mMapDrawing = new MapDrawing(mApp.getMapPath()); if (!mMapDrawing.openMap()) { mMapDrawing.createMap(); // loadFile(null); // for debug } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mStackCards = new ArrayList<ArrayList<CardView>>(); mStackCards.add(new ArrayList<CardView>()); mStackCards.add(new ArrayList<CardView>()); mIsStackEnabled = new boolean[2]; mIsStackEnabled[0] = true; mIsStackEnabled[1] = true; mVerticalPadding = getResources().getInteger(R.integer.vertical_card_magin); mHorizontalPadding = getResources().getInteger(R.integer.horizontal_card_magin); gDetector = new GestureDetector(this, mGestureListener); mLayout = (RelativeLayout)findViewById(R.id.main_relative_layout); ViewTreeObserver observer = mLayout.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { mLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this); } mCardHeight = mLayout.getHeight(); mCardWidth = mLayout.getWidth() / 2; for (int x = 0; x < STARTING_NUMBER_CARDS; x++) { addNewCard(RIGHT_STACK); } } }); }
private void initView(Context context) { mMeasureHelper = new MeasureHelper(this); mSurfaceCallback = new SurfaceCallback(); setSurfaceTextureListener(mSurfaceCallback); SimpleGestureListener gestureListener = new SimpleGestureListener(); mGestureDetector = new GestureDetector(context, gestureListener); gestureListener.setListener(this); }
public HorizontalListView(Context context, AttributeSet attrs) { super(context, attrs); mEdgeGlowLeft = new EdgeEffectCompat(context); mEdgeGlowRight = new EdgeEffectCompat(context); mGestureDetector = new GestureDetector(context, mGestureListener); bindGestureDetector(); initView(); retrieveXmlConfiguration(context, attrs); setWillNotDraw(false); // If the OS version is high enough then set the friction on the fling tracker */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { HoneycombPlus.setFriction(mFlingTracker, FLING_FRICTION); } }
public PreviewChartTouchHandler(Context context, Chart chart) { super(context, chart); gestureDetector = new GestureDetector(context, new PreviewChartGestureListener()); scaleGestureDetector = new ScaleGestureDetector(context, new ChartScaleGestureListener()); // Disable value touch and selection mode, by default not needed for preview chart. isValueTouchEnabled = false; isValueSelectionEnabled = false; }
public ChartTouchHandler(Context context, Chart chart) { this.chart = chart; this.computator = chart.getChartComputator(); this.renderer = chart.getChartRenderer(); gestureDetector = new GestureDetector(context, new ChartGestureListener()); scaleGestureDetector = new ScaleGestureDetector(context, new ChartScaleGestureListener()); chartScroller = new ChartScroller(context); chartZoomer = new ChartZoomer(context, ZoomType.HORIZONTAL_AND_VERTICAL); }
public RecyclerViewOnItemClickListener(Context context, OnItemClickListener listener) { this.listener = listener; gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }); }
/** * Constructs an helper instance. * * @param context a valid context * @param container the view hosting the zoomable content * @param listener a listener for events */ public ZoomEngine(Context context, View container, Listener listener) { mView = container; mListener = listener; mFlingScroller = new OverScroller(context); mScaleDetector = new ScaleGestureDetector(context, new PinchListener()); if (Build.VERSION.SDK_INT >= 19) mScaleDetector.setQuickScaleEnabled(false); mFlingDragDetector = new GestureDetector(context, new FlingScrollListener()); container.getViewTreeObserver().addOnGlobalLayoutListener(this); }
public PhotoViewAttacher(ImageView imageView, boolean zoomable) { mImageView = new WeakReference<>(imageView); imageView.setDrawingCacheEnabled(true); imageView.setOnTouchListener(this); ViewTreeObserver observer = imageView.getViewTreeObserver(); if (null != observer) observer.addOnGlobalLayoutListener(this); // Make sure we using MATRIX Scale Type setImageViewScaleTypeMatrix(imageView); if (imageView.isInEditMode()) { return; } // Create Gesture Detectors... mScaleDragDetector = VersionedGestureDetector.newInstance( imageView.getContext(), this); mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() { // forward long click listener @Override public void onLongPress(MotionEvent e) { if (null != mLongClickListener) { mLongClickListener.onLongClick(getImageView()); } } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (mSingleFlingListener != null) { if (getScale() > DEFAULT_MIN_SCALE) { return false; } if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) { return false; } return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY); } return false; } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); mBaseRotation = 0.0f; // Finally, update the UI so that we're zoomable setZoomable(zoomable); }
/**初始化 * @return * @must 调用 */ public void init() { minDistanceY = context.getResources().getDimension(R.dimen.min_distance_y); maxDistanceY = context.getResources().getDimension(R.dimen.max_distance_y); gestureDetector = new GestureDetector(context, this); lv.setOnTouchListener(onTouchListener == null ? this : onTouchListener); }
private void initLoopView(Context context) { this.context = context; handler = new MessageHandler(this); gestureDetector = new GestureDetector(context, new LoopViewGestureListener(this)); gestureDetector.setIsLongpressEnabled(false); isLoop = true; totalScrollY = 0; initPosition = -1; initPaints(); }
/** * Constructor * * @param context * the current context * @param listener * the scrolling listener */ public WheelScroller(Context context, ScrollingListener listener) { gestureDetector = new GestureDetector(context, gestureListener); gestureDetector.setIsLongpressEnabled(false); scroller = new Scroller(context); this.listener = listener; this.context = context; }
public ItemTouchListenerAdapter( RecyclerView recyclerView, RecyclerViewOnItemClickListener listener) { if (recyclerView == null || listener == null) { throw new IllegalArgumentException("RecyclerView and Listener arguments can not be null"); } this.recyclerView = recyclerView; this.listener = listener; this.gestureDetector = new GestureDetector(recyclerView.getContext(), this); }
public void setOnDoubleTapListener(GestureDetector.OnDoubleTapListener newOnDoubleTapListener) { if(newOnDoubleTapListener != null) { this.mGestureDetector.setOnDoubleTapListener(newOnDoubleTapListener); } else { this.mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); } }
/** * Initializes class data * * @param context the context */ private void initData(Context context) { mContext = context; gestureDetector = new GestureDetector(context, gestureListener); gestureDetector.setIsLongpressEnabled(false); scroller = new Scroller(context); TEXT_SIZE = ToolUtils.dip2px(context, TEXT_SIZE); ITEM_OFFSET = ToolUtils.dip2px(context, ITEM_OFFSET); }
public RecyclerItemClickListener(Context context, OnItemClickListener listener) { mListener = listener; mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }); }
/** * Constructor needed to inflate from XML. */ public NewTabPageScrollView(Context context, AttributeSet attrs) { super(context, attrs); mGestureDetector = new GestureDetector( getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { boolean retVal = super.onSingleTapUp(e); requestFocus(); return retVal; } }); }
private void initMenu(ViewHolder holder) { Toolbar toolbar = holder.get(R.id.toolbar); toolbar.setLogo(R.mipmap.logo_actionbar); toolbar.setTitle(""); DrawerLayout drawer = holder.get(R.id.drawer_layout); setSupportActionBar(toolbar); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); // 双击 666 final GestureDetector detector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onDoubleTap(MotionEvent e) { quickToTop(); // 快速返回头部 return super.onDoubleTap(e); } }); toolbar.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { detector.onTouchEvent(event); return false; } }); toolbar.setOnClickListener(this); holder.setOnClickListener(this, R.id.fab); loadMenuData(); }