|
|
|
@ -12,10 +12,10 @@ import com.google.gson.JsonDeserializer; |
|
|
|
import com.google.gson.JsonElement; |
|
|
|
import com.google.gson.JsonElement; |
|
|
|
import com.google.gson.JsonObject; |
|
|
|
import com.google.gson.JsonObject; |
|
|
|
import com.google.gson.JsonParseException; |
|
|
|
import com.google.gson.JsonParseException; |
|
|
|
import com.google.gson.JsonParser; |
|
|
|
|
|
|
|
import com.google.gson.annotations.SerializedName; |
|
|
|
import com.google.gson.annotations.SerializedName; |
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.json.JSONObject; |
|
|
|
import org.simpleframework.xml.ElementList; |
|
|
|
import org.simpleframework.xml.ElementList; |
|
|
|
import org.simpleframework.xml.Path; |
|
|
|
import org.simpleframework.xml.Path; |
|
|
|
import org.simpleframework.xml.Root; |
|
|
|
import org.simpleframework.xml.Root; |
|
|
|
@ -45,28 +45,28 @@ public class Result { |
|
|
|
@SerializedName("filters") |
|
|
|
@SerializedName("filters") |
|
|
|
private LinkedHashMap<String, List<Filter>> filters; |
|
|
|
private LinkedHashMap<String, List<Filter>> filters; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SerializedName("header") |
|
|
|
|
|
|
|
private JsonElement header; |
|
|
|
@SerializedName("playUrl") |
|
|
|
@SerializedName("playUrl") |
|
|
|
private String playUrl; |
|
|
|
private String playUrl; |
|
|
|
@SerializedName("header") |
|
|
|
@SerializedName("jxFrom") |
|
|
|
private String header; |
|
|
|
private String jxFrom; |
|
|
|
@SerializedName("flag") |
|
|
|
|
|
|
|
private String flag; |
|
|
|
|
|
|
|
@SerializedName("url") |
|
|
|
|
|
|
|
private String url; |
|
|
|
|
|
|
|
@SerializedName("parse") |
|
|
|
@SerializedName("parse") |
|
|
|
private Integer parse; |
|
|
|
private Integer parse; |
|
|
|
@SerializedName("jx") |
|
|
|
@SerializedName("jx") |
|
|
|
private Integer jx; |
|
|
|
private Integer jx; |
|
|
|
|
|
|
|
@SerializedName("flag") |
|
|
|
|
|
|
|
private String flag; |
|
|
|
|
|
|
|
@SerializedName("url") |
|
|
|
|
|
|
|
private String url; |
|
|
|
|
|
|
|
|
|
|
|
public static Result fromJson(String str) { |
|
|
|
public static Result fromJson(String str) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Type type = new TypeToken<LinkedHashMap<String, List<Filter>>>() { |
|
|
|
Type type = new TypeToken<LinkedHashMap<String, List<Filter>>>() {}.getType(); |
|
|
|
}.getType(); |
|
|
|
|
|
|
|
Gson gson = new GsonBuilder().registerTypeAdapter(type, new FiltersAdapter()).create(); |
|
|
|
Gson gson = new GsonBuilder().registerTypeAdapter(type, new FiltersAdapter()).create(); |
|
|
|
Result result = gson.fromJson(str, Result.class); |
|
|
|
Result result = gson.fromJson(str, Result.class); |
|
|
|
return result == null ? new Result() : result; |
|
|
|
return result == null ? new Result() : result; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -75,13 +75,20 @@ public class Result { |
|
|
|
try { |
|
|
|
try { |
|
|
|
return new Persister().read(Result.class, str); |
|
|
|
return new Persister().read(Result.class, str); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Result fromObject(JSONObject object) { |
|
|
|
|
|
|
|
return objectFrom(object.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static Result objectFrom(String str) { |
|
|
|
public static Result objectFrom(String str) { |
|
|
|
|
|
|
|
try { |
|
|
|
return new Gson().fromJson(str, Result.class); |
|
|
|
return new Gson().fromJson(str, Result.class); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<Class> getTypes() { |
|
|
|
public List<Class> getTypes() { |
|
|
|
@ -104,6 +111,10 @@ public class Result { |
|
|
|
return filters == null ? new LinkedHashMap<>() : filters; |
|
|
|
return filters == null ? new LinkedHashMap<>() : filters; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JsonElement getHeader() { |
|
|
|
|
|
|
|
return header; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getPlayUrl() { |
|
|
|
public String getPlayUrl() { |
|
|
|
return TextUtils.isEmpty(playUrl) ? "" : playUrl; |
|
|
|
return TextUtils.isEmpty(playUrl) ? "" : playUrl; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -112,8 +123,8 @@ public class Result { |
|
|
|
this.playUrl = playUrl; |
|
|
|
this.playUrl = playUrl; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getHeader() { |
|
|
|
public String getJxFrom() { |
|
|
|
return TextUtils.isEmpty(header) ? "" : header; |
|
|
|
return TextUtils.isEmpty(jxFrom) ? "" : jxFrom; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Integer getParse() { |
|
|
|
public Integer getParse() { |
|
|
|
@ -124,6 +135,10 @@ public class Result { |
|
|
|
this.parse = parse; |
|
|
|
this.parse = parse; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Integer getJx() { |
|
|
|
|
|
|
|
return jx == null ? 0 : jx; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getFlag() { |
|
|
|
public String getFlag() { |
|
|
|
return TextUtils.isEmpty(flag) ? "" : flag; |
|
|
|
return TextUtils.isEmpty(flag) ? "" : flag; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -132,10 +147,6 @@ public class Result { |
|
|
|
this.flag = flag; |
|
|
|
this.flag = flag; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Integer getJx() { |
|
|
|
|
|
|
|
return jx == null ? 0 : jx; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getUrl() { |
|
|
|
public String getUrl() { |
|
|
|
return TextUtils.isEmpty(url) ? "" : url; |
|
|
|
return TextUtils.isEmpty(url) ? "" : url; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -144,10 +155,12 @@ public class Result { |
|
|
|
this.url = url; |
|
|
|
this.url = url; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean hasHeader() { |
|
|
|
|
|
|
|
return getHeader() != null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Map<String, String> getHeaders() { |
|
|
|
public Map<String, String> getHeaders() { |
|
|
|
HashMap<String, String> headers = new HashMap<>(); |
|
|
|
return hasHeader() ? Json.toMap(getHeader()) : new HashMap<>(); |
|
|
|
if (getHeader().isEmpty()) return headers; |
|
|
|
|
|
|
|
return Json.toMap(JsonParser.parseString(getHeader())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
@NonNull |
|
|
|
|