DayNightSwitch icon indicating copy to clipboard operation
DayNightSwitch copied to clipboard

DayNightSwitch

Open hamdiayadi opened this issue 4 years ago • 0 comments

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

    }

}

});

hamdiayadi avatar Jan 12 '21 20:01 hamdiayadi