List of usage examples for android.view GestureDetector GestureDetector
@Deprecated
public GestureDetector(OnGestureListener listener)
From source file:org.dvbviewer.controller.ui.fragments.Remote.java
/** * Inititalize./*from ww w . j a v a2s. c om*/ * * @author RayBa * @date 07.04.2013 */ private void inititalize() { detector = new GestureDetector(getGestureListener()); flipper = (ViewFlipper) content.findViewById(R.id.flipper); flipper.setOnTouchListener(this); btnMoveDown = (Button) content.findViewById(R.id.ButtonMoveDown); btnMoveDown.setOnTouchListener(this); btnMoveDown.setOnClickListener(this); btnMoveUp = (Button) content.findViewById(R.id.ButtonMoveUp); btnMoveUp.setOnTouchListener(this); btnMoveUp.setOnClickListener(this); btnOk = (Button) content.findViewById(R.id.ButtonOK); btnOk.setOnTouchListener(this); btnOk.setOnClickListener(this); btnMoveLeft = (Button) content.findViewById(R.id.ButtonMoveLeft); btnMoveLeft.setOnTouchListener(this); btnMoveLeft.setOnClickListener(this); btnMoveRight = (Button) content.findViewById(R.id.ButtonMoveRight); btnMoveRight.setOnTouchListener(this); btnMoveRight.setOnClickListener(this); btnBack = (Button) content.findViewById(R.id.ButtonBack); btnBack.setOnTouchListener(this); btnBack.setOnClickListener(this); btnMenu = (Button) content.findViewById(R.id.ButtonMenu); btnMenu.setOnTouchListener(this); btnMenu.setOnClickListener(this); btnMenu.setOnLongClickListener(this); btnVideos = (Button) content.findViewById(R.id.ButtonVideos); btnVideos.setOnTouchListener(this); btnVideos.setOnClickListener(this); btnStepFoward = (Button) content.findViewById(R.id.ButtonStepForward); btnStepFoward.setOnTouchListener(this); btnStepFoward.setOnClickListener(this); btnStepBack = (Button) content.findViewById(R.id.ButtonStepBack); btnStepBack.setOnTouchListener(this); btnStepBack.setOnClickListener(this); btnText = (Button) content.findViewById(R.id.ButtonText); btnText.setOnTouchListener(this); btnText.setOnClickListener(this); btnPause = (Button) content.findViewById(R.id.ButtonPause); btnPause.setOnTouchListener(this); btnPause.setOnClickListener(this); btnStop = (Button) content.findViewById(R.id.ButtonStop); btnStop.setOnTouchListener(this); btnStop.setOnClickListener(this); btnRed = (Button) content.findViewById(R.id.ButtonRed); btnRed.setOnTouchListener(this); btnRed.setOnClickListener(this); btnGreen = (Button) content.findViewById(R.id.ButtonGreen); btnGreen.setOnTouchListener(this); btnGreen.setOnClickListener(this); btnYellow = (Button) content.findViewById(R.id.ButtonYellow); btnYellow.setOnTouchListener(this); btnYellow.setOnClickListener(this); btnBlue = (Button) content.findViewById(R.id.ButtonBlue); btnBlue.setOnTouchListener(this); btnBlue.setOnClickListener(this); // Number Buttons btnOne = (Button) content.findViewById(R.id.ButtonOne); btnOne.setOnTouchListener(this); btnOne.setOnClickListener(this); btnTwo = (Button) content.findViewById(R.id.ButtonTwo); btnTwo.setOnTouchListener(this); btnTwo.setOnClickListener(this); btnThree = (Button) content.findViewById(R.id.ButtonThree); btnThree.setOnTouchListener(this); btnThree.setOnClickListener(this); btnFour = (Button) content.findViewById(R.id.ButtonFour); btnFour.setOnTouchListener(this); btnFour.setOnClickListener(this); btnFive = (Button) content.findViewById(R.id.ButtonFive); btnFive.setOnTouchListener(this); btnFive.setOnClickListener(this); btnSix = (Button) content.findViewById(R.id.ButtonSix); btnSix.setOnTouchListener(this); btnSix.setOnClickListener(this); btnSeven = (Button) content.findViewById(R.id.ButtonSeven); btnSeven.setOnTouchListener(this); btnSeven.setOnClickListener(this); btnEight = (Button) content.findViewById(R.id.ButtonEight); btnEight.setOnTouchListener(this); btnEight.setOnClickListener(this); btnNine = (Button) content.findViewById(R.id.ButtonNine); btnNine.setOnTouchListener(this); btnNine.setOnClickListener(this); btnZero = (Button) content.findViewById(R.id.ButtonZero); btnZero.setOnTouchListener(this); btnZero.setOnClickListener(this); btnNumberBack = (Button) content.findViewById(R.id.ButtonStepBack_Numbers); btnNumberBack.setOnTouchListener(this); btnNumberBack.setOnClickListener(this); btnNumberForward = (Button) content.findViewById(R.id.ButtonStepForward_Numbers); btnNumberForward.setOnTouchListener(this); btnNumberForward.setOnClickListener(this); inFromLeft = AnimationUtils.loadAnimation(getActivity(), R.anim.in_from_left); outToLeft = AnimationUtils.loadAnimation(getActivity(), R.anim.out_to_left); inFromRight = AnimationUtils.loadAnimation(getActivity(), R.anim.in_from_right); outToRight = AnimationUtils.loadAnimation(getActivity(), R.anim.out_to_right); }
From source file:github.daneren2005.dsub.fragments.NowPlayingFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { rootView = inflater.inflate(R.layout.download, container, false); setTitle(R.string.button_bar_now_playing); WindowManager w = context.getWindowManager(); Display d = w.getDefaultDisplay();// w w w.j av a2s .c o m 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) rootView.findViewById(R.id.download_playlist_flipper); emptyTextView = (TextView) rootView.findViewById(R.id.download_empty); songTitleTextView = (TextView) rootView.findViewById(R.id.download_song_title); albumArtImageView = (ImageView) rootView.findViewById(R.id.download_album_art_image); positionTextView = (TextView) rootView.findViewById(R.id.download_position); durationTextView = (TextView) rootView.findViewById(R.id.download_duration); statusTextView = (TextView) rootView.findViewById(R.id.download_status); progressBar = (SeekBar) rootView.findViewById(R.id.download_progress_bar); previousButton = (AutoRepeatButton) rootView.findViewById(R.id.download_previous); nextButton = (AutoRepeatButton) rootView.findViewById(R.id.download_next); pauseButton = rootView.findViewById(R.id.download_pause); stopButton = rootView.findViewById(R.id.download_stop); startButton = rootView.findViewById(R.id.download_start); repeatButton = (ImageButton) rootView.findViewById(R.id.download_repeat); bookmarkButton = (ImageButton) rootView.findViewById(R.id.download_bookmark); rateBadButton = (ImageButton) rootView.findViewById(R.id.download_rating_bad); rateGoodButton = (ImageButton) rootView.findViewById(R.id.download_rating_good); toggleListButton = rootView.findViewById(R.id.download_toggle_list); playlistView = (RecyclerView) rootView.findViewById(R.id.download_list); FastScroller fastScroller = (FastScroller) rootView.findViewById(R.id.download_fast_scroller); fastScroller.attachRecyclerView(playlistView); setupLayoutManager(playlistView, false); ItemTouchHelper touchHelper = new ItemTouchHelper(new DownloadFileItemHelperCallback(this, true)); touchHelper.attachToRecyclerView(playlistView); starButton = (ImageButton) rootView.findViewById(R.id.download_star); if (Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true)) { starButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DownloadFile currentDownload = getDownloadService().getCurrentPlaying(); if (currentDownload != null) { final Entry currentSong = currentDownload.getSong(); toggleStarred(currentSong, new OnStarChange() { @Override void starChange(boolean starred) { if (currentSong.isStarred()) { starButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star)); } else { if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { starButton.setImageResource( DrawableTint.getDrawableRes(context, R.attr.star_outline)); } else { starButton.setImageResource(R.drawable.ic_toggle_star_outline_dark); } } } }); } } }); } else { starButton.setVisibility(View.GONE); } View.OnTouchListener touchListener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { return gestureScanner.onTouchEvent(me); } }; pauseButton.setOnTouchListener(touchListener); stopButton.setOnTouchListener(touchListener); startButton.setOnTouchListener(touchListener); bookmarkButton.setOnTouchListener(touchListener); rateBadButton.setOnTouchListener(touchListener); rateGoodButton.setOnTouchListener(touchListener); emptyTextView.setOnTouchListener(touchListener); albumArtImageView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { if (me.getAction() == MotionEvent.ACTION_DOWN) { lastY = (int) me.getRawY(); } return gestureScanner.onTouchEvent(me); } }); previousButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().previous(); return null; } }.execute(); setControlsVisible(true); } }); previousButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(-INCREMENT_TIME); } }); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Boolean>(context) { @Override protected Boolean doInBackground() throws Throwable { getDownloadService().next(); return true; } }.execute(); setControlsVisible(true); } }); nextButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(INCREMENT_TIME); } }); pauseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().pause(); return null; } }.execute(); } }); stopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().reset(); return null; } }.execute(); } }); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { start(); return null; } }.execute(); } }); repeatButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { RepeatMode repeatMode = getDownloadService().getRepeatMode().next(); getDownloadService().setRepeatMode(repeatMode); switch (repeatMode) { case OFF: Util.toast(context, R.string.download_repeat_off); break; case ALL: Util.toast(context, R.string.download_repeat_all); break; case SINGLE: Util.toast(context, R.string.download_repeat_single); break; default: break; } updateRepeatButton(); setControlsVisible(true); } }); bookmarkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { createBookmark(); } }); rateBadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } DownloadFile downloadFile = downloadService.getCurrentPlaying(); if (downloadFile == null) { return; } Entry entry = downloadFile.getSong(); // If rating == 1, already set so unset if (entry.getRating() == 1) { setRating(entry, 0); if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_dark); } else { rateBadButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_bad)); } } else { // Immediately skip to the next song downloadService.next(true); // Otherwise set rating to 1 setRating(entry, 1); rateBadButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_action_rating_bad_selected)); // Make sure good rating is blank if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_dark); } else { rateGoodButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_good)); } } } }); rateGoodButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } DownloadFile downloadFile = downloadService.getCurrentPlaying(); if (downloadFile == null) { return; } Entry entry = downloadFile.getSong(); // If rating == 5, already set so unset if (entry.getRating() == 5) { setRating(entry, 0); if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_dark); } else { rateGoodButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_good)); } } else { // Otherwise set rating to maximum setRating(entry, 5); rateGoodButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_action_rating_good_selected)); // Make sure bad rating is blank if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_dark); } else { rateBadButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_bad)); } } } }); toggleListButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleFullscreenAlbumArt(); setControlsVisible(true); } }); View overlay = rootView.findViewById(R.id.download_overlay_buttons); final int overlayHeight = overlay != null ? overlay.getHeight() : -1; albumArtImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (overlayHeight == -1 || lastY < (view.getBottom() - overlayHeight)) { toggleFullscreenAlbumArt(); setControlsVisible(true); } } }); progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(final SeekBar seekBar) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().seekTo(progressBar.getProgress()); return null; } @Override protected void done(Void result) { seekInProgress = false; } }.execute(); } @Override public void onStartTrackingTouch(final SeekBar seekBar) { seekInProgress = true; } @Override public void onProgressChanged(final SeekBar seekBar, final int position, final boolean fromUser) { if (fromUser) { positionTextView.setText(Util.formatDuration(position / 1000)); setControlsVisible(true); } } }); if (Build.MODEL.equals("Nexus 4") || Build.MODEL.equals("GT-I9100")) { View slider = rootView.findViewById(R.id.download_slider); slider.setPadding(0, 0, 0, 0); } return rootView; }
From source file:github.popeen.dsub.fragments.NowPlayingFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { rootView = inflater.inflate(R.layout.download, container, false); setTitle(R.string.button_bar_now_playing); WindowManager w = context.getWindowManager(); Display d = w.getDefaultDisplay();/*from ww w. jav a 2 s .co m*/ 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) rootView.findViewById(R.id.download_playlist_flipper); emptyTextView = (TextView) rootView.findViewById(R.id.download_empty); songTitleTextView = (TextView) rootView.findViewById(R.id.download_song_title); albumArtImageView = (ImageView) rootView.findViewById(R.id.download_album_art_image); positionTextView = (TextView) rootView.findViewById(R.id.download_position); durationTextView = (TextView) rootView.findViewById(R.id.download_duration); statusTextView = (TextView) rootView.findViewById(R.id.download_status); progressBar = (SeekBar) rootView.findViewById(R.id.download_progress_bar); previousButton = (AutoRepeatButton) rootView.findViewById(R.id.download_previous); nextButton = (AutoRepeatButton) rootView.findViewById(R.id.download_next); rewindButton = (AutoRepeatButton) rootView.findViewById(R.id.download_rewind); fastforwardButton = (AutoRepeatButton) rootView.findViewById(R.id.download_fastforward); pauseButton = rootView.findViewById(R.id.download_pause); stopButton = rootView.findViewById(R.id.download_stop); startButton = rootView.findViewById(R.id.download_start); repeatButton = (ImageButton) rootView.findViewById(R.id.download_repeat); bookmarkButton = (ImageButton) rootView.findViewById(R.id.download_bookmark); rateBadButton = (ImageButton) rootView.findViewById(R.id.download_rating_bad); rateGoodButton = (ImageButton) rootView.findViewById(R.id.download_rating_good); playbackSpeedButton = (ImageButton) rootView.findViewById(R.id.download_playback_speed); toggleListButton = rootView.findViewById(R.id.download_toggle_list); playlistView = (RecyclerView) rootView.findViewById(R.id.download_list); FastScroller fastScroller = (FastScroller) rootView.findViewById(R.id.download_fast_scroller); fastScroller.attachRecyclerView(playlistView); setupLayoutManager(playlistView, false); ItemTouchHelper touchHelper = new ItemTouchHelper(new DownloadFileItemHelperCallback(this, true)); touchHelper.attachToRecyclerView(playlistView); starButton = (ImageButton) rootView.findViewById(R.id.download_star); if (Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true)) { starButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getDownloadService().toggleStarred(); setControlsVisible(true); } }); } else { starButton.setVisibility(View.GONE); } View.OnTouchListener touchListener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { return gestureScanner.onTouchEvent(me); } }; pauseButton.setOnTouchListener(touchListener); stopButton.setOnTouchListener(touchListener); startButton.setOnTouchListener(touchListener); bookmarkButton.setOnTouchListener(touchListener); rateBadButton.setOnTouchListener(touchListener); rateGoodButton.setOnTouchListener(touchListener); playbackSpeedButton.setOnTouchListener(touchListener); emptyTextView.setOnTouchListener(touchListener); albumArtImageView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { if (me.getAction() == MotionEvent.ACTION_DOWN) { lastY = (int) me.getRawY(); } return gestureScanner.onTouchEvent(me); } }); previousButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().previous(); return null; } }.execute(); setControlsVisible(true); } }); previousButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(true); } }); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Boolean>(context) { @Override protected Boolean doInBackground() throws Throwable { getDownloadService().next(); return true; } }.execute(); setControlsVisible(true); } }); nextButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(false); } }); rewindButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { changeProgress(true); } }); rewindButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(true); } }); fastforwardButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { changeProgress(false); } }); fastforwardButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(false); } }); pauseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().pause(); return null; } }.execute(); } }); stopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().reset(); return null; } }.execute(); } }); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { start(); return null; } }.execute(); } }); repeatButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { RepeatMode repeatMode = getDownloadService().getRepeatMode().next(); getDownloadService().setRepeatMode(repeatMode); switch (repeatMode) { case OFF: Util.toast(context, R.string.download_repeat_off); break; case ALL: Util.toast(context, R.string.download_repeat_all); break; case SINGLE: Util.toast(context, R.string.download_repeat_single); break; default: break; } updateRepeatButton(); setControlsVisible(true); } }); bookmarkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { createBookmark(); setControlsVisible(true); } }); rateBadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } downloadService.toggleRating(1); setControlsVisible(true); } }); rateGoodButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } downloadService.toggleRating(5); setControlsVisible(true); } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setPlaybackSpeed(); } else { playbackSpeedButton.setVisibility(View.GONE); } toggleListButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleFullscreenAlbumArt(); setControlsVisible(true); } }); View overlay = rootView.findViewById(R.id.download_overlay_buttons); final int overlayHeight = overlay != null ? overlay.getHeight() : -1; albumArtImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (overlayHeight == -1 || lastY < (view.getBottom() - overlayHeight)) { toggleFullscreenAlbumArt(); setControlsVisible(true); } } }); progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(final SeekBar seekBar) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().seekTo(progressBar.getProgress()); return null; } @Override protected void done(Void result) { seekInProgress = false; } }.execute(); } @Override public void onStartTrackingTouch(final SeekBar seekBar) { seekInProgress = true; } @Override public void onProgressChanged(final SeekBar seekBar, final int position, final boolean fromUser) { if (fromUser) { positionTextView.setText(Util.formatDuration(position / 1000)); setControlsVisible(true); } DownloadService downloadService = getDownloadService(); TextView textTimer = (TextView) context.findViewById(R.id.textTimer); if (downloadService != null && downloadService.getSleepTimer()) { int timeRemaining = downloadService.getSleepTimeRemaining(); textTimer.setText(context.getResources().getString(R.string.download_stop_time_remaining, Util.formatDuration(timeRemaining))); if (timeRemaining > 0) { textTimer.setVisibility(View.VISIBLE); } else { textTimer.setVisibility(View.GONE); } } else { if (textTimer != null) { textTimer.setVisibility(View.GONE); } } } }); return rootView; }
From source file:dk.ciid.android.infobooth.activities.IntroductionActivity.java
@Override public void onCreate(Bundle savedInstanceState) { /* Variables received through Intent */ Intent openActivity = getIntent(); // this is just for example purpose isInDebugMode = openActivity.getBooleanExtra("isInDebugMode", true); // should the app send a welcome sms after subscribing? voice1 = openActivity.getStringExtra("voice1"); // path to voice file 1 voice2 = openActivity.getStringExtra("voice2"); // path to voice file 2 voice3 = openActivity.getStringExtra("voice3"); // path to voice file 3 voice4 = openActivity.getStringExtra("voice4"); // path to voice file 4 voice5 = openActivity.getStringExtra("voice5"); // path to voice file 5 voice6 = openActivity.getStringExtra("voice6"); // path to voice file 6 /* Variables received through Intent */ super.onCreate(savedInstanceState); /* ARDUINO COMMUNICATION STUFF ********************************************/ // a reference to the USB system service is obtained so that you can call its methods later on mUsbManager = UsbManager.getInstance(this); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, filter); if (getLastNonConfigurationInstance() != null) { mAccessory = (UsbAccessory) getLastNonConfigurationInstance(); openAccessory(mAccessory);//from www .j a va 2s.c o m } /* ARDUINO COMMUNICATION STUFF ********************************************/ gestureScanner = new GestureDetector(this); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_introduction); // Set up sound playback initMediaPlayer(); runOnUiThread(new Runnable() { public void run() { if (isInDebugMode) Toast.makeText(getApplicationContext(), "Debug mode is ON", Toast.LENGTH_SHORT).show(); } }); }
From source file:dk.ciid.android.infobooth.activities.SubscriptionFinalActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { /* Variables received through Intent */ Intent openActivity = getIntent(); // this is just for example purpose isInDebugMode = openActivity.getBooleanExtra("isInDebugMode", true); // should the app send a welcome sms after subscribing? phoneNum = openActivity.getStringExtra("phoneNum"); // get the phonenumber submitted in the last activity selectedService = openActivity.getIntExtra("selectedService", 1); // array position of selected service in last activity serviceIdItems = openActivity.getStringArrayListExtra("serviceIdItems"); // arraylist of service id's (in database) serviceNameItems = openActivity.getStringArrayListExtra("serviceNameItems"); // arraylist of service names serviceDescItems = openActivity.getStringArrayListExtra("serviceDescItems"); // arraylist of service descriptions voice1 = openActivity.getStringExtra("voice1"); // path to voice file 1 voice2 = openActivity.getStringExtra("voice2"); // path to voice file 2 voice3 = openActivity.getStringExtra("voice3"); // path to voice file 3 voice4 = openActivity.getStringExtra("voice4"); // path to voice file 4 voice5 = openActivity.getStringExtra("voice5"); // path to voice file 5 voice6 = openActivity.getStringExtra("voice6"); // path to voice file 6 /* Variables received through Intent */ // TODO Auto-generated method stub super.onCreate(savedInstanceState); /* ARDUINO COMMUNICATION STUFF ********************************************/ // a reference to the USB system service is obtained so that you can call its methods later on mUsbManager = UsbManager.getInstance(this); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, filter); if (getLastNonConfigurationInstance() != null) { mAccessory = (UsbAccessory) getLastNonConfigurationInstance(); openAccessory(mAccessory);//w ww. j a v a 2 s .c o m } /* ARDUINO COMMUNICATION STUFF ********************************************/ gestureScanner = new GestureDetector(this); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_subscription_final); if (!isInDebugMode) { try { //SmsManager smsManager = SmsManager.getDefault(); //smsManager.sendTextMessage(phoneNumber, null, SMSMessage, null, null); Toast.makeText(getApplicationContext(), "Thanks for subscribing!", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS failed, please try again later!", Toast.LENGTH_SHORT) .show(); e.printStackTrace(); } } else { Toast.makeText(getApplicationContext(), "Debug mode - no SMS sent to save money :)", Toast.LENGTH_SHORT) .show(); } // Set up sound playback initMediaPlayer(); }
From source file:es.farfuteam.vncpp.controller.CanvasActivity.java
/** * @brief The Android onCreate method/* ww w . j a v a 2 s . c o m*/ * @details The Android onCreate method. Initializes the CanvasView, SlidingMenu, VncBridgeJNI. * Also calls the method to start the connection */ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //No se muestra la barra de accion superior requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.canvas); canvas = (CanvasView) findViewById(R.id.vnc_canvas); Bundle info = getIntent().getExtras(); progressDialog = new ProgressDialog(this); final String load = getString(R.string.loadingtext); final String loadImage = getString(R.string.loadingbodytext); progressDialog.setTitle(load); progressDialog.setMessage(loadImage); final String cancel = getString(R.string.cancel); progressDialog.setButton(cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { vnc.finishVnc(); finishConnection(); } }); progressDialog.show(); progressDialog.setCancelable(false); menu = new SlidingMenu(this); startSlideMenu(); runTimerConnection(); String aux_quality = info.getString("color"); QualityArray quality = QualityArray.valueOf(aux_quality); iniConnection(info.getString("ip"), info.getString("port"), info.getString("psw"), quality, info.getBoolean("wifi")); inputMgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); GestureListener gestureListener = new GestureListener(); gesture = new GestureDetector(gestureListener); scaleGesture = new ScaleGestureDetector(this, gestureListener); endScrollRun = new Runnable() { @Override public void run() { while (drag || oneLoopMore) { oneLoopMore = false; try { Thread.sleep(TIMER_SCROLL); } catch (InterruptedException e) { // Auto-generated catch block } } canvas.endDrag(); } }; }
From source file:com.mobicage.rogerthat.plugins.messaging.FriendsThreadActivity.java
@Override protected void onServiceBound() { mMessagingPlugin = mService.getPlugin(MessagingPlugin.class); mFriendsPlugin = mService.getPlugin(FriendsPlugin.class); mMessageStore = mMessagingPlugin.getStore(); mMyEmail = mService.getIdentityStore().getIdentity().getEmail(); createCursor();// w ww .j av a 2s .c o m mMessageCount = getCursor().getCount(); startManagingCursor(getCursor()); setListAdapter(new MessageThreadAdapter(this, getCursor())); scrollToBeAckedPosition(getCursor()); String memberFilter = getIntent().getStringExtra(MessagingPlugin.MEMBER_FILTER); InputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); Slider instance = new Slider(this, this, new LeftSwiper(this, mMessagingPlugin, mParentMessageKey, memberFilter), new RightSwiper(this, mMessagingPlugin, mParentMessageKey, memberFilter)); instance.setOnDoubleTapListener(new Slider.OnDoubleTapListener() { @Override public boolean onDoubleTap(MotionEvent event) { if (mSendMessageView.getVisibility() == View.VISIBLE) { if (InputMethodManager != null) { mSendMessageView.showKeyboard(); } } return true; } }); mGestureScanner = new GestureDetector(instance); UIUtils.showHint(this, mService, HINT_SWIPE, R.string.hint_swipe); mSendMessageView = (SendMessageView) findViewById(R.id.chat_container); reloadMessage(); if (SystemUtils.isFlagEnabled(mFlags, MessagingPlugin.FLAG_ALLOW_REPLY)) { mSendMessageView.setActive(this, mService, null, null, mParentMessageKey, mFlags, mParentMessageKey, mParentMessage.default_priority, mParentMessage.default_sticky); } else { mSendMessageView.setVisibility(View.GONE); } setThreadBackground(); }
From source file:org.chromium.content_shell.Shell.java
/** * Initializes the ContentView based on the native tab contents pointer passed in. * @param nativeTabContents The pointer to the native tab contents object. */// w w w .ja v a 2 s . co m @SuppressWarnings("unused") @CalledByNative private void initFromNativeTabContents(int nativeTabContents) { gestureDetector = new GestureDetector(new GestureListener()); mContentView = ContentView.newInstance(getContext(), nativeTabContents, mWindow); mContentView.setOnTouchListener(this); if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.getUrl()); ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentView, new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mContentView.requestFocus(); mContentViewRenderView.setCurrentContentView(mContentView); }
From source file:com.justone.android.main.MainActivity.java
@SuppressWarnings("deprecation") @Override/* w w w .j ava 2s. com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); currentContext = this; //listviewview this.viewMap = new HashMap<String, ListViewAdapter>(); // this.asynImageLoader = JustOne.getAsynImageLoader(); this.dataOp = JustOne.getDataOp(); // this.res = getResources(); // Resource object to get Drawables // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites() .detectNetwork().penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects() .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build()); justOne = (JustOne) getApplication(); justOne.pushActivity(this); // view LayoutInflater inflater = LayoutInflater.from(this); //details_page_setitem = inflater.inflate(R.layout.one_details_page_setitem, null); main_item = inflater.inflate(R.layout.activity_main, null); bind_item = inflater.inflate(R.layout.one_details_page_binditem, null); about_one = inflater.inflate(R.layout.about_one, null); //microblog = inflater.inflate(R.layout.one_details_page_microblog, null); feedback = inflater.inflate(R.layout.feedback, null); setContentView(main_item); initData(); // view mListView = (ListView) findViewById(R.id.tab2); //ArrayList<ArrayList<String>> list_data = loadData("list",data); listAdapter = new ListViewAdapter(this, mList, mGist, R.id.scrollview, R.layout.list_item); mListView.setAdapter(listAdapter); /* mListView1 = (ListView) findViewById(R.id.tab1); //ArrayList<ArrayList<String>> collect_data = loadData("collect",data); collectAdapter = new ListViewAdapter(this,mList, mGist, R.id.collectScrollview, R.layout.collect_item); mListView1.setAdapter(collectAdapter); */ homeListView = (ListView) findViewById(R.id.homeTab); homeAdapter = new ListViewAdapter(this, mList, mGist, R.id.homeScrollView, R.layout.home_item); homeListView.setAdapter(homeAdapter); qaListView = (ListView) findViewById(R.id.QAtab); //ArrayList<ArrayList<String>> QA_data = loadData("QA",data); QAAdapter = new ListViewAdapter(this, mList, mGist, R.id.qaScrollView, R.layout.qa_item); qaListView.setAdapter(QAAdapter); //detailView = (ListView) findViewById(R.id.tab3); //ArrayList<ArrayList<String>> detail_data = loadData("detail",data); //detailAdapter = new ListViewAdapter(this, // mList, mGist, // R.id.detailScrollView, R.layout.detail_item); //detailView.setAdapter(detailAdapter); /*//loading list view loadingView = (ListView) findViewById(R.id.loading_view); //ArrayList<ArrayList<String>> detail_data = loadData("detail",data); loadingAdapter = new ListViewAdapter(this, mList, mGist, R.id.loadingScrollView, R.layout.one_welcome_ad); loadingView.setAdapter(loadingAdapter); */ tabs = (TabHost) findViewById(R.id.tabhost); tabWidget = (TabWidget) findViewById(android.R.id.tabs); int width = 100; int height = 100; tabs.setup(); tabs.addTab(tabs.newTabSpec("home tab").setIndicator("", this.res.getDrawable(R.drawable.home_tab_selector)) .setContent(R.id.homeTab)); tabs.addTab(tabs.newTabSpec("list tab").setIndicator("", this.res.getDrawable(R.drawable.one_tab_selector)) .setContent(R.id.tab2)); tabs.addTab(tabs.newTabSpec("QA Tab").setIndicator("", this.res.getDrawable(R.drawable.qa_tab_selector)) .setContent(R.id.QAtab)); /* tabs.addTab(tabs.newTabSpec("second tab").setIndicator("", null) .setContent(R.id.tab1));*/ //tabs.addTab(tabs.newTabSpec("second tab").setIndicator("",this.res.getDrawable(R.drawable.more_tab_selector)) // .setContent(R.id.tab3)); tabs.setCurrentTab(0); for (int i = 0; i < tabWidget.getChildCount(); i++) { /** * fill_parent */ tabWidget.getChildAt(i).getLayoutParams().height = height; tabWidget.getChildAt(i).getLayoutParams().width = width; /** * tab */ final TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title); tv.setTextColor(this.getResources().getColorStateList(android.R.color.white)); tv.setTextSize(15); tv.setGravity(Gravity.TOP); } mActivityName = getString(R.string.activity_c_label); mStatusTracker.setStatus(mActivityName, getString(R.string.on_create)); Utils.printStatus(mStatusView, mStatusAllView); detector = new GestureDetector(this); viewMap.put("home", this.homeAdapter); // View returnBackToIndex = main_item.findViewById(R.id.returnBackToIndex_layout); returnBackToIndex.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { MainActivity.this.finish(); // TODO Auto-generated method stub } }); userFirstTips(); }
From source file:org.thoughtcrime.securesms.MediaPreviewActivity.java
private void initializeObservers() { viewModel.getPreviewData().observe(this, previewData -> { if (previewData == null || mediaPager == null || mediaPager.getAdapter() == null) { return; }/*from ww w . ja v a 2 s . c o m*/ View playbackControls = ((MediaItemAdapter) mediaPager.getAdapter()) .getPlaybackControls(mediaPager.getCurrentItem()); if (previewData.getAlbumThumbnails().isEmpty() && previewData.getCaption() == null && playbackControls == null) { detailsContainer.setVisibility(View.GONE); } else { detailsContainer.setVisibility(View.VISIBLE); } albumRail.setVisibility(previewData.getAlbumThumbnails().isEmpty() ? View.GONE : View.VISIBLE); albumRailAdapter.setMedia(previewData.getAlbumThumbnails(), previewData.getActivePosition()); albumRail.smoothScrollToPosition(previewData.getActivePosition()); captionContainer.setVisibility(previewData.getCaption() == null ? View.GONE : View.VISIBLE); caption.setText(previewData.getCaption()); if (playbackControls != null) { ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); playbackControls.setLayoutParams(params); playbackControlsContainer.removeAllViews(); playbackControlsContainer.addView(playbackControls); } else { playbackControlsContainer.removeAllViews(); } }); clickDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { if (e.getY() < detailsContainer.getTop()) { detailsContainer.setVisibility( detailsContainer.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE); } return super.onSingleTapUp(e); } }); }