Update
This commit is contained in:
parent
07c0b7b09b
commit
9922c3060a
|
|
@ -8,7 +8,6 @@ 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.Notice;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -41,7 +40,6 @@ public class Init {
|
||||||
public static void init(Context context) {
|
public static void init(Context context) {
|
||||||
get().app = ((Application) context);
|
get().app = ((Application) context);
|
||||||
SpiderDebug.log("自定義爬蟲代碼載入成功!");
|
SpiderDebug.log("自定義爬蟲代碼載入成功!");
|
||||||
Notice.show("https://raw.githubusercontent.com/FongMi/CatVodSpider/main/json/notice.json");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void execute(Runnable runnable) {
|
public static void execute(Runnable runnable) {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
package com.github.catvod.utils;
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import com.github.catvod.crawler.Spider;
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttp;
|
||||||
import com.github.catvod.spider.Init;
|
|
||||||
import com.github.catvod.ui.ScrollTextView;
|
import com.github.catvod.ui.ScrollTextView;
|
||||||
|
import com.github.catvod.utils.Utils;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
|
@ -16,31 +18,41 @@ import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class Notice {
|
public class Notice extends Spider {
|
||||||
|
|
||||||
private static final String SPACE = " ";
|
private static final String SPACE = " ";
|
||||||
private ScrollTextView view;
|
private ScrollTextView view;
|
||||||
|
private String extend;
|
||||||
private int duration;
|
private int duration;
|
||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
public static void show(String url) {
|
public static void show(String extend) {
|
||||||
new Notice().init(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(String url) {
|
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault());
|
Notice notice = new Notice();
|
||||||
String json = OkHttp.string(url);
|
notice.init(null, extend);
|
||||||
JSONObject object = new JSONObject(json);
|
notice.homeContent(false);
|
||||||
msg = object.optString("msg");
|
|
||||||
duration = object.optInt("duration", 30);
|
|
||||||
String date = object.optString("date");
|
|
||||||
boolean show = msg.length() > 0 && (date.isEmpty() || new Date().after(sdf.parse(date)));
|
|
||||||
if (show) Init.run(this::createView);
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Context context, String extend) {
|
||||||
|
this.extend = extend;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String homeContent(boolean filter) throws Exception {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault());
|
||||||
|
String json = OkHttp.string(extend);
|
||||||
|
JSONObject object = new JSONObject(json);
|
||||||
|
msg = object.optString("msg");
|
||||||
|
duration = object.optInt("duration", 30);
|
||||||
|
String date = object.optString("date");
|
||||||
|
boolean show = msg.length() > 0 && (date.isEmpty() || new Date().after(sdf.parse(date)));
|
||||||
|
if (show) Init.run(this::createView);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
private void createView() {
|
private void createView() {
|
||||||
createText();
|
createText();
|
||||||
createRoot();
|
createRoot();
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
388b76449e755e157bf0812c5621bd78
|
4698f64899d582ca9986f8c45564dd38
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;388b76449e755e157bf0812c5621bd78",
|
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;4698f64899d582ca9986f8c45564dd38",
|
||||||
"wallpaper": "https://gao.chuqiuyu.tk",
|
"wallpaper": "https://gao.chuqiuyu.tk",
|
||||||
"sites": [
|
"sites": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;388b76449e755e157bf0812c5621bd78",
|
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;4698f64899d582ca9986f8c45564dd38",
|
||||||
"wallpaper": "http://饭太硬.ga/深色壁纸/api.php",
|
"wallpaper": "http://饭太硬.ga/深色壁纸/api.php",
|
||||||
"sites": [
|
"sites": [
|
||||||
{
|
{
|
||||||
|
|
@ -226,6 +226,15 @@
|
||||||
"api": "csp_Push",
|
"api": "csp_Push",
|
||||||
"searchable": 1,
|
"searchable": 1,
|
||||||
"changeable": 0
|
"changeable": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "公告",
|
||||||
|
"name": "公告",
|
||||||
|
"type": 3,
|
||||||
|
"api": "csp_Notice",
|
||||||
|
"searchable": 0,
|
||||||
|
"changeable": 0,
|
||||||
|
"ext": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/json/notice.json"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"doh": [
|
"doh": [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue