From e5af822975ea2fcaab664de847e26795151a1780 Mon Sep 17 00:00:00 2001 From: John Carlson Date: Mon, 2 Jan 2017 00:27:02 -0600 Subject: [PATCH] Add support for RatingBar and SeekBar --- .../untriggered/sample/MainActivity.java | 52 ++++++++++++++++ app/src/main/res/layout/activity_main.xml | 22 +++++++ .../untriggered/UntriggeredCheckBox.java | 2 +- .../untriggered/UntriggeredRadioButton.java | 2 +- .../untriggered/UntriggeredRatingBar.java | 46 ++++++++++++++ .../untriggered/UntriggeredSeekBar.java | 61 +++++++++++++++++++ .../untriggered/UntriggeredSwitchCompat.java | 2 +- 7 files changed, 184 insertions(+), 3 deletions(-) create mode 100644 untriggered/src/main/java/com/commit451/untriggered/UntriggeredRatingBar.java create mode 100644 untriggered/src/main/java/com/commit451/untriggered/UntriggeredSeekBar.java diff --git a/app/src/main/java/com/commit451/untriggered/sample/MainActivity.java b/app/src/main/java/com/commit451/untriggered/sample/MainActivity.java index f074fb8..02f2255 100644 --- a/app/src/main/java/com/commit451/untriggered/sample/MainActivity.java +++ b/app/src/main/java/com/commit451/untriggered/sample/MainActivity.java @@ -6,8 +6,14 @@ import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; +import android.widget.RatingBar; +import android.widget.SeekBar; import com.commit451.untriggered.UntriggeredCheckBox; +import com.commit451.untriggered.UntriggeredRadioButton; +import com.commit451.untriggered.UntriggeredRatingBar; +import com.commit451.untriggered.UntriggeredSeekBar; +import com.commit451.untriggered.UntriggeredSwitchCompat; public class MainActivity extends AppCompatActivity { @@ -18,6 +24,10 @@ protected void onCreate(Bundle savedInstanceState) { final ViewGroup root = (ViewGroup) findViewById(R.id.root); final UntriggeredCheckBox checkBox = (UntriggeredCheckBox) findViewById(R.id.checkbox); + final UntriggeredRadioButton radioButton = (UntriggeredRadioButton) findViewById(R.id.radio); + final UntriggeredSwitchCompat switchCompat = (UntriggeredSwitchCompat) findViewById(R.id.switch_thing); + final UntriggeredRatingBar ratingBar = (UntriggeredRatingBar) findViewById(R.id.ratingbar); + final UntriggeredSeekBar seekBar= (UntriggeredSeekBar) findViewById(R.id.seekbar); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override @@ -26,10 +36,52 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { .show(); } }); + radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + Snackbar.make(root, "Radio set to " + isChecked + " and I am triggered!", Snackbar.LENGTH_SHORT) + .show(); + } + }); + switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + Snackbar.make(root, "Switch set to " + isChecked + " and I am triggered!", Snackbar.LENGTH_SHORT) + .show(); + } + }); + ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { + @Override + public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { + Snackbar.make(root, "RatingBar set to " + rating + " and I am triggered!", Snackbar.LENGTH_SHORT) + .show(); + } + }); + seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + Snackbar.make(root, "Seekbar set to " + progress + " and I am triggered!", Snackbar.LENGTH_SHORT) + .show(); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } + }); findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { checkBox.setCheckedUntriggered(!checkBox.isChecked()); + radioButton.setCheckedUntriggered(!radioButton.isChecked()); + switchCompat.setCheckedUntriggered(!switchCompat.isChecked()); + seekBar.setProgressUntriggered(50); + ratingBar.setRatingUntriggered(2.5f); } }); } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ca174c0..15ddbe1 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -17,6 +17,28 @@ android:layout_height="wrap_content" android:text="Hello World!" /> + + + + + + + +