Update jar
This commit is contained in:
parent
3d0ab8264b
commit
bb0814460d
|
|
@ -39,9 +39,9 @@ public class Init {
|
|||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
SpiderDebug.log("自定義爬蟲代碼載入成功!");
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -5,27 +5,40 @@ import android.graphics.Typeface;
|
|||
import android.view.Gravity;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.spider.Init;
|
||||
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;
|
||||
|
||||
public class Notice {
|
||||
|
||||
private static final String SPACE = " ";
|
||||
private ScrollTextView view;
|
||||
private String text;
|
||||
private int time;
|
||||
private int duration;
|
||||
private String msg;
|
||||
|
||||
public static void show(String msg) {
|
||||
new Notice().init(msg);
|
||||
public static void show(String url) {
|
||||
new Notice().init(url);
|
||||
}
|
||||
|
||||
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);
|
||||
public void init(String url) {
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault());
|
||||
String json = OkHttp.string(url);
|
||||
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() {
|
||||
|
|
@ -37,10 +50,10 @@ public class Notice {
|
|||
|
||||
private void createText() {
|
||||
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.setTextSize(20);
|
||||
view.setDuration(time);
|
||||
view.setDuration(duration);
|
||||
view.setText(sb.toString());
|
||||
view.setTypeface(null, Typeface.BOLD);
|
||||
view.setPadding(0, Utils.dp2px(16), 0, Utils.dp2px(16));
|
||||
|
|
@ -55,7 +68,7 @@ public class Notice {
|
|||
}
|
||||
|
||||
private void hide() {
|
||||
Init.run(() -> Utils.removeView(view), time * 1000);
|
||||
Init.run(() -> Utils.removeView(view), duration * 1000);
|
||||
}
|
||||
|
||||
private void setColor() {
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
1e23f38ff329bcc8c9bdb0f39378d9ac
|
||||
388b76449e755e157bf0812c5621bd78
|
||||
|
|
|
|||
Loading…
Reference in New Issue