List of usage examples for android.view GestureDetector GestureDetector
public GestureDetector(Context context, OnGestureListener listener)
From source file:de.skubware.opentraining.activity.start_training.FExDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_fex_detail, container, false); // show the current exercise ImageView imageview = (ImageView) rootView.findViewById(R.id.imageview); // set gesture detector this.mGestureScanner = new GestureDetector(this.getActivity(), new ExerciseDetailOnGestureListener(this, imageview, mExercise)); // Images/*from ww w. j a v a2 s .co m*/ if (!mExercise.getImagePaths().isEmpty()) { DataHelper data = new DataHelper(getActivity()); imageview.setImageDrawable(data.getDrawable(mExercise.getImagePaths().get(0).toString())); } else { imageview.setImageResource(R.drawable.ic_launcher); } imageview.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return mGestureScanner.onTouchEvent(event); } }); // set adapter ListView listView = (ListView) rootView.findViewById(R.id.list); final TrainingEntryListAdapter mAdapter = new TrainingEntryListAdapter( (SherlockFragmentActivity) getActivity(), mExercise, mTrainingEntry); listView.setAdapter(mAdapter); SwipeDismissListViewTouchListener touchListener = new SwipeDismissListViewTouchListener(listView, new SwipeDismissListViewTouchListener.OnDismissCallback() { @Override public void onDismiss(ListView listView, int[] reverseSortedPositions) { for (int position : reverseSortedPositions) { mAdapter.remove(position); } mAdapter.notifyDataSetChanged(); } }); listView.setOnTouchListener(touchListener); // Setting this scroll listener is required to ensure that during // ListView scrolling, // we don't look for swipes. listView.setOnScrollListener(touchListener.makeScrollListener()); return rootView; }
From source file:br.com.fatec.jade.barcode.BarcodeCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. */// w ww .java 2s . co m @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.barcode_capture); mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) 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); // 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(); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); Snackbar.make(mGraphicOverlay, "Toque para capturar. Gesto de pina para zoom", Snackbar.LENGTH_LONG) .show(); }
From source file:com.karrel.sunstudyenglish.base.ocr.OcrCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. *//*from ww w . j a v a2 s . c o m*/ @Override public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.ocr_capture); mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<OcrGraphic>) findViewById(R.id.graphicOverlay); // Set good defaults for capturing text. boolean autoFocus = true; boolean useFlash = false; // 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(); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); Snackbar.make(mGraphicOverlay, "Tap to Speak. Pinch/Stretch to zoom", Snackbar.LENGTH_LONG).show(); mWordSet = new HashSet<>(); findViewById(R.id.completeCollection).setOnClickListener(onCompliteListener); }
From source file:it.jaschke.alexandria.barcode.BarcodeCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. *///from ww w.jav a 2 s . c om @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.barcode_capture); mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) 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); // 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(); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); Snackbar.make(mGraphicOverlay, getString(R.string.tap_to_capture), Snackbar.LENGTH_LONG).show(); }
From source file:com.simadanesh.handheld.BarcodeCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. *//*from w ww. j ava2 s . co m*/ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.barcode_capture); mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) 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); // 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(); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); Snackbar.make(mGraphicOverlay, "Tap to capture. Pinch/Stretch to zoom", Snackbar.LENGTH_LONG).show(); }
From source file:org.strongswan.android.ui.fragment.ImcStateFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.imc_state_fragment, container, false); mButton = (LinearLayout) view.findViewById(R.id.imc_state_button); mButton.setOnClickListener(new OnClickListener() { @Override//w w w .j a v a2s .c o m public void onClick(View v) { Intent intent; if (mService != null && !mService.getRemediationInstructions().isEmpty()) { intent = new Intent(getActivity(), RemediationInstructionsActivity.class); intent.putParcelableArrayListExtra( RemediationInstructionsFragment.EXTRA_REMEDIATION_INSTRUCTIONS, new ArrayList<RemediationInstruction>(mService.getRemediationInstructions())); } else { intent = new Intent(getActivity(), LogActivity.class); } startActivity(intent); } }); final GestureDetector gestures = new GestureDetector(getActivity(), new GestureDetector.SimpleOnGestureListener() { /* a better value would be getScaledTouchExplorationTapSlop() but that is hidden */ private final int mMinDistance = ViewConfiguration.get(getActivity()).getScaledTouchSlop() * 4; @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (Math.abs(e1.getX() - e2 .getX()) >= mMinDistance) { /* only if the user swiped a minimum horizontal distance */ if (mService != null) { mService.setImcState(ImcState.UNKNOWN); } return true; } return false; } }); mButton.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return gestures.onTouchEvent(event); } }); mStateView = (TextView) view.findViewById(R.id.imc_state); mAction = (TextView) view.findViewById(R.id.action); return view; }
From source file:spinc.spmmvp.google_vision.ocrRead_Complete.OcrCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. *///from w w w . j a v a 2s . c o m @Override public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.ocr_capture_complete); mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<OcrGraphic>) findViewById(R.id.graphicOverlay); // Set good defaults for capturing text. boolean autoFocus = true; boolean useFlash = false; // 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(); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); Snackbar.make(mGraphicOverlay, "Tap to Speak. Pinch/Stretch to zoom", Snackbar.LENGTH_LONG).show(); // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { if (status == TextToSpeech.SUCCESS) { Log.d("OnInitListener", "Text to speech engine started successfully."); tts.setLanguage(Locale.US); } else { Log.d("OnInitListener", "Error starting the text to speech engine."); } } }; tts = new TextToSpeech(this.getApplicationContext(), listener); }
From source file:com.androidhighfives.lift.UI.Claim.BarcodeCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. *//*from w ww . j ava 2 s . c o m*/ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.barcode_capture); mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) 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); // 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(); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); Snackbar.make(mGraphicOverlay, "Tap to capture. Pinch/Stretch to zoom", Snackbar.LENGTH_INDEFINITE).show(); }
From source file:uy.com.lifan.lifantracker.barcodereader.BarcodeCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. */// w ww . jav a 2 s . c om @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.barcode_capture); mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) findViewById(R.id.graphicOverlay); // read parameters from the intent used to launch the activity. boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, true); boolean useFlash = getIntent().getBooleanExtra(UseFlash, false); // 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(); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); Snackbar.make(mGraphicOverlay, "Presionar para capturar", Snackbar.LENGTH_LONG).show(); }
From source file:com.woxthebox.draglistview.KanbanBoardView.java
@Override protected void onFinishInflate() { super.onFinishInflate(); Resources res = getResources(); boolean isPortrait = res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; if (isPortrait) { mColumnWidth = (int) (res.getDisplayMetrics().widthPixels); } else {//from w w w . j a v a 2s . co m mColumnWidth = (int) (res.getDisplayMetrics().density * 320); } mGestureDetector = new GestureDetector(getContext(), new GestureListener()); mColumnGestureListener = new ColumnGestureListener(); mColumnGestureDetector = new GestureDetector(getContext(), mColumnGestureListener); mScroller = new Scroller(getContext(), new DecelerateInterpolator(1.1f)); mAutoScroller = new AutoScroller(getContext(), this); mAutoScroller.setAutoScrollMode(snapToColumnWhenDragging() ? AutoScroller.AutoScrollMode.COLUMN : AutoScroller.AutoScrollMode.POSITION); mDragItem = new DragItem(getContext()); mRootLayout = new FrameLayout(getContext()); mRootLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); mColumnLayout = new LinearLayout(getContext()); mColumnLayout.setOrientation(LinearLayout.HORIZONTAL); mColumnLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); mColumnLayout.setMotionEventSplittingEnabled(false); mRootLayout.addView(mColumnLayout); mRootLayout.addView(mDragItem.getDragItemView()); addView(mRootLayout); }