Support trans to zh_tw

This commit is contained in:
FongMi 2022-09-25 21:25:49 +08:00
parent fcbb86067b
commit 24fa14896c
8 changed files with 42 additions and 37 deletions

View File

@ -1,5 +1,6 @@
package com.github.catvod.bean; package com.github.catvod.bean;
import com.github.catvod.utils.Trans;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@ -18,11 +19,9 @@ public class Class {
public static List<Class> arrayFrom(String str) { public static List<Class> arrayFrom(String str) {
Type listType = new TypeToken<List<Class>>() {}.getType(); Type listType = new TypeToken<List<Class>>() {}.getType();
return new Gson().fromJson(str, listType); List<Class> items = new Gson().fromJson(str, listType);
} for (Class item : items) item.typeName = Trans.get(item.typeName);
return items;
public Class(int typeId, String typeName) {
this(String.valueOf(typeId), typeName);
} }
public Class(String typeId, String typeName) { public Class(String typeId, String typeName) {
@ -31,7 +30,7 @@ public class Class {
public Class(String typeId, String typeName, String typeFlag) { public Class(String typeId, String typeName, String typeFlag) {
this.typeId = typeId; this.typeId = typeId;
this.typeName = typeName; this.typeName = Trans.get(typeName);
this.typeFlag = typeFlag; this.typeFlag = typeFlag;
} }

View File

@ -1,5 +1,6 @@
package com.github.catvod.bean; package com.github.catvod.bean;
import com.github.catvod.utils.Trans;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.util.List; import java.util.List;
@ -15,20 +16,13 @@ public class Filter {
public Filter(String key, String name, List<Value> value) { public Filter(String key, String name, List<Value> value) {
this.key = key; this.key = key;
this.name = name; this.name = Trans.get(name);
this.value = value; this.value = value;
} }
public void setKey(String key) { public void trans() {
this.key = key; name = Trans.get(name);
} for (Value item : value) item.n = Trans.get(item.n);
public void setName(String name) {
this.name = name;
}
public void setValue(List<Value> value) {
this.value = value;
} }
public static class Value { public static class Value {
@ -39,7 +33,7 @@ public class Filter {
private String v; private String v;
public Value(String n, String v) { public Value(String n, String v) {
this.n = n; this.n = Trans.get(n);
this.v = v; this.v = v;
} }
} }

View File

@ -13,6 +13,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class Result { public class Result {
@ -84,7 +85,9 @@ public class Result {
public Result filters(JSONObject object) { public Result filters(JSONObject object) {
if (object == null) return this; if (object == null) return this;
Type listType = new TypeToken<LinkedHashMap<String, List<Filter>>>() {}.getType(); Type listType = new TypeToken<LinkedHashMap<String, List<Filter>>>() {}.getType();
this.filters = new Gson().fromJson(object.toString(), listType); LinkedHashMap<String, List<Filter>> filters = new Gson().fromJson(object.toString(), listType);
for (Map.Entry<String, List<Filter>> entry : filters.entrySet()) for (Filter filter : entry.getValue()) filter.trans();
this.filters = filters;
return this; return this;
} }

View File

@ -1,5 +1,6 @@
package com.github.catvod.bean; package com.github.catvod.bean;
import com.github.catvod.utils.Trans;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
public class Vod { public class Vod {
@ -35,14 +36,14 @@ public class Vod {
} }
public Vod(String vodId, String vodName, String vodPic, String vodRemarks) { public Vod(String vodId, String vodName, String vodPic, String vodRemarks) {
this.vodId = vodId; setVodId(vodId);
this.vodName = vodName; setVodName(vodName);
this.vodPic = vodPic; setVodPic(vodPic);
this.vodRemarks = vodRemarks; setVodRemarks(vodRemarks);
} }
public void setTypeName(String typeName) { public void setTypeName(String typeName) {
this.typeName = typeName; this.typeName = Trans.get(typeName);
} }
public void setVodId(String vodId) { public void setVodId(String vodId) {
@ -50,7 +51,7 @@ public class Vod {
} }
public void setVodName(String vodName) { public void setVodName(String vodName) {
this.vodName = vodName; this.vodName = Trans.get(vodName);
} }
public void setVodPic(String vodPic) { public void setVodPic(String vodPic) {
@ -58,31 +59,31 @@ public class Vod {
} }
public void setVodRemarks(String vodRemarks) { public void setVodRemarks(String vodRemarks) {
this.vodRemarks = vodRemarks; this.vodRemarks = Trans.get(vodRemarks);
} }
public void setVodYear(String vodYear) { public void setVodYear(String vodYear) {
this.vodYear = vodYear; this.vodYear = Trans.get(vodYear);
} }
public void setVodArea(String vodArea) { public void setVodArea(String vodArea) {
this.vodArea = vodArea; this.vodArea = Trans.get(vodArea);
} }
public void setVodActor(String vodActor) { public void setVodActor(String vodActor) {
this.vodActor = vodActor; this.vodActor = Trans.get(vodActor);
} }
public void setVodDirector(String vodDirector) { public void setVodDirector(String vodDirector) {
this.vodDirector = vodDirector; this.vodDirector = Trans.get(vodDirector);
} }
public void setVodContent(String vodContent) { public void setVodContent(String vodContent) {
this.vodContent = vodContent; this.vodContent = Trans.get(vodContent);
} }
public void setVodPlayFrom(String vodPlayFrom) { public void setVodPlayFrom(String vodPlayFrom) {
this.vodPlayFrom = vodPlayFrom; this.vodPlayFrom = Trans.get(vodPlayFrom);
} }
public void setVodPlayUrl(String vodPlayUrl) { public void setVodPlayUrl(String vodPlayUrl) {

View File

@ -7,6 +7,7 @@ import android.os.Looper;
import android.widget.Toast; import android.widget.Toast;
import com.github.catvod.crawler.SpiderDebug; import com.github.catvod.crawler.SpiderDebug;
import com.github.catvod.utils.Trans;
public class Init { public class Init {
@ -32,6 +33,7 @@ public class Init {
public static void init(Context context) { public static void init(Context context) {
SpiderDebug.log("自定義爬蟲代碼載入成功!"); SpiderDebug.log("自定義爬蟲代碼載入成功!");
get().app = ((Application) context); get().app = ((Application) context);
Trans.init();
} }
public static void show(String msg) { public static void show(String msg) {

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -1 +1 @@
b1e298fe19e3e29f2c3c2c8649ef38ae 55f8554f0182282795c202c2dc96f27b