Update jar
This commit is contained in:
parent
3d0ab8264b
commit
bb0814460d
|
|
@ -39,9 +39,9 @@ public class Init {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(Context context) {
|
public static void init(Context context) {
|
||||||
SpiderDebug.log("自定義爬蟲代碼載入成功!");
|
|
||||||
get().app = ((Application) context);
|
get().app = ((Application) context);
|
||||||
Notice.show("FongMi 天下第一;10");
|
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) {
|
||||||
|
|
|
||||||
|
|
@ -5,27 +5,40 @@ import android.graphics.Typeface;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import com.github.catvod.net.OkHttp;
|
||||||
import com.github.catvod.spider.Init;
|
import com.github.catvod.spider.Init;
|
||||||
import com.github.catvod.ui.ScrollTextView;
|
import com.github.catvod.ui.ScrollTextView;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class Notice {
|
public class Notice {
|
||||||
|
|
||||||
private static final String SPACE = " ";
|
private static final String SPACE = " ";
|
||||||
private ScrollTextView view;
|
private ScrollTextView view;
|
||||||
private String text;
|
private int duration;
|
||||||
private int time;
|
private String msg;
|
||||||
|
|
||||||
public static void show(String msg) {
|
public static void show(String url) {
|
||||||
new Notice().init(msg);
|
new Notice().init(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(String extend) {
|
public void init(String url) {
|
||||||
String[] splits = extend.split(";");
|
try {
|
||||||
this.text = splits[0];
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault());
|
||||||
this.time = splits.length > 1 ? Integer.parseInt(splits[1]) : 30;
|
String json = OkHttp.string(url);
|
||||||
Init.run(this::createView);
|
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);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createView() {
|
private void createView() {
|
||||||
|
|
@ -37,10 +50,10 @@ public class Notice {
|
||||||
|
|
||||||
private void createText() {
|
private void createText() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < 2; i++) sb.append(SPACE).append(text);
|
for (int i = 0; i < 2; i++) sb.append(SPACE).append(msg);
|
||||||
view = new ScrollTextView(Init.context());
|
view = new ScrollTextView(Init.context());
|
||||||
view.setTextSize(20);
|
view.setTextSize(20);
|
||||||
view.setDuration(time);
|
view.setDuration(duration);
|
||||||
view.setText(sb.toString());
|
view.setText(sb.toString());
|
||||||
view.setTypeface(null, Typeface.BOLD);
|
view.setTypeface(null, Typeface.BOLD);
|
||||||
view.setPadding(0, Utils.dp2px(16), 0, Utils.dp2px(16));
|
view.setPadding(0, Utils.dp2px(16), 0, Utils.dp2px(16));
|
||||||
|
|
@ -55,7 +68,7 @@ public class Notice {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hide() {
|
private void hide() {
|
||||||
Init.run(() -> Utils.removeView(view), time * 1000);
|
Init.run(() -> Utils.removeView(view), duration * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setColor() {
|
private void setColor() {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
1e23f38ff329bcc8c9bdb0f39378d9ac
|
388b76449e755e157bf0812c5621bd78
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue