本文整理汇总了Java中android.view.GestureDetector类的典型用法代码示例。如果您正苦于以下问题:Java GestureDetector类的具体用法?Java GestureDetector怎么用?Java GestureDetector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GestureDetector类属于android.view包,在下文中一共展示了GestureDetector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cleanup
import android.view.GestureDetector; //导入依赖的package包/类
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;
}
}
示例2: initVideoView
import android.view.GestureDetector; //导入依赖的package包/类
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());
}
示例3: EntityView
import android.view.GestureDetector; //导入依赖的package包/类
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);
}
}
});
}
示例4: PhotoViewAttacher
import android.view.GestureDetector; //导入依赖的package包/类
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);
}
}
示例5: onCreate
import android.view.GestureDetector; //导入依赖的package包/类
@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;
}
});
}
示例6: onCreate
import android.view.GestureDetector; //导入依赖的package包/类
@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));
}
示例7: onCreate
import android.view.GestureDetector; //导入依赖的package包/类
@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");
}
示例8: onCreate
import android.view.GestureDetector; //导入依赖的package包/类
@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);
}
示例9: initWorkspace
import android.view.GestureDetector; //导入依赖的package包/类
/**
* 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);
}
}
示例10: PhotoViewAttacher
import android.view.GestureDetector; //导入依赖的package包/类
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);
}
}
示例11: sharedConstructing
import android.view.GestureDetector; //导入依赖的package包/类
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());
}
示例12: sharedConstructing
import android.view.GestureDetector; //导入依赖的package包/类
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());
}
示例13: sharedConstructing
import android.view.GestureDetector; //导入依赖的package包/类
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());
}
示例14: initLayout
import android.view.GestureDetector; //导入依赖的package包/类
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;
}
});
}
示例15: setContentView
import android.view.GestureDetector; //导入依赖的package包/类
/**设置该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);
}
});
}