|
|
|
|
@ -11,20 +11,16 @@ public class ErrorEvent { |
|
|
|
|
private final int retry; |
|
|
|
|
private String msg; |
|
|
|
|
|
|
|
|
|
public static void url() { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.URL, 0)); |
|
|
|
|
public static void url(int retry) { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.URL, retry)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void parse() { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.PARSE, 0)); |
|
|
|
|
public static void flag() { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.FLAG, 0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void format(int retry) { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.FORMAT, retry)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void episode() { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.EPISODE, 0)); |
|
|
|
|
public static void parse() { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.PARSE, 0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void timeout() { |
|
|
|
|
@ -41,18 +37,9 @@ public class ErrorEvent { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ErrorEvent(Type type, int retry, String msg) { |
|
|
|
|
this.msg = msg; |
|
|
|
|
this.type = type; |
|
|
|
|
this.retry = retry; |
|
|
|
|
this.msg = msg; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private int getResId() { |
|
|
|
|
if (type == Type.URL) return R.string.error_play_url; |
|
|
|
|
if (type == Type.PARSE) return R.string.error_play_parse; |
|
|
|
|
if (type == Type.FORMAT) return R.string.error_play_format; |
|
|
|
|
if (type == Type.EPISODE) return R.string.error_play_episode; |
|
|
|
|
if (type == Type.TIMEOUT) return R.string.error_play_timeout; |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Type getType() { |
|
|
|
|
@ -63,15 +50,19 @@ public class ErrorEvent { |
|
|
|
|
return retry; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean isFormat() { |
|
|
|
|
return Type.FORMAT.equals(getType()); |
|
|
|
|
public boolean isUrl() { |
|
|
|
|
return Type.URL.equals(getType()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getMsg() { |
|
|
|
|
return getResId() == -1 ? msg : ResUtil.getString(getResId()); |
|
|
|
|
if (type == Type.URL) return ResUtil.getString(R.string.error_play_url); |
|
|
|
|
if (type == Type.FLAG) return ResUtil.getString(R.string.error_play_flag); |
|
|
|
|
if (type == Type.PARSE) return ResUtil.getString(R.string.error_play_parse); |
|
|
|
|
if (type == Type.TIMEOUT) return ResUtil.getString(R.string.error_play_timeout); |
|
|
|
|
return msg; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public enum Type { |
|
|
|
|
URL, PARSE, FORMAT, EPISODE, TIMEOUT, EXTRACT |
|
|
|
|
URL, FLAG, PARSE, TIMEOUT, EXTRACT |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|