Market support type
This commit is contained in:
parent
3948614ea1
commit
57bdb165e6
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.github.catvod.bean.market;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.github.catvod.bean.Class;
|
||||||
|
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.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Data {
|
||||||
|
|
||||||
|
@SerializedName("name")
|
||||||
|
private String name;
|
||||||
|
@SerializedName("list")
|
||||||
|
private List<Item> list;
|
||||||
|
|
||||||
|
public static List<Data> arrayFrom(String str) {
|
||||||
|
Type listType = new TypeToken<ArrayList<Data>>() {}.getType();
|
||||||
|
return new Gson().fromJson(str, listType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return TextUtils.isEmpty(name) ? "" : name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Item> getList() {
|
||||||
|
return list == null ? Collections.emptyList() : list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Vod> getVod() {
|
||||||
|
List<Vod> list = new ArrayList<>();
|
||||||
|
for (Item item : getList()) list.add(item.vod());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class type() {
|
||||||
|
return new Class(getName(), getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,13 +3,7 @@ package com.github.catvod.bean.market;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Item {
|
public class Item {
|
||||||
|
|
||||||
|
|
@ -19,11 +13,8 @@ public class Item {
|
||||||
private String url;
|
private String url;
|
||||||
@SerializedName("icon")
|
@SerializedName("icon")
|
||||||
private String icon;
|
private String icon;
|
||||||
|
@SerializedName("version")
|
||||||
public static List<Item> arrayFrom(String str) {
|
private String version;
|
||||||
Type listType = new TypeToken<ArrayList<Item>>() {}.getType();
|
|
||||||
return new Gson().fromJson(str, listType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return TextUtils.isEmpty(name) ? "" : name;
|
return TextUtils.isEmpty(name) ? "" : name;
|
||||||
|
|
@ -37,7 +28,11 @@ public class Item {
|
||||||
return TextUtils.isEmpty(icon) ? "" : icon;
|
return TextUtils.isEmpty(icon) ? "" : icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return TextUtils.isEmpty(version) ? "" : version;
|
||||||
|
}
|
||||||
|
|
||||||
public Vod vod() {
|
public Vod vod() {
|
||||||
return new Vod(getUrl(), getName(), getIcon());
|
return new Vod(getUrl(), getName(), getIcon(), getVersion(), Vod.Style.rect(1.0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,10 @@ import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import com.github.catvod.bean.Class;
|
||||||
import com.github.catvod.bean.Result;
|
import com.github.catvod.bean.Result;
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
import com.github.catvod.bean.market.Item;
|
import com.github.catvod.bean.market.Data;
|
||||||
import com.github.catvod.crawler.Spider;
|
import com.github.catvod.crawler.Spider;
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttp;
|
||||||
import com.github.catvod.utils.FileUtil;
|
import com.github.catvod.utils.FileUtil;
|
||||||
|
|
@ -18,6 +19,7 @@ import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
@ -25,7 +27,7 @@ import okhttp3.Response;
|
||||||
public class Market extends Spider {
|
public class Market extends Spider {
|
||||||
|
|
||||||
private ProgressDialog dialog;
|
private ProgressDialog dialog;
|
||||||
private List<Item> items;
|
private List<Data> datas;
|
||||||
private boolean busy;
|
private boolean busy;
|
||||||
|
|
||||||
public boolean isBusy() {
|
public boolean isBusy() {
|
||||||
|
|
@ -38,14 +40,20 @@ public class Market extends Spider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Context context, String extend) throws Exception {
|
public void init(Context context, String extend) throws Exception {
|
||||||
items = Item.arrayFrom(extend);
|
datas = Data.arrayFrom(extend);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String homeVideoContent() {
|
public String homeContent(boolean filter) throws Exception {
|
||||||
List<Vod> list = new ArrayList<>();
|
List<Class> classes = new ArrayList<>();
|
||||||
for (Item item : items) list.add(item.vod());
|
if (datas.size() > 1) for (int i = 1; i < datas.size(); i++) classes.add(datas.get(i).type());
|
||||||
return Result.string(list);
|
return Result.string(classes, datas.get(0).getVod());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||||
|
for (Data data : datas) if (data.getName().equals(tid)) return Result.string(data.getVod());
|
||||||
|
return super.categoryContent(tid, pg, filter, extend);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
e7ecd94c00583729f5ee1a87370573ef
|
75e53be144f567045cf1de67327d5478
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue