Search in sources :

Example 1 with OnSettingsChangedListener

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);
            }
        }
    });
}
Also used : App(com.instructure.speedgrader.util.App) OnSettingsChangedListener(com.instructure.speedgrader.interfaces.OnSettingsChangedListener) HelveticaTextView(com.instructure.speedgrader.views.HelveticaTextView) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) TutorialUtils(com.instructure.pandautils.utils.TutorialUtils) HelveticaTextView(com.instructure.speedgrader.views.HelveticaTextView) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) CompoundButton(android.widget.CompoundButton) SwitchCompat(android.support.v7.widget.SwitchCompat)

Aggregations

SwitchCompat (android.support.v7.widget.SwitchCompat)1 View (android.view.View)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 TutorialUtils (com.instructure.pandautils.utils.TutorialUtils)1 OnSettingsChangedListener (com.instructure.speedgrader.interfaces.OnSettingsChangedListener)1 App (com.instructure.speedgrader.util.App)1 HelveticaTextView (com.instructure.speedgrader.views.HelveticaTextView)1 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)1