List of usage examples for android.view ScaleGestureDetector ScaleGestureDetector
public ScaleGestureDetector(Context context, OnScaleGestureListener listener)
From source file:ca.frozen.rpicameraviewer.views.ZoomPanTextureView.java
private void initialize(Context context) { // create the gesture recognizers panDetector = new GestureDetectorCompat(context, new PanListener()); scaleDetector = new ScaleGestureDetector(context, new ScaleListener()); }
From source file:com.apptentive.android.sdk.util.image.PreviewImageView.java
public PreviewImageView(Context context, AttributeSet attrs) { super(context, attrs); super.setScaleType(ScaleType.MATRIX); scaleGestureDetector = new ScaleGestureDetector(context, this); gestureDetector = new GestureDetectorCompat(context, new PreviewGestureListener()); touchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); super.setScaleType(ScaleType.MATRIX); this.setOnTouchListener(this); }
From source file:com.hippo.ehviewer.gallery.gl.GestureRecognizer.java
public GestureRecognizer(Context context, Listener listener) { mListener = listener;/* ww w.ja v a2 s. c o m*/ MyGestureListener gestureListener = new MyGestureListener(); mGestureDetector = new GestureDetectorCompat(context, gestureListener, null /* ignoreMultitouch */); mGestureDetector.setOnDoubleTapListener(gestureListener); mScaleDetector = new ScaleGestureDetector(context, new MyScaleListener()); mDownUpDetector = new DownUpDetector(new MyDownUpListener()); }
From source file:com.guanqing.hao.OcrCaptureActivity.java
private void init() { mDimView = findViewById(R.id.dim_view); final CameraSourcePreview preview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<OcrGraphic>) findViewById(R.id.graphicOverlay); mDict = new Dict(this); mCameraSourceHelper = new CameraSourceHelper(this, preview, mGraphicOverlay, mDict); gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, mCameraSourceHelper); // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override/*from w ww. j a v a 2 s .co m*/ public void onInit(final int status) { if (status == TextToSpeech.SUCCESS) { tts.setLanguage(Locale.US); } } }; tts = new TextToSpeech(this.getApplicationContext(), listener); }
From source file:com.maxwen.wallpaper.board.fragments.BaseFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ViewHelper.resetViewBottomPadding(mRecyclerView, ((WallpaperBoardActivity) getActivity()).getNavBarHeight(), true);// ww w . j a v a 2 s.c o m setHasOptionsMenu(true); mDefaultSpan = getActivity().getResources().getInteger(R.integer.wallpapers_column_count); mMaxSpan = getActivity().getResources().getInteger(R.integer.wallpapers_max_column_count); mMinSpan = getActivity().getResources().getInteger(R.integer.wallpapers_min_column_count); mCurrentSpan = Math.min(Preferences.getPreferences(getActivity()).getColumnSpanCount(mDefaultSpan), mMaxSpan); //mRecyclerView.setItemAnimator(new DefaultItemAnimator()); mRecyclerView.setItemAnimator(new SlideInLeftAnimator()); mRecyclerView.setLayoutManager(new WallpaperGridLayoutManager(getActivity(), mCurrentSpan)); mRecyclerView.setHasFixedSize(false); //set scale gesture detector mScaleGestureDetector = new ScaleGestureDetector(getActivity(), new ScaleGestureDetector.SimpleOnScaleGestureListener() { @Override public boolean onScale(ScaleGestureDetector detector) { final float sf = detector.getScaleFactor(); if (detector.getTimeDelta() > 200 && Math.abs(detector.getCurrentSpan() - detector.getPreviousSpan()) > 100) { if (detector.getCurrentSpan() - detector.getPreviousSpan() < -1) { int span = Math.min(mCurrentSpan + 1, mMaxSpan); if (span != mCurrentSpan) { mCurrentSpan = span; ViewHelper.setSpanCountToColumns(getActivity(), mRecyclerView, mCurrentSpan); Preferences.getPreferences(getActivity()).setColumnSpanCount(mCurrentSpan); onSpanCountChanged(); } return true; } else if (detector.getCurrentSpan() - detector.getPreviousSpan() > 1) { int span = Math.max(mCurrentSpan - 1, mMinSpan); if (span != mCurrentSpan) { mCurrentSpan = span; ViewHelper.setSpanCountToColumns(getActivity(), mRecyclerView, mCurrentSpan); Preferences.getPreferences(getActivity()).setColumnSpanCount(mCurrentSpan); onSpanCountChanged(); } ViewHelper.setSpanCountToColumns(getActivity(), mRecyclerView, mCurrentSpan); return true; } } return false; } @Override public void onScaleEnd(ScaleGestureDetector detector) { mRecyclerView.setNestedScrollingEnabled(true); } @Override public boolean onScaleBegin(ScaleGestureDetector detector) { mRecyclerView.setNestedScrollingEnabled(false); return true; } }); mRecyclerView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { mScaleGestureDetector.onTouchEvent(event); return mScaleGestureDetector.isInProgress(); } }); }
From source file:com.example.manan.enhancedurdureader.EpubReader.BookView.java
@TargetApi(Build.VERSION_CODES.KITKAT) @Override/*from ww w . j av a 2 s . c o m*/ public void onActivityCreated(Bundle saved) { super.onActivityCreated(saved); view = (WebView) getView().findViewById(R.id.Viewport); view.getSettings().setTextZoom(textSize); mScaleDetector = new ScaleGestureDetector(getActivity().getBaseContext(), new ScaleGestureDetector.OnScaleGestureListener() { @Override public void onScaleEnd(ScaleGestureDetector detector) { } @Override public boolean onScaleBegin(ScaleGestureDetector detector) { return true; } @Override public boolean onScale(ScaleGestureDetector detector) { //Log.w(LOG_KEY, "zoom ongoing, scale: " + detector.getScaleFactor()); return false; } }); // enable JavaScript for cool things to happen! view.getSettings().setJavaScriptEnabled(true); // ----- SWIPE PAGE view.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { /* if (state == ViewStateEnum.books) swipePage(v, event, 0); //int fontSize, newFont;*/ WebView view = (WebView) v; switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: x1 = event.getX(); break; case MotionEvent.ACTION_UP: if (mode != ZOOM && swipeFlag) { //if (state == ViewStateEnum.books) //swipePage(v, event, 0); } break; case MotionEvent.ACTION_POINTER_DOWN: oldDist = spacing(event); if (oldDist > 10f) { mode = ZOOM; } break; case MotionEvent.ACTION_POINTER_UP: mode = NONE; break; case MotionEvent.ACTION_MOVE: if (mode == ZOOM) { float newDist = spacing(event); if (newDist > 10f) { float scale = newDist / oldDist; if (scale > 1) { int currentTextSize = view.getSettings().getTextZoom(); textSize = currentTextSize + 15; view.getSettings().setTextZoom(textSize); mode = NONE; swipeFlag = false; } else { int currentTextSize = view.getSettings().getTextZoom(); textSize = currentTextSize - 15; view.getSettings().setTextZoom(textSize); mode = NONE; swipeFlag = false; } } } break; } return view.onTouchEvent(event); } }); // ----- NOTE & LINK view.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { Message msg = new Message(); msg.setTarget(new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); String url = msg.getData().getString(getString(R.string.url)); if (url != null) navigator.setNote(url, index); } }); view.requestFocusNodeHref(msg); return false; } }); view.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { try { navigator.setBookPage(url, index); } catch (Exception e) { errorMessage(getString(R.string.error_LoadPage)); } return true; } }); loadPage(viewedPage); }
From source file:ru.jango.j0widget.imagebrowser.ImageBrowserView.java
private void init(Context ctx) { scaleGestureDetector = new ScaleGestureDetector(ctx, new ScaleListener()); gestureDetector = new GestureDetectorCompat(ctx, new GestureListener()); scroller = new OverScroller(ctx); zoomer = new Zoomer(getResources().getInteger(android.R.integer.config_shortAnimTime)); maxZoom = DEFAULT_MAX_ZOOM;//from ww w . j a v a 2s .co m }
From source file:com.jsibbold.zoomage.ZoomageView.java
public ZoomageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); scaleDetector = new ScaleGestureDetector(context, this); ScaleGestureDetectorCompat.setQuickScaleEnabled(scaleDetector, false); startScaleType = getScaleType();/*from ww w.j a v a 2s. c o m*/ TypedArray values = context.obtainStyledAttributes(attrs, com.jsibbold.zoomage.R.styleable.ZoomageView); zoomable = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_zoomable, true); translatable = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_translatable, true); animateOnReset = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_animateOnReset, true); autoCenter = values.getBoolean(R.styleable.ZoomageView_zoomage_autoCenter, true); restrictBounds = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_restrictBounds, false); minScale = values.getFloat(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_minScale, MIN_SCALE); maxScale = values.getFloat(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_maxScale, MAX_SCALE); autoResetMode = AutoResetMode.Parser.fromInt(values .getInt(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_autoResetMode, AutoResetMode.UNDER)); verifyScaleRange(); values.recycle(); }
From source file:com.shizhefei.view.largeimage.LargeImageView.java
public LargeImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mScroller = ScrollerCompat.create(getContext(), null); scaleHelper = new ScaleHelper(); setFocusable(true);//from w w w. j a va 2s. c om setWillNotDraw(false); gestureDetector = new GestureDetector(context, simpleOnGestureListener); scaleGestureDetector = new ScaleGestureDetector(context, onScaleGestureListener); imageBlockLoader = new BlockImageLoader(context); imageBlockLoader.setOnImageLoadListener(this); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:com.google.android.apps.muzei.util.PanScaleProxyView.java
public PanScaleProxyView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setWillNotDraw(true);// ww w . ja v a 2s. c om // Sets up interactions mScaleGestureDetector = new ScaleGestureDetector(context, mScaleGestureListener); ScaleGestureDetectorCompat.setQuickScaleEnabled(mScaleGestureDetector, true); mGestureDetector = new GestureDetectorCompat(context, mGestureListener); mScroller = new OverScroller(context); mZoomer = new Zoomer(context); }