This commit is contained in:
Gangphon 2024-06-26 18:36:33 +08:00
parent d6917767b4
commit 25af5d918f
4 changed files with 63 additions and 26 deletions

View File

@ -11,7 +11,7 @@ android {
minSdk 21
targetSdk 34
versionCode 1
versionName "2.1.2"
versionName "2.1.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -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);
}
}

View File

@ -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<JSMap> 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<JSMap> 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<JSMap> 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<JSMap> 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");

View File

@ -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<Bitmap> 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);