use of com.instructure.speedgrader.interfaces.OnSettingsChangedListener in project instructure-android by instructure.
the class HomeActivity method initSettingsListeners.
public void initSettingsListeners() {
final SwitchCompat hideNamesSwitch = (SwitchCompat) findViewById(R.id.sg_options_hideNames_switch);
final SwitchCompat showUngradedFirstSwitch = (SwitchCompat) findViewById(R.id.sg_options_showUngradedFirst_switch);
final SwitchCompat showUngradedCountSwitch = (SwitchCompat) findViewById(R.id.sg_options_viewUngradedCount_switch);
final HelveticaTextView hideNamesLabel = (HelveticaTextView) findViewById(R.id.sg_options_hideNames);
final HelveticaTextView showUngradedFirstLabel = (HelveticaTextView) findViewById(R.id.sg_options_showUngradedFirst);
final HelveticaTextView viewUngradedCountLabel = (HelveticaTextView) findViewById(R.id.sg_options_viewUngradedCount);
final ImageView pulse = (ImageView) findViewById(R.id.pulse);
new TutorialUtils(HomeActivity.this, App.getPrefs(), pulse, TutorialUtils.TYPE.COLOR_CHANGING_DIALOG).setContent(getString(R.string.tutorial_tipHideStudentNames), getString(R.string.tutorial_tipHideStudentNamesMessage)).build();
hideNamesLabel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hideNamesSwitch.toggle();
}
});
showUngradedFirstLabel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showUngradedFirstSwitch.toggle();
}
});
viewUngradedCountLabel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showUngradedCountSwitch.toggle();
}
});
// Set Switch defaults
final App applicationManager = (App) getApplication();
// Set Default values for our switches
hideNamesSwitch.setChecked(applicationManager.showStudentNames());
showUngradedFirstSwitch.setChecked(applicationManager.showUngradedStudentsFirst());
showUngradedCountSwitch.setChecked(applicationManager.showUngradedCount());
// set On check changed listeners
hideNamesSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
applicationManager.setShowStudentNames(isChecked);
}
});
showUngradedFirstSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
applicationManager.setShowUngradedStudentsFirst(isChecked);
}
});
showUngradedCountSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
applicationManager.setShowUngradedCount(isChecked);
if (getSupportFragmentManager().findFragmentById(R.id.content_frame) instanceof OnSettingsChangedListener) {
((OnSettingsChangedListener) getSupportFragmentManager().findFragmentById(R.id.content_frame)).onShowUngradedCountChanged(isChecked);
}
}
});
}
Aggregations