一个枚举的使用小例子:
public class CommonLoadingBar {
public static enum Type {
NO_DIALOG, SHOW_LOADING, SHOW_NET_EXCEPTION, SHOW_NO_DATA, NORMAL_FEES
}
private Type mLoadingType = null;
public CommonLoadingBar(View view) {
mLoadingType = Type.NO_DIALOG;
}
public void showViewType(Type type) {
if (type != Type.SHOW_LOADING && type != Type.SHOW_NET_EXCEPTION
&& type != Type.SHOW_NO_DATA && type != Type.NORMAL_FEES) {
return;
}
mLoadingType = type;
if (mView != null && mView.getVisibility() != View.VISIBLE) {
mView.setVisibility(View.VISIBLE);
}
if (type == Type.SHOW_LOADING) {
showLoadingDialog();
} else if (type == Type.SHOW_NET_EXCEPTION) {
showNetException();
} else if (type == Type.SHOW_NO_DATA) {
showNoData();
} else if (type == Type.NORMAL_FEES) {
showNormalFees();
}
}
}