简介
xxx
示例一
Style
package com.github.ybq.android.spinkit;
public enum Style {
ROTATING_PLANE(0),
DOUBLE_BOUNCE(1),
WAVE(2),
WANDERING_CUBES(3),
PULSE(4),
CHASING_DOTS(5),
THREE_BOUNCE(6),
CIRCLE(7),
CUBE_GRID(8),
FADING_CIRCLE(9),
FOLDING_CUBE(10),
ROTATING_CIRCLE(11),
MULTIPLE_PULSE(12),
PULSE_RING(13),
MULTIPLE_PULSE_RING(14);
private int value;
private Style(int value) {
this.value = value;
}
}
主代码
Style style = Style.values()[2];
示例二
Classification
package value;
/**
* Created on 2019/7/23.
*
* @author 郑少鹏
* @desc 类别
*/
public enum Classification {
/**
* 节日问候
*/
HOLIDAY_GREETINGS("节日问候", 1),
/**
* 生日问候
*/
BIRTHDAY_GREETINGS("生日问候", 2),
/**
* 用药回访
*/
DRUG_RETURN_VISIT("用药回访", 3),
/**
* 活动通知
*/
ACTIVITY_NOTICE("活动通知", 4),
/**
* 沉睡回访
*/
SLEEPING_BACK("沉睡回访", 5);
/**
* 描述
*/
private String description;
/**
* 标志
*/
private int flag;
/**
* constructor
*
* @param description 描述
* @param flag 标志
*/
Classification(String description, int flag) {
this.description = description;
this.flag = flag;
}
/**
* 类别
*
* @param flag 标志
* @return 类别
*/
public static Classification getClassification(int flag) {
for (Classification c : Classification.values()) {
if (c.flag == flag) {
return c;
}
}
return null;
}
/**
* 描述
*
* @param flag 标志
* @return 描述
*/
public static String getDescription(int flag) {
for (Classification classification : Classification.values()) {
if (classification.flag == flag) {
return classification.description;
}
}
return null;
}
/**
* 标志
*
* @param description 描述
* @return 标志
*/
public static int getFlag(String description) {
for (Classification c : Classification.values()) {
if (c.description.equals(description)) {
return c.flag;
}
}
return 0;
}
public String getDescription() {
return description;
}
public int getFlag() {
return flag;
}}
主代码
Classification c = Classification.getClassification(flag);
if (null == c) {
return;
}
switch (c) {
// 节日问候
case HOLIDAY_GREETINGS:
break;
// 生日问候
case BIRTHDAY_GREETINGS:
break;
// 用药回访
case DRUG_RETURN_VISIT:
break;
// 活动通知
case ACTIVITY_NOTICE:
break;
// 沉睡回访
case SLEEPING_BACK:
break;
default:
break;
}
Classification.getDescription(flag);
Classification.getFlag(description);