|
|
|
|
@ -10,36 +10,43 @@ public class ErrorEvent { |
|
|
|
|
private final Type type; |
|
|
|
|
private final int retry; |
|
|
|
|
private String msg; |
|
|
|
|
private int code; |
|
|
|
|
|
|
|
|
|
public static void url(int retry) { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.URL, retry)); |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.URL, retry, -1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void url(int retry, int code) { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.URL, retry, code)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void flag() { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.FLAG, 0)); |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.FLAG, 0, -1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void parse() { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.PARSE, 0)); |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.PARSE, 0, -1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void timeout() { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.TIMEOUT, 0)); |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.TIMEOUT, 0, -1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void extract(String msg) { |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.EXTRACT, 0, msg)); |
|
|
|
|
EventBus.getDefault().post(new ErrorEvent(Type.EXTRACT, 0, -1, msg)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ErrorEvent(Type type, int retry) { |
|
|
|
|
public ErrorEvent(Type type, int retry, int code) { |
|
|
|
|
this.type = type; |
|
|
|
|
this.retry = retry; |
|
|
|
|
this.code = code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ErrorEvent(Type type, int retry, String msg) { |
|
|
|
|
public ErrorEvent(Type type, int retry, int code, String msg) { |
|
|
|
|
this.msg = msg; |
|
|
|
|
this.type = type; |
|
|
|
|
this.retry = retry; |
|
|
|
|
this.code = code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Type getType() { |
|
|
|
|
@ -54,6 +61,10 @@ public class ErrorEvent { |
|
|
|
|
return Type.URL.equals(getType()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getCode() { |
|
|
|
|
return code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getMsg() { |
|
|
|
|
if (type == Type.URL) return ResUtil.getString(R.string.error_play_url); |
|
|
|
|
if (type == Type.FLAG) return ResUtil.getString(R.string.error_play_flag); |
|
|
|
|
|