Skip to content

DayNightSwitch #5

Description

@hamdiayadi

hello , I'm using the DayNightSwitch that you offered , I tried it with the same code that you did and it worked , but when I tried to set the theme to AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); when is_night is true in the onSwitch , but it doesn't work , the switcher doesn't toggle even when I called the toggle method ..

what happen is when I click on the widget the theme is set to night but the widget doesn't toggle , the next time I click the widget toggle and goes to moon , the third click it goes to day theme and return to day part ... any solution please? this is my code

dayNightSwitch=(DayNightSwitch) findViewById(R.id.day);
dayNightSwitch.setListener(new DayNightSwitchListener() {
@OverRide
public void onSwitch(boolean is_night) {
if(is_night) {

        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
    }
    else {

       AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);

    }

}

});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions