1.1.48
This commit is contained in:
parent
1329d0b66d
commit
1d536269fe
|
@ -11,7 +11,7 @@ android {
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "2.1.46-3568"
|
versionName "2.1.48"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -357,8 +357,10 @@ public class Prog extends AbsLayout {
|
||||||
} else if(src.type.equals("DigitalClock")) src.view = new SrcDigitalClock(this, source);
|
} else if(src.type.equals("DigitalClock")) src.view = new SrcDigitalClock(this, source);
|
||||||
else if(src.type.startsWith("DigitalClock")) src.view = new SrcDigiClock(this, source);
|
else if(src.type.startsWith("DigitalClock")) src.view = new SrcDigiClock(this, source);
|
||||||
else if(src.type.equals("AnalogClock")) src.view = new SrcAnaClock(this, geo.width, geo.height, Util.programDir + "/" + id, source);
|
else if(src.type.equals("AnalogClock")) src.view = new SrcAnaClock(this, geo.width, geo.height, Util.programDir + "/" + id, source);
|
||||||
else if(src.type.equals("WebURL")) src.view = new SrcWeb(this, source);
|
else if(src.type.equals("WebURL")) {
|
||||||
else if(src.type.equals("Timer")) src.view = new SrcTimer(this, source);
|
var url = source.str("url");
|
||||||
|
if(url!=null) src.view = new SrcWeb(this, url, source);
|
||||||
|
} else if(src.type.equals("Timer")) src.view = new SrcTimer(this, source);
|
||||||
else if(src.type.equals("Countdown")) src.view = new SrcCountdown(this, source);
|
else if(src.type.equals("Countdown")) src.view = new SrcCountdown(this, source);
|
||||||
else if(src.type.startsWith("Environ")) src.view = new SrcEnviron(this, source);
|
else if(src.type.startsWith("Environ")) src.view = new SrcEnviron(this, source);
|
||||||
else if(src.type.startsWith("Weather")) src.view = new SrcWeather(context, source);
|
else if(src.type.startsWith("Weather")) src.view = new SrcWeather(context, source);
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class SrcEnviron extends View implements Choreographer.FrameCallback, Int
|
||||||
try {
|
try {
|
||||||
for(var item : items) {
|
for(var item : items) {
|
||||||
item.nums.clear();
|
item.nums.clear();
|
||||||
if(item.unit==null) {
|
if(item.key.startsWith("windDir")) {
|
||||||
var num = intent.getIntExtra(item.key, -1);
|
var num = intent.getIntExtra(item.key, -1);
|
||||||
if(num>=0 && num<=15) {
|
if(num>=0 && num<=15) {
|
||||||
if(directs[num].length() < 3) item.nums.add(imgMap.get(directs[num]));
|
if(directs[num].length() < 3) item.nums.add(imgMap.get(directs[num]));
|
||||||
|
|
|
@ -14,6 +14,7 @@ import gnph.util.URLConn;
|
||||||
public class SrcVisitor extends WebView implements Choreographer.FrameCallback {
|
public class SrcVisitor extends WebView implements Choreographer.FrameCallback {
|
||||||
|
|
||||||
String html, lineHeight, prefix, url;
|
String html, lineHeight, prefix, url;
|
||||||
|
int interval;
|
||||||
|
|
||||||
public SrcVisitor(Prog prog, JSMap json) {
|
public SrcVisitor(Prog prog, JSMap json) {
|
||||||
super(prog.getContext());
|
super(prog.getContext());
|
||||||
|
@ -24,6 +25,7 @@ public class SrcVisitor extends WebView implements Choreographer.FrameCallback {
|
||||||
html = json.stnn("html").replace("%{yesterday.", "%{arr.-1.");
|
html = json.stnn("html").replace("%{yesterday.", "%{arr.-1.");
|
||||||
lineHeight = json.str("lineHeight");
|
lineHeight = json.str("lineHeight");
|
||||||
url = json.str("url");
|
url = json.str("url");
|
||||||
|
interval = json.intg("interval", 15)*1000;
|
||||||
if(url!=null) {
|
if(url!=null) {
|
||||||
var token = json.str("token");
|
var token = json.str("token");
|
||||||
if(token!=null) url += "?dataKey="+token;
|
if(token!=null) url += "?dataKey="+token;
|
||||||
|
@ -88,7 +90,7 @@ public class SrcVisitor extends WebView implements Choreographer.FrameCallback {
|
||||||
public void doFrame(long ms) {
|
public void doFrame(long ms) {
|
||||||
if(! isShown()) return;
|
if(! isShown()) return;
|
||||||
if(ms>=nextMs) {
|
if(ms>=nextMs) {
|
||||||
nextMs = ms + 15000;
|
nextMs = ms + interval;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,17 @@ package com.xixun.xixunplayer;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.http.SslError;
|
import android.net.http.SslError;
|
||||||
|
import android.os.Build;
|
||||||
import android.view.Choreographer;
|
import android.view.Choreographer;
|
||||||
import android.webkit.SslErrorHandler;
|
import android.webkit.SslErrorHandler;
|
||||||
|
import android.webkit.WebResourceError;
|
||||||
|
import android.webkit.WebResourceRequest;
|
||||||
|
import android.webkit.WebResourceResponse;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import gnph.util.JSMap;
|
import gnph.util.JSMap;
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
@SuppressLint("ViewConstructor")
|
||||||
|
@ -15,10 +21,12 @@ public class SrcWeb extends WebView implements Choreographer.FrameCallback {
|
||||||
|
|
||||||
String url;
|
String url;
|
||||||
int refresh;
|
int refresh;
|
||||||
|
ArrayList<Choreographer.FrameCallback> calls;
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
public SrcWeb(Prog prog, JSMap json) {
|
public SrcWeb(Prog prog, String url, JSMap json) {
|
||||||
super(prog.getContext());
|
super(prog.getContext());
|
||||||
|
this.url = url;
|
||||||
var settings = getSettings();
|
var settings = getSettings();
|
||||||
settings.setJavaScriptEnabled(true);
|
settings.setJavaScriptEnabled(true);
|
||||||
settings.setDomStorageEnabled(true);
|
settings.setDomStorageEnabled(true);
|
||||||
|
@ -41,27 +49,45 @@ public class SrcWeb extends WebView implements Choreographer.FrameCallback {
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
view.loadUrl("javascript:window.scrollTo("+json.str("offX", "0")+", "+json.str("offY", "0")+")");
|
view.loadUrl("javascript:window.scrollTo("+json.str("offX", "0")+", "+json.str("offY", "0")+")");
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
||||||
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
if(request.isForMainFrame() && error.getErrorCode()==-2 && request.getUrl().toString().equals(url)) needReload = true;
|
||||||
|
Util.println(" WebView ReceivedError "+error.getErrorCode()+" "+error.getDescription()+"; isForMainFrame "+request.isForMainFrame()+" URL "+request.getUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||||
|
Util.println(" WebView ReceivedHttpError "+errorResponse.getStatusCode()+"; isForMainFrame "+request.isForMainFrame()+" URL "+request.getUrl());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
loadUrl(url = json.str("url"));
|
loadUrl(url);
|
||||||
refresh = json.intg("refreshSec")*1000;
|
refresh = json.intg("refreshSec")*1000;
|
||||||
if(Util.custom==Util.Custom.Yishi) {
|
if(refresh==0 || Util.custom!=Util.Custom.Yishi) this.calls = prog.calls;
|
||||||
prog.calls.add(this);
|
prog.calls.add(this);
|
||||||
} else {
|
|
||||||
if(refresh>0 && url!=null) prog.calls.add(this);
|
|
||||||
}
|
|
||||||
nextMs = System.currentTimeMillis() + refresh;
|
nextMs = System.currentTimeMillis() + refresh;
|
||||||
}
|
}
|
||||||
|
|
||||||
long nextMs;
|
long nextMs;
|
||||||
int w, h;
|
int cnt, w, h;
|
||||||
|
boolean needReload;
|
||||||
@Override
|
@Override
|
||||||
public void doFrame(long ms) {
|
public void doFrame(long ms) {
|
||||||
if(! isShown()) return;
|
if(! isShown()) return;
|
||||||
|
|
||||||
if(Util.custom==Util.Custom.Yishi) {
|
if(Util.custom==Util.Custom.Yishi) {
|
||||||
if(refresh>0 && url!=null && ms>=nextMs) {
|
if(refresh > 0) {
|
||||||
nextMs = ms + refresh;
|
if(ms>=nextMs) {
|
||||||
loadUrl(url);
|
nextMs = ms + refresh;
|
||||||
|
loadUrl(url);
|
||||||
|
}
|
||||||
|
} else if(++cnt>=600) {
|
||||||
|
cnt = 0;
|
||||||
|
if(needReload) {
|
||||||
|
needReload = false;
|
||||||
|
loadUrl(url);
|
||||||
|
Util.println(" WebView Refreshed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(Util.screenWidth!=w || Util.screenHeight!=h) {
|
if(Util.screenWidth!=w || Util.screenHeight!=h) {
|
||||||
w = Util.screenWidth;
|
w = Util.screenWidth;
|
||||||
|
@ -70,9 +96,21 @@ public class SrcWeb extends WebView implements Choreographer.FrameCallback {
|
||||||
setLayoutParams(new AbsLayout.LayoutParams(0, 0, w, h));
|
setLayoutParams(new AbsLayout.LayoutParams(0, 0, w, h));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(ms>=nextMs) {
|
if(refresh > 0) {
|
||||||
nextMs = ms + refresh;
|
if(ms>=nextMs) {
|
||||||
loadUrl(url);
|
nextMs = ms + refresh;
|
||||||
|
loadUrl(url);
|
||||||
|
}
|
||||||
|
} else if(++cnt>=600) {
|
||||||
|
cnt = 0;
|
||||||
|
if(needReload) {
|
||||||
|
needReload = false;
|
||||||
|
loadUrl(url);
|
||||||
|
Util.println(" WebView Refreshed");
|
||||||
|
} else if(calls!=null) {
|
||||||
|
calls.remove(this);
|
||||||
|
calls = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user