Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DayNightSwitch #5

Open
hamdiayadi opened this issue Jan 12, 2021 · 0 comments
Open

DayNightSwitch #5

hamdiayadi opened this issue Jan 12, 2021 · 0 comments

Comments

@hamdiayadi
Copy link

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);

    }

}

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant