You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.4 KiB
62 lines
1.4 KiB
package com.fr.widgettheme; |
|
|
|
import com.fr.base.theme.TemplateTheme; |
|
import com.fr.widgettheme.theme.widget.style.MobileThemedWidgetStyle; |
|
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
|
|
|
/** |
|
* 主题样式预览终端类型 |
|
* |
|
* @author obo |
|
* @since 11.0 |
|
* Created on 2024/2/2 |
|
*/ |
|
public enum ThemePreviewTerminal { |
|
|
|
/** |
|
* 桌面端,为默认类型 |
|
*/ |
|
PC(0) { |
|
@Override |
|
public ThemedWidgetStyle getThemeWidgetStyle(TemplateTheme theme) { |
|
return (ThemedWidgetStyle) theme.getWidgetStyle(); |
|
} |
|
}, |
|
|
|
/** |
|
* 移动端 |
|
*/ |
|
MOBILE(1) { |
|
@Override |
|
public ThemedWidgetStyle getThemeWidgetStyle(TemplateTheme theme) { |
|
return (MobileThemedWidgetStyle) theme.getMobileWidgetStyle(); |
|
} |
|
}; |
|
|
|
/** |
|
* 类型码 |
|
*/ |
|
final int code; |
|
|
|
ThemePreviewTerminal(int code) { |
|
this.code = code; |
|
} |
|
|
|
public int getCode() { |
|
return code; |
|
} |
|
|
|
public abstract ThemedWidgetStyle getThemeWidgetStyle(TemplateTheme theme); |
|
|
|
/** |
|
* 根据code获取对应的枚举 |
|
*/ |
|
public static ThemePreviewTerminal getTypeByCode(int code) { |
|
for (ThemePreviewTerminal type : ThemePreviewTerminal.values()) { |
|
if (type.code == code) { |
|
return type; |
|
} |
|
} |
|
throw new IllegalArgumentException("Invalid ThemePreviewTerminalType code :" + code); |
|
} |
|
}
|
|
|