Merge branch 'main' of https://github.com/FongMi/CatVodSpider
This commit is contained in:
commit
28c7ff96ce
|
|
@ -8,7 +8,6 @@ import android.os.Looper;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.utils.Notice;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
|
@ -39,9 +38,8 @@ public class Init {
|
|||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
SpiderDebug.log("自定義爬蟲代碼載入成功!");
|
||||
get().app = ((Application) context);
|
||||
Notice.show("FongMi 天下第一;10");
|
||||
SpiderDebug.log("自定義爬蟲代碼載入成功!");
|
||||
}
|
||||
|
||||
public static void execute(Runnable runnable) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
package com.github.catvod.spider;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.Base64;
|
||||
import android.view.Gravity;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.ui.ScrollTextView;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
public class Notice extends Spider {
|
||||
|
||||
private static final String SPACE = " ";
|
||||
private ScrollTextView view;
|
||||
private String extend;
|
||||
private int duration;
|
||||
private String msg;
|
||||
|
||||
public static void show(String extend) {
|
||||
try {
|
||||
Notice notice = new Notice();
|
||||
notice.init(null, extend);
|
||||
notice.homeContent(false);
|
||||
} 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 = extend.startsWith("http") ? OkHttp.string(extend) : new String(Base64.decode(extend, Base64.DEFAULT));
|
||||
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, 500);
|
||||
return "";
|
||||
}
|
||||
|
||||
private void createView() {
|
||||
createText();
|
||||
createRoot();
|
||||
setColor();
|
||||
hide();
|
||||
}
|
||||
|
||||
private void createText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < 2; i++) sb.append(SPACE).append(msg);
|
||||
view = new ScrollTextView(Init.context());
|
||||
view.setTextSize(20);
|
||||
view.setDuration(duration);
|
||||
view.setText(sb.toString());
|
||||
view.setTypeface(null, Typeface.BOLD);
|
||||
view.setPadding(0, Utils.dp2px(16), 0, Utils.dp2px(16));
|
||||
view.setBackgroundColor(Color.argb(200, 255, 255, 255));
|
||||
view.startScroll();
|
||||
}
|
||||
|
||||
private void createRoot() {
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.gravity = Gravity.TOP;
|
||||
Utils.addView(view, params);
|
||||
}
|
||||
|
||||
private void hide() {
|
||||
Init.run(() -> Utils.removeView(view), duration * 1000);
|
||||
}
|
||||
|
||||
private void setColor() {
|
||||
Init.run(runnable, 500);
|
||||
}
|
||||
|
||||
private final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Random random = new Random();
|
||||
view.setTextColor(Color.argb(255, random.nextInt(128), random.nextInt(128), random.nextInt(128)));
|
||||
setColor();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
package com.github.catvod.utils;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.Gravity;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.github.catvod.spider.Init;
|
||||
import com.github.catvod.ui.ScrollTextView;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Notice {
|
||||
|
||||
private static final String SPACE = " ";
|
||||
private ScrollTextView view;
|
||||
private String text;
|
||||
private int time;
|
||||
|
||||
public static void show(String msg) {
|
||||
new Notice().init(msg);
|
||||
}
|
||||
|
||||
public void init(String extend) {
|
||||
String[] splits = extend.split(";");
|
||||
this.text = splits[0];
|
||||
this.time = splits.length > 1 ? Integer.parseInt(splits[1]) : 30;
|
||||
Init.run(this::createView);
|
||||
}
|
||||
|
||||
private void createView() {
|
||||
createText();
|
||||
createRoot();
|
||||
setColor();
|
||||
hide();
|
||||
}
|
||||
|
||||
private void createText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < 2; i++) sb.append(SPACE).append(text);
|
||||
view = new ScrollTextView(Init.context());
|
||||
view.setTextSize(20);
|
||||
view.setDuration(time);
|
||||
view.setText(sb.toString());
|
||||
view.setTypeface(null, Typeface.BOLD);
|
||||
view.setPadding(0, Utils.dp2px(16), 0, Utils.dp2px(16));
|
||||
view.setBackgroundColor(Color.argb(200, 255, 255, 255));
|
||||
view.startScroll();
|
||||
}
|
||||
|
||||
private void createRoot() {
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.gravity = Gravity.TOP;
|
||||
Utils.addView(view, params);
|
||||
}
|
||||
|
||||
private void hide() {
|
||||
Init.run(() -> Utils.removeView(view), time * 1000);
|
||||
}
|
||||
|
||||
private void setColor() {
|
||||
Init.run(runnable, 500);
|
||||
}
|
||||
|
||||
private final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Random random = new Random();
|
||||
view.setTextColor(Color.argb(255, random.nextInt(128), random.nextInt(128), random.nextInt(128)));
|
||||
setColor();
|
||||
}
|
||||
};
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
1e23f38ff329bcc8c9bdb0f39378d9ac
|
||||
83302c0b9c22927f527219dc290dc6ad
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;1e23f38ff329bcc8c9bdb0f39378d9ac",
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;83302c0b9c22927f527219dc290dc6ad",
|
||||
"wallpaper": "https://gao.chuqiuyu.tk",
|
||||
"sites": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;1e23f38ff329bcc8c9bdb0f39378d9ac",
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;83302c0b9c22927f527219dc290dc6ad",
|
||||
"wallpaper": "http://饭太硬.ga/深色壁纸/api.php",
|
||||
"sites": [
|
||||
{
|
||||
|
|
@ -226,6 +226,15 @@
|
|||
"api": "csp_Push",
|
||||
"searchable": 1,
|
||||
"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": [
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"msg": "FongMi 天下第一",
|
||||
"date": "20230604000000",
|
||||
"duration": 10
|
||||
}
|
||||
Loading…
Reference in New Issue