List of usage examples for android.view GestureDetector GestureDetector
@Deprecated
public GestureDetector(OnGestureListener listener)
From source file:com.sutromedia.android.core.PhotoActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.image);/*from ww w . j av a2 s. c om*/ mSwitcher = (ImageViewSwitcher) findViewById(R.image.switcher); mSwitcher.setImageId(R.image.photo); mSwitcher.setLayouts(R.layout.image_view_outside, R.layout.image_view_inside); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in)); mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out)); mFlingDetector = new GestureDetector(new MyGestureDetector()); checkInitialNavigation(savedInstanceState); }
From source file:foam.littlej.android.app.ui.phone.ViewReportPhotoActivity.java
private void initReport(int position) { photos = photo.getPhotosByReportId(reportId); // Hack:: get by report ID, if it returns nothing get by checkin ID // FIXME:: make this independent of ID if (photos.size() == 0) { photos = photo.getPhotosByCheckinId(reportId); }//w w w .j a va 2s.c om if (view.imageSwitcher != null) { view.imageSwitcher.setFactory(this); view.imageSwitcher.setOnTouchListener(this); } gestureDetector = new GestureDetector(new GestureDetectorListener()); if (photos != null && photos.size() > 0) { fileName = photos.get(position).getPhoto(); setImage(view.imageSwitcher); int page = position; this.setTitle(page + 1); } }
From source file:com.linkbubble.ui.BubbleFlowView.java
public BubbleFlowView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mViews = new ArrayList<View>(); mContent = new FrameLayout(context); mContent.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT)); addView(mContent);//from w ww .j a va 2s .com mIsExpanded = true; setOnTouchListener(mOnTouchListener); mVerticalGestureDetector = new GestureDetector(mVerticalGestureListener); }
From source file:com.mobicage.rogerthat.plugins.friends.ServiceSearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.service_search); mSearchCategoryLabels = (LinearLayout) findViewById(R.id.search_category); mSearchCategoryViewFlipper = (SafeViewFlipper) findViewById(R.id.search_result_lists); mSearchInfoByCategory = new HashMap<String, ServiceSearchActivity.SearchInfo>(); mSearchInfoByListView = new HashMap<AbsListView, ServiceSearchActivity.SearchInfo>(); mGestureScanner = new GestureDetector(new ViewFlipperSlider(mOnSwipeLeft, mOnSwipeRight)); final Context ctx = this; final EditText editText = (EditText) findViewById(R.id.search_text); editText.setOnEditorActionListener(new OnEditorActionListener() { @Override/*from www . j a va2s .c o m*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) { if (!TextUtils.isEmptyOrWhitespace(mSearchString)) { UIUtils.hideKeyboard(ServiceSearchActivity.this, v); launchFindServiceCall(); return true; } } return false; } }); editText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { mSearchString = s.toString(); clearSearches(); } }); findViewById(R.id.search_button).setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { if (TextUtils.isEmptyOrWhitespace(mSearchString)) { mSearchString = ""; } UIUtils.hideKeyboard(ctx, editText); clearSearches(); launchFindServiceCall(); } }); }
From source file:org.openremote.android.console.GroupActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); Log.i("OpenRemote-ORIENTATION", "onCreate:" + display.getOrientation()); if (display != null && display.getOrientation() == 1) { isLandscape = true;// www. ja v a2s . co m lastConfigurationOrientation = Configuration.ORIENTATION_LANDSCAPE; } else { isLandscape = false; lastConfigurationOrientation = Configuration.ORIENTATION_PORTRAIT; } this.gestureScanner = new GestureDetector(this); if (groupViews == null) { groupViews = new HashMap<Integer, GroupView>(); } if (navigationHistory == null) { navigationHistory = new ArrayList<Navigate>(); } recoverLastGroupScreen(); addControllerRefreshEventListener(); initOrientationListener(); }
From source file:org.transdroid.gui.search.Search.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); registerForContextMenu(findViewById(R.id.results)); getListView().setTextFilterEnabled(true); getListView().setOnItemClickListener(onSearchResultSelected); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); empty = (TextView) findViewById(android.R.id.empty); addSelected = (LinearLayout) findViewById(R.id.add_selected); addSelectedButton = (Button) findViewById(R.id.add_selectedbutton); addSelectedButton.setOnClickListener(addSelectedClicked); // Swiping or flinging between server configurations gestureDetector = new GestureDetector(new SearchScreenGestureListener()); getListView().setOnTouchListener(this); handleIntent(getIntent());// w ww .j a v a 2s . c o m }
From source file:com.mobicage.rogerthat.plugins.friends.RecommendServiceActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.recommend_service); mViewFlipper = (ViewFlipper) findViewById(R.id.view_flipper); if (!AppConstants.FRIENDS_ENABLED) { LinearLayout rtf = (LinearLayout) findViewById(R.id.recommend_to_friends); mViewFlipper.removeView(rtf);//from ww w. j av a2 s .c om RelativeLayout rl = (RelativeLayout) findViewById(R.id.rogerthat_layout); rl.setVisibility(View.GONE); View ci = findViewById(R.id.contacts_indicator); ci.setVisibility(View.VISIBLE); } if (AppConstants.FACEBOOK_APP_ID == null) { LinearLayout rof = (LinearLayout) findViewById(R.id.recommend_on_fb); mViewFlipper.removeView(rof); RelativeLayout fl = (RelativeLayout) findViewById(R.id.facebook_layout); fl.setVisibility(View.GONE); } Swiper leftSwiper = new Swiper() { @Override public Intent onSwipe() { int i = mViewFlipper.getDisplayedChild() + 1; if (i < mViewFlipper.getChildCount()) { displayTab(i); } return null; } }; Swiper rightSwiper = new Swiper() { @Override public Intent onSwipe() { int i = mViewFlipper.getDisplayedChild(); if (i > 0) { displayTab(i - 1); } return null; } }; mGestureScanner = new GestureDetector(new Slider(this, this, leftSwiper, rightSwiper)); Intent intent = getIntent(); mServiceEmail = intent.getStringExtra(SERVICE_EMAIL); mShareDescription = intent.getStringExtra(SHARE_DESCRIPTION); mShareCaption = intent.getStringExtra(SHARE_CAPTION); Uri shareLinkUrl = Uri.parse(intent.getStringExtra(SHARE_LINK_URL)); Builder b = shareLinkUrl.buildUpon(); b.appendQueryParameter("from", "phone"); b.appendQueryParameter("target", "fbwall"); b.build(); mShareLinkUrl = b.toString(); mShareImageUrl = intent.getStringExtra(SHARE_IMAGE_URL); mUiHelper = new UiLifecycleHelper(this, null); mUiHelper.onCreate(savedInstanceState); }
From source file:net.sourceforge.kalimbaradio.androidapp.activity.DownloadActivity.java
/** * Called when the activity is first created. */// w w w . j a v a2 s . c o m @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.download); WindowManager w = getWindowManager(); Display d = w.getDefaultDisplay(); swipeDistance = (d.getWidth() + d.getHeight()) * PERCENTAGE_OF_SCREEN_FOR_SWIPE / 100; swipeVelocity = (d.getWidth() + d.getHeight()) * PERCENTAGE_OF_SCREEN_FOR_SWIPE / 100; gestureScanner = new GestureDetector(this); playlistFlipper = (ViewFlipper) findViewById(R.id.download_playlist_flipper); emptyTextView = (TextView) findViewById(R.id.download_empty); songTitleTextView = (TextView) findViewById(R.id.download_song_title); artistTextView = (TextView) findViewById(R.id.download_artist); albumArtImageView = (ImageView) findViewById(R.id.download_album_art_image); positionTextView = (TextView) findViewById(R.id.download_position); durationTextView = (TextView) findViewById(R.id.download_duration); statusTextView = (TextView) findViewById(R.id.download_status); progressBar = (SeekBar) findViewById(R.id.download_progress_bar); playlistView = (ListView) findViewById(R.id.download_list); previousButton = findViewById(R.id.download_previous); nextButton = findViewById(R.id.download_next); pauseButton = findViewById(R.id.download_pause); stopButton = findViewById(R.id.download_stop); startButton = findViewById(R.id.download_start); shuffleButton = findViewById(R.id.download_shuffle); repeatButton = (ImageButton) findViewById(R.id.download_repeat); equalizerButton = (Button) findViewById(R.id.download_equalizer); visualizerButton = (Button) findViewById(R.id.download_visualizer); // jukeboxButton = (Button) findViewById(R.id.download_jukebox); // shareButton = (ImageView) findViewById(R.id.download_share); // starButton = (ImageView) findViewById(R.id.download_star); LinearLayout visualizerViewLayout = (LinearLayout) findViewById(R.id.download_visualizer_view_layout); toggleListButton = (ImageButton) findViewById(R.id.download_toggle_list); View.OnTouchListener touchListener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { return gestureScanner.onTouchEvent(me); } }; previousButton.setOnTouchListener(touchListener); nextButton.setOnTouchListener(touchListener); pauseButton.setOnTouchListener(touchListener); stopButton.setOnTouchListener(touchListener); // startButton.setOnTouchListener(touchListener); equalizerButton.setOnTouchListener(touchListener); visualizerButton.setOnTouchListener(touchListener); //jukeboxButton.setOnTouchListener(touchListener); //shareButton.setOnTouchListener(touchListener); //starButton.setOnTouchListener(touchListener); emptyTextView.setOnTouchListener(touchListener); albumArtImageView.setOnTouchListener(touchListener); previousButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfNetworkOrStorageUnavailable(); getDownloadService().previous(); onCurrentChanged(); onProgressChanged(); } }); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfNetworkOrStorageUnavailable(); if (getDownloadService().getCurrentPlayingIndex() < getDownloadService().size() - 1) { getDownloadService().next(); onCurrentChanged(); onProgressChanged(); } } }); pauseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getDownloadService().pause(); onCurrentChanged(); onProgressChanged(); } }); stopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getDownloadService().reset(); onCurrentChanged(); onProgressChanged(); } }); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfNetworkOrStorageUnavailable(); start(); onCurrentChanged(); onProgressChanged(); } }); shuffleButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getDownloadService().shuffle(); Util.toast(DownloadActivity.this, R.string.download_menu_shuffle_notification); setControlsVisible(true); } }); repeatButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { RepeatMode repeatMode = getDownloadService().getRepeatMode().next(); getDownloadService().setRepeatMode(repeatMode); onDownloadListChanged(); switch (repeatMode) { case OFF: Util.toast(DownloadActivity.this, R.string.download_repeat_off); break; case ALL: Util.toast(DownloadActivity.this, R.string.download_repeat_all); break; case SINGLE: Util.toast(DownloadActivity.this, R.string.download_repeat_single); break; default: break; } setControlsVisible(true); } }); equalizerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(DownloadActivity.this, EqualizerActivity.class)); setControlsVisible(true); } }); visualizerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean active = !visualizerView.isActive(); visualizerView.setActive(active); getDownloadService().setShowVisualization(visualizerView.isActive()); updateButtons(); Util.toast(DownloadActivity.this, active ? R.string.download_visualizer_on : R.string.download_visualizer_off); setControlsVisible(true); } }); /* jukeboxButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean jukeboxEnabled = !getDownloadService().isJukeboxEnabled(); getDownloadService().setJukeboxEnabled(jukeboxEnabled); updateButtons(); Util.toast(DownloadActivity.this, jukeboxEnabled ? R.string.download_jukebox_on : R.string.download_jukebox_off, false); setControlsVisible(true); } });*/ /*shareButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (currentPlaying != null) { ShareUtil.shareInBackground(DownloadActivity.this, currentPlaying.getSong()); } setControlsVisible(true); } });*/ /*starButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (currentPlaying != null) { MusicDirectory.Entry song = currentPlaying.getSong(); StarUtil.starInBackground(DownloadActivity.this, song, !song.isStarred()); starButton.setImageResource(song.isStarred() ? R.drawable.starred : R.drawable.unstarred); } setControlsVisible(true); } });*/ toggleListButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleFullscreenAlbumArt(); } }); progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int position, boolean fromUser) { if (fromUser) { Util.toast(DownloadActivity.this, Util.formatDuration(position / 1000), true); setControlsVisible(true); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { // Notification that the user has started a touch gesture. Clients may want to use this to disable advancing the seekbar. seekInProgress = true; } @Override public void onStopTrackingTouch(SeekBar seekBar) { // Notification that the user has finished a touch gesture. Clients may want to use this to re-enable advancing the seekbar. seekInProgress = false; int position = seekBar.getProgress(); Util.toast(DownloadActivity.this, Util.formatDuration(position / 1000), true); getDownloadService().seekTo(position); } }); playlistView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { warnIfNetworkOrStorageUnavailable(); getDownloadService().play(position); onCurrentChanged(); onProgressChanged(); } }); registerForContextMenu(playlistView); DownloadService downloadService = getDownloadService(); if (downloadService != null && getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, false)) { warnIfNetworkOrStorageUnavailable(); downloadService.setShufflePlayEnabled(true); } boolean visualizerAvailable = downloadService != null && downloadService.getVisualizerController() != null; boolean equalizerAvailable = downloadService != null && downloadService.getEqualizerController() != null; if (!equalizerAvailable) { equalizerButton.setVisibility(View.GONE); } if (!visualizerAvailable) { visualizerButton.setVisibility(View.GONE); } else { visualizerView = new VisualizerView(this); visualizerViewLayout.addView(visualizerView, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT)); } final View overflowButton = findViewById(R.id.download_overflow); overflowButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new PopupMenuHelper().showMenu(DownloadActivity.this, overflowButton, R.menu.nowplaying); } }); }
From source file:nl.sogeti.android.gpstracker.actions.Statistics.java
/** * Called when the activity is first created. *///from w w w .ja v a 2 s . c o m @Override protected void onCreate(Bundle load) { super.onCreate(load); mUnits = new UnitsI18n(this, new UnitsI18n.UnitsChangeListener() { @Override public void onUnitsChange() { drawTrackingStatistics(); } }); setContentView(R.layout.statistics); Toolbar toolbar = (Toolbar) findViewById(R.id.support_actionbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mViewFlipper = (ViewFlipper) findViewById(R.id.flipper); mViewFlipper.setDrawingCacheEnabled(true); mSlideLeftIn = AnimationUtils.loadAnimation(this, R.anim.slide_left_in); mSlideLeftOut = AnimationUtils.loadAnimation(this, R.anim.slide_left_out); mSlideRightIn = AnimationUtils.loadAnimation(this, R.anim.slide_right_in); mSlideRightOut = AnimationUtils.loadAnimation(this, R.anim.slide_right_out); mGraphTimeSpeed = (GraphCanvas) mViewFlipper.getChildAt(0); mGraphDistanceSpeed = (GraphCanvas) mViewFlipper.getChildAt(1); mGraphTimeAltitude = (GraphCanvas) mViewFlipper.getChildAt(2); mGraphDistanceAltitude = (GraphCanvas) mViewFlipper.getChildAt(3); mGraphTimeSpeed.setType(GraphCanvas.TIMESPEEDGRAPH); mGraphDistanceSpeed.setType(GraphCanvas.DISTANCESPEEDGRAPH); mGraphTimeAltitude.setType(GraphCanvas.TIMEALTITUDEGRAPH); mGraphDistanceAltitude.setType(GraphCanvas.DISTANCEALTITUDEGRAPH); mGestureDetector = new GestureDetector(new MyGestureDetector()); maxSpeedView = (TextView) findViewById(R.id.stat_maximumspeed); mAscensionView = (TextView) findViewById(R.id.stat_ascension); mElapsedTimeView = (TextView) findViewById(R.id.stat_elapsedtime); overallavgSpeedView = (TextView) findViewById(R.id.stat_overallaveragespeed); avgSpeedView = (TextView) findViewById(R.id.stat_averagespeed); distanceView = (TextView) findViewById(R.id.stat_distance); starttimeView = (TextView) findViewById(R.id.stat_starttime); endtimeView = (TextView) findViewById(R.id.stat_endtime); waypointsView = (TextView) findViewById(R.id.stat_waypoints); if (load != null && load.containsKey(TRACKURI)) { mTrackUri = Uri.withAppendedPath(Tracks.CONTENT_URI, load.getString(TRACKURI)); } else { mTrackUri = this.getIntent().getData(); } }
From source file:com.mobicage.rogerthat.AddFriendsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { T.UI();/*from w w w .j av a2 s .c o m*/ super.onCreate(savedInstanceState); setContentView(R.layout.add_friends); final int btnText; switch (AppConstants.FRIENDS_CAPTION) { case COLLEAGUES: btnText = R.string.invite_colleague; break; case CONTACTS: btnText = R.string.invite_contact; break; case FRIENDS: default: btnText = R.string.invite_friend; break; } ((Button) findViewById(R.id.add_via_email_button)).setText(btnText); mViewFlipper = (ViewFlipper) findViewById(R.id.view_flipper); Swiper leftSwiper = new Swiper() { @Override public Intent onSwipe() { int i = mViewFlipper.getDisplayedChild(); if (i < mViewFlipper.getChildCount()) { displayTab(i + 1); } return null; } }; Swiper rightSwiper = new Swiper() { @Override public Intent onSwipe() { int i = mViewFlipper.getDisplayedChild(); if (i > 0) { displayTab(i - 1); } return null; } }; mGestureScanner = new GestureDetector(new Slider(this, this, leftSwiper, rightSwiper)); Intent intent = getIntent(); if (intent.hasExtra(INTENT_KEY_LAUNCHINFO)) { if (intent.getStringExtra(INTENT_KEY_LAUNCHINFO).equals(INTENT_VALUE_SHOW_CONTACTS)) { displayTab(0); } else if (intent.getStringExtra(INTENT_KEY_LAUNCHINFO).equals(INTENT_VALUE_SHOW_FACEBOOK)) { displayTab(1); } } ((TextView) findViewById(R.id.add_via_contacts_description)) .setText(getString(R.string.add_via_contacts_description, getString(R.string.app_name))); ((TextView) findViewById(R.id.add_via_facebook_description)) .setText(getString(R.string.add_via_facebook_description, getString(R.string.app_name))); mUiHelper = new UiLifecycleHelper(this, null); mUiHelper.onCreate(savedInstanceState); }