Skip to content

Instantly share code, notes, and snippets.

@shadow7
Created March 7, 2016 22:28
Show Gist options
  • Select an option

  • Save shadow7/7b079cbaab0fc732c00d to your computer and use it in GitHub Desktop.

Select an option

Save shadow7/7b079cbaab0fc732c00d to your computer and use it in GitHub Desktop.
Enum with default values
public enum NotificationCard {
WHOOPS(0, KEY_DISMISSED_WHOOPS, R.string.notification_safe_info_title,
R.string.notification_safe_info_message, R.raw.ic_alien,
R.color.common_deep_purple, R.string.ok),
SAFE_INFO(1, KEY_DISMISSED_SAFE_INFO, R.string.notification_safe_info_title,
R.string.notification_safe_info_message, R.raw.ic_chameleon_framed,
R.color.common_proxy_purple, R.string.ok),
SHARE_PROFILE(2, KEY_DISMISSED_SHARE_PROFILE, R.string.notification_share_profile_title,
R.string.notification_share_profile_message, R.raw.ic_carroll_share,
R.color.common_blue, R.string.ok),
CUSTOM_URL(3, KEY_DISMISSED_CUSTOM_URL, R.string.notification_custom_url_title,
R.string.notification_custom_url_message, R.raw.ic_sexbot_custom, R.color
.common_blue, R.string.ok),
INVITE_FRIENDS(4, KEY_DISMISSED_INVITE_FRIENDS, R.string.notification_invite_friends_title,
R.string.notification_invite_friends_message, R.raw.ic_jamal,
R.color.common_light_blue, R.string.send_invite),
PUBLIC_GROUPS(5, KEY_DISMISSED_PUBLIC_GROUP, R.string.notification_public_groups_title,
R.string.notification_public_groups_message, R.raw.ic_chameleon_framed,
R.color.common_proxy_purple, R.string.ok),
MAIN_GROUPS(6, KEY_DISMISSED_MAIN_GROUP, R.string.notification_main_groups_title,
R.string.notification_main_groups_message, R.raw.ic_owl,
R.color.common_proxy_orange, R.string.ok);
private int value;
private String key;
private int titleRes;
private int messageRes;
private int iconRes;
private int colorRes;
private int actionRes;
NotificationCard(
int value, String key, int titleRes, int messageRes, int iconRes, int colorRes,
int actionRes) {
this.value = value;
this.key = key;
this.titleRes = titleRes;
this.messageRes = messageRes;
this.iconRes = iconRes;
this.colorRes = colorRes;
this.actionRes = actionRes;
}
public static NotificationCard get(int intValue) {
for (NotificationCard notificationCard : NotificationCard.values()) {
if (notificationCard.value == intValue) {
return notificationCard;
}
}
return NotificationCard.WHOOPS;
}
public int getValue() {
return value;
}
public String getKey() {
return key;
}
public int getTitleRes() {
return titleRes;
}
public int getMessageRes() {
return messageRes;
}
public int getIconRes() {
return iconRes;
}
public int getColorRes() {
return colorRes;
}
public int getActionRes() {
return actionRes;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment