use of androidx.annotation.StyleRes in project android-styled-dialogs by avast.
the class BaseDialogFragment method resolveTheme.
/**
* Resolves the theme to be used for the dialog.
*
* @return The theme.
*/
@StyleRes
private int resolveTheme() {
// First check if getTheme() returns some usable theme.
int theme = getTheme();
if (theme != 0) {
return theme;
}
// Get the light/dark attribute from the Activity's Theme.
boolean useLightTheme = isActivityThemeLight();
// Now check if developer overrides the Activity's Theme with an argument.
Bundle args = getArguments();
if (args != null) {
if (args.getBoolean(BaseDialogBuilder.ARG_USE_DARK_THEME)) {
// Developer is explicitly using the dark theme.
useLightTheme = false;
} else if (args.getBoolean(BaseDialogBuilder.ARG_USE_LIGHT_THEME)) {
// Developer is explicitly using the light theme.
useLightTheme = true;
}
}
return useLightTheme ? R.style.SDL_Dialog : R.style.SDL_Dark_Dialog;
}