From 16afebf0609af0f024baf5f76f1853d8fe82baf2 Mon Sep 17 00:00:00 2001 From: duqingquan-jpc Date: Wed, 28 Dec 2022 19:31:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9lottie=20=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E4=B8=BA=20=E9=A1=B9=E7=9B=AEstatic=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utssdk/app-android/assets => static}/anim_a.json | 0 .../utssdk/app-android/assets => static}/anim_b.json | 0 .../uts-animation-view/utssdk/app-android/index.vue | 10 +++++++--- 3 files changed, 7 insertions(+), 3 deletions(-) rename {uni_modules/uts-animation-view/utssdk/app-android/assets => static}/anim_a.json (100%) rename {uni_modules/uts-animation-view/utssdk/app-android/assets => static}/anim_b.json (100%) diff --git a/uni_modules/uts-animation-view/utssdk/app-android/assets/anim_a.json b/static/anim_a.json similarity index 100% rename from uni_modules/uts-animation-view/utssdk/app-android/assets/anim_a.json rename to static/anim_a.json diff --git a/uni_modules/uts-animation-view/utssdk/app-android/assets/anim_b.json b/static/anim_b.json similarity index 100% rename from uni_modules/uts-animation-view/utssdk/app-android/assets/anim_b.json rename to static/anim_b.json diff --git a/uni_modules/uts-animation-view/utssdk/app-android/index.vue b/uni_modules/uts-animation-view/utssdk/app-android/index.vue index 310ad08..70ee829 100644 --- a/uni_modules/uts-animation-view/utssdk/app-android/index.vue +++ b/uni_modules/uts-animation-view/utssdk/app-android/index.vue @@ -9,7 +9,8 @@ import View from 'android.view.View' import LottieAnimationView from 'com.airbnb.lottie.LottieAnimationView' import LottieDrawable from 'com.airbnb.lottie.LottieDrawable' - + import FileInputStream from 'java.io.FileInputStream' + import { UTSAndroid } from "io.dcloud.uts"; class CustomAnimListener extends Animator.AnimatorListener { @@ -90,11 +91,14 @@ if(this.$el != null){ let lottieAnimationView = this.$el! if (!TextUtils.isEmpty(newPath)) { + + if (newPath.startsWith("http://") || newPath.startsWith("https://")) { lottieAnimationView.setAnimationFromUrl(newPath) } else { - // 默认是asset了 - lottieAnimationView.setAnimation(newPath) + // 默认是static了 + var realJsonPath = UTSAndroid.getResourcePath("static/" + newPath) + lottieAnimationView.setAnimation(new FileInputStream(realJsonPath),newPath) } } if (this.autoplay) { -- GitLab