List of usage examples for android.view GestureDetector GestureDetector
public GestureDetector(Context context, OnGestureListener listener)
From source file:com.abct.tljr.news.widget.ZoomableImageView.java
private void init(Context context) { mPaint = new Paint(); mPaint.setDither(true);// w w w. ja va2 s . c o m mPaint.setFilterBitmap(true); mPaint.setAntiAlias(true); // Setup the refresh runnable mRefresh = new Runnable() { @Override public void run() { postInvalidate(); } }; // Setup the gesture and scale listeners mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); mGestureDetector = new GestureDetector(context, new MyGestureListener()); // Force hardware acceleration if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) setLayerType(View.LAYER_TYPE_HARDWARE, null); }
From source file:com.dongdong.wheel.WheelView.java
/** * Initializes class data/* w ww. j ava2 s . co m*/ * * @param context the context */ private void initData(Context context) { mGestureDetector = new GestureDetector(context, gestureListener); mGestureDetector.setIsLongpressEnabled(false); mScroller = new Scroller(context); }
From source file:com.library.core.view.HorizontalListView.java
private synchronized void initViewForSpecific() { mLeftViewIndex = mSpecificPosition - 1; mRightViewIndex = mSpecificPosition + 1; mFirstPosition = mSpecificPosition;/* w ww . ja va 2 s .co m*/ mDisplayOffset = 0; mCurrentX = 0; mNextX = 0; mMaxX = Integer.MAX_VALUE; mScroller = new Scroller(getContext()); mGesture = new GestureDetector(getContext(), mOnGesture); System.out.println("initViewForSpecific mMaxX = Integer.MAX_VALUE"); }
From source file:com.plugin.weight.ripple.RippleLayoutView.java
/** * Method that initializes all fields and sets listeners * * @param context Context used to create this view * @param attrs Attribute used to initialize fields *//* w w w .j a v a2 s . c o m*/ private void init(final Context context, final AttributeSet attrs) { if (isInEditMode()) return; final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleLayoutView); rippleColor = typedArray.getColor(R.styleable.RippleLayoutView_rv_color, ContextCompat.getColor(context, R.color.rippelColor));//? rippleType = typedArray.getInt(R.styleable.RippleLayoutView_rv_type, 0);//? hasToZoom = typedArray.getBoolean(R.styleable.RippleLayoutView_rv_zoom, false);//? isCentered = typedArray.getBoolean(R.styleable.RippleLayoutView_rv_centered, false);//? rippleDuration = typedArray.getInteger(R.styleable.RippleLayoutView_rv_rippleDuration, rippleDuration); frameRate = typedArray.getInteger(R.styleable.RippleLayoutView_rv_framerate, frameRate); rippleAlpha = typedArray.getInteger(R.styleable.RippleLayoutView_rv_alpha, rippleAlpha); ripplePadding = typedArray.getDimensionPixelSize(R.styleable.RippleLayoutView_rv_ripplePadding, 0); canvasHandler = new Handler(); zoomScale = typedArray.getFloat(R.styleable.RippleLayoutView_rv_zoomScale, 1.03f); zoomDuration = typedArray.getInt(R.styleable.RippleLayoutView_rv_zoomDuration, 200); typedArray.recycle(); paint = new Paint(); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL); paint.setColor(rippleColor); paint.setAlpha(rippleAlpha); this.setWillNotDraw(false); gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override public void onLongPress(MotionEvent event) { super.onLongPress(event); animateRipple(event); sendClickEvent(true); } @Override public boolean onSingleTapConfirmed(MotionEvent e) { return true; } @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }); this.setDrawingCacheEnabled(true); this.setClickable(true); }
From source file:divya.myvision.TessActivity.java
/** * Initializes the UI and creates the detector pipeline. *//* ww w . j a v a 2s . c om*/ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.ocr_capture); mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<TessGraphic>) findViewById(R.id.graphicOverlay); // read parameters from the intent used to launch the activity. boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, false); boolean useFlash = getIntent().getBooleanExtra(UseFlash, false); String fps = getIntent().getStringExtra(FPS); String fontSize = getIntent().getStringExtra(FontSize); String orientation = getIntent().getStringExtra(Orientation); String lang = getIntent().getStringExtra(Lang); if (orientation.equals("Landscape")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (orientation.equals("Portrait")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } Settings.setFontSize(Float.parseFloat(fontSize)); // Check for the camera permission before accessing the camera. If the // permission is not granted yet, request permission. int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA); if (rc == PackageManager.PERMISSION_GRANTED) { createCameraSource(autoFocus, useFlash, fps); } else { requestCameraPermission(); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); Snackbar.make(mGraphicOverlay, R.string.info_msg, Snackbar.LENGTH_LONG).show(); setLang(lang); }
From source file:de.skubware.opentraining.activity.create_workout.ExerciseTypeDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_exercisetype_detail, container, false); ViewGroup rootLayout = (ViewGroup) rootView.findViewById(R.id.fragment_exercisetype_detail_layout); // If Image Exists if (!mExercise.getImagePaths().isEmpty()) { // Create Image View ImageView imageView = new ImageView(rootView.getContext()); imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setPadding(20, 20, 20, 20); rootLayout.addView(imageView);/*from ww w. j a va 2 s . co m*/ imageView.setVisibility(View.VISIBLE); // set gesture detector this.mGestureScanner = new GestureDetector(this.getActivity(), new ExerciseDetailOnGestureListener(this, imageView, mExercise)); //Set Image DataHelper data = new DataHelper(getActivity()); imageView.setImageDrawable(data.getDrawable(mExercise.getImagePaths().get(0).toString())); rootView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return mGestureScanner.onTouchEvent(event); } }); } else { TextView textView = new TextView(rootView.getContext()); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); textView.setGravity(Gravity.CENTER); textView.setPadding(10, 10, 10, 10); textView.setText(Html.fromHtml(mExercise.getDescription())); rootLayout.addView(textView); } return rootView; }
From source file:com.gigigo.vuforia.core.sdkimagerecognition.cloudrecognition.CloudRecognition.java
public void on_Create() { try {//w w w . j av a 2s.c om if (this.mLicenseKey == "" || this.mAccessKey == "" || this.mSecretKey == "") { Log.e(this.mActivity.getResources().getString(R.string.orchextra_auth_error_tag), this.mActivity.getResources().getString(R.string.orchextra_auth_error_text)); this.mActivity.finish(); } else { vuforiaAppSession = new VuforiaSession(this, this.mLicenseKey); startLoadingAnimation(); vuforiaAppSession.initAR(this.mActivity, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Creates the GestureDetector listener for processing double tap mGestureDetector = new GestureDetector(this.mActivity, new GestureListener()); mIsDroidDevice = android.os.Build.MODEL.toLowerCase().startsWith("droid"); } } catch (Throwable tr) { GGGLogImpl.log(tr.getMessage(), LogLevel.ERROR); } }
From source file:robert.com.basiclibrary.base.BaseActivity.java
/**Activity??? * @param layoutResID//w w w. ja v a 2 s . com * @param listener * @use ? * *1.onCreatesuper.onCreate?setContentView(layoutResID, this); * *2.?onDragBottom? * *3.??onClickonDragBottom */ 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); } }); }
From source file:it.configure.imageloader.zoom.PhotoViewAttacher.java
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//from ww w . j a v a 2s. co m 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); } }
From source file:io.syng.fragment.WebViewFragment.java
protected void init() { webView = makeWebView();//from w ww .j a v a 2 s . co m createViews(); if (!webView.isInitialized()) { webView.init(cordovaInterface, pluginEntries, preferences); } webView.getView().requestFocusFromTouch(); cordovaInterface.onCordovaInit(webView.getPluginManager()); //webView.clearCache(); android.webkit.CookieManager.getInstance().removeAllCookie(); // Wire the hardware volume controls to control media if desired. String volumePref = preferences.getString("DefaultVolumeStream", ""); if ("media".equals(volumePref.toLowerCase(Locale.ENGLISH))) { getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC); } BaseActivity activity = (BaseActivity) getActivity(); activity.hideToolbar(2); gestureDetector = new GestureDetector(webView.getContext(), this); webView.getView().setOnTouchListener(this); }