diff --git a/XixunPlayer/app/build.gradle b/XixunPlayer/app/build.gradle index 009676e..411b680 100644 --- a/XixunPlayer/app/build.gradle +++ b/XixunPlayer/app/build.gradle @@ -11,7 +11,7 @@ android { minSdk 21 targetSdk 34 versionCode 1 - versionName "2.1.2" + versionName "2.1.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/Prog.java b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/Prog.java index 0deb6da..900bbf2 100644 --- a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/Prog.java +++ b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/Prog.java @@ -3,8 +3,10 @@ package com.xixun.xixunplayer; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; +import android.graphics.Canvas; import android.graphics.Color; import android.net.Uri; +import android.os.CountDownTimer; import android.speech.tts.TextToSpeech; import android.view.Choreographer; import android.view.View; @@ -332,8 +334,23 @@ public class Prog extends AbsLayout { var www = width + hhh; webView.getLayoutParams().width = www; view.imgs.set(0, Bitmap.createBitmap(www, hhh, Bitmap.Config.ARGB_8888)); - box.addView(webView); - view.webView = webView; + addView(webView); + var atimer = new CountDownTimer(500, 500) { + @Override + public void onTick(long millisUntilFinished) {} + @Override + public void onFinish() { + var canvas = new Canvas(view.imgs.get(0)); + webView.draw(canvas); + webView.setVisibility(GONE); + view.freshCnt = view.cur = 0; + if(view.effect=='l') view.end = -(view.imgs.get(0).getWidth()-view.step); + else if(view.effect=='r') view.end = view.imgs.get(0).getWidth()-view.step; + view.invalidate(); + } + }; + if(isShown()) atimer.start(); + else timer = atimer; }); } }, "java"); @@ -343,6 +360,8 @@ public class Prog extends AbsLayout { if(src.view==null) continue; src.view.setVisibility(GONE); src.view.setLayoutParams(geo); + src.scaleX = (float) source.dbl("scaleX", 1); + src.scaleY = (float) source.dbl("scaleY", 1); box.addView(src.view); layer.srcs.add(src); src = new Source(); @@ -395,10 +414,21 @@ public class Prog extends AbsLayout { Util.printStackTrace(e); } } - + CountDownTimer timer; + @Override + public void onVisibilityAggregated(boolean isVisible) { + super.onVisibilityAggregated(isVisible); + if(isVisible) { + if(timer!=null) { + timer.start(); + timer = null; + } + } + } public static class Source { View view; + float scaleX = 1, scaleY = 1; long startMilli, endMilli = Long.MAX_VALUE; int startTime, entryDur, exitStart = Integer.MAX_VALUE, exitDur, endTime, ff; Effect entryEff, exitEff; @@ -556,8 +586,8 @@ public class Prog extends AbsLayout { view.setTranslationX(0); view.setTranslationY(0); view.setAlpha(1); - view.setScaleX(1); - view.setScaleY(1); + view.setScaleX(scaleX); + view.setScaleY(scaleY); view.setRotation(0); } } diff --git a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcEnviron.java b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcEnviron.java index 662a298..a8ca205 100644 --- a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcEnviron.java +++ b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcEnviron.java @@ -51,17 +51,36 @@ public class SrcEnviron extends View implements Choreographer.FrameCallback, Int } catch (Exception ignored) {} var values = json.jsmap("values"); if(values!=null) { - title = BitmapFactory.decodeFile(Util.programDir+"/"+json.stnn("title")); - var entrys = values.entrySet(); - for(var entry : entrys) imgMap.put(entry.getKey(), BitmapFactory.decodeFile(Util.programDir+"/"+entry.getValue())); - JSList jitems = json.jslist("items"); - for(var jitem : jitems) { - var unit = jitem.str("unit"); - items.add(new Item(jitem.str("name"), BitmapFactory.decodeFile(Util.programDir + "/" + jitem.stnn("label")), unit == null ? null : BitmapFactory.decodeFile(Util.programDir + "/" + unit))); + if(values.get("0") instanceof String) { + var titleStr = json.str("title"); + if(titleStr!=null) title = BitmapFactory.decodeFile(Util.programDir+"/"+titleStr); + var entrys = values.entrySet(); + for(var entry : entrys) imgMap.put(entry.getKey(), BitmapFactory.decodeFile(Util.programDir+"/"+entry.getValue())); + JSList jitems = json.jslist("items"); + for(var jitem : jitems) { + var unit = jitem.str("unit"); + items.add(new Item(jitem.str("name"), BitmapFactory.decodeFile(Util.programDir + "/" + jitem.stnn("label")), unit == null ? null : BitmapFactory.decodeFile(Util.programDir + "/" + unit))); + } + } else { + var big = BitmapFactory.decodeFile(Util.programDir+"/"+json.stnn("id")); + var titleGeo = json.jsmap("title"); + if(titleGeo!=null) title = Bitmap.createBitmap(big, titleGeo.intg("x"), titleGeo.intg("y"), titleGeo.intg("w"), titleGeo.intg("h")); + var entrys = values.entrySet(); + for(var entry : entrys) { + var val = (JSMap) entry.getValue(); + imgMap.put(entry.getKey(), Bitmap.createBitmap(big, val.intg("x"), val.intg("y"), val.intg("w"), val.intg("h"))); + } + JSList jitems = json.jslist("items"); + for(var jitem : jitems) { + var label = jitem.jsmap("label"); + var unit = jitem.jsmap("unit"); + items.add(new Item(jitem.str("name"), Bitmap.createBitmap(big, label.intg("x"), label.intg("y"), label.intg("w"), label.intg("h")), unit == null ? null : Bitmap.createBitmap(big, unit.intg("x"), unit.intg("y"), unit.intg("w"), unit.intg("h")))); + } } } else { JSList pics = json.jslist("arrayPics"); - if(pics!=null && ! pics.isEmpty() && pics.get(0).containsKey("startX")) { + if(pics==null) return; + if(! pics.isEmpty() && pics.get(0).containsKey("startX")) { var big = BitmapFactory.decodeFile(Util.programDir+"/"+json.stnn("id")); for(var pic : pics) { var startX = pic.intg("startX"); diff --git a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcScroll.java b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcScroll.java index 648ecdb..dce12f1 100644 --- a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcScroll.java +++ b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcScroll.java @@ -7,7 +7,6 @@ import android.graphics.Canvas; import android.graphics.Rect; import android.view.Choreographer; import android.view.View; -import android.webkit.WebView; import androidx.annotation.NonNull; @@ -21,7 +20,6 @@ public class SrcScroll extends View implements Choreographer.FrameCallback { ArrayList imgs = new ArrayList<>(); Rect rect = new Rect(); int interval, cur, end, step; - WebView webView; char effect; public SrcScroll(Prog prog, JSMap json, Bitmap img) { @@ -58,21 +56,11 @@ public class SrcScroll extends View implements Choreographer.FrameCallback { } if(effect!=0) prog.calls.add(this); } - int aaaaaa; @Override protected void onDraw(@NonNull Canvas canvas) { super.onDraw(canvas); if(imgs.isEmpty()) return; try { - if(webView!=null && aaaaaa++>30) { - var canva = new Canvas(imgs.get(0)); - webView.draw(canva); - webView.setVisibility(GONE); - webView = null; - freshCnt = cur = 0; - if(effect=='l') end = -(imgs.get(0).getWidth()-step); - else if(effect=='r') end = imgs.get(0).getWidth()-step; - } drawOther(canvas); } catch (Throwable e) { setVisibility(GONE);