List of usage examples for android.view ScaleGestureDetector ScaleGestureDetector
public ScaleGestureDetector(Context context, OnScaleGestureListener listener)
From source file:com.zenithed.core.widget.scaledimageview.ScaledImageView.java
/** * Sets up gesture detection and finds the original image dimensions. Nothing else is done until onDraw() is called * because the view dimensions will normally be unknown when this method is called. */// ww w . j a v a 2 s. c om private void initialize(Context context) { mContext = context; mScroller = new Scroller(mContext); mZoomer = new Zoomer(mContext); mMovementGestureDetector = new GestureDetectorCompat(mContext, mMovementGestureListener); mScaleGestureDetector = new ScaleGestureDetector(mContext, mScaleGestureListener); // by default the view must be enabled since it doesn't contain any content. setEnabled(false); }
From source file:com.juick.android.ThreadFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); xmppServiceServiceGetter = new Utils.ServiceGetter<XMPPService>(getActivity(), XMPPService.class); handler = new Handler(); parentMessagesSource = (MessagesSource) getArguments().getSerializable("messagesSource"); originalMessage = (JuickMessage) getArguments().getSerializable("originalMessage"); prefetched = (JuickMessage) getArguments().getSerializable("prefetched"); if (parentMessagesSource != null) parentMessagesSource.setContext(getActivity()); sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); trackLastRead = sp.getBoolean("lastReadMessages", true); if (Build.VERSION.SDK_INT >= 8) { mScaleDetector = new ScaleGestureDetector(getActivity(), new ScaleListener()); }/*from www.ja va 2s. c om*/ IntentFilter f = new IntentFilter(XMPPService.ACTION_THREAD_MESSAGE_RECEIVED); getActivity().registerReceiver(recv, f); }
From source file:com.example.zayankovsky.homework.ui.ImageDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.image_detail); getWindow().getDecorView().setBackgroundResource( PreferenceManager.getDefaultSharedPreferences(this).getString("theme", "light").equals("dark") ? R.color.darkColorTransparent : R.color.lightColorTransparent); // Set up activity to go full screen getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); // Locate the main ImageView and TextView mImageView = (ImageView) findViewById(R.id.imageView); final TextView mTextView = (TextView) findViewById(R.id.textView); mSectionNumber = getIntent().getIntExtra(SECTION_NUMBER, 0); registerForContextMenu(mImageView);/*from w w w . j a v a 2 s .c o m*/ mImageView.setLongClickable(false); // Enable some additional newer visibility and ActionBar features // to create a more immersive photo viewing experience final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { // Set home as up actionBar.setDisplayHomeAsUpEnabled(true); // Hide and show the ActionBar and TextView as the visibility changes mImageView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); if (mSectionNumber == 1) { mTextView.animate().translationY(mTextView.getHeight()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mTextView.setVisibility(View.GONE); } }); } } else { actionBar.show(); if (mSectionNumber == 1) { mTextView.animate().translationY(0).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mTextView.setVisibility(View.VISIBLE); } }); } } } }); // Start low profile mode and hide ActionBar mImageView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); } GestureListener.init(this, mImageView); ScaleGestureListener.init(mImageView); // Use the ImageWorker to load the image into the ImageView // (so a single cache can be used over all pages in the ViewPager) // based on the extra passed in to this activity int position = getIntent().getIntExtra(POSITION, 0); switch (mSectionNumber) { case 0: GalleryWorker.loadImage(position, mImageView); break; case 1: FotkiWorker.loadImage(position, mImageView); mTextView.setText(getResources().getString(R.string.detail_text, FotkiWorker.getAuthor(), new SimpleDateFormat("d MMMM yyyy", Locale.getDefault()).format(FotkiWorker.getPublished()))); break; case 2: ResourcesWorker.loadImage(position, mImageView); break; } setTitle(ImageWorker.getTitle()); // First we create the GestureListener that will include all our callbacks. // Then we create the GestureDetector, which takes that listener as an argument. GestureDetector.SimpleOnGestureListener gestureListener = new GestureListener(); final GestureDetector gd = new GestureDetector(this, gestureListener); ScaleGestureDetector.SimpleOnScaleGestureListener scaleGestureListener = new ScaleGestureListener(); final ScaleGestureDetector sgd = new ScaleGestureDetector(this, scaleGestureListener); /* For the view where gestures will occur, we create an onTouchListener that sends * all motion events to the gesture detectors. When the gesture detectors * actually detects an event, it will use the callbacks we created in the * SimpleOnGestureListener and SimpleOnScaleGestureListener to alert our application. */ findViewById(R.id.frameLayout).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { gd.onTouchEvent(motionEvent); sgd.onTouchEvent(motionEvent); return true; } }); }
From source file:br.com.brolam.cloudvision.ui.NoteVisionActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_note_vision); this.toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//ww w.ja va 2 s . com // Show the Up button in the action bar. ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<OcrGraphic>) findViewById(R.id.graphicOverlay); this.fabFlashOnOff = (FloatingActionButton) this.findViewById(R.id.fabFlashOnOff); this.fabCameraPlayStop = (FloatingActionButton) this.findViewById(R.id.fabCameraPlayStop); this.fabAdd = (FloatingActionButton) this.findViewById(R.id.fabAdd); this.contentNoteVisionCamera = this.findViewById(R.id.contentNoteVisionCamera); this.contentNoteVisionKeyboard = this.findViewById(R.id.contentNoteVisionKeyboard); this.editTextTitle = (EditText) this.findViewById(R.id.editTextTitle); this.editTextContent = (EditText) this.findViewById(R.id.editTextContent); setSaveInstanceState(savedInstanceState); // 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(); } else { ActivityHelper.requestCameraPermission(TAG, this, mGraphicOverlay); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); /* * Criar um LoginHelper para registrar o login do usurio no aplicativo. * Veja os mtodos onResume, onPause e onActivityResult para mais detalhes * sobre o fluxo de registro do usurio. */ this.loginHelper = new LoginHelper(this, null, this); }
From source file:io.asv.mtgocr.ocrreader.OcrCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. *//*from www. ja va 2 s . c om*/ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.ocr_capture); //region asv imgBgCard = (ImageView) findViewById(R.id.imgBgCard); btnOk = (Button) findViewById(R.id.btnOk); btnCancel = (Button) findViewById(R.id.btnCancel); fabOcr = (FloatingActionButton) findViewById(R.id.fabOcr); txtSearch = (EditText) findViewById(R.id.txtSearch); lytSearch = (RelativeLayout) findViewById(R.id.lytSearch); lytRecycler = (RelativeLayout) findViewById(R.id.lytRecycler); topLayout = (LinearLayout) findViewById(R.id.topLayout); btnOk.setOnClickListener(this); btnCancel.setOnClickListener(this); fabOcr.setOnClickListener(this); //mnu1 //endregion mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<OcrGraphic>) findViewById(R.id.graphicOverlay); // read parameters from the intent used to launch the activity. boolean autoFocus = getIntent().getBooleanExtra(App.INTENT_AUTO_FOCUS, false); boolean useFlash = getIntent().getBooleanExtra(App.INTENT_USE_FLASH, false); mPersistorMode = getIntent().getStringExtra(App.INTENT_PERSISTOR_MODE); loadPersistModeDataCardInfo(); //region RecyclerView setUpRecyclerView(); lytRecycler.setVisibility(View.VISIBLE); fabOcr.setVisibility(View.VISIBLE); topLayout.setVisibility(View.GONE); //endregion showPersistorUI(); //region 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); } else { requestCameraPermission(); } //endregion gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); }
From source file:uk.co.tekkies.readings.fragment.PassageFragment.java
private void registerGestureDetector(View mainView) { scaleGestureDetector = new ScaleGestureDetector(getActivity(), new TextViewOnScaleGestureListener()); ScrollView rootView = (ScrollView) mainView.findViewById(R.id.scrollView1); rootView.setOnTouchListener(new OnTouchListener() { @Override/*w w w . j a va2 s .c o m*/ public boolean onTouch(View v, MotionEvent event) { scaleGestureDetector.onTouchEvent(event); return scaleGestureDetector.isInProgress(); } }); }
From source file:com.android.gallery3d.filtershow.imageshow.ImageShow.java
public void setupGestureDetector(Context context) { mGestureDetector = new GestureDetector(context, this); mScaleGestureDetector = new ScaleGestureDetector(context, this); }
From source file:com.juick.android.MessagesFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final ViewConfiguration configuration = ViewConfiguration.get(getActivity()); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); databaseGetter = new Utils.ServiceGetter<DatabaseService>(getActivity(), DatabaseService.class); handler = new Handler(); sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); trackLastRead = sp.getBoolean("lastReadMessages", true); alternativeLongClick = sp.getBoolean("alternativeLongClick", false); Bundle args = getArguments();//from w w w . j ava2 s. c om if (args != null) { messagesSource = (MessagesSource) args.getSerializable("messagesSource"); } if (messagesSource == null) messagesSource = new JuickCompatibleURLMessagesSource(getActivity(), "dummy"); if (messagesSource.getContext() == null) messagesSource.setContext(JuickAdvancedApplication.instance); mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); mFlipAnimation.setInterpolator(new LinearInterpolator()); mFlipAnimation.setDuration(250); mFlipAnimation.setFillAfter(true); mReverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); mReverseFlipAnimation.setInterpolator(new LinearInterpolator()); mReverseFlipAnimation.setDuration(250); mReverseFlipAnimation.setFillAfter(true); if (Build.VERSION.SDK_INT >= 8) { mScaleDetector = new ScaleGestureDetector(getActivity(), new ScaleListener()); } }
From source file:org.deviceconnect.android.deviceplugin.theta.fragment.ThetaVRModeFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { mStorage = new ThetaObjectStorage(getContext()); setRetainInstance(true);/*from ww w. j a va2 s. co m*/ ThetaDeviceApplication app = (ThetaDeviceApplication) getActivity().getApplication(); mDataCache = app.getCache(); View rootView = inflater.inflate(R.layout.theta_vr_mode, null); mRightLayout = (RelativeLayout) rootView.findViewById(R.id.right_ui); mSphereView = (SphericalImageView) rootView.findViewById(R.id.vr_view); SphericalViewApi api = app.getSphericalViewApi(); mSphereView.setViewApi(api); mSphereView.setOnTouchListener(new View.OnTouchListener() { private boolean mIsEnabledLongTouch = true; @Override public boolean onTouch(final View view, final MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_UP) { mIsEnabledLongTouch = true; return true; } if (motionEvent.getPointerCount() == 1) { if (mIsEnabledLongTouch && motionEvent.getEventTime() - motionEvent.getDownTime() >= 300) { mSphereView.resetCameraDirection(); } } else { mIsEnabledLongTouch = false; mScaleDetector.onTouchEvent(motionEvent); } return true; } }); init3DButtons(rootView); enableView(); mScaleDetector = new ScaleGestureDetector(getActivity(), new ScaleGestureDetector.SimpleOnScaleGestureListener() { @Override public boolean onScale(final ScaleGestureDetector detector) { mScaleFactor /= detector.getScaleFactor(); double scale = mScaleFactor; if (scale > MAX_FOV) { scale = MAX_FOV; mScaleFactor = MAX_FOV; } if (scale < MIN_FOV) { scale = MIN_FOV; mScaleFactor = MIN_FOV; } mSphereView.setFOV(scale); return true; } }); return rootView; }