Example usage for android.widget SeekBar setOnSeekBarChangeListener

List of usage examples for android.widget SeekBar setOnSeekBarChangeListener

Introduction

In this page you can find the example usage for android.widget SeekBar setOnSeekBarChangeListener.

Prototype

public void setOnSeekBarChangeListener(OnSeekBarChangeListener l) 

Source Link

Document

Sets a listener to receive notifications of changes to the SeekBar's progress level.

Usage

From source file:de.uni_weimar.m18.anatomiederstadt.element.SliderFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_slider, container, false);
    SeekBar sb = (SeekBar) view.findViewById(R.id.seekBar);
    // scale mMin and mMax
    mMin = (int) (mMin / mGranularity);
    mMax = (int) (mMax / mGranularity);
    sb.setMax(mMax - mMin);/*from w w  w. j a  va2s .c o m*/
    sb.setProgress((mMax - mMin) / 2);
    final RelativeLayout balloon = (RelativeLayout) view.findViewById(R.id.indicatorBalloon);
    final Space space = (Space) view.findViewById(R.id.balloonSpace);

    final Context context = getActivity();
    final TextView balloonText = (TextView) view.findViewById(R.id.indicatorTextView);
    final float[] value = { 0.0f };
    sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            p.addRule(RelativeLayout.ABOVE, seekBar.getId());
            Rect thumbRect = seekBar.getThumb().getBounds();
            value[0] = mMin + progress * mGranularity;
            String valueString = new DecimalFormat("#.##").format(value[0]);
            balloonText.setText(String.valueOf(valueString) + " " + mSuffix);
            int balloonWidth = balloonText.getWidth();
            p.setMargins(thumbRect.centerX() - balloonWidth / 2, 0, 0, 0);
            balloon.setLayoutParams(p);
            balloon.setVisibility(View.VISIBLE);

            final Animation animFadeOut = AnimationUtils.loadAnimation(context, R.anim.fade_out);
            balloon.startAnimation(animFadeOut);
            animFadeOut.setStartOffset(1000);
            animFadeOut.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    balloon.setVisibility(View.INVISIBLE);
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            LevelStateManager stateManager = ((AnatomieDerStadtApplication) getActivity()
                    .getApplicationContext()).getStateManager(getActivity());
            stateManager.saveFloat(mVar, value[0]);
        }
    });
    return view;
}

From source file:org.dharmaseed.android.PlayTalkActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_play_talk);

    // Turn on action bar up/home button
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }/*from   w  w w  .  j  a  v a2s.  co  m*/

    // Get the ID of the talk to display
    Intent i = getIntent();
    talkID = (int) i.getLongExtra(NavigationActivity.TALK_DETAIL_EXTRA, 0);

    dbManager = DBManager.getInstance(this);

    // only hit the DB again if we know the talk is different than the one
    // we have saved.
    // for example, if the user selects a talk, exits, and re-opens it, no need
    // to hit the DB again, since we already have that talk saved
    if (talk == null || talk.getId() != talkID) {
        Cursor cursor = getCursor();
        if (cursor.moveToFirst()) {
            // convert DB result to an object
            talk = new Talk(cursor);
            talk.setId(talkID);
        } else {
            Log.e(LOG_TAG, "Could not look up talk, id=" + talkID);
            cursor.close();
            return;
        }
        cursor.close();
    } // else we already have the talk, just re-draw the page

    // Set the talk title
    TextView titleView = (TextView) findViewById(R.id.play_talk_talk_title);
    titleView.setText(talk.getTitle());

    // Set the teacher name
    TextView teacherView = (TextView) findViewById(R.id.play_talk_teacher);
    teacherView.setText(talk.getTeacherName());

    // Set the center name
    TextView centerView = (TextView) findViewById(R.id.play_talk_center);
    centerView.setText(talk.getCenterName());

    // Set the talk description
    TextView descriptionView = (TextView) findViewById(R.id.play_talk_talk_description);
    descriptionView.setText(talk.getDescription());

    // Set teacher photo
    String photoFilename = talk.getPhotoFileName();
    ImageView photoView = (ImageView) findViewById(R.id.play_talk_teacher_photo);
    Log.i(LOG_TAG, "photoFilename: " + photoFilename);
    try {
        FileInputStream photo = openFileInput(photoFilename);
        photoView.setImageBitmap(BitmapFactory.decodeStream(photo));
    } catch (FileNotFoundException e) {
        Drawable icon = ContextCompat.getDrawable(this, R.drawable.dharmaseed_icon);
        photoView.setImageDrawable(icon);
    }

    // set the image of the download button based on whether the talk is
    // downloaded or not
    toggleDownloadImage();

    // Set date
    TextView dateView = (TextView) findViewById(R.id.play_talk_date);
    String recDate = talk.getDate();
    SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
        dateView.setText(DateFormat.getDateInstance().format(parser.parse(recDate)));
    } catch (ParseException e) {
        dateView.setText("");
        Log.w(LOG_TAG, "Could not parse talk date for talk ID " + talkID);
    }

    // Get/create a persistent fragment to manage the MediaPlayer instance
    FragmentManager fm = getSupportFragmentManager();
    talkPlayerFragment = (TalkPlayerFragment) fm.findFragmentByTag("talkPlayerFragment");
    if (talkPlayerFragment == null) {
        // add the fragment
        talkPlayerFragment = new TalkPlayerFragment();
        fm.beginTransaction().add(talkPlayerFragment, "talkPlayerFragment").commit();
    } else if (talkPlayerFragment.getMediaPlayer().isPlaying()) {
        setPPButton("ic_media_pause");
    }

    // Set the talk duration
    final TextView durationView = (TextView) findViewById(R.id.play_talk_talk_duration);
    double duration = talk.getDurationInMinutes();
    String durationStr = DateUtils.formatElapsedTime((long) (duration * 60));
    durationView.setText(durationStr);

    // Start a handler to periodically update the seek bar and talk time
    final SeekBar seekBar = (SeekBar) findViewById(R.id.play_talk_seek_bar);
    seekBar.setMax((int) (duration * 60 * 1000));
    userDraggingSeekBar = false;
    userSeekBarPosition = 0;
    seekBar.setOnSeekBarChangeListener(this);
    final Handler handler = new Handler();
    final MediaPlayer mediaPlayer = talkPlayerFragment.getMediaPlayer();
    handler.post(new Runnable() {
        @Override
        public void run() {
            handler.postDelayed(this, 1000);
            if (talkPlayerFragment.getMediaPrepared() && !userDraggingSeekBar) {
                try {
                    int pos = mediaPlayer.getCurrentPosition();
                    int mpDuration = mediaPlayer.getDuration();
                    seekBar.setMax(mpDuration);
                    seekBar.setProgress(pos);
                    String posStr = DateUtils.formatElapsedTime(pos / 1000);
                    String mpDurStr = DateUtils.formatElapsedTime(mpDuration / 1000);
                    durationView.setText(posStr + "/" + mpDurStr);
                } catch (IllegalStateException e) {
                }
            }
        }
    });
}

From source file:org.ciasaboark.tacere.activity.SettingsActivity.java

private void drawAlarmWidgets() {
    TextView alarmTV = (TextView) findViewById(id.settings_alarmText);
    if (prefs.getIsServiceActivated()) {
        alarmTV.setTextColor(getResources().getColor(R.color.textcolor));
    } else {/* ww  w.  j av a 2s. c om*/
        alarmTV.setTextColor(getResources().getColor(R.color.textColorDisabled));
    }

    //the alarm volumes toggle
    Switch alarmSwitch = (Switch) findViewById(id.adjustAlarmCheckBox);
    alarmSwitch.setChecked(prefs.getAdjustAlarm());
    alarmSwitch.setEnabled(prefs.getIsServiceActivated());
    findViewById(id.settings_alarmBox).setEnabled(prefs.getIsServiceActivated());

    //the alarm volumes slider
    SeekBar alarmSB = (SeekBar) findViewById(id.alarmSeekBar);
    alarmSB.setMax(VolumesManager.getMaxAlarmVolume());
    alarmSB.setProgress(prefs.getCurAlarmVolume());
    if (prefs.getAdjustAlarm() && prefs.getIsServiceActivated()) {
        this.animateRevealView(alarmSB);
        alarmSB.setEnabled(true);
    } else {
        alarmSB.setEnabled(false);
        this.animateHideView(alarmSB);
    }
    alarmSB.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            prefs.setCurAlarmVolume(progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            //required stub
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            //required stub
        }
    });
}

From source file:com.brewcrewfoo.performance.fragments.BatteryInfo.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup root, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.battery_info, root, false);

    mbattery_percent = (TextView) view.findViewById(R.id.batt_percent);
    mbattery_volt = (TextView) view.findViewById(R.id.batt_volt);
    mbattery_status = (TextView) view.findViewById(R.id.batt_status);
    mBattIcon = (ImageView) view.findViewById(R.id.batt_icon);

    if (new File(BAT_VOLT_PATH).exists()) {
        int volt = Integer.parseInt(Helpers.readOneLine(BAT_VOLT_PATH));
        if (volt > 5000)
            volt = (int) Math.round(volt / 1000.0);// in microvolts
        mbattery_volt.setText(volt + " mV");
        mBattIcon.setVisibility(ImageView.GONE);
        mbattery_volt.setVisibility(TextView.VISIBLE);
        mbattery_volt.setOnClickListener(new View.OnClickListener() {
            @Override/*from w  w w .  jav a2s  .  c  o m*/
            public void onClick(View view) {
                Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
                if (powerUsageIntent.resolveActivity(context.getPackageManager()) != null)
                    startActivity(powerUsageIntent);
            }
        });
        mbattery_volt.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                mBattIcon.setVisibility(ImageView.VISIBLE);
                mbattery_volt.setVisibility(TextView.GONE);
                return true;
            }
        });
    } else {
        mBattIcon.setVisibility(ImageView.VISIBLE);
        mbattery_volt.setVisibility(TextView.GONE);
        mBattIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
                    startActivity(powerUsageIntent);
                } catch (Exception e) {
                }
            }
        });
    }

    SeekBar mBlxSlider = (SeekBar) view.findViewById(R.id.blx_slider);
    if (new File(BLX_PATH).exists()) {
        no_settings = false;
        mBlxSlider.setMax(100);

        mBlxVal = (TextView) view.findViewById(R.id.blx_val);
        mBlxVal.setText(getString(R.string.blx_title) + " " + Helpers.readOneLine(BLX_PATH) + "%");

        mBlxSlider.setProgress(Integer.parseInt(Helpers.readOneLine(BLX_PATH)));
        mBlxSlider.setOnSeekBarChangeListener(this);
        Switch mSetOnBoot = (Switch) view.findViewById(R.id.blx_sob);
        mSetOnBoot.setChecked(mPreferences.getBoolean(BLX_SOB, false));
        mSetOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton v, boolean checked) {
                final SharedPreferences.Editor editor = mPreferences.edit();
                editor.putBoolean(BLX_SOB, checked);
                if (checked) {
                    editor.putInt(PREF_BLX, Integer.parseInt(Helpers.readOneLine(BLX_PATH)));
                }
                editor.commit();
            }
        });
    } else {
        LinearLayout mpart = (LinearLayout) view.findViewById(R.id.blx_layout);
        mpart.setVisibility(LinearLayout.GONE);
    }
    mFastChargePath = Helpers.fastcharge_path();
    if (mFastChargePath != null) {
        no_settings = false;
        mFastchargeOnBoot = (Switch) view.findViewById(R.id.fastcharge_sob);
        mFastchargeOnBoot.setChecked(
                mPreferences.getBoolean(PREF_FASTCHARGE, Helpers.readOneLine(mFastChargePath).equals("1")));
        mFastchargeOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton v, boolean checked) {
                mPreferences.edit().putBoolean(PREF_FASTCHARGE, checked).apply();
                final NotificationManager nm = (NotificationManager) context
                        .getSystemService(Context.NOTIFICATION_SERVICE);
                if (checked) {
                    new CMDProcessor().su.runWaitFor("busybox echo 1 > " + mFastChargePath);
                    Notification n = new Notification.Builder(context)
                            .setContentTitle(context.getText(R.string.app_name))
                            .setContentText(context.getText(R.string.fast_charge_notification_title))
                            .setTicker(context.getText(R.string.fast_charge_notification_title))
                            .setSmallIcon(R.drawable.ic_fastcharge).setWhen(System.currentTimeMillis())
                            .getNotification();
                    //n.flags = Notification.FLAG_NO_CLEAR;
                    nm.notify(1337, n);
                } else {
                    new CMDProcessor().su.runWaitFor("busybox echo 0 > " + mFastChargePath);
                    nm.cancel(1337);
                }
            }
        });
    } else {
        LinearLayout mpart = (LinearLayout) view.findViewById(R.id.fastcharge_layout);
        mpart.setVisibility(LinearLayout.GONE);
    }
    if (no_settings) {
        LinearLayout ns = (LinearLayout) view.findViewById(R.id.no_settings);
        ns.setVisibility(LinearLayout.VISIBLE);
    }

    return view;
}

From source file:com.android.profilerapp.network.NetworkFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    myFragmentView = inflater.inflate(R.layout.fragment_network, container, false);
    myConnectivityManager = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);

    final SeekBar numDownloadsSeekBar = ((SeekBar) myFragmentView.findViewById(R.id.seekNumDownloads));
    final Button downloadButton = (Button) myFragmentView.findViewById(R.id.download);
    updateButtonText(numDownloadsSeekBar, downloadButton);
    downloadButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from   www  .  j ava 2 s.  c om*/
        public void onClick(View v) {
            int numSimultaneousDownloads = numDownloadsSeekBar.getProgress() + 1;
            for (int i = 0; i < numSimultaneousDownloads; i++) {
                download();
            }
        }
    });
    numDownloadsSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            updateButtonText(numDownloadsSeekBar, downloadButton);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    if (myStatisticsThread == null) {
        myStatisticsThread = getStatisticThread();
        myStatisticsThread.start();
    }

    return myFragmentView;
}

From source file:com.mobilevue.vod.VideoControllerView.java

private void initControllerView(View v) {
    mPauseButton = (ImageButton) v.findViewById(R.id.pause);
    if (mPauseButton != null) {
        mPauseButton.requestFocus();//from w  ww .java 2s.  co m
        mPauseButton.setOnClickListener(mPauseListener);
    }

    /*
     * mFullscreenButton = (ImageButton) v.findViewById(R.id.fullscreen); if
     * (mFullscreenButton != null) { mFullscreenButton.requestFocus();
     * mFullscreenButton.setOnClickListener(mFullscreenListener); }
     */

    mFfwdButton = (ImageButton) v.findViewById(R.id.ffwd);
    if (mFfwdButton != null) {
        mFfwdButton.setOnClickListener(mFfwdListener);
        if (!mFromXml) {
            mFfwdButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
        }
    }

    mRewButton = (ImageButton) v.findViewById(R.id.rew);
    if (mRewButton != null) {
        mRewButton.setOnClickListener(mRewListener);
        if (!mFromXml) {
            mRewButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
        }
    }

    // By default these are hidden. They will be enabled when
    // setPrevNextListeners() is called
    mNextButton = (ImageButton) v.findViewById(R.id.next);
    if (mNextButton != null && !mFromXml && !mListenersSet) {
        mNextButton.setVisibility(View.GONE);
    }
    mPrevButton = (ImageButton) v.findViewById(R.id.prev);
    if (mPrevButton != null && !mFromXml && !mListenersSet) {
        mPrevButton.setVisibility(View.GONE);
    }

    mProgress = (ProgressBar) v.findViewById(R.id.mediacontroller_progress);
    if (mProgress != null) {
        if (mProgress instanceof SeekBar) {
            SeekBar seeker = (SeekBar) mProgress;
            seeker.setOnSeekBarChangeListener(mSeekListener);
        }
        mProgress.setMax(1000);
    }

    mEndTime = (TextView) v.findViewById(R.id.time);
    mCurrentTime = (TextView) v.findViewById(R.id.time_current);
    mFormatBuilder = new StringBuilder();
    mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());

    installPrevNextListeners();

}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.VisualSectionFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.activity_display_visual, container, false);

    ///*from w w w  .j a  va 2 s  .co m*/
    // Init seekbars
    //
    final TextView tvColorSample = (TextView) rootView.findViewById(R.id.tvColorSample);

    SeekBar sbRed = (SeekBar) rootView.findViewById(R.id.seekBarRed);
    sbRed.setMax(255);
    final TextView tvRValue = (TextView) rootView.findViewById(R.id.textViewRedValue);

    SeekBar sbG = (SeekBar) rootView.findViewById(R.id.seekBarGreen);
    sbG.setMax(255);
    final TextView tvGValue = (TextView) rootView.findViewById(R.id.textViewGreenValue);

    SeekBar sbB = (SeekBar) rootView.findViewById(R.id.seekBarBlue);
    sbB.setMax(255);
    final TextView tvBValue = (TextView) rootView.findViewById(R.id.textViewBlueValue);

    sbRed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            tvRValue.setText(String.valueOf(progress));

            String sR = (String) tvRValue.getText();
            Integer IsR = new Integer(sR);

            String sG = (String) tvGValue.getText();
            Integer IsG = new Integer(sG);

            String sB = (String) tvBValue.getText();
            Integer IsB = new Integer(sB);

            String hex = String.format("#%02x%02x%02x", IsR, IsG, IsB);

            tvColorSample.setBackgroundColor(Color.parseColor(hex));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }
    });

    sbG.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            tvGValue.setText(String.valueOf(progress));

            String sR = (String) tvRValue.getText();
            Integer IsR = new Integer(sR);

            String sG = (String) tvGValue.getText();
            Integer IsG = new Integer(sG);

            String sB = (String) tvBValue.getText();
            Integer IsB = new Integer(sB);

            String hex = String.format("#%02x%02x%02x", IsR, IsG, IsB);

            tvColorSample.setBackgroundColor(Color.parseColor(hex));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }
    });

    sbB.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            tvBValue.setText(String.valueOf(progress));

            String sR = (String) tvRValue.getText();
            Integer IsR = new Integer(sR);

            String sG = (String) tvGValue.getText();
            Integer IsG = new Integer(sG);

            String sB = (String) tvBValue.getText();
            Integer IsB = new Integer(sB);

            String hex = String.format("#%02x%02x%02x", IsR, IsG, IsB);

            tvColorSample.setBackgroundColor(Color.parseColor(hex));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }
    });

    //
    // Init number pickers
    // 
    final RadioButton rbF = (RadioButton) rootView.findViewById(R.id.rbFullColor);
    final RadioButton rbP = (RadioButton) rootView.findViewById(R.id.rbPartColor);

    npLedStart = (NumberPicker) rootView.findViewById(R.id.npLedStart);
    npLedStart.setMaxValue(15);
    npLedStart.setMinValue(0);
    npLedStart.setValue(0);
    //npLedStart.setWrapSelectorWheel(false);
    npLedStart.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        @Override
        public void onValueChange(NumberPicker numberPicker, int i, int i2) {
            rbP.setChecked(true);
            rbF.setChecked(false);

        }
    });

    npLedEnd = (NumberPicker) rootView.findViewById(R.id.npLedStop);
    npLedEnd.setMaxValue(15);
    npLedEnd.setMinValue(0);
    npLedEnd.setValue(15);
    //npLedEnd.setWrapSelectorWheel(false);
    npLedEnd.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        @Override
        public void onValueChange(NumberPicker numberPicker, int i, int i2) {
            rbP.setChecked(true);
            rbF.setChecked(false);
        }
    });

    return rootView;
}

From source file:com.example.shuhei.googlemaproute.MapsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);

    //// w  w w  . j  a  va2s.com
    progressDialog = new ProgressDialog(this);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setMessage("......");
    progressDialog.hide();

    //?
    markerPoints = new ArrayList<LatLng>();
    markerPoints2 = new ArrayList<LatLng>();

    SupportMapFragment mapfragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    SupportMapFragment mapfragment2 = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map2);

    gMap = mapfragment.getMap();
    gMap2 = mapfragment2.getMap();

    //??
    LatLng latLng = new LatLng(34.71985, 135.234388);
    gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 13));
    gMap2.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 13));

    if (gMap != null) {

        gMap.setMyLocationEnabled(true);

        gMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
            @Override
            public void onCameraChange(CameraPosition cameraPosition) {
                gMap2.animateCamera(CameraUpdateFactory.zoomTo(gMap.getCameraPosition().zoom));
            }
        });

        //
        gMap.setOnMapClickListener(new OnMapClickListener() {
            @Override
            public void onMapClick(LatLng point) {

                //??
                if (markerPoints.size() > 1) {
                    markerPoints.clear();
                    gMap.clear();
                    map1sw = false;
                }

                markerPoints.add(point);

                options = new MarkerOptions();
                options.position(point);

                if (markerPoints.size() == 1) {
                    options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
                    // options.icon(BitmapDescriptorFactory.fromResource(R.drawable.green));
                    options.title("A");

                } else if (markerPoints.size() == 2) {
                    options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
                    //options.icon(BitmapDescriptorFactory.fromResource(R.drawable.red));
                    options.title("B");

                }

                gMap.addMarker(options);

                gMap.setOnMarkerClickListener(new OnMarkerClickListener() {
                    @Override
                    public boolean onMarkerClick(Marker marker) {
                        // TODO Auto-generated method stub

                        String title = marker.getTitle();
                        if (title.equals("A")) {
                            marker.setSnippet(info_A);

                        } else if (title.equals("B")) {
                            marker.setSnippet(info_B);
                        }

                        return false;
                    }
                });

                if (markerPoints.size() >= 2) {
                    map1sw = true;
                    //
                    routeSearch();

                }
            }
        });
    }

    if (gMap2 != null) {

        gMap2.setMyLocationEnabled(true);

        //
        gMap2.setOnMapClickListener(new OnMapClickListener() {
            @Override
            public void onMapClick(LatLng point) {

                //??
                if (markerPoints2.size() > 1) {
                    markerPoints2.clear();
                    gMap2.clear();
                    map2sw = true;
                }

                markerPoints2.add(point);

                options2 = new MarkerOptions();
                options2.position(point);

                if (markerPoints2.size() == 1) {
                    options2.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
                    // options.icon(BitmapDescriptorFactory.fromResource(R.drawable.green));
                    options2.title("A");

                } else if (markerPoints2.size() == 2) {
                    options2.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
                    //options.icon(BitmapDescriptorFactory.fromResource(R.drawable.red));
                    options2.title("B");

                }

                gMap2.addMarker(options2);

                gMap2.setOnMarkerClickListener(new OnMarkerClickListener() {
                    @Override
                    public boolean onMarkerClick(Marker marker) {
                        // TODO Auto-generated method stub

                        String title = marker.getTitle();
                        if (title.equals("A")) {
                            marker.setSnippet(info_A2);

                        } else if (title.equals("B")) {
                            marker.setSnippet(info_B2);
                        }

                        return false;
                    }
                });

                if (markerPoints2.size() >= 2) {
                    //
                    map2sw = true;
                    routeSearch2();
                }
            }
        });
    }

    seekBar = (SeekBar) findViewById(R.id.SeekBar01);

    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // ???????
            //tv1.setText("Current Value:"+progress);
            Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.map);
            fragment.getView().setAlpha((float) seekBar.getProgress() / (float) 10.0);
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
            // ???????
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
            // ???????
        }
    });
}

From source file:taylorandtanner.gasscanmk1.OcrCaptureActivity.java

/**
 * Initializes the UI and creates the detector pipeline.
 *//*from  w w  w  . j  a  v  a2s .c  om*/
@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.ocr_capture);

    Button next = (Button) findViewById(R.id.button3);
    next.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent myIntent = new Intent(view.getContext(), MainActivity.class);
            startActivityForResult(myIntent, 0);
        }

    });
    TextView tv1 = (TextView) findViewById(R.id.forStation);
    TextView tv1a = (TextView) findViewById(R.id.station);
    TextView tv2 = (TextView) findViewById(R.id.forPrice);
    TextView tv2a = (TextView) findViewById(R.id.totalPrice);
    TextView tv3 = (TextView) findViewById(R.id.forGallons);
    TextView tv3a = (TextView) findViewById(R.id.gallons);
    TextView tv4 = (TextView) findViewById(R.id.forPriceGal);
    TextView tv4a = (TextView) findViewById(R.id.priceGal);
    TextView tv5 = (TextView) findViewById(R.id.forMileage);
    TextView tv5a = (TextView) findViewById(R.id.mileage);

    tv1.setTextColor(Color.RED);
    tv1a.setTextColor(Color.BLACK);
    //Set others black
    tv3.setTextColor(Color.argb(0, 0, 0, 0));
    tv4.setTextColor(Color.argb(0, 0, 0, 0));
    tv5.setTextColor(Color.argb(0, 0, 0, 0));
    tv2.setTextColor(Color.argb(0, 0, 0, 0));
    tv3a.setTextColor(Color.argb(0, 0, 0, 0));
    tv4a.setTextColor(Color.argb(0, 0, 0, 0));
    tv5a.setTextColor(Color.argb(0, 0, 0, 0));
    tv2a.setTextColor(Color.argb(0, 0, 0, 0));

    final Button acceptOCRButton = (Button) findViewById(R.id.acceptOCRButton);
    acceptOCRButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            System.out.println("CLICKED!!1");

            String outputGal = ((TextView) findViewById(R.id.forGallons)).getText().toString();
            String outputPriceGal = ((TextView) findViewById(R.id.forPriceGal)).getText().toString();
            String outputMileage = ((TextView) findViewById(R.id.forMileage)).getText().toString();
            String outputPrice = ((TextView) findViewById(R.id.forPrice)).getText().toString();
            String outputStation = ((TextView) findViewById(R.id.forStation)).getText().toString();
            ReceiptEntry outputReceipt = new ReceiptEntry(outputPrice, outputGal, outputPriceGal, outputMileage,
                    "unassigned", outputStation);

            SerializeMethod(outputReceipt);
            // Intent activityChangeIntent = new Intent(OcrCaptureActivity.this, ReceiptForm.class);
            // OcrCaptureActivity.this.startActivity(activityChangeIntent);

        }
    });

    final SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub

            TextView t1 = (TextView) findViewById(R.id.forStation);
            TextView t1a = (TextView) findViewById(R.id.station);
            TextView t2 = (TextView) findViewById(R.id.forPrice);
            TextView t2a = (TextView) findViewById(R.id.totalPrice);
            TextView t3 = (TextView) findViewById(R.id.forGallons);
            TextView t3a = (TextView) findViewById(R.id.gallons);
            TextView t4 = (TextView) findViewById(R.id.forPriceGal);
            TextView t4a = (TextView) findViewById(R.id.priceGal);
            TextView t5 = (TextView) findViewById(R.id.forMileage);
            TextView t5a = (TextView) findViewById(R.id.mileage);

            if (seekBar.getProgress() >= 0 && seekBar.getProgress() < 20) {
                if (t1.getText().toString().equals("00"))
                    t1.setTextColor(Color.RED);
                else
                    t1.setTextColor(Color.BLUE);
                t1a.setTextColor(Color.BLACK);
                //Set others black
                t3.setTextColor(Color.argb(0, 0, 0, 0));
                t4.setTextColor(Color.argb(0, 0, 0, 0));
                t5.setTextColor(Color.argb(0, 0, 0, 0));
                t2.setTextColor(Color.argb(0, 0, 0, 0));
                t3a.setTextColor(Color.argb(0, 0, 0, 0));
                t4a.setTextColor(Color.argb(0, 0, 0, 0));
                t5a.setTextColor(Color.argb(0, 0, 0, 0));
                t2a.setTextColor(Color.argb(0, 0, 0, 0));
            }
            if (seekBar.getProgress() >= 20 && seekBar.getProgress() < 40) {
                if (t2.getText().toString().equals("00"))
                    t2.setTextColor(Color.RED);
                else
                    t2.setTextColor(Color.BLUE);
                t2a.setTextColor(Color.BLACK);
                //Set others black
                t3.setTextColor(Color.argb(0, 0, 0, 0));
                t4.setTextColor(Color.argb(0, 0, 0, 0));
                t5.setTextColor(Color.argb(0, 0, 0, 0));
                t1.setTextColor(Color.argb(0, 0, 0, 0));
                t3a.setTextColor(Color.argb(0, 0, 0, 0));
                t4a.setTextColor(Color.argb(0, 0, 0, 0));
                t5a.setTextColor(Color.argb(0, 0, 0, 0));
                t1a.setTextColor(Color.argb(0, 0, 0, 0));
            } else if (seekBar.getProgress() >= 40 && seekBar.getProgress() < 60) {
                if (t3.getText().toString().equals("00"))
                    t3.setTextColor(Color.RED);
                else
                    t3.setTextColor(Color.BLUE);
                t3a.setTextColor(Color.BLACK);
                //Set others black
                t2.setTextColor(Color.argb(0, 0, 0, 0));
                t4.setTextColor(Color.argb(0, 0, 0, 0));
                t5.setTextColor(Color.argb(0, 0, 0, 0));
                t1.setTextColor(Color.argb(0, 0, 0, 0));
                t2a.setTextColor(Color.argb(0, 0, 0, 0));
                t4a.setTextColor(Color.argb(0, 0, 0, 0));
                t5a.setTextColor(Color.argb(0, 0, 0, 0));
                t1a.setTextColor(Color.argb(0, 0, 0, 0));
            } else if (seekBar.getProgress() >= 60 && seekBar.getProgress() < 80) {
                if (t4.getText().toString().equals("00"))
                    t4.setTextColor(Color.RED);
                else
                    t4.setTextColor(Color.BLUE);
                t4a.setTextColor(Color.BLACK);
                //Set others black
                t2.setTextColor(Color.argb(0, 0, 0, 0));
                t3.setTextColor(Color.argb(0, 0, 0, 0));
                t5.setTextColor(Color.argb(0, 0, 0, 0));
                t1.setTextColor(Color.argb(0, 0, 0, 0));
                t2a.setTextColor(Color.argb(0, 0, 0, 0));
                t3a.setTextColor(Color.argb(0, 0, 0, 0));
                t5a.setTextColor(Color.argb(0, 0, 0, 0));
                t1a.setTextColor(Color.argb(0, 0, 0, 0));
            } else if (seekBar.getProgress() >= 80 && seekBar.getProgress() <= 100) {
                if (t5.getText().toString().equals("00"))
                    t5.setTextColor(Color.RED);
                else
                    t5.setTextColor(Color.BLUE);
                t5a.setTextColor(Color.BLACK);
                //Set others black
                t2.setTextColor(Color.argb(0, 0, 0, 0));
                t4.setTextColor(Color.argb(0, 0, 0, 0));
                t3.setTextColor(Color.argb(0, 0, 0, 0));
                t1.setTextColor(Color.argb(0, 0, 0, 0));
                t2a.setTextColor(Color.argb(0, 0, 0, 0));
                t4a.setTextColor(Color.argb(0, 0, 0, 0));
                t3a.setTextColor(Color.argb(0, 0, 0, 0));
                t1a.setTextColor(Color.argb(0, 0, 0, 0));
            }

        }
    });

    mPreview = (CameraSourcePreview) findViewById(R.id.preview);
    mGraphicOverlay = (GraphicOverlay<OcrGraphic>) findViewById(R.id.graphicOverlay);

    // Set good defaults for capturing text.
    boolean autoFocus = true;
    boolean useFlash = false;

    // Check for the camera permission before accessing the camera.  If the
    // permission is not granted yet, request permission.
    int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
    if (rc == PackageManager.PERMISSION_GRANTED) {
        createCameraSource(autoFocus, useFlash);
    } else {
        requestCameraPermission();
    }

    gestureDetector = new GestureDetector(this, new CaptureGestureListener());
    scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener());

    /*Snackbar.make(mGraphicOverlay, "Tap the text to place into the desired field. \n Select" +
        " 'confirm' when you are happy with the selection.",
        Snackbar.LENGTH_LONG)
        .show();*/

    // Set up the Text To Speech engine.
    /* TextToSpeech.OnInitListener listener =
        new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                if (status == TextToSpeech.SUCCESS) {
                    Log.d("OnInitListener", "Text to speech engine started successfully.");
                    tts.setLanguage(Locale.US);
                } else {
                    Log.d("OnInitListener", "Error starting the text to speech engine.");
                }
            }
        };
     tts = new TextToSpeech(this.getApplicationContext(), listener);*/
}

From source file:com.rks.musicx.ui.fragments.PlayingViews.Playing4Fragment.java

@Override
protected void playingView() {
    if (getMusicXService() != null) {
        String title = getMusicXService().getsongTitle();
        String artist = getMusicXService().getsongArtistName();
        songTitle.setText(title);/*from  ww w.  j  a  v a  2  s.c  om*/
        songTitle.setSelected(true);
        songTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        songArtist.setText(artist);
        Helper.rotationAnim(albumArtwork);
        Helper.rotationAnim(playpausebutton);
        int dur = getMusicXService().getDuration();
        seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                if (b && getMusicXService() != null
                        && (getMusicXService().isPlaying() || getMusicXService().isPaused())) {
                    getMusicXService().seekto(seekBar.getProgress());
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
            }
        });
        if (dur != -1) {
            seekbar.setMax(dur);
            totalDur.setText(Helper.durationCalculator(dur));
        }
        updateQueuePos(getMusicXService().returnpos());
        LyricsHelper.LoadLyrics(getContext(), title, artist, getMusicXService().getsongAlbumName(),
                getMusicXService().getsongData(), lrcview);
        bitmap = new bitmap() {
            @Override
            public void bitmapwork(Bitmap bitmap) {
                albumArtwork.setImageBitmap(bitmap);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurArtwork);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurQArtwork);
            }

            @Override
            public void bitmapfailed(Bitmap bitmap) {
                albumArtwork.setImageBitmap(bitmap);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurArtwork);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurQArtwork);
            }
        };
        palette = new palette() {
            @Override
            public void palettework(Palette palette) {
                final int[] colors = Helper.getAvailableColor(getContext(), palette);
                if (Extras.getInstance().artworkColor()) {
                    colorMode(colors[0]);
                } else {
                    colorMode(accentColor);
                }
                ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
                        ((ColorDrawable) controlsBg.getBackground()).getColor(), colors[0]);
                colorAnimation.setDuration(250); // milliseconds
                colorAnimation.addUpdateListener(
                        animator -> controlsBg.setBackgroundColor((int) animator.getAnimatedValue()));
                colorAnimation.start();
            }
        };
        if (mVisualizer != null) {
            if (vizualview != null) {
                vizualview.setEnabled(true);
            }
            mVisualizer.setEnabled(true);
        }
    }
}