List of usage examples for android.widget SeekBar setOnSeekBarChangeListener
public void setOnSeekBarChangeListener(OnSeekBarChangeListener l)
From source file:mx.klozz.xperience.tweaker.fragments.VoltageControlSettings.java
private void showDialog(final int min, final int step, final int total) { final LayoutInflater factory = LayoutInflater.from(context); final View voltageDialog = factory.inflate(R.layout.voltage_dialog, null); final SeekBar voltageSeek = (SeekBar) voltageDialog.findViewById(R.id.voltageSeek); final TextView voltageMeter = (TextView) voltageDialog.findViewById(R.id.voltageMeter); final String savedMv = mVoltage.getSavedMV(); final int savedVolt = Integer.parseInt(savedMv); voltageMeter.setText(savedMv + um);//from ww w . jav a2 s. c o m voltageSeek.setMax(total); voltageSeek.setProgress(getNearestStepIndex(savedVolt, vmin, vstep, nvsteps)); voltageSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar sb, int progress, boolean fromUser) { if (fromUser) { final String volt = Integer.toString(progress * step + min); voltageMeter.setText(volt + um); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); new AlertDialog.Builder(context).setTitle(mVoltage.getFreq() + " kHz").setView(voltageDialog) .setPositiveButton(getResources().getString(R.string.ps_volt_save), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); final String value = Integer.toString(voltageSeek.getProgress() * step + min); SharedPreferences.Editor editor = mPreferences.edit(); editor.putString(mVoltage.getFreq(), value).commit(); mVoltage.setSavedMV(value); mAdapter.notifyDataSetChanged(); } }) .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).create().show(); }
From source file:org.dpadgett.timer.WorldClockFragment.java
private void newClockDialog(final int position) { final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(context.getString(R.string.world_clock_select_timezone)); final Map<String, String> timezoneNameToId = new HashMap<String, String>(); final Set<Integer> timezones = new TreeSet<Integer>(); final Map<Integer, List<String>> offsetToName = new HashMap<Integer, List<String>>(); final long currentTime = System.currentTimeMillis(); for (final String timezone : TimeZone.getAvailableIDs()) { final TimeZone tz = TimeZone.getTimeZone(timezone); final boolean isDaylight = tz.useDaylightTime(); final String timezoneName = tz.getDisplayName(isDaylight, TimeZone.LONG, Locale.getDefault()); if (timezoneNameToId.containsKey(timezoneName)) { continue; }/*from w w w .ja v a 2s. co m*/ final int millisOffset = tz.getOffset(currentTime); timezones.add(millisOffset); if (!offsetToName.containsKey(millisOffset)) { offsetToName.put(millisOffset, new ArrayList<String>()); } offsetToName.get(millisOffset).add(timezoneName); timezoneNameToId.put(timezoneName, timezone); } for (final List<String> names : offsetToName.values()) { Collections.sort(names); } if (position > -1) { builder.setPositiveButton(context.getString(R.string.world_clock_button_remove), new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { clockList.remove(position); clocksListAdapter.notifyDataSetChanged(); final SharedPreferences.Editor prefs = context .getSharedPreferences("WorldClocks", Context.MODE_PRIVATE).edit(); prefs.putInt("numClocks", clockList.size()); int idx; for (idx = position; idx < clockList.size(); idx++) { prefs.putString("clock" + idx, clockList.get(idx)); } prefs.remove("clock" + idx); prefs.commit(); } }); } final LinearLayout tzView = (LinearLayout) LayoutInflater.from(context) .inflate(R.layout.timezone_picker_dialog, (ViewGroup) finder.findViewById(R.id.layout_root)); final List<String> initialItems = new ArrayList<String>(); initialItems.add(context.getString(R.string.world_clock_timezone_gmt)); initialItems.add(context.getString(R.string.world_clock_timezone_utc)); final ArrayAdapter<String> adapter = ArrayAdapter.newArrayAdapter(context, R.layout.timezone_dialog_list_item, initialItems); final ListView timezoneList = (ListView) tzView.findViewById(R.id.timezoneList); timezoneList.setAdapter(adapter); final TextView sliderView = (TextView) tzView.findViewById(R.id.timezoneLabel); final SeekBar timezoneSeeker = (SeekBar) tzView.findViewById(R.id.timezoneSeeker); final List<Integer> timezonesList = new ArrayList<Integer>(timezones); timezoneSeeker.setMax(timezonesList.size() - 1); if (position > -1) { final int offset = TimeZone.getTimeZone(clockList.get(position)).getOffset(currentTime); timezoneSeeker.setProgress(timezonesList.indexOf(offset)); } else { timezoneSeeker.setProgress(timezonesList.indexOf(0)); } timezoneSeeker.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { // initialize the timezoneSeeker { onProgressChanged(timezoneSeeker, timezoneSeeker.getProgress(), false); } @Override public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) { adapter.clear(); adapter.addAll(offsetToName.get(timezonesList.get(progress))); final int millisOffset = timezonesList.get(progress); String offset = String.format("%02d:%02d", Math.abs(millisOffset / 1000 / 60 / 60), Math.abs(millisOffset / 1000 / 60) % 60); if (millisOffset / 1000 / 60 / 60 < 0) { offset = "-" + offset; } else { offset = "+" + offset; } sliderView.setText(context.getString(R.string.world_clock_timezone_label) + offset); } @Override public void onStartTrackingTouch(final SeekBar seekBar) { } @Override public void onStopTrackingTouch(final SeekBar seekBar) { } }); builder.setView(tzView); final AlertDialog alert = builder.create(); timezoneList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int selectedPosition, final long id) { final String timezoneName = adapter.getItem(selectedPosition); final String timezone = timezoneNameToId.get(timezoneName); addNewClock(timezone, position); alert.dismiss(); } }); alert.show(); }
From source file:com.esri.arcgisruntime.generateofflinemapoverrides.MainActivity.java
/** * Creates parameters dialog and handles processing of input to generateOfflineMap(...) when Start Job button is clicked. *//* w w w . j a v a 2 s.c o m*/ private void showParametersDialog() { View overrideParametersView = getLayoutInflater().inflate(R.layout.override_parameters_dialog, null); // min and max seek bars TextView currMinScaleTextView = overrideParametersView.findViewById(R.id.currMinScaleTextView); TextView currMaxScaleTextView = overrideParametersView.findViewById(R.id.currMaxScaleTextview); SeekBar minScaleSeekBar = buildSeekBar(overrideParametersView.findViewById(R.id.minScaleSeekBar), currMinScaleTextView, 22, 15); SeekBar maxScaleSeekBar = buildSeekBar(overrideParametersView.findViewById(R.id.maxScaleSeekBar), currMaxScaleTextView, 23, 20); minScaleSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { currMinScaleTextView.setText(String.valueOf(progress)); if (progress >= maxScaleSeekBar.getProgress()) { // set max to 1 more than min value (since max must always be greater than min) currMaxScaleTextView.setText(String.valueOf(progress + 1)); maxScaleSeekBar.setProgress(progress + 1); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); maxScaleSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { currMaxScaleTextView.setText(String.valueOf(progress)); if (progress <= minScaleSeekBar.getProgress()) { // set min to 1 less than max value (since min must always be less than max) currMinScaleTextView.setText(String.valueOf(progress - 1)); minScaleSeekBar.setProgress(progress - 1); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // extent buffer seek bar SeekBar extentBufferDistanceSeekBar = buildSeekBar( overrideParametersView.findViewById(R.id.extentBufferDistanceSeekBar), overrideParametersView.findViewById(R.id.currExtentBufferDistanceTextView), 500, 300); // include layers checkboxes CheckBox systemValves = overrideParametersView.findViewById(R.id.systemValvesCheckBox); CheckBox serviceConnections = overrideParametersView.findViewById(R.id.serviceConnectionsCheckBox); // min hydrant flow rate seek bar SeekBar minHydrantFlowRateSeekBar = buildSeekBar( overrideParametersView.findViewById(R.id.minHydrantFlowRateSeekBar), overrideParametersView.findViewById(R.id.currMinHydrantFlowRateTextView), 2000, 500); // crop layer to extent checkbox CheckBox waterPipes = overrideParametersView.findViewById(R.id.waterPipesCheckBox); // setup dialog AlertDialog.Builder overrideParametersDialogBuilder = new AlertDialog.Builder(this); AlertDialog overrideParametersDialog = overrideParametersDialogBuilder.create(); overrideParametersDialogBuilder.setView(overrideParametersView).setTitle("Override Parameters") .setCancelable(true) .setNegativeButton("Cancel", (dialog, which) -> overrideParametersDialog.dismiss()) .setPositiveButton("Start Job", (dialog, which) -> { // re-create download area geometry in case user hasn't changed the Viewpoint mDownloadArea.setGeometry(createDownloadAreaGeometry()); defineParameters(minScaleSeekBar.getProgress(), maxScaleSeekBar.getProgress(), extentBufferDistanceSeekBar.getProgress(), systemValves.isChecked(), serviceConnections.isChecked(), minHydrantFlowRateSeekBar.getProgress(), waterPipes.isChecked()); }).show(); }
From source file:org.opencv.samples.facedetect.PlayerViewDemoActivity.java
public void onResume() { super.onResume(); if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) { Toast.makeText(this, "No camera on this device", Toast.LENGTH_LONG).show(); } else {/*from www. ja va2s . co m*/ cameraId = findFrontFacingCamera(); if (cameraId < 0) { Toast.makeText(this, "No front facing camera found.", Toast.LENGTH_LONG).show(); } else { camera = Camera.open(cameraId); } } camera.startPreview(); YouTubePlayerView youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view); youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, this); playListButton = (Button) findViewById(R.id.button1); SeekBar seekBar1 = (SeekBar) findViewById(R.id.seekBar1); seekBar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // seekBarValue.setText(String.valueOf(progress)); progress1 = progress; ImageView gauge = (ImageView) findViewById(R.id.gaugeImage); if (progress <= 6) gauge.setImageDrawable(gauges[0]); else if (progress > 6 && progress <= 13) gauge.setImageDrawable(gauges[1]); else if (progress > 13 && progress <= 19) gauge.setImageDrawable(gauges[2]); else if (progress > 19 && progress <= 25) gauge.setImageDrawable(gauges[3]); else if (progress > 25 && progress <= 31) gauge.setImageDrawable(gauges[4]); else if (progress > 31 && progress <= 37) gauge.setImageDrawable(gauges[5]); else if (progress > 37 && progress <= 43) gauge.setImageDrawable(gauges[6]); else if (progress > 43 && progress <= 49) gauge.setImageDrawable(gauges[7]); else if (progress < 49 && progress <= 55) gauge.setImageDrawable(gauges[8]); else if (progress > 55 && progress <= 61) gauge.setImageDrawable(gauges[9]); else if (progress > 61 && progress <= 67) gauge.setImageDrawable(gauges[10]); else if (progress > 67 && progress <= 73) gauge.setImageDrawable(gauges[11]); else if (progress > 73 && progress <= 79) gauge.setImageDrawable(gauges[12]); else if (progress > 79 && progress <= 85) gauge.setImageDrawable(gauges[13]); else if (progress > 85 && progress <= 91) gauge.setImageDrawable(gauges[14]); else if (progress > 91) gauge.setImageDrawable(gauges[15]); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { setIdArray(); } }); CheckBox checkFd = (CheckBox) findViewById(R.id.checkBox1); checkFd.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) faceDetection = true; else { tvTop.setText("Let`s play your mood!"); faceDetection = false; } } }); happyImage = (ImageView) findViewById(R.id.hapyFace); happyImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (faceDetection == false) { sadImage.setImageDrawable(getResources().getDrawable(R.drawable.sad_bw)); happyImage.setImageDrawable(getResources().getDrawable(R.drawable.happy)); happyImage.bringToFront(); currentMood = new String("happy"); setIdArray(); } } }); sadImage = (ImageView) findViewById(R.id.sadFace); sadImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (faceDetection == false) { sadImage.setImageDrawable(getResources().getDrawable(R.drawable.sad)); happyImage.setImageDrawable(getResources().getDrawable(R.drawable.happy_bw)); sadImage.bringToFront(); currentMood = new String("sad"); setIdArray(); } } }); timerAlert(); mFacebookBtn = (CheckBox) findViewById(R.id.cb_facebook); mProgress = new ProgressDialog(this); mFacebook = new Facebook(APP_ID); SessionStore.restore(mFacebook, this); if (mFacebook.isSessionValid()) { mFacebookBtn.setChecked(true); String name = SessionStore.getName(this); name = (name.equals("")) ? "Unknown" : name; mFacebookBtn.setText(" Facebook (" + name + ")"); mFacebookBtn.setTextColor(Color.WHITE); } mFacebookBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onFacebookClick(); } }); }
From source file:com.smithdtyler.prettygoodmusicplayer.NowPlaying.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent originIntent = getIntent();// ww w .ja v a 2s . c om if (originIntent.getBooleanExtra("From_Notification", false)) { String artistName = originIntent.getStringExtra(ArtistList.ARTIST_NAME); String artistAbsPath = originIntent.getStringExtra(ArtistList.ARTIST_ABS_PATH_NAME); if (artistName != null && artistAbsPath != null) { Log.i(TAG, "Now Playing was launched from a notification, setting up its back stack"); // Reference: https://developer.android.com/reference/android/app/TaskStackBuilder.html TaskStackBuilder tsb = TaskStackBuilder.create(this); Intent intent = new Intent(this, ArtistList.class); tsb.addNextIntent(intent); intent = new Intent(this, AlbumList.class); intent.putExtra(ArtistList.ARTIST_NAME, artistName); intent.putExtra(ArtistList.ARTIST_ABS_PATH_NAME, artistAbsPath); tsb.addNextIntent(intent); String albumName = originIntent.getStringExtra(AlbumList.ALBUM_NAME); if (albumName != null) { intent = new Intent(this, SongList.class); intent.putExtra(AlbumList.ALBUM_NAME, albumName); intent.putExtra(ArtistList.ARTIST_NAME, artistName); intent.putExtra(ArtistList.ARTIST_ABS_PATH_NAME, artistAbsPath); tsb.addNextIntent(intent); } intent = new Intent(this, NowPlaying.class); tsb.addNextIntent(intent); tsb.startActivities(); } } SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); String theme = sharedPref.getString("pref_theme", getString(R.string.light)); String size = sharedPref.getString("pref_text_size", getString(R.string.medium)); Log.i(TAG, "got configured theme " + theme); Log.i(TAG, "got configured size " + size); // These settings were fixed in english for a while, so check for old style settings as well as language specific ones. if (theme.equalsIgnoreCase(getString(R.string.dark)) || theme.equalsIgnoreCase("dark")) { Log.i(TAG, "setting theme to " + theme); if (size.equalsIgnoreCase(getString(R.string.small)) || size.equalsIgnoreCase("small")) { setTheme(R.style.PGMPDarkSmall); } else if (size.equalsIgnoreCase(getString(R.string.medium)) || size.equalsIgnoreCase("medium")) { setTheme(R.style.PGMPDarkMedium); } else { setTheme(R.style.PGMPDarkLarge); } } else if (theme.equalsIgnoreCase(getString(R.string.light)) || theme.equalsIgnoreCase("light")) { Log.i(TAG, "setting theme to " + theme); if (size.equalsIgnoreCase(getString(R.string.small)) || size.equalsIgnoreCase("small")) { setTheme(R.style.PGMPLightSmall); } else if (size.equalsIgnoreCase(getString(R.string.medium)) || size.equalsIgnoreCase("medium")) { setTheme(R.style.PGMPLightMedium); } else { setTheme(R.style.PGMPLightLarge); } } boolean fullScreen = sharedPref.getBoolean("pref_full_screen_now_playing", false); currentFullScreen = fullScreen; if (fullScreen) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); } setContentView(R.layout.activity_now_playing); if (savedInstanceState == null) { doBindService(true); startPlayingRequired = true; } else { doBindService(false); startPlayingRequired = false; } // Get the message from the intent Intent intent = getIntent(); if (intent.getBooleanExtra(KICKOFF_SONG, false)) { desiredArtistName = intent.getStringExtra(ArtistList.ARTIST_NAME); desiredAlbumName = intent.getStringExtra(AlbumList.ALBUM_NAME); desiredArtistAbsPath = intent.getStringExtra(ArtistList.ARTIST_ABS_PATH_NAME); desiredSongAbsFileNames = intent.getStringArrayExtra(SongList.SONG_ABS_FILE_NAME_LIST); desiredAbsSongFileNamesPosition = intent.getIntExtra(SongList.SONG_ABS_FILE_NAME_LIST_POSITION, 0); desiredSongProgress = intent.getIntExtra(MusicPlaybackService.TRACK_POSITION, 0); Log.d(TAG, "Got song names " + desiredSongAbsFileNames + " position " + desiredAbsSongFileNamesPosition); TextView et = (TextView) findViewById(R.id.artistName); et.setText(desiredArtistName); et = (TextView) findViewById(R.id.albumName); et.setText(desiredAlbumName); } // The song name field will be set when we get our first update update from the service. final ImageButton pause = (ImageButton) findViewById(R.id.playPause); pause.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { playPause(); } }); ImageButton previous = (ImageButton) findViewById(R.id.previous); previous.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { previous(); } }); previous.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { jumpBack(); return true; } }); ImageButton next = (ImageButton) findViewById(R.id.next); next.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { next(); } }); final ImageButton shuffle = (ImageButton) findViewById(R.id.shuffle); shuffle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { toggleShuffle(); } }); final ImageButton jumpback = (ImageButton) findViewById(R.id.jumpback); jumpback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { jumpBack(); } }); SeekBar seekBar = (SeekBar) findViewById(R.id.songProgressBar); seekBar.setEnabled(true); seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { private int requestedProgress; @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { Log.v(TAG, "drag location updated..." + progress); this.requestedProgress = progress; updateSongProgressLabel(progress); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { NowPlaying.this.userDraggingProgress = true; } @Override public void onStopTrackingTouch(SeekBar seekBar) { Message msg = Message.obtain(null, MusicPlaybackService.MSG_SEEK_TO); msg.getData().putInt(MusicPlaybackService.TRACK_POSITION, requestedProgress); try { Log.i(TAG, "Sending a request to seek!"); mService.send(msg); } catch (RemoteException e) { e.printStackTrace(); } NowPlaying.this.userDraggingProgress = false; } }); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.smithdtyler.ACTION_EXIT"); exitReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.i(TAG, "Received exit request, shutting down..."); Intent msgIntent = new Intent(getBaseContext(), MusicPlaybackService.class); msgIntent.putExtra("Message", MusicPlaybackService.MSG_STOP_SERVICE); startService(msgIntent); finish(); } }; registerReceiver(exitReceiver, intentFilter); }
From source file:edu.berkeley.boinc.PrefsActivity.java
public void onItemClick(View view) { final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); Object item = view.getTag();//from www. j a v a2 s. c om if (item instanceof PrefsListItemWrapperValue) { final PrefsListItemWrapperValue valueWrapper = (PrefsListItemWrapperValue) item; if (Logging.DEBUG) Log.d(Logging.TAG, "PrefsActivity onItemClick Value " + valueWrapper.ID); if (valueWrapper.isPct) { // show dialog with slider dialog.setContentView(R.layout.prefs_layout_dialog_pct); // setup slider TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status); sliderProgress.setText(valueWrapper.status.intValue() + " " + getString(R.string.prefs_unit_pct)); Double seekBarDefault = valueWrapper.status / 10; SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar); slider.setProgress(seekBarDefault.intValue()); slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { String progressString = (progress * 10) + " " + getString(R.string.prefs_unit_pct); TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status); sliderProgress.setText(progressString); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); } else if (valueWrapper.isNumber) { if (!getHostInfo()) { if (Logging.WARNING) Log.w(Logging.TAG, "onItemClick missing hostInfo"); return; } // show dialog with slider dialog.setContentView(R.layout.prefs_layout_dialog_pct); TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status); sliderProgress.setText("" + valueWrapper.status.intValue()); SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar); // slider setup depending on actual preference if (valueWrapper.ID == R.string.prefs_cpu_number_cpus_header) { slider.setMax(hostinfo.p_ncpus); slider.setProgress(valueWrapper.status.intValue()); slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (progress == 0) progress = 1; // do not allow 0 cpus String progressString = String.valueOf(progress); TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status); sliderProgress.setText(progressString); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); } else if (valueWrapper.ID == R.string.prefs_gui_log_level_header) { slider.setMax(5); slider.setProgress(valueWrapper.status.intValue()); slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { String progressString = String.valueOf(progress); TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status); sliderProgress.setText(progressString); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); } } else { // show dialog with edit text dialog.setContentView(R.layout.prefs_layout_dialog); } // show preference name ((TextView) dialog.findViewById(R.id.pref)).setText(valueWrapper.ID); // setup buttons Button confirm = (Button) dialog.findViewById(R.id.confirm); confirm.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { double value = 0.0; Boolean clientPref = true; if (valueWrapper.isPct) { SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar); value = slider.getProgress() * 10; } else if (valueWrapper.isNumber) { SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar); int sbProgress = slider.getProgress(); if (valueWrapper.ID == R.string.prefs_cpu_number_cpus_header) { if (sbProgress == 0) sbProgress = 1; value = numberCpuCoresToPct(sbProgress); } else if (valueWrapper.ID == R.string.prefs_gui_log_level_header) { appPrefs.setLogLevel(sbProgress); updateValuePref(valueWrapper.ID, (double) sbProgress); clientPref = false; // avoid writing client prefs via rpc updateLayout(); } } else { EditText edit = (EditText) dialog.findViewById(R.id.Input); String input = edit.getText().toString(); Double valueTmp = parseInputValueToDouble(input); if (valueTmp == null) return; value = valueTmp; } if (clientPref) writeClientValuePreference(valueWrapper.ID, value); dialog.dismiss(); } }); Button cancel = (Button) dialog.findViewById(R.id.cancel); cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } else { // instance of PrefsListItemWrapper, i.e. client log flags PrefsListItemWrapper wrapper = (PrefsListItemWrapper) item; if (Logging.DEBUG) Log.d(Logging.TAG, "PrefsActivity onItemClick super " + wrapper.ID); dialog.setContentView(R.layout.prefs_layout_dialog_selection); final ArrayList<ClientLogOption> options = new ArrayList<ClientLogOption>(); String[] array = getResources().getStringArray(R.array.prefs_client_log_flags); for (String option : array) options.add(new ClientLogOption(option)); ListView lv = (ListView) dialog.findViewById(R.id.selection); new PrefsLogOptionsListAdapter(this, lv, R.id.selection, options); // setup buttons Button confirm = (Button) dialog.findViewById(R.id.confirm); confirm.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ArrayList<String> selectedOptions = new ArrayList<String>(); for (ClientLogOption option : options) if (option.selected) selectedOptions.add(option.name); if (Logging.DEBUG) Log.d(Logging.TAG, selectedOptions.size() + " log flags selected"); new SetCcConfigAsync().execute(formatOptionsToCcConfig(selectedOptions)); dialog.dismiss(); } }); Button cancel = (Button) dialog.findViewById(R.id.cancel); cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }
From source file:net.xpece.android.support.preference.SeekBarPreference.java
@Override public void onBindViewHolder(final PreferenceViewHolder holder) { super.onBindViewHolder(holder); final SeekBar seekBar = (SeekBar) holder.findViewById(R.id.seekbar); holder.itemView.setOnKeyListener(buildSeekBarKeyListener(seekBar)); final TextView info = (TextView) holder.findViewById(R.id.seekbar_value); if (info != null) { mInfoViews.put(info, this); bindInfo(info);//from www. j a v a2s .c o m } if (seekBar == null) { Log.e(TAG, "SeekBar view is null in onBindViewHolder."); return; } seekBar.setOnSeekBarChangeListener(mSeekBarChangeListener); seekBar.setMax(mMax - mMin); // If the increment is not zero, use that. Otherwise, use the default mKeyProgressIncrement // in AbsSeekBar when it's zero. This default increment value is set by AbsSeekBar // after calling setMax. That's why it's important to call setKeyProgressIncrement after // calling setMax() since setMax() can change the increment value. if (mSeekBarIncrement != 0) { seekBar.setKeyProgressIncrement(mSeekBarIncrement); } else { mSeekBarIncrement = seekBar.getKeyProgressIncrement(); } seekBar.setProgress(mSeekBarValue - mMin); seekBar.setEnabled(isEnabled()); fixDrawableStateOnAndroid2(seekBar); }
From source file:it.scoppelletti.mobilepower.preference.SeekBarPreference.java
/** * Collega la preferenza al dialogo. //from ww w.j a va2 s. c o m * * @param view Dialogo. */ @Override protected void onBindDialogView(View view) { SeekBar control; if (myValue > myValueMax) { myValue = myValueMax; } myEditingPreview = (TextView) view.findViewById(R.id.txt_value); if (!StringUtils.isBlank(myPreview)) { myEditingPreview.setText("", TextView.BufferType.SPANNABLE); myEditingPreview.setSpannableFactory(new SeekBarPreference.PreviewSpannableFactory(this)); } setEditingValue(myValue); control = (SeekBar) view.findViewById(R.id.bar_value); control.setMax(myValueMax - myValueMin); control.setProgress(myValue - myValueMin); control.setOnSeekBarChangeListener(new SeekBarPreference.OnValueChangeListener(this)); }
From source file:wseemann.media.fmpdemo.activity.MediaPlayerActivity.java
/** Called when the activity is first created. */ @Override/*from w w w .j ava 2s .c o m*/ public void onCreate(Bundle icicle) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); super.onCreate(icicle); setContentView(R.layout.activity_media_player); setVolumeControlStream(AudioManager.STREAM_MUSIC); mCurrentTime = (TextView) findViewById(R.id.position_text); mTotalTime = (TextView) findViewById(R.id.duration_text); mProgress = (ProgressBar) findViewById(R.id.seek_bar); mPrevButton = (ImageButton) findViewById(R.id.previous_button); mPrevButton.setOnClickListener(mPrevListener); mPauseButton = (ImageButton) findViewById(R.id.play_pause_button); mPauseButton.setOnClickListener(mPauseListener); mNextButton = (ImageButton) findViewById(R.id.next_button); mNextButton.setOnClickListener(mNextListener); seekmethod = 1; mDeviceHasDpad = (getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD); mShuffleButton = (ImageButton) findViewById(R.id.shuffle_button); mShuffleButton.setOnClickListener(mShuffleListener); mRepeatButton = (ImageButton) findViewById(R.id.repeat_button); mRepeatButton.setOnClickListener(mRepeatListener); if (mProgress instanceof SeekBar) { SeekBar seeker = (SeekBar) mProgress; seeker.setOnSeekBarChangeListener(mSeekListener); } mProgress.setMax(1000); mPager = (ViewPager) findViewById(R.id.pager); }
From source file:com.irccloud.android.activity.VideoPlayerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(R.style.ImageViewerTheme);// w ww . j a va2s. c o m if (savedInstanceState == null) overridePendingTransition(R.anim.slide_in_right, R.anim.fade_out); setContentView(R.layout.activity_video_player); toolbar = findViewById(R.id.toolbar); try { setSupportActionBar(toolbar); } catch (Throwable t) { } if (Build.VERSION.SDK_INT < 21) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); } else if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.splash_logo); if (cloud != null) { setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, getResources().getColor(android.R.color.black))); } getWindow().setStatusBarColor(getResources().getColor(android.R.color.black)); getWindow().setNavigationBarColor(getResources().getColor(android.R.color.black)); if (Build.VERSION.SDK_INT >= 23) { getWindow().getDecorView().setSystemUiVisibility( getWindow().getDecorView().getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } } getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (Build.VERSION.SDK_INT > 16) { getWindow().getDecorView() .setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onSystemUiVisibilityChange(int visibility) { if ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) { toolbar.setAlpha(0); toolbar.animate().alpha(1); controls.setAlpha(0); controls.animate().alpha(1); hide_actionbar(); } else { toolbar.setAlpha(1); toolbar.animate().alpha(0); controls.setAlpha(1); controls.animate().alpha(0); } } }); } controls = findViewById(R.id.controls); mProgress = findViewById(R.id.progress); rew = findViewById(R.id.rew); rew.setEnabled(false); rew.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { handler.removeCallbacks(mHideRunnable); handler.post(rewindRunnable); } if (motionEvent.getAction() == MotionEvent.ACTION_UP) { handler.removeCallbacks(rewindRunnable); hide_actionbar(); } return false; } }); play = findViewById(R.id.play); play.setEnabled(false); play.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { video.start(); handler.post(mUpdateRunnable); hide_actionbar(); } }); pause = findViewById(R.id.pause); pause.setEnabled(false); pause.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { video.pause(); handler.post(mUpdateRunnable); handler.removeCallbacks(mHideRunnable); } }); ffwd = findViewById(R.id.ffwd); ffwd.setEnabled(false); ffwd.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { handler.removeCallbacks(mHideRunnable); handler.post(ffwdRunnable); } if (motionEvent.getAction() == MotionEvent.ACTION_UP) { handler.removeCallbacks(ffwdRunnable); hide_actionbar(); } return false; } }); time_current = findViewById(R.id.time_current); time = findViewById(R.id.time); seekBar = findViewById(R.id.mediacontroller_progress); seekBar.setEnabled(false); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { video.seekTo(progress); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { if (video.isPlaying()) video.pause(); handler.removeCallbacks(mHideRunnable); } @Override public void onStopTrackingTouch(SeekBar seekBar) { hide_actionbar(); } }); video = findViewById(R.id.video); video.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (Build.VERSION.SDK_INT > 16) { if ((getWindow().getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); } else { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); hide_actionbar(); } } else { if (toolbar.getVisibility() == View.VISIBLE) { toolbar.setVisibility(View.GONE); controls.setVisibility(View.GONE); } else { toolbar.setVisibility(View.VISIBLE); controls.setVisibility(View.VISIBLE); hide_actionbar(); } } return false; } }); video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mediaPlayer) { mediaPlayer.start(); mProgress.setVisibility(View.GONE); rew.setEnabled(true); pause.setEnabled(true); play.setEnabled(true); ffwd.setEnabled(true); seekBar.setEnabled(true); handler.post(mUpdateRunnable); hide_actionbar(); } }); video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mediaPlayer) { video.pause(); video.seekTo(video.getDuration()); handler.removeCallbacks(mHideRunnable); if (Build.VERSION.SDK_INT > 16) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); } else { toolbar.setVisibility(View.VISIBLE); controls.setVisibility(View.VISIBLE); } } }); video.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mediaPlayer, int i, int i1) { AlertDialog d = new AlertDialog.Builder(VideoPlayerActivity.this).setTitle("Playback Failed") .setMessage("An error occured while trying to play this video") .setPositiveButton("Download", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (Build.VERSION.SDK_INT >= 16 && ActivityCompat.checkSelfPermission( VideoPlayerActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(VideoPlayerActivity.this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0); } else { DownloadManager d = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); if (d != null) { DownloadManager.Request r = new DownloadManager.Request( Uri.parse(getIntent().getDataString().replace( getResources().getString(R.string.VIDEO_SCHEME), "http"))); r.setNotificationVisibility( DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); r.allowScanningByMediaScanner(); d.enqueue(r); } } } }).setNegativeButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { finish(); } }).create(); d.show(); return true; } }); if (getIntent() != null && getIntent().getDataString() != null) { Uri url = Uri.parse( getIntent().getDataString().replace(getResources().getString(R.string.VIDEO_SCHEME), "http")); if (url.getHost().endsWith("facebook.com")) { new FacebookTask().execute(url); } else { video.setVideoURI(url); } Answers.getInstance().logContentView(new ContentViewEvent().putContentType("Video")); } else { finish(); } }