diff --git a/app/build.gradle b/app/build.gradle index 3e0ec2b3..b69d1e12 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,5 +43,6 @@ dependencies { implementation 'com.google.code.gson:gson:2.8.6' implementation 'cn.wanghaomiao:JsoupXpath:2.5.1' implementation 'com.google.zxing:core:3.3.0' + //implementation 'com.orhanobut:logger:2.2.0' implementation 'org.jsoup:jsoup:1.15.3' } \ No newline at end of file diff --git a/app/src/main/java/com/github/catvod/bean/star/Card.java b/app/src/main/java/com/github/catvod/bean/star/Card.java new file mode 100644 index 00000000..c43d8123 --- /dev/null +++ b/app/src/main/java/com/github/catvod/bean/star/Card.java @@ -0,0 +1,61 @@ +package com.github.catvod.bean.star; + +import android.text.TextUtils; + +import com.github.catvod.bean.Vod; +import com.google.gson.Gson; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.Collections; +import java.util.List; + +public class Card { + + @SerializedName("name") + private String name; + @SerializedName("img") + private String img; + @SerializedName("id") + private String id; + @SerializedName("countStr") + private String countStr; + @SerializedName("url") + private String url; + @SerializedName("cards") + private List cards; + + public static List arrayFrom(String str) { + Type listType = new TypeToken>() {}.getType(); + return new Gson().fromJson(str, listType); + } + + public String getName() { + return TextUtils.isEmpty(name) ? "" : name; + } + + public String getImg() { + return TextUtils.isEmpty(img) ? "" : img; + } + + public String getId() { + return TextUtils.isEmpty(id) ? "" : id; + } + + public String getCountStr() { + return TextUtils.isEmpty(countStr) ? "" : countStr; + } + + public String getUrl() { + return TextUtils.isEmpty(url) ? "" : url; + } + + public List getCards() { + return cards == null ? Collections.emptyList() : cards; + } + + public Vod vod() { + return new Vod(getId(), getName(), getImg(), getCountStr()); + } +} diff --git a/app/src/main/java/com/github/catvod/bean/star/Condition.java b/app/src/main/java/com/github/catvod/bean/star/Condition.java new file mode 100644 index 00000000..f3354405 --- /dev/null +++ b/app/src/main/java/com/github/catvod/bean/star/Condition.java @@ -0,0 +1,65 @@ +package com.github.catvod.bean.star; + +import com.github.catvod.bean.Filter; +import com.google.gson.Gson; +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class Condition { + + @SerializedName("label") + private List> label; + @SerializedName("country") + private List country; + @SerializedName("time") + private List time; + + public static Condition objectFrom(String str) { + return new Gson().fromJson(str, Condition.class); + } + + public List> getLabel() { + return label == null ? Collections.emptyList() : label; + } + + public List getCountry() { + return country == null ? Collections.emptyList() : country; + } + + public List getTime() { + return time == null ? Collections.emptyList() : time; + } + + public List getFilter() { + List filters = new ArrayList<>(); + filters.add(new Filter("type", "類型", getTypeValues())); + filters.add(new Filter("area", "地區", getAreaValues())); + filters.add(new Filter("year", "年份", getYearValues())); + return filters; + } + + private List getTypeValues() { + List values = new ArrayList<>(); + values.add(new Filter.Value("全部", "")); + for (List list : getLabel()) values.add(new Filter.Value(list.get(0))); + return values; + } + + private List getAreaValues() { + List values = new ArrayList<>(); + values.add(new Filter.Value("全部", "")); + for (String text : getCountry()) values.add(new Filter.Value(text)); + return values; + } + + private List getYearValues() { + List values = new ArrayList<>(); + values.add(new Filter.Value("全部", "")); + Collections.sort(getTime(), Collections.reverseOrder()); + for (Integer year : getTime()) if (year >= 2010) values.add(new Filter.Value(String.valueOf(year))); + return values; + } +} diff --git a/app/src/main/java/com/github/catvod/bean/star/Detail.java b/app/src/main/java/com/github/catvod/bean/star/Detail.java new file mode 100644 index 00000000..58c290bb --- /dev/null +++ b/app/src/main/java/com/github/catvod/bean/star/Detail.java @@ -0,0 +1,96 @@ +package com.github.catvod.bean.star; + +import com.google.gson.Gson; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class Detail { + + @SerializedName("id") + private Integer id; + @SerializedName("videos") + private List