List of usage examples for android.support.v4.view GestureDetectorCompat GestureDetectorCompat
public GestureDetectorCompat(Context context, OnGestureListener onGestureListener)
From source file:com.seek.ruler.SimpleRulerView.java
/** * set default//from ww w . j a v a2 s.c o m * * @param attrs */ private void init(AttributeSet attrs) { DisplayMetrics dm = getResources().getDisplayMetrics(); mIntervalDis = dm.density * 5; mRulerLineWidth = dm.density * 2; mTextSize = dm.scaledDensity * 14; TypedArray typedArray = attrs == null ? null : getContext().obtainStyledAttributes(attrs, R.styleable.simpleRulerView); if (typedArray != null) { mHighlightColor = typedArray.getColor(R.styleable.simpleRulerView_highlightColor, mHighlightColor); mTextColor = typedArray.getColor(R.styleable.simpleRulerView_textColor, mTextColor); mRulerColor = typedArray.getColor(R.styleable.simpleRulerView_rulerColor, mRulerColor); mIntervalValue = typedArray.getFloat(R.styleable.simpleRulerView_intervalValue, mIntervalValue); mMaxValue = typedArray.getFloat(R.styleable.simpleRulerView_maxValue, mMaxValue); mMinValue = typedArray.getFloat(R.styleable.simpleRulerView_minValue, mMinValue); mTextSize = typedArray.getDimension(R.styleable.simpleRulerView_textSize, mTextSize); mRulerLineWidth = typedArray.getDimension(R.styleable.simpleRulerView_rulerLineWidth, mRulerLineWidth); mIntervalDis = typedArray.getDimension(R.styleable.simpleRulerView_intervalDistance, mIntervalDis); retainLength = typedArray.getInteger(R.styleable.simpleRulerView_retainLength, 0); } calculateTotal(); mRulerPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mRulerPaint.setStrokeWidth(mRulerLineWidth); mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); mTextPaint.setTextAlign(Paint.Align.CENTER); mTextPaint.setTextSize(mTextSize); mGestureDetectorCompat = new GestureDetectorCompat(getContext(), this); mScroller = new OverScroller(getContext(), new DecelerateInterpolator()); setSelectedIndex(0); }
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. *//* w ww . j av a 2 s. co m*/ 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.samsistemas.calendarview.widget.CalendarView.java
/** * Constructor with arguments. It receives a * Context used to get the resources.//from w ww . jav a 2 s. c om * * @param context - the context used to get the resources. */ public CalendarView(Context context) { this(context, null); //Initialize the gesture listener needed.. mGestureDetector = new GestureDetectorCompat(context, new CalendarGestureDetector()); }
From source file:com.google.android.gms.location.sample.locationupdates.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); httpQueue = Volley.newRequestQueue(this); // Locate the UI widgets. mStartUpdatesButton = (ImageView) findViewById(R.id.start_updates_button); mStopUpdatesButton = (ImageView) findViewById(R.id.stop_updates_button); mLatitudeTextView = (TextView) findViewById(R.id.latitude_text); mLongitudeTextView = (TextView) findViewById(R.id.longitude_text); mLastUpdateTimeTextView = (TextView) findViewById(R.id.last_update_time_text); myMainLayout = (LinearLayout) findViewById(R.id.myMainLayout); // Set labels. mLatitudeLabel = getResources().getString(R.string.latitude_label); mLongitudeLabel = getResources().getString(R.string.longitude_label); mLastUpdateTimeLabel = getResources().getString(R.string.last_update_time_label); mDetector = new GestureDetectorCompat(this, this); mDetector.setOnDoubleTapListener(this); mRequestingLocationUpdates = false;/* w w w . j a v a 2 s . c o m*/ mLastUpdateTime = ""; // Update values using data stored in the Bundle. updateValuesFromBundle(savedInstanceState); // Kick off the process of building a GoogleApiClient and requesting the LocationServices // API. buildGoogleApiClient(); myVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); }
From source file:com.samsistemas.calendarview.widget.CalendarView.java
/** * Constructor with arguments. It receives a * Context used to get the resources./*from w w w .j av a 2 s . co m*/ * * @param context - the context used to get the resources. * @param attrs - attribute set with custom styles. */ public CalendarView(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; //Initialize the gesture listener needed.. mGestureDetector = new GestureDetectorCompat(context, new CalendarGestureDetector()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CUPCAKE) { if (isInEditMode()) { return; } } getAttributes(attrs); init(); }
From source file:com.golfmarin.golf.HoleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hole); final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub); stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { @Override/* w w w.j av a 2 s . c o m*/ public void onLayoutInflated(WatchViewStub stub) { holeView = (TextView) stub.findViewById(R.id.hole); backView = (TextView) stub.findViewById(R.id.back); middleView = (TextView) stub.findViewById(R.id.middle); frontView = (TextView) stub.findViewById(R.id.front); progressView = (ProgressBar) stub.findViewById(R.id.progress_bar); // getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } }); // Set startup state, which triggers a new search for the closest course. startup = true; // Enable the ambient mode setAmbientEnabled(); // Initialize data model containing all golf courses DataModel dm = new DataModel(this); allCourses = dm.getCourses(); // Check for an extra that specifies the golf course name // If present, initialize currentCourse object and disable course selection Bundle extras = getIntent().getExtras(); if (extras != null) { String courseName = extras.getString("course"); // Find the course object and verify that it has holes for (Course course : allCourses) { if (course.name.equals(courseName) && (course.holeList.size() > 0)) { currentCourse = course; allHoles = currentCourse.holeList; currentHoleNum = 1; currentHole = allHoles.get(0); Log.i(TAG, "Set currentCourse using a notification extra: " + currentCourse.name); Log.i(TAG, "ProgressView: " + progressView); // progressView.setVisibility(View.GONE); // holeView.setText("Hole"); startup = false; break; } } } // Setup a local broadcast receiver messageFilter = new IntentFilter(Intent.ACTION_SEND); messageReceiver = new MessageReceiver(); // Set up gesture detector gestureDetector = new GestureDetectorCompat(this, new MyGestureListener()); // Set up dismiss overlay view dismissOverlayView = (DismissOverlayView) findViewById(R.id.dismiss_overlay); dismissOverlayView.setIntroText(R.string.dismiss_intro); dismissOverlayView.showIntroIfNecessary(); /* // Set up sensor listener senSensorM*anager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); senAccelerometer = senSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); senSensorManager.registerListener(this, senAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); */ // Turn off auto brightness Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); }
From source file:com.google.corp.productivity.specialprojects.android.samples.fft.AnalyzeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { // Debug.startMethodTracing("calc"); super.onCreate(savedInstanceState); setContentView(R.layout.main);// w w w . j av a2 s .c o m DPRatio = getResources().getDisplayMetrics().density; final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); Log.i(TAG, " max mem = " + maxMemory + "k"); // set and get preferences in PreferenceActivity PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // Set variable according to the preferences updatePreferenceSaved(); textRMSChar = new char[getString(R.string.textview_RMS_text).length()]; textCurChar = new char[getString(R.string.textview_cur_text).length()]; textRecChar = new char[getString(R.string.textview_rec_text).length()]; textPeakChar = new char[getString(R.string.textview_peak_text).length()]; graphView = (AnalyzeView) findViewById(R.id.plot); // travel Views, and attach ClickListener to the views that contain android:tag="select" visit((ViewGroup) graphView.getRootView(), new Visit() { @Override public void exec(View view) { view.setOnLongClickListener(AnalyzeActivity.this); view.setOnClickListener(AnalyzeActivity.this); ((TextView) view).setFreezesText(true); } }, "select"); Resources res = getResources(); getAudioSourceNameFromIdPrepare(res); listItemTextSize = res.getDimension(R.dimen.button_text_fontsize); listItemTitleTextSize = res.getDimension(R.dimen.button_text_small_fontsize); /// initialize pop up window items list // http://www.codeofaninja.com/2013/04/show-listview-as-drop-down-android.html popupMenuSampleRate = popupMenuCreate(validateAudioRates(res.getStringArray(R.array.sample_rates)), R.id.button_sample_rate); popupMenuFFTLen = popupMenuCreate(res.getStringArray(R.array.fft_len), R.id.button_fftlen); popupMenuAverage = popupMenuCreate(res.getStringArray(R.array.fft_ave_num), R.id.button_average); mDetector = new GestureDetectorCompat(this, new AnalyzerGestureListener()); setTextViewFontSize(); }
From source file:com.emmasuzuki.quickreturnlistview.view.QuickReturnListView.java
private void initialize() { mScrollSettleHandler = new ScrollSettleHandler(); mGestureListener = new GestureDetectorCompat(getContext(), new GestureListener(mOnFlingListener)); mScrollSettleHandler.setOnSettleHandlerListener(new ScrollSettleHandler.OnSettleHandlerListener() { @Override// w w w . j a va2 s. c o m public void onHandleMessage() { // If first item is visible, do nothing if (mSettleEnabled && mState == STATE_RETURNING) { final int destY; // If more than half of quick return view is on screen, settle to show completely if (mQuickReturnView.getTop() > getTop() - mQuickReturnHeight / 2) { destY = 0; mState = STATE_ONSCREEN; // Else settle to hide completely } else { destY = -mQuickReturnHeight; mState = STATE_OFFSCREEN; } animateQuickReturnViewToDest(destY); } } }); refreshViews(); }
From source file:com.inmobi.ultrapush.AnalyzeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { // Debug.startMethodTracing("calc"); super.onCreate(savedInstanceState); setContentView(R.layout.main);//w ww . j a va2 s. c o m DPRatio = getResources().getDisplayMetrics().density; final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); Log.i(TAG, " max mem = " + maxMemory + "k"); // set and get preferences in PreferenceActivity PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // Set variable according to the preferences updatePreferenceSaved(); textRMSChar = new char[getString(R.string.textview_RMS_text).length()]; textCurChar = new char[getString(R.string.textview_cur_text).length()]; textRecChar = new char[getString(R.string.textview_rec_text).length()]; textPeakChar = new char[getString(R.string.textview_peak_text).length()]; graphView = (AnalyzeView) findViewById(R.id.plot); // travel Views, and attach ClickListener to the views that contain android:tag="select" visit((ViewGroup) graphView.getRootView(), new Visit() { @Override public void exec(View view) { view.setOnLongClickListener(AnalyzeActivity.this); view.setOnClickListener(AnalyzeActivity.this); ((TextView) view).setFreezesText(true); } }, "select"); Resources res = getResources(); getAudioSourceNameFromIdPrepare(res); listItemTextSize = res.getDimension(R.dimen.button_text_fontsize); listItemTitleTextSize = res.getDimension(R.dimen.button_text_small_fontsize); /// initialize pop up window items list // http://www.codeofaninja.com/2013/04/show-listview-as-drop-down-android.html popupMenuSampleRate = popupMenuCreate(validateAudioRates(res.getStringArray(R.array.sample_rates)), R.id.button_sample_rate); popupMenuFFTLen = popupMenuCreate(res.getStringArray(R.array.fft_len), R.id.button_fftlen); popupMenuAverage = popupMenuCreate(res.getStringArray(R.array.fft_ave_num), R.id.button_average); mDetector = new GestureDetectorCompat(this, new AnalyzerGestureListener()); setTextViewFontSize(); }
From source file:im.vector.fragments.HomeFragment.java
private void initViews() { // Invitations mInvitationsSection.setTitle(R.string.invitations_header); mInvitationsSection.setHideIfEmpty(true); mInvitationsSection.setPlaceholders(null, getString(R.string.no_result_placeholder)); mInvitationsSection.setupRoomRecyclerView( new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false), R.layout.adapter_item_room_invite, false, this, this, null); // Favourites mFavouritesSection.setTitle(R.string.bottom_action_favourites); mFavouritesSection.setHideIfEmpty(true); mFavouritesSection.setPlaceholders(null, getString(R.string.no_result_placeholder)); mFavouritesSection.setupRoomRecyclerView( new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false), R.layout.adapter_item_circular_room_view, true, this, null, null); // People//w w w.j a v a 2 s .c om mDirectChatsSection.setTitle(R.string.bottom_action_people); mDirectChatsSection.setPlaceholders(getString(R.string.no_conversation_placeholder), getString(R.string.no_result_placeholder)); mDirectChatsSection.setupRoomRecyclerView( new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false), R.layout.adapter_item_circular_room_view, true, this, null, null); // Rooms mRoomsSection.setTitle(R.string.bottom_action_rooms); mRoomsSection.setPlaceholders(getString(R.string.no_room_placeholder), getString(R.string.no_result_placeholder)); mRoomsSection.setupRoomRecyclerView( new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false), R.layout.adapter_item_circular_room_view, true, this, null, null); // Low priority mLowPrioritySection.setTitle(R.string.low_priority_header); mLowPrioritySection.setHideIfEmpty(true); mLowPrioritySection.setPlaceholders(null, getString(R.string.no_result_placeholder)); mLowPrioritySection.setupRoomRecyclerView( new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false), R.layout.adapter_item_circular_room_view, true, this, null, null); mHomeSectionViews = Arrays.asList(mInvitationsSection, mFavouritesSection, mDirectChatsSection, mRoomsSection, mLowPrioritySection); // Add listeners to hide the floating button when needed final GestureDetectorCompat gestureDetector = new GestureDetectorCompat(mActivity, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onDown(MotionEvent event) { return true; } @Override public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) { if (mActivity.getFloatingActionButton() != null && mNestedScrollView.getBottom() > mActivity.getFloatingActionButton().getTop()) { mActivity.hideFloatingActionButton(getTag()); } return true; } }); mNestedScrollView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (null != mNestedScrollView) { gestureDetector.onTouchEvent(event); return mNestedScrollView.onTouchEvent(event); } else { return false; } } }); mNestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() { @Override public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) { mActivity.hideFloatingActionButton(getTag()); } }); }