Compare commits

..

59 Commits

Author SHA1 Message Date
Martin
fc78fd9d1d 优化 2024-08-08 16:44:07 +08:00
Martin
8ddaf20e4f 中英文翻译问题 2024-08-07 09:27:02 +08:00
Martin
6e08a8db35 中英文图片问题 2024-08-06 09:35:53 +08:00
Martin
d61d142ec1 优化[社区评论排版]
修复[官方通知-“點擊查看”-英文翻譯]
2024-08-05 14:27:52 +08:00
Martin
27c2261fac 刪除多餘的strings文件 2024-08-05 14:09:10 +08:00
Martin
730f681f31 处理合并pd代码后,strings文件错乱问题 2024-08-05 13:40:54 +08:00
Martin
1c3c0badfc Merge branch 'refs/heads/新潘多拉_6.9.0_合并PD' into 新潘多拉
# Conflicts:
#	config.gradle
#	live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java
2024-08-02 17:27:39 +08:00
Martin
3493a58590 去除无引用文件
修复一下问题:
1.心愿单
2.开播通知问题
3.头像框闪烁问题
2024-08-02 17:20:20 +08:00
Martin
fb7998a42d 优化官方通知标题显示样式 2024-08-01 16:55:00 +08:00
Martin
f157a5862d 合并6.8.0代码 2024-08-01 13:08:08 +08:00
Martin
c3ffb658c8 修复单人PK,弹出多个弹窗问题 2024-07-29 18:28:35 +08:00
Martin
807827564b 修复单人PK,弹出多个弹窗问题 2024-07-29 16:52:57 +08:00
Martin
59712d0da9 优化PK过程中关播问题 2024-07-29 14:04:44 +08:00
Martin
60e82fa8e4 主播端展示天梯赛信息 2024-07-29 13:45:24 +08:00
Martin
b37d278ae4 解决关播闪退问题 2024-07-29 13:28:50 +08:00
fc7f949f7a 调整跳转消息页方法 2024-07-27 12:13:23 +08:00
5f107fef25 修复缺少的接口请求
修复消息列表数组下标越界问题
2024-07-27 11:14:30 +08:00
Martin
05f1bc6e20 Merge remote-tracking branch 'origin/新潘多拉_6.9.0' into 新潘多拉_6.9.0 2024-07-26 18:39:54 +08:00
Martin
d167ae82b4 6.9.0 2024-07-26 18:38:53 +08:00
18142669586
f9b0d33f6e 升级34版本,以及谷歌内购7.0版本 2024-07-26 15:39:14 +08:00
18142669586
47a8e7f473 修复用户开播提示初始化未成功 2024-07-26 15:37:45 +08:00
Martin
5d0f29db42 直播间消息列表 2024-07-23 17:46:35 +08:00
520491a804 修复声网下播后小窗还有流的问题 2024-07-22 18:21:25 +08:00
b5d4b88753 同步PD代码 2024-07-22 13:28:09 +08:00
18142669586
b9891367ad 升级34版本,以及谷歌内购7.0版本 2024-07-10 15:04:24 +08:00
88d438695e 更新融云IM版本 5.6.10→5.7.0 2024-07-10 14:33:02 +08:00
a372bdcda6 Merge remote-tracking branch 'origin/新潘多拉' into 新潘多拉 2024-07-10 14:32:39 +08:00
2d3f1064b3 同步PD:日志系统
同步PD:6.7.1
2024-07-10 09:42:54 +08:00
6f7e5b123a 同步PD:日志系统 2024-07-10 09:41:58 +08:00
cff607eabb udpate 2024-07-04 13:44:39 +08:00
acf20107c1 调整注册后首次弹窗时间 2024-06-21 18:11:45 +08:00
de8d5d78ff 同步PD修复内容:
[修复首页English分类下,下拉刷新没有数据问题]
同步PD打包脚本
2024-06-20 18:04:54 +08:00
0ff76e1e47 同步PD修复内容:
fix[修復小窗播放白屏問題]
潘多拉:
调整回融云拦截声音&震动
消息通知调用声音&震动
2024-06-19 15:24:37 +08:00
65b045ca61 同步PD修复内容:
FIX[修复BUG]
2024-06-18 19:24:23 +08:00
08804a45d6 同步PD修复内容:
修复整蛊设置连击数有xN的字符
修复PK时整蛊观众端联系方式会闪动问题
2024-06-18 18:36:39 +08:00
2f52ff9124 同步PD修复内容:
add[新增添加整蠱禮物提示]
2024-06-18 18:34:57 +08:00
38a63230eb 同步PD整蛊内容
同步PD修复内容
调整进游戏房就关掉小窗
2024-06-18 14:46:41 +08:00
a1635151dc 调整测试反馈问题 2024-06-17 11:28:58 +08:00
96cfadd335 同步PD:
修复暂时离开功能无效问题
调整购买守护的动画效果
2024-06-16 11:09:45 +08:00
4c9f3d9936 新增打招呼弹窗震动&声音
同步PD修复问题:
修复:
1:开播闪屏问题
2:游戏房消息重复(或不显示)
3:模拟器或部分机型滑动声网直播间会白屏问题
4:PK条在平板模式下显示太高问题
5:PK没断开能收到其他人邀请的问题
2024-06-16 11:05:48 +08:00
d09b01dbad add[主播b账号-消息设置,设置后需支持重置取消] 2024-06-13 12:53:38 +08:00
0d49654adf add[生日往前选择1900(当前最多可选到1990年)] 2024-06-13 09:41:31 +08:00
7a5d2b90d8 add[打招呼弹窗是否取消可配置,后台新增配置开关。] 2024-06-12 14:52:30 +08:00
7b6eb7bbed add[收到消息时(包括弹窗和消息)需出现提示音+手机震动] 2024-06-12 14:41:01 +08:00
d7ea130f86 同步PD问题:
修复游戏房发言重复/不显示问题
修复贵族不显示英文问题
2024-06-07 16:59:39 +08:00
c263e3543c 6.7.0谷歌送审版本 2024-06-07 10:39:47 +08:00
4628079ac7 新增新用户注册后FirebaseAnalytics.logEvent调用
尝试修复美颜会闪屏问题(待观察)
修复跨机子设置备注不显示在列表上的问题
修复聊天列表会出现PK消息的问题
2024-06-06 15:30:17 +08:00
405909f3b3 合并声网代码 2024-06-05 17:55:05 +08:00
c926037cb6 调整进入直播间等待时长15→4 2024-05-23 13:05:46 +08:00
403b4c2aa3 6.6.9版本 2024-05-21 12:58:06 +08:00
4513d8495f 修复33000 2024-05-09 14:12:41 +08:00
cc355b0177 移除友盟SDK 2024-05-08 13:05:16 +08:00
b2da6e4ea1 同步PD 2024-05-08 11:19:51 +08:00
dc652050ac Merge branch 'dev_改版主分支-升级融云SDK&AGP8' into 新潘多拉 2024-05-06 16:36:15 +08:00
4298ff2dae 修复消息页面头像显示不正常/无法点进聊天页的问题 2024-05-06 16:34:56 +08:00
4695e040a1 调整gradle打包脚本 2024-05-06 14:42:31 +08:00
0a87f300b4 Merge branch 'dev_改版主分支-升级融云SDK&AGP8' into 新潘多拉 2024-05-06 13:44:31 +08:00
18142669586
c3aa0d5c12 1 2024-05-06 13:36:50 +08:00
d9d5cf7046 修复 直播间跳转其他人直播间失败(上上周问题) 2024-04-22 13:56:26 +08:00
1838 changed files with 58138 additions and 17924 deletions

View File

@ -8,7 +8,7 @@ plugins {
id 'kotlin-parcelize'
id 'img-optimizer'
}
apply from: "../package_config.gradle"
android {
namespace "com.yunbao.faceunity"
@ -39,6 +39,7 @@ android {
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
//abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
abiFilters "armeabi-v7a", "arm64-v8a"
}
}
@ -72,10 +73,10 @@ dependencies {
implementation rootProject.ext.dependencies["recyclerview-androidx"]
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//common
implementation project(path: ':common')
api project(path: ':common')
implementation 'com.faceunity:core:8.3.1'
implementation 'com.faceunity:model:8.3.1'
api 'com.faceunity:core:8.7.0'
api 'com.faceunity:model:8.7.0'
//implementation 'com.faceunity:nama:8.3.1' //-

View File

@ -1,26 +0,0 @@
package com.yunbao.faceunity;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.yunbao.faceunity.test", appContext.getPackageName());
}
}

View File

@ -96,11 +96,17 @@ public class FaceManager implements SensorEventListener {
faceUnityView.setIFaceUnityInter(new FaceUnityView.IFaceUnityInter() {
@Override
public void onPause() {
if(onMirrorChanged!=null){
onMirrorChanged.onChange(false);
}
pauseFace = true;
}
@Override
public void onStart() {
if(onMirrorChanged!=null){
onMirrorChanged.onChange(true);
}
pauseFace = false;
}
});
@ -295,7 +301,18 @@ public class FaceManager implements SensorEventListener {
}
OnMirrorChanged onMirrorChanged;
public void setOnMirrorChanged(OnMirrorChanged onMirrorChanged) {
this.onMirrorChanged = onMirrorChanged;
}
public interface FaceStatusChanged {
void onFaceChanged(int num);
}
public interface OnMirrorChanged{
void onChange(boolean falg);
}
}

View File

@ -52,10 +52,10 @@ public class FURenderer extends IFURenderer {
/* 特效FURenderKit*/
private FURenderKit mFURenderKit;
public FURenderKit mFURenderKit;
/* AI道具*/
public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor_lite.bundle";
public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor.bundle";
public static String BUNDLE_AI_HUMAN = "model" + File.separator + "ai_human_processor.bundle";
/* GL 线程 ID */

View File

@ -15,7 +15,7 @@ public class FaceUnityConfig {
/************************** 算法Model ******************************/
// 人脸识别
public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor_lite.bundle";
public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor.bundle";
// 手势
public static String BUNDLE_AI_HAND = "model" + File.separator + "ai_hand_processor.bundle";

View File

@ -13,7 +13,7 @@ import com.google.gson.JsonObject;
import com.yunbao.faceunity.entity.net.FineStickerEntity;
import com.yunbao.faceunity.utils.FaceUnityData;
import com.yunbao.faceunity.utils.FileUtils;
import com.yunbao.faceunity.utils.ZipUtils;
import com.yunbao.common.utils.ZipUtils;
import java.io.File;
import java.util.ArrayList;

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/main_color" android:state_checked="true" />
<item android:color="@color/main_color" android:state_selected="true" />
<item android:color="@android:color/white" />
</selector>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="10dp" />
<solid android:color="@android:color/white" />
</shape>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp" />
<gradient
android:endColor="#682EB8"
android:startColor="#7D219E" />
</shape>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
</shape>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="4dp"
android:topLeftRadius="4dp" />
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
</shape>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="4dp"
android:topLeftRadius="4dp" />
<solid android:color="@android:color/white" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
</shape>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bg_radio_left_check" android:state_checked="true" />
<item android:drawable="@drawable/bg_radio_left" />
</selector>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
</shape>
</item>
<item>
<layer-list >
<item
android:left="-1dp" >
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
</shape>
</item>
</layer-list>
</item>
</selector>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:left="-1dp">
<shape android:shape="rectangle">
<corners
android:bottomRightRadius="4dp"
android:topRightRadius="4dp" />
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
</shape>
</item>
</layer-list>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomRightRadius="4dp"
android:topRightRadius="4dp" />
<solid android:color="@android:color/white" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
</shape>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bg_radio_right_check" android:state_checked="true" />
<item android:drawable="@drawable/bg_radio_right" />
</selector>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@android:id/background"
android:drawable="@mipmap/bg_live_seek_bar_light" />
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<solid android:color="#00FFFFFF" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="#00FFFFFF" />
</shape>
</clip>
</item>
</layer-list>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#BD050F14" />
<corners android:radius="4dp" />
</shape>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/icon_beauty_box_style_none_checked" android:state_selected="true" />
<item android:drawable="@mipmap/icon_beauty_box_style_none_normal" />
</selector>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/icon_green_smooth_open_checked" android:state_selected="true" />
<item android:drawable="@mipmap/icon_green_smooth_open_normal" />
</selector>

View File

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="281dp"
android:layout_height="147dp"
android:background="@drawable/bg_confirm_dialog">
<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="39dp"
android:gravity="center"
android:text="@string/dialog_confirm_delete"
android:textColor="@color/btn_live_photo_text"
android:layout_centerHorizontal="true"
android:textSize="15sp" />
<View
android:layout_width="265dp"
android:layout_height="1dp"
android:layout_marginTop="97dp"
android:background="@color/divider_line_color"
android:layout_centerHorizontal="true"/>
<View
android:layout_width="1dp"
android:layout_height="34dp"
android:layout_marginBottom="7dp"
android:background="@color/divider_line_color"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true" />
<TextView
android:id="@+id/tv_cancel"
android:layout_width="140dp"
android:layout_height="48dp"
android:gravity="center"
android:text="@string/cancel"
android:textColor="@color/btn_live_photo_text"
android:textSize="16sp"
android:layout_alignParentBottom="true"/>
<TextView
android:id="@+id/tv_confirm"
android:layout_width="140dp"
android:layout_height="48dp"
android:gravity="center"
android:text="@string/confirm"
android:textColor="@color/main_color"
android:textSize="16sp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>

View File

@ -1,64 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lyt_bottom"
android:layout_width="match_parent"
android:layout_height="@dimen/x266"
android:background="@color/primary_list"
android:gravity="bottom"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/x167"
android:layout_gravity="center_vertical"
android:background="@color/primary_list"
android:gravity="center_vertical"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/x1"
android:background="@color/divider_line_color" />
<com.yunbao.faceunity.checkbox.CheckGroup
android:id="@+id/rg_anim"
android:layout_width="match_parent"
android:layout_height="@dimen/x98"
android:background="@color/primary_list">
<com.yunbao.faceunity.checkbox.CheckBoxCompat
android:id="@+id/cb_animoji"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/transparent"
android:button="@null"
android:checked="true"
android:gravity="center"
android:text="@string/animoji_filter"
android:textColor="@color/bottom_radio_color"
android:textSize="@dimen/text_size_26" />
<com.yunbao.faceunity.checkbox.CheckBoxCompat
android:id="@+id/cb_filter"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/transparent"
android:button="@null"
android:gravity="center"
android:text="@string/cartoon_filter"
android:textColor="@color/bottom_radio_color"
android:textSize="@dimen/text_size_26" />
</com.yunbao.faceunity.checkbox.CheckGroup>
</LinearLayout>

View File

@ -1,81 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cyt_main"
android:layout_width="match_parent"
android:layout_height="@dimen/x268"
android:background="#BD050F14"
android:gravity="center_horizontal"
android:orientation="vertical">
<com.yunbao.faceunity.seekbar.DiscreteSeekBar
android:id="@+id/beauty_seek_bar"
android:layout_width="@dimen/x528"
android:layout_height="@dimen/x48"
android:layout_marginTop="@dimen/x24"
android:layout_marginBottom="@dimen/x16"
app:dsb_indicatorColor="@color/main_color"
app:dsb_indicatorElevation="0dp"
app:dsb_indicatorPopupEnabled="true"
app:dsb_max="100"
app:dsb_min="0"
app:dsb_progressColor="@color/main_color"
app:dsb_rippleColor="@color/main_color"
app:dsb_scrubberHeight="@dimen/x4"
app:dsb_thumbSize="@dimen/x32"
app:dsb_trackBaseHeight="@dimen/x16"
app:dsb_trackColor="@color/colorWhite"
app:dsb_trackHeight="@dimen/x4"
app:dsb_value="0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/x180"
android:layout_gravity="bottom"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/lyt_beauty_recover"
android:layout_width="@dimen/x132"
android:layout_height="@dimen/x180"
android:layout_gravity="bottom"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_beauty_recover"
android:layout_width="@dimen/x88"
android:layout_height="@dimen/x88"
android:layout_marginBottom="@dimen/x18"
android:scaleType="centerInside"
android:src="@mipmap/icon_control_recover" />
<TextView
android:id="@+id/tv_beauty_recover"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/x30"
android:gravity="center_vertical"
android:text="@string/recover"
android:textColor="@color/tv_main_color_selector"
android:textSize="@dimen/text_size_20" />
</LinearLayout>
<View
android:id="@+id/iv_line"
android:layout_width="@dimen/x1"
android:layout_height="@dimen/x40"
android:layout_marginTop="@dimen/x40"
android:background="@color/divider_line_color" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="@dimen/x180" />
</LinearLayout>
</LinearLayout>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="@dimen/x172"
android:background="@color/primary_list"
android:padding="@dimen/x16" />

View File

@ -1,200 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/x472"
android:gravity="bottom"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.yunbao.faceunity.widget.TouchStateImageView
android:id="@+id/iv_compare"
android:layout_width="@dimen/x72"
android:layout_height="@dimen/x72"
android:layout_marginStart="@dimen/x34"
android:layout_marginBottom="@dimen/x34"
android:src="@mipmap/icon_beauty_face_contrast"
android:visibility="gone" />
<Button
android:id="@+id/iv_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="@dimen/x34"
android:text="去除效果"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout
android:id="@+id/fyt_bottom_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/primary_list"
android:orientation="vertical">
<com.yunbao.faceunity.seekbar.DiscreteSeekBar
android:id="@+id/beauty_seek_bar"
android:layout_width="@dimen/x528"
android:layout_height="@dimen/x48"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/x24"
android:layout_marginBottom="@dimen/x15"
app:dsb_indicatorColor="@color/main_color"
app:dsb_indicatorElevation="0dp"
app:dsb_indicatorPopupEnabled="true"
app:dsb_max="100"
app:dsb_min="0"
app:dsb_progressColor="@color/main_color"
app:dsb_rippleColor="@color/main_color"
app:dsb_scrubberHeight="@dimen/x4"
app:dsb_thumbSize="@dimen/x32"
app:dsb_trackBaseHeight="@dimen/x16"
app:dsb_trackColor="@color/colorWhite"
app:dsb_trackHeight="@dimen/x4"
app:dsb_value="0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/x180"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/lyt_beauty_recover"
android:layout_width="@dimen/x132"
android:layout_height="@dimen/x180"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_beauty_recover"
android:layout_width="@dimen/x88"
android:layout_height="@dimen/x88"
android:layout_marginBottom="@dimen/x18"
android:scaleType="centerInside"
android:src="@mipmap/icon_control_recover" />
<TextView
android:id="@+id/tv_beauty_recover"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/x30"
android:gravity="center_vertical"
android:text="@string/recover"
android:textColor="@color/tv_main_color_selector"
android:textSize="@dimen/text_size_20" />
</LinearLayout>
<LinearLayout
android:id="@+id/lyt_style_recover"
android:layout_width="@dimen/x132"
android:layout_height="@dimen/x180"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="@dimen/x88"
android:layout_height="@dimen/x88"
android:layout_marginBottom="@dimen/x18"
android:scaleType="centerInside"
android:src="@drawable/icon_beauty_style_none_selector" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/x30"
android:gravity="center_vertical"
android:text="@string/beauty_face_style_none"
android:textColor="@color/tv_main_color_selector"
android:textSize="@dimen/text_size_20" />
</LinearLayout>
<View
android:id="@+id/iv_line"
android:layout_width="@dimen/x1"
android:layout_height="@dimen/x40"
android:layout_marginTop="@dimen/x24"
android:background="@color/divider_line_color" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="@dimen/x180"
android:layout_gravity="bottom" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/x1"
android:background="@color/divider_line_color" />
</LinearLayout>
<com.yunbao.faceunity.checkbox.CheckGroup
android:id="@+id/beauty_radio_group"
android:layout_width="match_parent"
android:layout_height="@dimen/x98"
android:background="#BD050F14"
android:orientation="horizontal">
<com.yunbao.faceunity.checkbox.CheckBoxCompat
android:id="@+id/beauty_radio_skin_beauty"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/transparent"
android:button="@null"
android:gravity="center"
android:text="@string/beauty_radio_skin_beauty"
android:textColor="@color/bottom_radio_color"
android:textSize="@dimen/text_size_26" />
<com.yunbao.faceunity.checkbox.CheckBoxCompat
android:id="@+id/beauty_radio_face_shape"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/transparent"
android:button="@null"
android:gravity="center"
android:text="@string/beauty_radio_face_shape"
android:textColor="@color/bottom_radio_color"
android:textSize="@dimen/text_size_26" />
<com.yunbao.faceunity.checkbox.CheckBoxCompat
android:id="@+id/beauty_radio_filter"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/transparent"
android:button="@null"
android:gravity="center"
android:text="@string/beauty_radio_filter"
android:textColor="@color/bottom_radio_color"
android:textSize="@dimen/text_size_26" />
<com.yunbao.faceunity.checkbox.CheckBoxCompat
android:id="@+id/beauty_radio_style"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/transparent"
android:button="@null"
android:gravity="center"
android:text="@string/beauty_radio_style"
android:textColor="@color/bottom_radio_color"
android:textSize="@dimen/text_size_26" />
</com.yunbao.faceunity.checkbox.CheckGroup>
</LinearLayout>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/container_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@ -160,7 +160,6 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/layout_faceunity_menu1"
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/x290"
android:background="@color/primary_list"
android:gravity="center_horizontal"
android:orientation="vertical">
<com.yunbao.faceunity.seekbar.DiscreteSeekBar
android:id="@+id/seek_bar"
android:layout_width="@dimen/x528"
android:layout_height="@dimen/x48"
android:layout_marginTop="@dimen/x24"
android:layout_marginBottom="@dimen/x38"
android:visibility="invisible"
app:dsb_indicatorColor="@color/main_color"
app:dsb_indicatorElevation="0dp"
app:dsb_indicatorPopupEnabled="true"
app:dsb_max="100"
app:dsb_min="0"
app:dsb_progressColor="@color/main_color"
app:dsb_rippleColor="@color/main_color"
app:dsb_scrubberHeight="@dimen/x4"
app:dsb_thumbSize="@dimen/x32"
app:dsb_trackBaseHeight="@dimen/x16"
app:dsb_trackColor="@color/colorWhite"
app:dsb_trackHeight="@dimen/x4"
app:dsb_value="0" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="@dimen/x180" />
</LinearLayout>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/x140"
android:layout_height="@dimen/x140"
android:orientation="vertical"
android:padding="@dimen/x10">
<com.yunbao.faceunity.widget.CircleImageView
android:id="@+id/iv_control"
android:layout_width="@dimen/x120"
android:layout_height="@dimen/x120"
android:layout_gravity="center"
android:background="@drawable/bg_control_oval_selector"
android:padding="@dimen/x6" />
</LinearLayout>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/x138"
android:layout_height="@dimen/x116">
<ImageView
android:id="@+id/iv_control"
android:layout_width="@dimen/x116"
android:layout_height="@dimen/x116"
android:background="@drawable/bg_control_square_selector"
android:padding="@dimen/x4"
android:scaleType="centerInside" />
</LinearLayout>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/x132"
android:layout_height="@dimen/x180"
android:gravity="center_horizontal|bottom"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_control"
android:layout_width="@dimen/x88"
android:layout_height="@dimen/x88"
android:layout_marginBottom="@dimen/x18"
android:scaleType="centerInside" />
<TextView
android:id="@+id/tv_control"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_marginBottom="@dimen/x30"
android:text="@string/recover"
android:textColor="@color/tv_main_color_selector"
android:textSize="@dimen/text_size_20" />
</LinearLayout>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/x138"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_height="@dimen/x180">
<ImageView
android:id="@+id/iv_control"
android:layout_width="@dimen/x108"
android:layout_height="@dimen/x108"
android:layout_marginBottom="@dimen/x16"
android:background="@drawable/bg_control_square_selector"
android:padding="@dimen/x4"
android:scaleType="centerInside" />
<TextView
android:id="@+id/tv_control"
android:layout_width="wrap_content"
android:layout_height="@dimen/x40"
android:layout_marginBottom="@dimen/x16"
android:textColor="@color/tv_main_color_selector"
android:textSize="@dimen/text_size_20" />
</LinearLayout>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View File

@ -1,754 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="x0">0.0px</dimen>
<dimen name="x1">0.64px</dimen>
<dimen name="x2">1.28px</dimen>
<dimen name="x3">1.92px</dimen>
<dimen name="x4">2.56px</dimen>
<dimen name="x5">3.19px</dimen>
<dimen name="x6">3.84px</dimen>
<dimen name="x7">4.48px</dimen>
<dimen name="x8">5.12px</dimen>
<dimen name="x9">5.76px</dimen>
<dimen name="x10">6.39px</dimen>
<dimen name="x11">7.04px</dimen>
<dimen name="x12">7.68px</dimen>
<dimen name="x13">8.32px</dimen>
<dimen name="x14">8.96px</dimen>
<dimen name="x15">9.59px</dimen>
<dimen name="x16">10.24px</dimen>
<dimen name="x17">10.88px</dimen>
<dimen name="x18">11.52px</dimen>
<dimen name="x19">12.16px</dimen>
<dimen name="x20">12.79px</dimen>
<dimen name="x21">13.44px</dimen>
<dimen name="x22">14.08px</dimen>
<dimen name="x23">14.71px</dimen>
<dimen name="x24">15.36px</dimen>
<dimen name="x25">16.0px</dimen>
<dimen name="x26">16.64px</dimen>
<dimen name="x27">17.27px</dimen>
<dimen name="x28">17.92px</dimen>
<dimen name="x29">18.56px</dimen>
<dimen name="x30">19.19px</dimen>
<dimen name="x31">19.84px</dimen>
<dimen name="x32">20.48px</dimen>
<dimen name="x33">21.12px</dimen>
<dimen name="x34">21.76px</dimen>
<dimen name="x35">22.4px</dimen>
<dimen name="x36">23.04px</dimen>
<dimen name="x37">23.68px</dimen>
<dimen name="x38">24.32px</dimen>
<dimen name="x39">24.96px</dimen>
<dimen name="x40">25.59px</dimen>
<dimen name="x41">26.24px</dimen>
<dimen name="x42">26.88px</dimen>
<dimen name="x43">27.51px</dimen>
<dimen name="x44">28.16px</dimen>
<dimen name="x45">28.8px</dimen>
<dimen name="x46">29.43px</dimen>
<dimen name="x47">30.08px</dimen>
<dimen name="x48">30.72px</dimen>
<dimen name="x49">31.35px</dimen>
<dimen name="x50">32.0px</dimen>
<dimen name="x51">32.64px</dimen>
<dimen name="x52">33.28px</dimen>
<dimen name="x53">33.91px</dimen>
<dimen name="x54">34.55px</dimen>
<dimen name="x55">35.2px</dimen>
<dimen name="x56">35.84px</dimen>
<dimen name="x57">36.48px</dimen>
<dimen name="x58">37.12px</dimen>
<dimen name="x59">37.75px</dimen>
<dimen name="x60">38.39px</dimen>
<dimen name="x61">39.04px</dimen>
<dimen name="x62">39.68px</dimen>
<dimen name="x63">40.32px</dimen>
<dimen name="x64">40.96px</dimen>
<dimen name="x65">41.6px</dimen>
<dimen name="x66">42.24px</dimen>
<dimen name="x67">42.87px</dimen>
<dimen name="x68">43.52px</dimen>
<dimen name="x69">44.16px</dimen>
<dimen name="x70">44.8px</dimen>
<dimen name="x71">45.44px</dimen>
<dimen name="x72">46.08px</dimen>
<dimen name="x73">46.71px</dimen>
<dimen name="x74">47.36px</dimen>
<dimen name="x75">48.0px</dimen>
<dimen name="x76">48.64px</dimen>
<dimen name="x77">49.28px</dimen>
<dimen name="x78">49.92px</dimen>
<dimen name="x79">50.56px</dimen>
<dimen name="x80">51.19px</dimen>
<dimen name="x81">51.84px</dimen>
<dimen name="x82">52.48px</dimen>
<dimen name="x83">53.12px</dimen>
<dimen name="x84">53.76px</dimen>
<dimen name="x85">54.4px</dimen>
<dimen name="x86">55.03px</dimen>
<dimen name="x87">55.68px</dimen>
<dimen name="x88">56.32px</dimen>
<dimen name="x89">56.96px</dimen>
<dimen name="x90">57.6px</dimen>
<dimen name="x91">58.24px</dimen>
<dimen name="x92">58.87px</dimen>
<dimen name="x93">59.52px</dimen>
<dimen name="x94">60.16px</dimen>
<dimen name="x95">60.8px</dimen>
<dimen name="x96">61.44px</dimen>
<dimen name="x97">62.08px</dimen>
<dimen name="x98">62.71px</dimen>
<dimen name="x99">63.35px</dimen>
<dimen name="x100">64.0px</dimen>
<dimen name="x101">64.64px</dimen>
<dimen name="x102">65.28px</dimen>
<dimen name="x103">65.92px</dimen>
<dimen name="x104">66.56px</dimen>
<dimen name="x105">67.19px</dimen>
<dimen name="x106">67.83px</dimen>
<dimen name="x107">68.47px</dimen>
<dimen name="x108">69.11px</dimen>
<dimen name="x109">69.76px</dimen>
<dimen name="x110">70.4px</dimen>
<dimen name="x111">71.04px</dimen>
<dimen name="x112">71.68px</dimen>
<dimen name="x113">72.32px</dimen>
<dimen name="x114">72.96px</dimen>
<dimen name="x115">73.6px</dimen>
<dimen name="x116">74.24px</dimen>
<dimen name="x117">74.87px</dimen>
<dimen name="x118">75.51px</dimen>
<dimen name="x119">76.15px</dimen>
<dimen name="x120">76.79px</dimen>
<dimen name="x121">77.43px</dimen>
<dimen name="x122">78.08px</dimen>
<dimen name="x123">78.72px</dimen>
<dimen name="x124">79.36px</dimen>
<dimen name="x125">80.0px</dimen>
<dimen name="x126">80.64px</dimen>
<dimen name="x127">81.28px</dimen>
<dimen name="x128">81.92px</dimen>
<dimen name="x129">82.56px</dimen>
<dimen name="x130">83.2px</dimen>
<dimen name="x131">83.84px</dimen>
<dimen name="x132">84.48px</dimen>
<dimen name="x133">85.12px</dimen>
<dimen name="x134">85.75px</dimen>
<dimen name="x135">86.4px</dimen>
<dimen name="x136">87.04px</dimen>
<dimen name="x137">87.68px</dimen>
<dimen name="x138">88.32px</dimen>
<dimen name="x139">88.96px</dimen>
<dimen name="x140">89.6px</dimen>
<dimen name="x141">90.24px</dimen>
<dimen name="x142">90.88px</dimen>
<dimen name="x143">91.52px</dimen>
<dimen name="x144">92.16px</dimen>
<dimen name="x145">92.8px</dimen>
<dimen name="x146">93.43px</dimen>
<dimen name="x147">94.07px</dimen>
<dimen name="x148">94.72px</dimen>
<dimen name="x149">95.36px</dimen>
<dimen name="x150">96.0px</dimen>
<dimen name="x151">96.64px</dimen>
<dimen name="x152">97.28px</dimen>
<dimen name="x153">97.92px</dimen>
<dimen name="x154">98.56px</dimen>
<dimen name="x155">99.2px</dimen>
<dimen name="x156">99.84px</dimen>
<dimen name="x157">100.48px</dimen>
<dimen name="x158">101.12px</dimen>
<dimen name="x159">101.75px</dimen>
<dimen name="x160">102.39px</dimen>
<dimen name="x161">103.04px</dimen>
<dimen name="x162">103.68px</dimen>
<dimen name="x163">104.32px</dimen>
<dimen name="x164">104.96px</dimen>
<dimen name="x165">105.6px</dimen>
<dimen name="x166">106.24px</dimen>
<dimen name="x167">106.88px</dimen>
<dimen name="x168">107.52px</dimen>
<dimen name="x169">108.16px</dimen>
<dimen name="x170">108.8px</dimen>
<dimen name="x171">109.43px</dimen>
<dimen name="x172">110.07px</dimen>
<dimen name="x173">110.72px</dimen>
<dimen name="x174">111.36px</dimen>
<dimen name="x175">112.0px</dimen>
<dimen name="x176">112.64px</dimen>
<dimen name="x177">113.28px</dimen>
<dimen name="x178">113.92px</dimen>
<dimen name="x179">114.56px</dimen>
<dimen name="x180">115.2px</dimen>
<dimen name="x181">115.84px</dimen>
<dimen name="x182">116.48px</dimen>
<dimen name="x183">117.12px</dimen>
<dimen name="x184">117.75px</dimen>
<dimen name="x185">118.39px</dimen>
<dimen name="x186">119.04px</dimen>
<dimen name="x187">119.68px</dimen>
<dimen name="x188">120.32px</dimen>
<dimen name="x189">120.96px</dimen>
<dimen name="x190">121.6px</dimen>
<dimen name="x191">122.24px</dimen>
<dimen name="x192">122.88px</dimen>
<dimen name="x193">123.52px</dimen>
<dimen name="x194">124.16px</dimen>
<dimen name="x195">124.8px</dimen>
<dimen name="x196">125.43px</dimen>
<dimen name="x197">126.07px</dimen>
<dimen name="x198">126.71px</dimen>
<dimen name="x199">127.36px</dimen>
<dimen name="x200">128.0px</dimen>
<dimen name="x201">128.64px</dimen>
<dimen name="x202">129.28px</dimen>
<dimen name="x203">129.92px</dimen>
<dimen name="x204">130.56px</dimen>
<dimen name="x205">131.2px</dimen>
<dimen name="x206">131.84px</dimen>
<dimen name="x207">132.48px</dimen>
<dimen name="x208">133.12px</dimen>
<dimen name="x209">133.75px</dimen>
<dimen name="x210">134.39px</dimen>
<dimen name="x211">135.03px</dimen>
<dimen name="x212">135.67px</dimen>
<dimen name="x213">136.31px</dimen>
<dimen name="x214">136.95px</dimen>
<dimen name="x215">137.59px</dimen>
<dimen name="x216">138.23px</dimen>
<dimen name="x217">138.87px</dimen>
<dimen name="x218">139.52px</dimen>
<dimen name="x219">140.16px</dimen>
<dimen name="x220">140.8px</dimen>
<dimen name="x221">141.44px</dimen>
<dimen name="x222">142.08px</dimen>
<dimen name="x223">142.72px</dimen>
<dimen name="x224">143.36px</dimen>
<dimen name="x225">144.0px</dimen>
<dimen name="x226">144.64px</dimen>
<dimen name="x227">145.28px</dimen>
<dimen name="x228">145.92px</dimen>
<dimen name="x229">146.56px</dimen>
<dimen name="x230">147.2px</dimen>
<dimen name="x231">147.84px</dimen>
<dimen name="x232">148.48px</dimen>
<dimen name="x233">149.12px</dimen>
<dimen name="x234">149.75px</dimen>
<dimen name="x235">150.39px</dimen>
<dimen name="x236">151.03px</dimen>
<dimen name="x237">151.67px</dimen>
<dimen name="x238">152.31px</dimen>
<dimen name="x239">152.95px</dimen>
<dimen name="x240">153.59px</dimen>
<dimen name="x241">154.23px</dimen>
<dimen name="x242">154.87px</dimen>
<dimen name="x243">155.51px</dimen>
<dimen name="x244">156.16px</dimen>
<dimen name="x245">156.8px</dimen>
<dimen name="x246">157.44px</dimen>
<dimen name="x247">158.08px</dimen>
<dimen name="x248">158.72px</dimen>
<dimen name="x249">159.36px</dimen>
<dimen name="x250">160.0px</dimen>
<dimen name="x251">160.64px</dimen>
<dimen name="x252">161.28px</dimen>
<dimen name="x253">161.92px</dimen>
<dimen name="x254">162.56px</dimen>
<dimen name="x255">163.2px</dimen>
<dimen name="x256">163.84px</dimen>
<dimen name="x257">164.48px</dimen>
<dimen name="x258">165.12px</dimen>
<dimen name="x259">165.76px</dimen>
<dimen name="x260">166.4px</dimen>
<dimen name="x261">167.04px</dimen>
<dimen name="x262">167.68px</dimen>
<dimen name="x263">168.32px</dimen>
<dimen name="x264">168.96px</dimen>
<dimen name="x265">169.6px</dimen>
<dimen name="x266">170.24px</dimen>
<dimen name="x267">170.87px</dimen>
<dimen name="x268">171.51px</dimen>
<dimen name="x269">172.16px</dimen>
<dimen name="x270">172.8px</dimen>
<dimen name="x271">173.44px</dimen>
<dimen name="x272">174.08px</dimen>
<dimen name="x273">174.72px</dimen>
<dimen name="x274">175.36px</dimen>
<dimen name="x275">176.0px</dimen>
<dimen name="x276">176.64px</dimen>
<dimen name="x277">177.28px</dimen>
<dimen name="x278">177.92px</dimen>
<dimen name="x279">178.56px</dimen>
<dimen name="x280">179.2px</dimen>
<dimen name="x281">179.84px</dimen>
<dimen name="x282">180.48px</dimen>
<dimen name="x283">181.12px</dimen>
<dimen name="x284">181.76px</dimen>
<dimen name="x285">182.4px</dimen>
<dimen name="x286">183.04px</dimen>
<dimen name="x287">183.68px</dimen>
<dimen name="x288">184.32px</dimen>
<dimen name="x289">184.96px</dimen>
<dimen name="x290">185.6px</dimen>
<dimen name="x291">186.24px</dimen>
<dimen name="x292">186.87px</dimen>
<dimen name="x293">187.51px</dimen>
<dimen name="x294">188.15px</dimen>
<dimen name="x295">188.8px</dimen>
<dimen name="x296">189.44px</dimen>
<dimen name="x297">190.08px</dimen>
<dimen name="x298">190.72px</dimen>
<dimen name="x299">191.36px</dimen>
<dimen name="x300">192.0px</dimen>
<dimen name="x301">192.64px</dimen>
<dimen name="x302">193.28px</dimen>
<dimen name="x303">193.92px</dimen>
<dimen name="x304">194.56px</dimen>
<dimen name="x305">195.2px</dimen>
<dimen name="x306">195.84px</dimen>
<dimen name="x307">196.48px</dimen>
<dimen name="x308">197.12px</dimen>
<dimen name="x309">197.76px</dimen>
<dimen name="x310">198.4px</dimen>
<dimen name="x311">199.04px</dimen>
<dimen name="x312">199.68px</dimen>
<dimen name="x313">200.32px</dimen>
<dimen name="x314">200.96px</dimen>
<dimen name="x315">201.6px</dimen>
<dimen name="x316">202.24px</dimen>
<dimen name="x317">202.87px</dimen>
<dimen name="x318">203.51px</dimen>
<dimen name="x319">204.15px</dimen>
<dimen name="x320">204.79px</dimen>
<dimen name="x321">205.44px</dimen>
<dimen name="x322">206.08px</dimen>
<dimen name="x323">206.72px</dimen>
<dimen name="x324">207.36px</dimen>
<dimen name="x325">208.0px</dimen>
<dimen name="x326">208.64px</dimen>
<dimen name="x327">209.28px</dimen>
<dimen name="x328">209.92px</dimen>
<dimen name="x329">210.56px</dimen>
<dimen name="x330">211.2px</dimen>
<dimen name="x331">211.84px</dimen>
<dimen name="x332">212.48px</dimen>
<dimen name="x333">213.12px</dimen>
<dimen name="x334">213.76px</dimen>
<dimen name="x335">214.4px</dimen>
<dimen name="x336">215.04px</dimen>
<dimen name="x337">215.68px</dimen>
<dimen name="x338">216.32px</dimen>
<dimen name="x339">216.96px</dimen>
<dimen name="x340">217.6px</dimen>
<dimen name="x341">218.24px</dimen>
<dimen name="x342">218.87px</dimen>
<dimen name="x343">219.51px</dimen>
<dimen name="x344">220.15px</dimen>
<dimen name="x345">220.79px</dimen>
<dimen name="x346">221.44px</dimen>
<dimen name="x347">222.08px</dimen>
<dimen name="x348">222.72px</dimen>
<dimen name="x349">223.36px</dimen>
<dimen name="x350">224.0px</dimen>
<dimen name="x351">224.64px</dimen>
<dimen name="x352">225.28px</dimen>
<dimen name="x353">225.92px</dimen>
<dimen name="x354">226.56px</dimen>
<dimen name="x355">227.2px</dimen>
<dimen name="x356">227.84px</dimen>
<dimen name="x357">228.48px</dimen>
<dimen name="x358">229.12px</dimen>
<dimen name="x359">229.76px</dimen>
<dimen name="x360">230.4px</dimen>
<dimen name="x361">231.04px</dimen>
<dimen name="x362">231.68px</dimen>
<dimen name="x363">232.32px</dimen>
<dimen name="x364">232.96px</dimen>
<dimen name="x365">233.6px</dimen>
<dimen name="x366">234.24px</dimen>
<dimen name="x367">234.87px</dimen>
<dimen name="x368">235.51px</dimen>
<dimen name="x369">236.15px</dimen>
<dimen name="x370">236.79px</dimen>
<dimen name="x371">237.43px</dimen>
<dimen name="x372">238.08px</dimen>
<dimen name="x373">238.72px</dimen>
<dimen name="x374">239.36px</dimen>
<dimen name="x375">240.0px</dimen>
<dimen name="x376">240.64px</dimen>
<dimen name="x377">241.28px</dimen>
<dimen name="x378">241.92px</dimen>
<dimen name="x379">242.56px</dimen>
<dimen name="x380">243.2px</dimen>
<dimen name="x381">243.84px</dimen>
<dimen name="x382">244.48px</dimen>
<dimen name="x383">245.12px</dimen>
<dimen name="x384">245.76px</dimen>
<dimen name="x385">246.4px</dimen>
<dimen name="x386">247.04px</dimen>
<dimen name="x387">247.68px</dimen>
<dimen name="x388">248.32px</dimen>
<dimen name="x389">248.96px</dimen>
<dimen name="x390">249.6px</dimen>
<dimen name="x391">250.24px</dimen>
<dimen name="x392">250.87px</dimen>
<dimen name="x393">251.51px</dimen>
<dimen name="x394">252.15px</dimen>
<dimen name="x395">252.79px</dimen>
<dimen name="x396">253.43px</dimen>
<dimen name="x397">254.08px</dimen>
<dimen name="x398">254.72px</dimen>
<dimen name="x399">255.36px</dimen>
<dimen name="x400">256.0px</dimen>
<dimen name="x401">256.63px</dimen>
<dimen name="x402">257.28px</dimen>
<dimen name="x403">257.91px</dimen>
<dimen name="x404">258.56px</dimen>
<dimen name="x405">259.19px</dimen>
<dimen name="x406">259.84px</dimen>
<dimen name="x407">260.47px</dimen>
<dimen name="x408">261.12px</dimen>
<dimen name="x409">261.75px</dimen>
<dimen name="x410">262.4px</dimen>
<dimen name="x411">263.04px</dimen>
<dimen name="x412">263.68px</dimen>
<dimen name="x413">264.32px</dimen>
<dimen name="x414">264.96px</dimen>
<dimen name="x415">265.6px</dimen>
<dimen name="x416">266.24px</dimen>
<dimen name="x417">266.88px</dimen>
<dimen name="x418">267.51px</dimen>
<dimen name="x419">268.16px</dimen>
<dimen name="x420">268.79px</dimen>
<dimen name="x421">269.44px</dimen>
<dimen name="x422">270.07px</dimen>
<dimen name="x423">270.72px</dimen>
<dimen name="x424">271.35px</dimen>
<dimen name="x425">272.0px</dimen>
<dimen name="x426">272.63px</dimen>
<dimen name="x427">273.28px</dimen>
<dimen name="x428">273.91px</dimen>
<dimen name="x429">274.56px</dimen>
<dimen name="x430">275.19px</dimen>
<dimen name="x431">275.84px</dimen>
<dimen name="x432">276.47px</dimen>
<dimen name="x433">277.12px</dimen>
<dimen name="x434">277.75px</dimen>
<dimen name="x435">278.4px</dimen>
<dimen name="x436">279.04px</dimen>
<dimen name="x437">279.68px</dimen>
<dimen name="x438">280.32px</dimen>
<dimen name="x439">280.96px</dimen>
<dimen name="x440">281.6px</dimen>
<dimen name="x441">282.24px</dimen>
<dimen name="x442">282.88px</dimen>
<dimen name="x443">283.51px</dimen>
<dimen name="x444">284.16px</dimen>
<dimen name="x445">284.79px</dimen>
<dimen name="x446">285.44px</dimen>
<dimen name="x447">286.07px</dimen>
<dimen name="x448">286.72px</dimen>
<dimen name="x449">287.35px</dimen>
<dimen name="x450">288.0px</dimen>
<dimen name="x451">288.63px</dimen>
<dimen name="x452">289.28px</dimen>
<dimen name="x453">289.91px</dimen>
<dimen name="x454">290.56px</dimen>
<dimen name="x455">291.19px</dimen>
<dimen name="x456">291.84px</dimen>
<dimen name="x457">292.47px</dimen>
<dimen name="x458">293.12px</dimen>
<dimen name="x459">293.75px</dimen>
<dimen name="x460">294.4px</dimen>
<dimen name="x461">295.04px</dimen>
<dimen name="x462">295.68px</dimen>
<dimen name="x463">296.32px</dimen>
<dimen name="x464">296.96px</dimen>
<dimen name="x465">297.6px</dimen>
<dimen name="x466">298.24px</dimen>
<dimen name="x467">298.88px</dimen>
<dimen name="x468">299.51px</dimen>
<dimen name="x469">300.16px</dimen>
<dimen name="x470">300.79px</dimen>
<dimen name="x471">301.44px</dimen>
<dimen name="x472">302.07px</dimen>
<dimen name="x473">302.72px</dimen>
<dimen name="x474">303.35px</dimen>
<dimen name="x475">304.0px</dimen>
<dimen name="x476">304.63px</dimen>
<dimen name="x477">305.28px</dimen>
<dimen name="x478">305.91px</dimen>
<dimen name="x479">306.56px</dimen>
<dimen name="x480">307.19px</dimen>
<dimen name="x481">307.84px</dimen>
<dimen name="x482">308.47px</dimen>
<dimen name="x483">309.12px</dimen>
<dimen name="x484">309.75px</dimen>
<dimen name="x485">310.4px</dimen>
<dimen name="x486">311.03px</dimen>
<dimen name="x487">311.68px</dimen>
<dimen name="x488">312.32px</dimen>
<dimen name="x489">312.96px</dimen>
<dimen name="x490">313.6px</dimen>
<dimen name="x491">314.24px</dimen>
<dimen name="x492">314.88px</dimen>
<dimen name="x493">315.51px</dimen>
<dimen name="x494">316.16px</dimen>
<dimen name="x495">316.79px</dimen>
<dimen name="x496">317.44px</dimen>
<dimen name="x497">318.07px</dimen>
<dimen name="x498">318.72px</dimen>
<dimen name="x499">319.35px</dimen>
<dimen name="x500">320.0px</dimen>
<dimen name="x501">320.63px</dimen>
<dimen name="x502">321.28px</dimen>
<dimen name="x503">321.91px</dimen>
<dimen name="x504">322.56px</dimen>
<dimen name="x505">323.19px</dimen>
<dimen name="x506">323.84px</dimen>
<dimen name="x507">324.47px</dimen>
<dimen name="x508">325.12px</dimen>
<dimen name="x509">325.75px</dimen>
<dimen name="x510">326.4px</dimen>
<dimen name="x511">327.03px</dimen>
<dimen name="x512">327.68px</dimen>
<dimen name="x513">328.32px</dimen>
<dimen name="x514">328.96px</dimen>
<dimen name="x515">329.6px</dimen>
<dimen name="x516">330.24px</dimen>
<dimen name="x517">330.88px</dimen>
<dimen name="x518">331.52px</dimen>
<dimen name="x519">332.16px</dimen>
<dimen name="x520">332.8px</dimen>
<dimen name="x521">333.44px</dimen>
<dimen name="x522">334.08px</dimen>
<dimen name="x523">334.72px</dimen>
<dimen name="x524">335.36px</dimen>
<dimen name="x525">336.0px</dimen>
<dimen name="x526">336.64px</dimen>
<dimen name="x527">337.28px</dimen>
<dimen name="x528">337.92px</dimen>
<dimen name="x529">338.56px</dimen>
<dimen name="x530">339.2px</dimen>
<dimen name="x531">339.84px</dimen>
<dimen name="x532">340.48px</dimen>
<dimen name="x533">341.12px</dimen>
<dimen name="x534">341.75px</dimen>
<dimen name="x535">342.4px</dimen>
<dimen name="x536">343.03px</dimen>
<dimen name="x537">343.68px</dimen>
<dimen name="x538">344.32px</dimen>
<dimen name="x539">344.96px</dimen>
<dimen name="x540">345.6px</dimen>
<dimen name="x541">346.24px</dimen>
<dimen name="x542">346.88px</dimen>
<dimen name="x543">347.52px</dimen>
<dimen name="x544">348.16px</dimen>
<dimen name="x545">348.8px</dimen>
<dimen name="x546">349.44px</dimen>
<dimen name="x547">350.08px</dimen>
<dimen name="x548">350.72px</dimen>
<dimen name="x549">351.36px</dimen>
<dimen name="x550">352.0px</dimen>
<dimen name="x551">352.64px</dimen>
<dimen name="x552">353.28px</dimen>
<dimen name="x553">353.92px</dimen>
<dimen name="x554">354.56px</dimen>
<dimen name="x555">355.2px</dimen>
<dimen name="x556">355.84px</dimen>
<dimen name="x557">356.48px</dimen>
<dimen name="x558">357.12px</dimen>
<dimen name="x559">357.75px</dimen>
<dimen name="x560">358.4px</dimen>
<dimen name="x561">359.03px</dimen>
<dimen name="x562">359.68px</dimen>
<dimen name="x563">360.31px</dimen>
<dimen name="x564">360.96px</dimen>
<dimen name="x565">361.6px</dimen>
<dimen name="x566">362.24px</dimen>
<dimen name="x567">362.88px</dimen>
<dimen name="x568">363.52px</dimen>
<dimen name="x569">364.16px</dimen>
<dimen name="x570">364.8px</dimen>
<dimen name="x571">365.44px</dimen>
<dimen name="x572">366.08px</dimen>
<dimen name="x573">366.72px</dimen>
<dimen name="x574">367.36px</dimen>
<dimen name="x575">368.0px</dimen>
<dimen name="x576">368.64px</dimen>
<dimen name="x577">369.28px</dimen>
<dimen name="x578">369.92px</dimen>
<dimen name="x579">370.56px</dimen>
<dimen name="x580">371.2px</dimen>
<dimen name="x581">371.84px</dimen>
<dimen name="x582">372.48px</dimen>
<dimen name="x583">373.12px</dimen>
<dimen name="x584">373.75px</dimen>
<dimen name="x585">374.4px</dimen>
<dimen name="x586">375.03px</dimen>
<dimen name="x587">375.68px</dimen>
<dimen name="x588">376.31px</dimen>
<dimen name="x589">376.96px</dimen>
<dimen name="x590">377.6px</dimen>
<dimen name="x591">378.24px</dimen>
<dimen name="x592">378.88px</dimen>
<dimen name="x593">379.52px</dimen>
<dimen name="x594">380.16px</dimen>
<dimen name="x595">380.8px</dimen>
<dimen name="x596">381.44px</dimen>
<dimen name="x597">382.08px</dimen>
<dimen name="x598">382.72px</dimen>
<dimen name="x599">383.36px</dimen>
<dimen name="x600">384.0px</dimen>
<dimen name="x601">384.64px</dimen>
<dimen name="x602">385.28px</dimen>
<dimen name="x603">385.92px</dimen>
<dimen name="x604">386.56px</dimen>
<dimen name="x605">387.2px</dimen>
<dimen name="x606">387.84px</dimen>
<dimen name="x607">388.48px</dimen>
<dimen name="x608">389.12px</dimen>
<dimen name="x609">389.75px</dimen>
<dimen name="x610">390.4px</dimen>
<dimen name="x611">391.03px</dimen>
<dimen name="x612">391.68px</dimen>
<dimen name="x613">392.31px</dimen>
<dimen name="x614">392.96px</dimen>
<dimen name="x615">393.6px</dimen>
<dimen name="x616">394.24px</dimen>
<dimen name="x617">394.88px</dimen>
<dimen name="x618">395.52px</dimen>
<dimen name="x619">396.16px</dimen>
<dimen name="x620">396.8px</dimen>
<dimen name="x621">397.44px</dimen>
<dimen name="x622">398.08px</dimen>
<dimen name="x623">398.72px</dimen>
<dimen name="x624">399.36px</dimen>
<dimen name="x625">400.0px</dimen>
<dimen name="x626">400.64px</dimen>
<dimen name="x627">401.28px</dimen>
<dimen name="x628">401.92px</dimen>
<dimen name="x629">402.56px</dimen>
<dimen name="x630">403.2px</dimen>
<dimen name="x631">403.84px</dimen>
<dimen name="x632">404.48px</dimen>
<dimen name="x633">405.12px</dimen>
<dimen name="x634">405.75px</dimen>
<dimen name="x635">406.4px</dimen>
<dimen name="x636">407.03px</dimen>
<dimen name="x637">407.68px</dimen>
<dimen name="x638">408.31px</dimen>
<dimen name="x639">408.96px</dimen>
<dimen name="x640">409.59px</dimen>
<dimen name="x641">410.24px</dimen>
<dimen name="x642">410.88px</dimen>
<dimen name="x643">411.52px</dimen>
<dimen name="x644">412.16px</dimen>
<dimen name="x645">412.8px</dimen>
<dimen name="x646">413.44px</dimen>
<dimen name="x647">414.08px</dimen>
<dimen name="x648">414.72px</dimen>
<dimen name="x649">415.36px</dimen>
<dimen name="x650">416.0px</dimen>
<dimen name="x651">416.64px</dimen>
<dimen name="x652">417.28px</dimen>
<dimen name="x653">417.92px</dimen>
<dimen name="x654">418.56px</dimen>
<dimen name="x655">419.2px</dimen>
<dimen name="x656">419.84px</dimen>
<dimen name="x657">420.48px</dimen>
<dimen name="x658">421.12px</dimen>
<dimen name="x659">421.75px</dimen>
<dimen name="x660">422.4px</dimen>
<dimen name="x661">423.03px</dimen>
<dimen name="x662">423.68px</dimen>
<dimen name="x663">424.31px</dimen>
<dimen name="x664">424.96px</dimen>
<dimen name="x665">425.59px</dimen>
<dimen name="x666">426.24px</dimen>
<dimen name="x667">426.88px</dimen>
<dimen name="x668">427.52px</dimen>
<dimen name="x669">428.16px</dimen>
<dimen name="x670">428.8px</dimen>
<dimen name="x671">429.44px</dimen>
<dimen name="x672">430.08px</dimen>
<dimen name="x673">430.72px</dimen>
<dimen name="x674">431.36px</dimen>
<dimen name="x675">432.0px</dimen>
<dimen name="x676">432.64px</dimen>
<dimen name="x677">433.28px</dimen>
<dimen name="x678">433.92px</dimen>
<dimen name="x679">434.56px</dimen>
<dimen name="x680">435.2px</dimen>
<dimen name="x681">435.84px</dimen>
<dimen name="x682">436.48px</dimen>
<dimen name="x683">437.12px</dimen>
<dimen name="x684">437.75px</dimen>
<dimen name="x685">438.4px</dimen>
<dimen name="x686">439.03px</dimen>
<dimen name="x687">439.68px</dimen>
<dimen name="x688">440.31px</dimen>
<dimen name="x689">440.96px</dimen>
<dimen name="x690">441.59px</dimen>
<dimen name="x691">442.24px</dimen>
<dimen name="x692">442.88px</dimen>
<dimen name="x693">443.52px</dimen>
<dimen name="x694">444.16px</dimen>
<dimen name="x695">444.8px</dimen>
<dimen name="x696">445.44px</dimen>
<dimen name="x697">446.08px</dimen>
<dimen name="x698">446.72px</dimen>
<dimen name="x699">447.36px</dimen>
<dimen name="x700">448.0px</dimen>
<dimen name="x701">448.64px</dimen>
<dimen name="x702">449.28px</dimen>
<dimen name="x703">449.92px</dimen>
<dimen name="x704">450.56px</dimen>
<dimen name="x705">451.2px</dimen>
<dimen name="x706">451.84px</dimen>
<dimen name="x707">452.48px</dimen>
<dimen name="x708">453.12px</dimen>
<dimen name="x709">453.75px</dimen>
<dimen name="x710">454.4px</dimen>
<dimen name="x711">455.03px</dimen>
<dimen name="x712">455.68px</dimen>
<dimen name="x713">456.31px</dimen>
<dimen name="x714">456.96px</dimen>
<dimen name="x715">457.59px</dimen>
<dimen name="x716">458.24px</dimen>
<dimen name="x717">458.88px</dimen>
<dimen name="x718">459.52px</dimen>
<dimen name="x719">460.16px</dimen>
<dimen name="x720">460.8px</dimen>
<dimen name="x721">461.44px</dimen>
<dimen name="x722">462.08px</dimen>
<dimen name="x723">462.72px</dimen>
<dimen name="x724">463.36px</dimen>
<dimen name="x725">464.0px</dimen>
<dimen name="x726">464.64px</dimen>
<dimen name="x727">465.28px</dimen>
<dimen name="x728">465.92px</dimen>
<dimen name="x729">466.56px</dimen>
<dimen name="x730">467.2px</dimen>
<dimen name="x731">467.84px</dimen>
<dimen name="x732">468.48px</dimen>
<dimen name="x733">469.12px</dimen>
<dimen name="x734">469.75px</dimen>
<dimen name="x735">470.4px</dimen>
<dimen name="x736">471.03px</dimen>
<dimen name="x737">471.68px</dimen>
<dimen name="x738">472.31px</dimen>
<dimen name="x739">472.96px</dimen>
<dimen name="x740">473.59px</dimen>
<dimen name="x741">474.24px</dimen>
<dimen name="x742">474.87px</dimen>
<dimen name="x743">475.52px</dimen>
<dimen name="x744">476.16px</dimen>
<dimen name="x745">476.8px</dimen>
<dimen name="x746">477.44px</dimen>
<dimen name="x747">478.08px</dimen>
<dimen name="x748">478.72px</dimen>
<dimen name="x749">479.36px</dimen>
<dimen name="x750">480px</dimen>
</resources>

File diff suppressed because it is too large Load Diff

View File

@ -5,29 +5,10 @@
<color name="colorAccent">#FF8D41</color>
<!--fulive demo 主配色-->
<color name="primary_background">#050F14</color>
<color name="primary_text">#2C2E30</color>
<color name="primary_list">#BD050F14</color>
<color name="primary_disable_state">#C6C6C6</color>
<color name="primary_border_background">#8A797A7B</color>
<color name="primary_border_background_old">#5C040B0E</color>
<color name="primary_selected">#1FB2FF</color>
<color name="primary_selected_old">#5EC7FE</color>
<color name="transparent">#00000000</color>
<color name="percent50translucentBlack">#80000000</color>
<color name="percent60translucentBlack">#99000000</color>
<color name="colorWhite">#FFFFFFFF</color>
<color name="main_color">#1FB2FF</color>
<color name="main_color_79CDF9">#FF79CDF9</color>
<color name="main_color_gray">#FFA8A8A8</color>
<color name="main_color_c5c5c5">#FFC5C5C5</color>
<color name="main_color_090017">#FF090017</color>
<color name="divider_line_color">#33FFFFFF</color>
<color name="divider_line_color2">#FFE5E5E5</color>
<color name="line_302D33">#FF302D33</color>
<color name="black_dialog_text">#31373E</color>
<color name="btn_live_photo_text">#2C2E30</color>
<!--For DiscreteSeekBar-->
<color name="dsb_progress_color">#ff009688</color>
@ -35,10 +16,5 @@
<color name="dsb_disabled_color">#66939393</color>
<color name="dsb_ripple_color_pressed">#77939393</color>
<color name="dsb_ripple_color_focused">#99999999</color>
<color name="bg_switch_button">#BBBBBB</color>
<color name="main_classification_gradient_start">#FFF661FF</color>
<color name="main_classification_gradient_end">#FF7755FC</color>
<color name="green">#FF00FF00</color>
<color name="blue">#FF0000FF</color>
</resources>

View File

@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="text_size_36">18sp</dimen>
<dimen name="text_size_34">17sp</dimen>
<dimen name="text_size_32">16sp</dimen>
<dimen name="text_size_30">15sp</dimen>
<dimen name="text_size_28">14sp</dimen>
<dimen name="text_size_26">13sp</dimen>
<dimen name="text_size_24">12sp</dimen>
<dimen name="text_size_22">11sp</dimen>
<dimen name="text_size_20">10sp</dimen>
</resources>

View File

@ -1,20 +1,4 @@
<resources>
<string name="camera_dialog_title">Warning</string>
<string name="camera_dialog_message">Camera permissions are disabled or the camera is occupied by another app!</string>
<string name="sorry_no_permission">Sorry ,your license is not supported for these functions.</string>
<string name="camera_dialog_open">Retry</string>
<string name="camera_dialog_back">quit</string>
<string name="fu_base_debug">Resolution:\n\t%dX%d\nFPS: %d\nRender time:\n\t%dms</string>
<string name="save_photo_success">Save photo successfully!</string>
<string name="save_video_success">Save video successfully!</string>
<string name="save_video_failed">Save video failed!</string>
<string name="save_video_too_short">The video is to short!</string>
<string name="save_video_wait">Please wait while the video is processing</string>
<string name="fu_base_is_tracking_text">No face tracking</string>
<string name="fu_base_incomplete_face_text">Incomplete face</string>
<string name="fu_base_input_type_single">SingleInput</string>
<string name="fu_base_input_type_double">DualInput</string>
<string name="beauty_box_heavy_blur_fine">Buffing</string>
<string name="beauty_box_color_level">Skin Tone</string>
@ -24,10 +8,6 @@
<string name="beauty_box_tooth_whiten">Whiten</string>
<string name="beauty_box_eye_enlarge">Enlarge</string>
<string name="beauty_box_eye_circle">Round</string>
<string name="beauty_box_cheek_natural">Origin</string>
<string name="beauty_box_cheek_goddess">Goddess</string>
<string name="beauty_box_cheek_long_face">Long face</string>
<string name="beauty_box_cheek_round_face">Round face</string>
<string name="beauty_box_cheekbones">Cheek</string>
<string name="beauty_box_lower_jaw">Jaw</string>
<string name="beauty_box_cheek_thinning">Lower Width</string>
@ -54,7 +34,6 @@
<string name="makeup_radio_highlight">Highlight</string>
<string name="makeup_radio_shadow">Shadow</string>
<string name="makeup_radio_remove">Remove</string>
<string name="makeup_customize">Custom</string>
<string name="makeup_peach_blossom">Peach</string>
<string name="makeup_boyfriend">Boyfriend</string>
<string name="makeup_clear">Clear</string>
@ -69,7 +48,6 @@
<string name="beauty_micro_long_nose">Nose Lift</string>
<string name="beauty_micro_eye_space">Eye Distance</string>
<string name="beauty_micro_eye_rotate">Eye Upturn</string>
<string name="beauty_face_style_none">None</string>
<string name="beauty_face_style_1">Style 1</string>
<string name="beauty_face_style_2">Style 2</string>
<string name="beauty_face_style_3">Style 3</string>
@ -77,13 +55,6 @@
<string name="beauty_face_style_5">Style 5</string>
<string name="beauty_face_style_6">Style 6</string>
<string name="beauty_face_style_7">Style 7</string>
<string name="beauty_face_style_toast">To use %s, cancel \'Style recommend\' first.</string>
<string name="select_data_photo">Photo</string>
<string name="select_data_video">Video</string>
<string name="select_data_title">Choose photo or video from your album</string>
<string name="image_file_does_not_exist">The selected image file does not exist.</string>
<string name="video_file_does_not_exist">The selected video file does not exist.</string>
<string name="future_warrior">Open your mouth</string>
<string name="jet_mask">Puff your cheeks</string>
@ -163,61 +134,13 @@
<string name="mitao_7">Peach 7</string>
<string name="mitao_8">Peach 8</string>
<string name="poster_take_photo">Please take photos by positive face.</string>
<string name="poster_change_face_error">change face failed</string>
<string name="poster_template_face_none">No template face detected, please re-upload</string>
<string name="dialog_no_track_face">No face detected, please re-upload</string>
<string name="dialog_no_incomplete_face">No face detected, please re-upload</string>
<string name="dialog_face_rotation_not_valid">Side face angle is too greater, please re-upload</string>
<string name="dialog_got">OK</string>
<string name="tip_dual_face">Multiple people detected, please choose one person for face fusion</string>
<string name="animoji_filter">Animoji</string>
<string name="cartoon_filter">Cartoon filter</string>
<string name="live_photo_back_not_save">Custom won\'t be saved after return</string>
<string name="live_photo_btn_delete">Delete</string>
<string name="live_photo_btn_cancel">Cancel</string>
<string name="live_photo_btn_delete_">Delete (%d)</string>
<string name="live_photo_empty_list_tip">Not created model</string>
<string name="live_photo_delete_effect">Delete model</string>
<string name="live_photo__delete_all">All</string>
<string name="confirm">Yes</string>
<string name="cancel">Cancel</string>
<string name="dialog_confirm_delete">Are you sure to delete?</string>
<string name="toast_delete_succeed">Delete succeed</string>
<string name="toast_delete_failed">Delete failed</string>
<string name="live_photo_save_succeed">Save succeed</string>
<string name="delete_avatar_model">Delete model</string>
<string name="new_avatar_model">Create model</string>
<string name="edit_avatar_model">Edit model</string>
<string name="avatar_face_hair">Hair style</string>
<string name="avatar_face_face">Face shape</string>
<string name="avatar_face_eye">Eyes</string>
<string name="avatar_face_lip">Mouth</string>
<string name="avatar_face_nose">Nose</string>
<string name="avatar_face_length">Face length</string>
<string name="avatar_face_width">Cheek width</string>
<string name="avatar_chin_width">Jaw width</string>
<string name="avatar_chin_height">Jaw length</string>
<string name="avatar_eye_position">Eye position</string>
<string name="avatar_eye_corner_height">Canthus position</string>
<string name="avatar_eye_height">Eye width</string>
<string name="avatar_eye_width">Eye length</string>
<string name="avatar_nose_position">Nose position</string>
<string name="avatar_nose_width">Nose width</string>
<string name="avatar_nose_height">Nose height</string>
<string name="avatar_mouth_position">Mouth position</string>
<string name="avatar_up_lip_thickness">Upper lip thickness</string>
<string name="avatar_down_lip_thickness">Down lip thickness</string>
<string name="avatar_lip_width">Lip width</string>
<string name="model_empty_tip">No model has been created</string>
<string name="dialog_reset_avatar_model">Reset all parameters to default?</string>
<string name="avatar_face_customize">Custom</string>
<string name="avatar_save_succeed">Save succeed</string>
<string name="recover">Recover</string>
<string name="makeup_lip_fog">Matte</string>
@ -284,9 +207,6 @@
<string name="makeup_combination_chuju">Daisy</string>
<string name="makeup_combination_gangfeng">HK style</string>
<string name="makeup_combination_rose">Rose</string>
<string name="makeup_combination_naicha">Milk tea</string>
<string name="makeup_combination_dousha">Bean paste</string>
<string name="makeup_combination_chaoa">Super a</string>
<string name="home_function_name_beauty">Beautification</string>
<string name="home_function_name_makeup">Makeup</string>
<string name="home_function_name_sticker">Sticker</string>
@ -299,16 +219,8 @@
<string name="beautify_hip_slim">Hip</string>
<string name="beautify_head_slim">Head shrink</string>
<string name="beautify_leg_thin_slim">Thin leg</string>
<string name="toast_not_detect_body">No message tracking</string>
<string name="pta_human_full_body">Body driver</string>
<string name="pta_human_half_body">Bust driver</string>
<string name="select_data_photo_or_video">Load picture or video</string>
<string name="toast_not_detect_gesture">No gesture tracking</string>
<string name="bg_seg_green_graphic">Keying</string>
<string name="bg_seg_green_background">Background</string>
<string name="bg_seg_green_key_color">Key color</string>
<string name="bg_seg_green_similarity">Similarity</string>
<string name="bg_seg_green_smooth">Smoothness</string>
@ -319,14 +231,9 @@
<string name="bg_seg_green_classroom">Classroom</string>
<string name="bg_seg_green_forest">Forest</string>
<string name="bg_seg_green_ink">Ink</string>
<string name="dialog_guide_bg_seg_green">Please use a solid background, a green screen is recommended for the best effect</string>
<string name="dialog_i_know">I know</string>
<string name="download_error">Download failed, please check the network and try again</string>
<string name="back">back</string>
<string name="safe_area_tips">The white area is a safe area and does not participate in green screen matting</string>
<string name="brow_height_tips">This function is only supported for high-end computers</string>
<string name="brow_space_tips">This function is only supported for high-end computers</string>
<string name="home_function_name_big_head">Funny big head</string>
@ -334,4 +241,5 @@
<string name="home_function_name_fine_sticker">Exquisite sticker</string>
<string name="dialog_reset">Reset</string>
<string name="menu_diy">Custom</string>
</resources>

View File

@ -18,9 +18,4 @@
<item name="android:padding">6dp</item>
</style>
<style name="SwitchCompat">
<item name="colorControlActivated">@color/main_color</item>
<item name="colorSwitchThumbNormal">#F1F1F1</item>
<item name="android:colorForeground">#FF2F2F2F</item>
</style>
</resources>

View File

@ -1,4 +1,6 @@
apply plugin: 'com.android.library'
apply from: "../package_config.gradle"
android {
namespace "com.samsung.android.sdk.iap.lib"
compileSdk rootProject.ext.android.compileSdkVersion

View File

@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.samsung.android.sdk.iap.lib"
android:versionCode="601000004"
android:versionName="6.1.0">
<!-- version code [Major/Minor/Bug fix release/Build number ] : x xx xxx xxx -->

View File

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** Created with STMS Automation System
*/ -->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- MIDS_SAPPS_POP_UNKNOWN_ERROR_OCCURRED -->
<string name="mids_sapps_pop_unknown_error_occurred">Unbekannter Fehler aufgetreten</string>
<!-- MIDS_SAPPS_HEADER_SAMSUNG_IN_APP_PURCHASE_ABB -->
<string name="mids_sapps_header_samsung_in_app_purchase_abb">Samsung In-App Purchase</string>
<!-- MIDS_SAPPS_POP_UNABLE_TO_OPEN_SAMSUNG_IN_APP_PURCHASE_MSG -->
<string name="mids_sapps_pop_unable_to_open_samsung_in_app_purchase_msg">Samsung In-App Purchase kann nicht geöffnet werden. Wechseln Sie zu „Berechtigungen“, erteilen Sie die erforderlichen Berechtigungen und versuchen Sie es anschließend erneut.</string>
<!-- DREAM_SAPPS_BODY_AUTHENTICATING_ING -->
<string name="dream_sapps_body_authenticating_ing">Authentifizierung wird durchgeführt\u2026</string>
<!-- DREAM_SAPPS_BODY_CONTACT_CUSTOMER_SERVICE_TO_COMPLETE_YOUR_PURCHASE -->
<string name="dream_sapps_body_contact_customer_service_to_complete_your_purchase">Wenden Sie sich an den Kundendienst, um Ihren Einkauf abzuschließen.</string>
<!-- DREAM_SAPPS_BODY_YOUR_PURCHASE_IS_COMPLETE -->
<string name="dream_sapps_body_your_purchase_is_complete">Ihr Kauf ist abgeschlossen.</string>
<!-- DREAM_PH_PHEADER_COULDNT_COMPLETE_PURCHASE -->
<string name="dream_ph_pheader_couldnt_complete_purchase">Abschließen des Kaufs nicht möglich</string>
<!-- DREAM_PH_BODY_TO_COMPLETE_THIS_PURCHASE_YOU_NEED_TO_UPDATE_THE_GALAXY_STORE -->
<string name="dream_ph_body_to_complete_this_purchase_you_need_to_update_the_galaxy_store">Sie müssen Galaxy Store aktualisieren, um diesen Kauf abzuschließen.</string>
<!-- DREAM_PH_BODY_TO_COMPLETE_THIS_PURCHASE_YOU_NEED_TO_ENABLE_THE_GALAXY_STORE_IN_SETTINGS -->
<string name="dream_ph_body_to_complete_this_purchase_you_need_to_enable_the_galaxy_store_in_settings">Sie müssen Galaxy Store in den Einstellungen aktivieren, um diesen Kauf abzuschließen.</string>
<!-- DREAM_PH_BODY_CONTACT_P1SSCUSTOMER_SERVICEP2SS_FOR_MORE_INFORMATION_N_NERROR_CODE_C_P3SS -->
<string name="dream_ph_body_contact_p1sscustomer_servicep2ss_for_more_information_n_nerror_code_c_p3ss">Weitere Informationen erhalten Sie vom %1$sKundendienst%2$s.\n\nFehlercode: %3$s</string>
<!-- IDS_COM_BODY_ERROR_CODE_C -->
<string name="ids_com_body_error_code_c">Fehlercode:</string>
<!-- MIDS_SAPPS_POP_TO_PURCHASE_ITEMS_YOU_NEED_TO_INSTALL_SAMSUNG_IN_APP_PURCHASE_INSTALL_Q -->
<string name="mids_sapps_pop_to_purchase_items_you_need_to_install_samsung_in_app_purchase_install_q">Wenn Sie Artikel kaufen möchten, müssen Sie Samsung In-App-Kauf installieren. Installieren?</string>
<!-- MIDS_SAPPS_POP_AN_INVALID_VALUE_HAS_BEEN_PROVIDED_FOR_SAMSUNG_IN_APP_PURCHASE -->
<string name="mids_sapps_pop_an_invalid_value_has_been_provided_for_samsung_in_app_purchase">Es wurde ein ungültiger Wert für Samsung In-App Purchase angegeben.</string>
<!-- MIDS_SAPPS_BODY_WAITING_ING -->
<string name="mids_sapps_body_waiting_ing">Warten\u2026</string>
<!-- MIDS_SAPPS_POP_PAYMENT_CANCELLED -->
<string name="mids_sapps_pop_payment_canceled">Zahlung abgebrochen</string>
<!-- MIDS_SAPPS_HEADER_UPDATE_GALAXY_APPS -->
<string name="mids_sapps_header_update_galaxy_apps">Aktualisieren von Galaxy Apps</string>
<!-- MIDS_SAPPS_POP_A_NEW_VERSION_IS_AVAILABLE_GALAXY_APPS_WILL_BE_UPDATED_TO_THE_LATEST_VERSION_TO_COMPLETE_THIS_PURCHASE -->
<string name="mids_sapps_pop_a_new_version_is_available_galaxy_apps_will_be_updated_to_the_latest_version_to_complete_this_purchase">Eine neue Version ist verfügbar. Galaxy Apps wird auf die neueste Version aktualisiert, um diesen Kauf abzuschließen.</string>
</resources>

View File

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** Created with STMS Automation System
*/ -->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- MIDS_SAPPS_POP_UNKNOWN_ERROR_OCCURRED -->
<string name="mids_sapps_pop_unknown_error_occurred">Дојде до непозната грешка.</string>
<!-- MIDS_SAPPS_HEADER_SAMSUNG_IN_APP_PURCHASE_ABB -->
<string name="mids_sapps_header_samsung_in_app_purchase_abb">Samsung In-App Purchase</string>
<!-- MIDS_SAPPS_POP_UNABLE_TO_OPEN_SAMSUNG_IN_APP_PURCHASE_MSG -->
<string name="mids_sapps_pop_unable_to_open_samsung_in_app_purchase_msg">Не може да се отвори Samsung In-App Purchase. Одете во Дозволи, а потоа овозможете ги бараните дозволи и обидете се повторно.</string>
<!-- DREAM_SAPPS_BODY_AUTHENTICATING_ING -->
<string name="dream_sapps_body_authenticating_ing">Се потврдува\u2026</string>
<!-- DREAM_SAPPS_BODY_CONTACT_CUSTOMER_SERVICE_TO_COMPLETE_YOUR_PURCHASE -->
<string name="dream_sapps_body_contact_customer_service_to_complete_your_purchase">Контактирајте со Службата за корисници за да го завршите Вашето купување.</string>
<!-- DREAM_SAPPS_BODY_YOUR_PURCHASE_IS_COMPLETE -->
<string name="dream_sapps_body_your_purchase_is_complete">Купувањето Ви е завршено.</string>
<!-- DREAM_PH_PHEADER_COULDNT_COMPLETE_PURCHASE -->
<string name="dream_ph_pheader_couldnt_complete_purchase">Не може да се заврши купувањето</string>
<!-- DREAM_PH_BODY_TO_COMPLETE_THIS_PURCHASE_YOU_NEED_TO_UPDATE_THE_GALAXY_STORE -->
<string name="dream_ph_body_to_complete_this_purchase_you_need_to_update_the_galaxy_store">За да го завршите ова купување, треба да го ажурирате Galaxy Store.</string>
<!-- DREAM_PH_BODY_TO_COMPLETE_THIS_PURCHASE_YOU_NEED_TO_ENABLE_THE_GALAXY_STORE_IN_SETTINGS -->
<string name="dream_ph_body_to_complete_this_purchase_you_need_to_enable_the_galaxy_store_in_settings">За да го завршите ова купување, треба да го овозможите Galaxy Store во Поставувања.</string>
<!-- DREAM_PH_BODY_CONTACT_P1SSCUSTOMER_SERVICEP2SS_FOR_MORE_INFORMATION_N_NERROR_CODE_C_P3SS -->
<string name="dream_ph_body_contact_p1sscustomer_servicep2ss_for_more_information_n_nerror_code_c_p3ss">Контактирајте со %1$sУслугите за корисниците%2$s за повеќе информации.\n\nШифра на грешка: %3$s</string>
<!-- IDS_COM_BODY_ERROR_CODE_C -->
<string name="ids_com_body_error_code_c">Шифра на грешка:</string>
<!-- MIDS_SAPPS_POP_TO_PURCHASE_ITEMS_YOU_NEED_TO_INSTALL_SAMSUNG_IN_APP_PURCHASE_INSTALL_Q -->
<string name="mids_sapps_pop_to_purchase_items_you_need_to_install_samsung_in_app_purchase_install_q">За да купувате ставки, треба да го инсталирате Samsung купување во апликација. Да се инсталира?</string>
<!-- MIDS_SAPPS_POP_AN_INVALID_VALUE_HAS_BEEN_PROVIDED_FOR_SAMSUNG_IN_APP_PURCHASE -->
<string name="mids_sapps_pop_an_invalid_value_has_been_provided_for_samsung_in_app_purchase">Дадена е неважечка вредност за Samsung In-App Purchase.</string>
<!-- MIDS_SAPPS_BODY_WAITING_ING -->
<string name="mids_sapps_body_waiting_ing">Се чека\u2026</string>
<!-- MIDS_SAPPS_POP_PAYMENT_CANCELLED -->
<string name="mids_sapps_pop_payment_canceled">Плаќањето е одложено.</string>
<!-- MIDS_SAPPS_HEADER_UPDATE_GALAXY_APPS -->
<string name="mids_sapps_header_update_galaxy_apps">Ажурирање на Galaxy Apps</string>
<!-- MIDS_SAPPS_POP_A_NEW_VERSION_IS_AVAILABLE_GALAXY_APPS_WILL_BE_UPDATED_TO_THE_LATEST_VERSION_TO_COMPLETE_THIS_PURCHASE -->
<string name="mids_sapps_pop_a_new_version_is_available_galaxy_apps_will_be_updated_to_the_latest_version_to_complete_this_purchase">Достапна е нова верзија. Galaxy Apps ќе се ажурира на најновата верзија за да го завршите купувањево.</string>
</resources>

37
SVGAlibrary/build.gradle Normal file
View File

@ -0,0 +1,37 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
}
compileOptions {
kotlinOptions.freeCompilerArgs += ['-module-name', "com.opensource.svgaplayer"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/MANIFEST.MF'
}
}
dependencies {
implementation 'com.squareup.wire:wire-runtime:4.4.1'
}

17
SVGAlibrary/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/PonyCui_Home/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -0,0 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.opensource.svgaplayer">
<application android:allowBackup="true" android:label="@string/app_name">
</application>
</manifest>

View File

@ -0,0 +1,9 @@
package com.opensource.svgaplayer
/**
* Created by miaojun on 2019/6/21.
* mail:1290846731@qq.com
*/
interface IClickAreaListener{
fun onResponseArea(key : String,x0 : Int, y0 : Int, x1 : Int, y1 : Int)
}

View File

@ -0,0 +1,119 @@
package com.opensource.svgaplayer
import android.content.Context
import com.opensource.svgaplayer.utils.log.LogUtils
import java.io.File
import java.net.URL
import java.security.MessageDigest
/**
* SVGA 缓存管理
*/
object SVGACache {
enum class Type {
DEFAULT,
FILE
}
private const val TAG = "SVGACache"
private var type: Type = Type.DEFAULT
private var cacheDir: String = "/"
get() {
if (field != "/") {
val dir = File(field)
if (!dir.exists()) {
dir.mkdirs()
}
}
return field
}
fun onCreate(context: Context?) {
onCreate(context, Type.DEFAULT)
}
fun onCreate(context: Context?, type: Type) {
if (isInitialized()) return
context ?: return
cacheDir = "${context.cacheDir.absolutePath}/svga/"
File(cacheDir).takeIf { !it.exists() }?.mkdirs()
this.type = type
}
/**
* 清理缓存
*/
fun clearCache() {
if (!isInitialized()) {
LogUtils.error(TAG, "SVGACache is not init!")
return
}
SVGAParser.threadPoolExecutor.execute {
clearDir(cacheDir)
LogUtils.info(TAG, "Clear svga cache done!")
}
}
// 清除目录下的所有文件
internal fun clearDir(path: String) {
try {
val dir = File(path)
dir.takeIf { it.exists() }?.let { parentDir ->
parentDir.listFiles()?.forEach { file ->
if (!file.exists()) {
return@forEach
}
if (file.isDirectory) {
clearDir(file.absolutePath)
}
file.delete()
}
}
} catch (e: Exception) {
LogUtils.error(TAG, "Clear svga cache path: $path fail", e)
}
}
fun isInitialized(): Boolean {
return "/" != cacheDir && File(cacheDir).exists()
}
fun isDefaultCache(): Boolean = type == Type.DEFAULT
fun isCached(cacheKey: String): Boolean {
return if (isDefaultCache()) {
buildCacheDir(cacheKey)
} else {
buildSvgaFile(
cacheKey
)
}.exists()
}
fun buildCacheKey(str: String): String {
val messageDigest = MessageDigest.getInstance("MD5")
messageDigest.update(str.toByteArray(charset("UTF-8")))
val digest = messageDigest.digest()
var sb = ""
for (b in digest) {
sb += String.format("%02x", b)
}
return sb
}
fun buildCacheKey(url: URL): String = buildCacheKey(url.toString())
fun buildCacheDir(cacheKey: String): File {
return File("$cacheDir$cacheKey/")
}
fun buildSvgaFile(cacheKey: String): File {
return File("$cacheDir$cacheKey.svga")
}
fun buildAudioFile(audio: String): File {
return File("$cacheDir$audio.mp3")
}
}

View File

@ -0,0 +1,13 @@
package com.opensource.svgaplayer
/**
* Created by cuiminghui on 2017/3/30.
*/
interface SVGACallback {
fun onPause()
fun onFinished()
fun onRepeat()
fun onStep(frame: Int, percentage: Double)
}

View File

@ -0,0 +1,9 @@
package com.opensource.svgaplayer
/**
* Created by miaojun on 2019/6/21.
* mail:1290846731@qq.com
*/
interface SVGAClickAreaListener{
fun onClick(clickKey : String)
}

View File

@ -0,0 +1,106 @@
package com.opensource.svgaplayer
import android.graphics.Canvas
import android.graphics.ColorFilter
import android.graphics.PixelFormat
import android.graphics.drawable.Drawable
import android.widget.ImageView
import com.opensource.svgaplayer.drawer.SVGACanvasDrawer
class SVGADrawable(val videoItem: SVGAVideoEntity, val dynamicItem: SVGADynamicEntity): Drawable() {
constructor(videoItem: SVGAVideoEntity): this(videoItem, SVGADynamicEntity())
var cleared = true
internal set (value) {
if (field == value) {
return
}
field = value
invalidateSelf()
}
var currentFrame = 0
internal set (value) {
if (field == value) {
return
}
field = value
invalidateSelf()
}
var scaleType: ImageView.ScaleType = ImageView.ScaleType.MATRIX
private val drawer = SVGACanvasDrawer(videoItem, dynamicItem)
override fun draw(canvas: Canvas?) {
if (cleared) {
return
}
canvas?.let {
drawer.drawFrame(it,currentFrame, scaleType)
}
}
override fun setAlpha(alpha: Int) {
}
override fun getOpacity(): Int {
return PixelFormat.TRANSPARENT
}
override fun setColorFilter(colorFilter: ColorFilter?) {
}
fun resume() {
videoItem.audioList.forEach { audio ->
audio.playID?.let {
if (SVGASoundManager.isInit()){
SVGASoundManager.resume(it)
}else{
videoItem.soundPool?.resume(it)
}
}
}
}
fun pause() {
videoItem.audioList.forEach { audio ->
audio.playID?.let {
if (SVGASoundManager.isInit()){
SVGASoundManager.pause(it)
}else{
videoItem.soundPool?.pause(it)
}
}
}
}
fun stop() {
videoItem.audioList.forEach { audio ->
audio.playID?.let {
if (SVGASoundManager.isInit()){
SVGASoundManager.stop(it)
}else{
videoItem.soundPool?.stop(it)
}
}
}
}
fun clear() {
videoItem.audioList.forEach { audio ->
audio.playID?.let {
if (SVGASoundManager.isInit()){
SVGASoundManager.stop(it)
}else{
videoItem.soundPool?.stop(it)
}
}
audio.playID = null
}
videoItem.clear()
}
}

View File

@ -0,0 +1,153 @@
package com.opensource.svgaplayer
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.text.BoringLayout
import android.text.StaticLayout
import android.text.TextPaint
import java.net.HttpURLConnection
import java.net.URL
/**
* Created by cuiminghui on 2017/3/30.
*/
class SVGADynamicEntity {
internal var dynamicHidden: HashMap<String, Boolean> = hashMapOf()
internal var dynamicImage: HashMap<String, Bitmap> = hashMapOf()
internal var dynamicText: HashMap<String, String> = hashMapOf()
internal var dynamicTextPaint: HashMap<String, TextPaint> = hashMapOf()
internal var dynamicStaticLayoutText: HashMap<String, StaticLayout> = hashMapOf()
internal var dynamicBoringLayoutText: HashMap<String, BoringLayout> = hashMapOf()
internal var dynamicDrawer: HashMap<String, (canvas: Canvas, frameIndex: Int) -> Boolean> = hashMapOf()
//点击事件回调map
internal var mClickMap : HashMap<String, IntArray> = hashMapOf()
internal var dynamicIClickArea: HashMap<String, IClickAreaListener> = hashMapOf()
internal var dynamicDrawerSized: HashMap<String, (canvas: Canvas, frameIndex: Int, width: Int, height: Int) -> Boolean> = hashMapOf()
internal var isTextDirty = false
fun setHidden(value: Boolean, forKey: String) {
this.dynamicHidden.put(forKey, value)
}
fun setDynamicImage(bitmap: Bitmap, forKey: String) {
this.dynamicImage.put(forKey, bitmap)
}
fun setDynamicImage(url: String, forKey: String) {
val handler = android.os.Handler()
SVGAParser.threadPoolExecutor.execute {
(URL(url).openConnection() as? HttpURLConnection)?.let {
try {
it.connectTimeout = 20 * 1000
it.requestMethod = "GET"
it.connect()
it.inputStream.use { stream ->
BitmapFactory.decodeStream(stream)?.let {
handler.post { setDynamicImage(it, forKey) }
}
}
} catch (e: Exception) {
e.printStackTrace()
} finally {
try {
it.disconnect()
} catch (disconnectException: Throwable) {
// ignored here
}
}
}
}
}
fun setDynamicText(text: String, textPaint: TextPaint, forKey: String) {
this.isTextDirty = true
this.dynamicText.put(forKey, text)
this.dynamicTextPaint.put(forKey, textPaint)
}
fun setDynamicText(layoutText: StaticLayout, forKey: String) {
this.isTextDirty = true
this.dynamicStaticLayoutText.put(forKey, layoutText)
}
fun setDynamicText(layoutText: BoringLayout, forKey: String) {
this.isTextDirty = true
BoringLayout.isBoring(layoutText.text,layoutText.paint)?.let {
this.dynamicBoringLayoutText.put(forKey,layoutText)
}
}
fun setDynamicDrawer(drawer: (canvas: Canvas, frameIndex: Int) -> Boolean, forKey: String) {
this.dynamicDrawer.put(forKey, drawer)
}
fun setClickArea(clickKey: List<String>) {
for(itemKey in clickKey){
dynamicIClickArea.put(itemKey,object : IClickAreaListener {
override fun onResponseArea(key: String, x0: Int, y0: Int, x1: Int, y1: Int) {
mClickMap.let {
if(it.get(key) == null){
it.put(key, intArrayOf(x0,y0,x1,y1))
}else{
it.get(key)?.let {
it[0] = x0
it[1] = y0
it[2] = x1
it[3] = y1
}
}
}
}
})
}
}
fun setClickArea(clickKey: String) {
dynamicIClickArea.put(clickKey, object : IClickAreaListener {
override fun onResponseArea(key: String, x0: Int, y0: Int, x1: Int, y1: Int) {
mClickMap.let {
if (it.get(key) == null) {
it.put(key, intArrayOf(x0, y0, x1, y1))
} else {
it.get(key)?.let {
it[0] = x0
it[1] = y0
it[2] = x1
it[3] = y1
}
}
}
}
})
}
fun setDynamicDrawerSized(drawer: (canvas: Canvas, frameIndex: Int, width: Int, height: Int) -> Boolean, forKey: String) {
this.dynamicDrawerSized.put(forKey, drawer)
}
fun clearDynamicObjects() {
this.isTextDirty = true
this.dynamicHidden.clear()
this.dynamicImage.clear()
this.dynamicText.clear()
this.dynamicTextPaint.clear()
this.dynamicStaticLayoutText.clear()
this.dynamicBoringLayoutText.clear()
this.dynamicDrawer.clear()
this.dynamicIClickArea.clear()
this.mClickMap.clear()
this.dynamicDrawerSized.clear()
}
}

View File

@ -0,0 +1,329 @@
package com.opensource.svgaplayer
import android.animation.Animator
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.content.Context
import android.os.Build
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.view.animation.LinearInterpolator
import android.widget.ImageView
import com.opensource.svgaplayer.utils.SVGARange
import com.opensource.svgaplayer.utils.log.LogUtils
import java.lang.ref.WeakReference
import java.net.URL
/**
* Created by PonyCui on 2017/3/29.
*/
open class SVGAImageView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ImageView(context, attrs, defStyleAttr) {
private val TAG = "SVGAImageView"
enum class FillMode {
Backward,
Forward,
Clear,
}
var isAnimating = false
private set
var loops = 0
@Deprecated(
"It is recommended to use clearAfterDetached, or manually call to SVGAVideoEntity#clear." +
"If you just consider cleaning up the canvas after playing, you can use FillMode#Clear.",
level = DeprecationLevel.WARNING
)
var clearsAfterStop = false
var clearsAfterDetached = false
var fillMode: FillMode = FillMode.Forward
var callback: SVGACallback? = null
private var mAnimator: ValueAnimator? = null
private var mItemClickAreaListener: SVGAClickAreaListener? = null
private var mAntiAlias = true
private var mAutoPlay = true
private val mAnimatorListener = AnimatorListener(this)
private val mAnimatorUpdateListener = AnimatorUpdateListener(this)
private var mStartFrame = 0
private var mEndFrame = 0
init {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
this.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
}
attrs?.let { loadAttrs(it) }
}
private fun loadAttrs(attrs: AttributeSet) {
val typedArray = context.theme.obtainStyledAttributes(attrs, R.styleable.SVGAImageView, 0, 0)
loops = typedArray.getInt(R.styleable.SVGAImageView_loopCount, 0)
clearsAfterStop = typedArray.getBoolean(R.styleable.SVGAImageView_clearsAfterStop, false)
clearsAfterDetached = typedArray.getBoolean(R.styleable.SVGAImageView_clearsAfterDetached, false)
mAntiAlias = typedArray.getBoolean(R.styleable.SVGAImageView_antiAlias, true)
mAutoPlay = typedArray.getBoolean(R.styleable.SVGAImageView_autoPlay, true)
typedArray.getString(R.styleable.SVGAImageView_fillMode)?.let {
when (it) {
"0" -> {
fillMode = FillMode.Backward
}
"1" -> {
fillMode = FillMode.Forward
}
"2" -> {
fillMode = FillMode.Clear
}
}
}
typedArray.getString(R.styleable.SVGAImageView_source)?.let {
parserSource(it)
}
typedArray.recycle()
}
private fun parserSource(source: String) {
val refImgView = WeakReference<SVGAImageView>(this)
val parser = SVGAParser(context)
if (source.startsWith("http://") || source.startsWith("https://")) {
parser.decodeFromURL(URL(source), createParseCompletion(refImgView))
} else {
parser.decodeFromAssets(source, createParseCompletion(refImgView))
}
}
private fun createParseCompletion(ref: WeakReference<SVGAImageView>): SVGAParser.ParseCompletion {
return object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
ref.get()?.startAnimation(videoItem)
}
override fun onError() {}
}
}
private fun startAnimation(videoItem: SVGAVideoEntity) {
this@SVGAImageView.post {
videoItem.antiAlias = mAntiAlias
setVideoItem(videoItem)
getSVGADrawable()?.scaleType = scaleType
if (mAutoPlay) {
startAnimation()
}
}
}
fun startAnimation() {
startAnimation(null, false)
}
fun startAnimation(range: SVGARange?, reverse: Boolean = false) {
stopAnimation(false)
play(range, reverse)
}
private fun play(range: SVGARange?, reverse: Boolean) {
LogUtils.info(TAG, "================ start animation ================")
val drawable = getSVGADrawable() ?: return
setupDrawable()
mStartFrame = Math.max(0, range?.location ?: 0)
val videoItem = drawable.videoItem
mEndFrame = Math.min(videoItem.frames - 1, ((range?.location ?: 0) + (range?.length ?: Int.MAX_VALUE) - 1))
val animator = ValueAnimator.ofInt(mStartFrame, mEndFrame)
animator.interpolator = LinearInterpolator()
animator.duration = ((mEndFrame - mStartFrame + 1) * (1000 / videoItem.FPS) / generateScale()).toLong()
animator.repeatCount = if (loops <= 0) 99999 else loops - 1
animator.addUpdateListener(mAnimatorUpdateListener)
animator.addListener(mAnimatorListener)
if (reverse) {
animator.reverse()
} else {
animator.start()
}
mAnimator = animator
}
private fun setupDrawable() {
val drawable = getSVGADrawable() ?: return
drawable.cleared = false
drawable.scaleType = scaleType
}
private fun getSVGADrawable(): SVGADrawable? {
return drawable as? SVGADrawable
}
@Suppress("UNNECESSARY_SAFE_CALL")
private fun generateScale(): Double {
var scale = 1.0
try {
val animatorClass = Class.forName("android.animation.ValueAnimator") ?: return scale
val getMethod = animatorClass.getDeclaredMethod("getDurationScale") ?: return scale
scale = (getMethod.invoke(animatorClass) as Float).toDouble()
if (scale == 0.0) {
val setMethod = animatorClass.getDeclaredMethod("setDurationScale",Float::class.java) ?: return scale
setMethod.isAccessible = true
setMethod.invoke(animatorClass,1.0f)
scale = 1.0
LogUtils.info(TAG,
"The animation duration scale has been reset to" +
" 1.0x, because you closed it on developer options.")
}
} catch (ignore: Exception) {
ignore.printStackTrace()
}
return scale
}
private fun onAnimatorUpdate(animator: ValueAnimator?) {
val drawable = getSVGADrawable() ?: return
drawable.currentFrame = animator?.animatedValue as Int
val percentage = (drawable.currentFrame + 1).toDouble() / drawable.videoItem.frames.toDouble()
callback?.onStep(drawable.currentFrame, percentage)
}
private fun onAnimationEnd(animation: Animator?) {
isAnimating = false
stopAnimation()
val drawable = getSVGADrawable()
if (drawable != null) {
when (fillMode) {
FillMode.Backward -> {
drawable.currentFrame = mStartFrame
}
FillMode.Forward -> {
drawable.currentFrame = mEndFrame
}
FillMode.Clear -> {
drawable.cleared = true
}
}
}
callback?.onFinished()
}
fun clear() {
getSVGADrawable()?.cleared = true
getSVGADrawable()?.clear()
// 清除对 drawable 的引用
setImageDrawable(null)
}
fun pauseAnimation() {
stopAnimation(false)
callback?.onPause()
}
fun stopAnimation() {
stopAnimation(clear = clearsAfterStop)
}
fun stopAnimation(clear: Boolean) {
mAnimator?.cancel()
mAnimator?.removeAllListeners()
mAnimator?.removeAllUpdateListeners()
getSVGADrawable()?.stop()
getSVGADrawable()?.cleared = clear
}
fun setVideoItem(videoItem: SVGAVideoEntity?) {
setVideoItem(videoItem, SVGADynamicEntity())
}
fun setVideoItem(videoItem: SVGAVideoEntity?, dynamicItem: SVGADynamicEntity?) {
if (videoItem == null) {
setImageDrawable(null)
} else {
val drawable = SVGADrawable(videoItem, dynamicItem ?: SVGADynamicEntity())
drawable.cleared = true
setImageDrawable(drawable)
}
}
fun stepToFrame(frame: Int, andPlay: Boolean) {
pauseAnimation()
val drawable = getSVGADrawable() ?: return
drawable.currentFrame = frame
if (andPlay) {
startAnimation()
mAnimator?.let {
it.currentPlayTime = (Math.max(0.0f, Math.min(1.0f, (frame.toFloat() / drawable.videoItem.frames.toFloat()))) * it.duration).toLong()
}
}
}
fun stepToPercentage(percentage: Double, andPlay: Boolean) {
val drawable = drawable as? SVGADrawable ?: return
var frame = (drawable.videoItem.frames * percentage).toInt()
if (frame >= drawable.videoItem.frames && frame > 0) {
frame = drawable.videoItem.frames - 1
}
stepToFrame(frame, andPlay)
}
fun setOnAnimKeyClickListener(clickListener : SVGAClickAreaListener){
mItemClickAreaListener = clickListener
}
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent?): Boolean {
if (event?.action != MotionEvent.ACTION_DOWN) {
return super.onTouchEvent(event)
}
val drawable = getSVGADrawable() ?: return super.onTouchEvent(event)
for ((key, value) in drawable.dynamicItem.mClickMap) {
if (event.x >= value[0] && event.x <= value[2] && event.y >= value[1] && event.y <= value[3]) {
mItemClickAreaListener?.let {
it.onClick(key)
return true
}
}
}
return super.onTouchEvent(event)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
stopAnimation(clearsAfterDetached)
if (clearsAfterDetached) {
clear()
}
}
private class AnimatorListener(view: SVGAImageView) : Animator.AnimatorListener {
private val weakReference = WeakReference<SVGAImageView>(view)
override fun onAnimationRepeat(animation: Animator?) {
weakReference.get()?.callback?.onRepeat()
}
override fun onAnimationEnd(animation: Animator?) {
weakReference.get()?.onAnimationEnd(animation)
}
override fun onAnimationCancel(animation: Animator?) {
weakReference.get()?.isAnimating = false
}
override fun onAnimationStart(animation: Animator?) {
weakReference.get()?.isAnimating = true
}
} // end of AnimatorListener
private class AnimatorUpdateListener(view: SVGAImageView) : ValueAnimator.AnimatorUpdateListener {
private val weakReference = WeakReference<SVGAImageView>(view)
override fun onAnimationUpdate(animation: ValueAnimator?) {
weakReference.get()?.onAnimatorUpdate(animation)
}
} // end of AnimatorUpdateListener
}

View File

@ -0,0 +1,565 @@
package com.opensource.svgaplayer
import android.content.Context
import android.net.http.HttpResponseCache
import android.os.Handler
import android.os.Looper
import com.opensource.svgaplayer.proto.MovieEntity
import com.opensource.svgaplayer.utils.log.LogUtils
import org.json.JSONObject
import java.io.*
import java.net.HttpURLConnection
import java.net.URL
import java.util.concurrent.Executors
import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.atomic.AtomicInteger
import java.util.zip.Inflater
import java.util.zip.ZipInputStream
/**
* Created by PonyCui 16/6/18.
*/
private var fileLock: Int = 0
private var isUnzipping = false
class SVGAParser(context: Context?) {
private var mContext = context?.applicationContext
init {
SVGACache.onCreate(context)
}
@Volatile
private var mFrameWidth: Int = 0
@Volatile
private var mFrameHeight: Int = 0
interface ParseCompletion {
fun onComplete(videoItem: SVGAVideoEntity)
fun onError()
}
interface PlayCallback{
fun onPlay(file: List<File>)
}
open class FileDownloader {
var noCache = false
open fun resume(url: URL, complete: (inputStream: InputStream) -> Unit, failure: (e: Exception) -> Unit): () -> Unit {
var cancelled = false
val cancelBlock = {
cancelled = true
}
threadPoolExecutor.execute {
try {
LogUtils.info(TAG, "================ svga file download start ================")
if (HttpResponseCache.getInstalled() == null && !noCache) {
LogUtils.error(TAG, "SVGAParser can not handle cache before install HttpResponseCache. see https://github.com/yyued/SVGAPlayer-Android#cache")
LogUtils.error(TAG, "在配置 HttpResponseCache 前 SVGAParser 无法缓存. 查看 https://github.com/yyued/SVGAPlayer-Android#cache ")
}
(url.openConnection() as? HttpURLConnection)?.let {
it.connectTimeout = 20 * 1000
it.requestMethod = "GET"
it.setRequestProperty("Connection", "close")
it.connect()
it.inputStream.use { inputStream ->
ByteArrayOutputStream().use { outputStream ->
val buffer = ByteArray(4096)
var count: Int
while (true) {
if (cancelled) {
LogUtils.warn(TAG, "================ svga file download canceled ================")
break
}
count = inputStream.read(buffer, 0, 4096)
if (count == -1) {
break
}
outputStream.write(buffer, 0, count)
}
if (cancelled) {
LogUtils.warn(TAG, "================ svga file download canceled ================")
return@execute
}
ByteArrayInputStream(outputStream.toByteArray()).use {
LogUtils.info(TAG, "================ svga file download complete ================")
complete(it)
}
}
}
}
} catch (e: Exception) {
LogUtils.error(TAG, "================ svga file download fail ================")
LogUtils.error(TAG, "error: ${e.message}")
e.printStackTrace()
failure(e)
}
}
return cancelBlock
}
}
var fileDownloader = FileDownloader()
companion object {
private const val TAG = "SVGAParser"
private val threadNum = AtomicInteger(0)
private var mShareParser = SVGAParser(null)
internal var threadPoolExecutor = Executors.newCachedThreadPool { r ->
Thread(r, "SVGAParser-Thread-${threadNum.getAndIncrement()}")
}
fun setThreadPoolExecutor(executor: ThreadPoolExecutor) {
threadPoolExecutor = executor
}
fun shareParser(): SVGAParser {
return mShareParser
}
}
fun init(context: Context) {
mContext = context.applicationContext
SVGACache.onCreate(mContext)
}
fun setFrameSize(frameWidth: Int, frameHeight: Int) {
mFrameWidth = frameWidth
mFrameHeight = frameHeight
}
fun decodeFromAssets(
name: String,
callback: ParseCompletion?,
playCallback: PlayCallback? = null
) {
if (mContext == null) {
LogUtils.error(TAG, "在配置 SVGAParser context 前, 无法解析 SVGA 文件。")
return
}
LogUtils.info(TAG, "================ decode $name from assets ================")
threadPoolExecutor.execute {
try {
mContext?.assets?.open(name)?.let {
this.decodeFromInputStream(
it,
SVGACache.buildCacheKey("file:///assets/$name"),
callback,
true,
playCallback,
alias = name
)
}
} catch (e: Exception) {
this.invokeErrorCallback(e, callback, name)
}
}
}
fun decodeFromURL(
url: URL,
callback: ParseCompletion?,
playCallback: PlayCallback? = null
): (() -> Unit)? {
if (mContext == null) {
LogUtils.error(TAG, "在配置 SVGAParser context 前, 无法解析 SVGA 文件。")
return null
}
val urlPath = url.toString()
LogUtils.info(TAG, "================ decode from url: $urlPath ================")
val cacheKey = SVGACache.buildCacheKey(url);
return if (SVGACache.isCached(cacheKey)) {
LogUtils.info(TAG, "this url cached")
threadPoolExecutor.execute {
if (SVGACache.isDefaultCache()) {
this.decodeFromCacheKey(cacheKey, callback, alias = urlPath)
} else {
this.decodeFromSVGAFileCacheKey(cacheKey, callback, playCallback, alias = urlPath)
}
}
return null
} else {
LogUtils.info(TAG, "no cached, prepare to download")
fileDownloader.resume(url, {
this.decodeFromInputStream(
it,
cacheKey,
callback,
false,
playCallback,
alias = urlPath
)
}, {
LogUtils.error(
TAG,
"================ svga file: $url download fail ================"
)
this.invokeErrorCallback(it, callback, alias = urlPath)
})
}
}
/**
* 读取解析本地缓存的 svga 文件.
*/
fun decodeFromSVGAFileCacheKey(
cacheKey: String,
callback: ParseCompletion?,
playCallback: PlayCallback?,
alias: String? = null
) {
threadPoolExecutor.execute {
try {
LogUtils.info(TAG, "================ decode $alias from svga cachel file to entity ================")
FileInputStream(SVGACache.buildSvgaFile(cacheKey)).use { inputStream ->
readAsBytes(inputStream)?.let { bytes ->
if (isZipFile(bytes)) {
this.decodeFromCacheKey(cacheKey, callback, alias)
} else {
LogUtils.info(TAG, "inflate start")
inflate(bytes)?.let {
LogUtils.info(TAG, "inflate complete")
val videoItem = SVGAVideoEntity(
MovieEntity.ADAPTER.decode(it),
File(cacheKey),
mFrameWidth,
mFrameHeight
)
LogUtils.info(TAG, "SVGAVideoEntity prepare start")
videoItem.prepare({
LogUtils.info(TAG, "SVGAVideoEntity prepare success")
this.invokeCompleteCallback(videoItem, callback, alias)
},playCallback)
} ?: this.invokeErrorCallback(
Exception("inflate(bytes) cause exception"),
callback,
alias
)
}
} ?: this.invokeErrorCallback(
Exception("readAsBytes(inputStream) cause exception"),
callback,
alias
)
}
} catch (e: java.lang.Exception) {
this.invokeErrorCallback(e, callback, alias)
} finally {
LogUtils.info(TAG, "================ decode $alias from svga cachel file to entity end ================")
}
}
}
fun decodeFromInputStream(
inputStream: InputStream,
cacheKey: String,
callback: ParseCompletion?,
closeInputStream: Boolean = false,
playCallback: PlayCallback? = null,
alias: String? = null
) {
if (mContext == null) {
LogUtils.error(TAG, "在配置 SVGAParser context 前, 无法解析 SVGA 文件。")
return
}
LogUtils.info(TAG, "================ decode $alias from input stream ================")
threadPoolExecutor.execute {
try {
readAsBytes(inputStream)?.let { bytes ->
if (isZipFile(bytes)) {
LogUtils.info(TAG, "decode from zip file")
if (!SVGACache.buildCacheDir(cacheKey).exists() || isUnzipping) {
synchronized(fileLock) {
if (!SVGACache.buildCacheDir(cacheKey).exists()) {
isUnzipping = true
LogUtils.info(TAG, "no cached, prepare to unzip")
ByteArrayInputStream(bytes).use {
unzip(it, cacheKey)
isUnzipping = false
LogUtils.info(TAG, "unzip success")
}
}
}
}
this.decodeFromCacheKey(cacheKey, callback, alias)
} else {
if (!SVGACache.isDefaultCache()) {
// 如果 SVGACache 设置类型为 FILE
threadPoolExecutor.execute {
SVGACache.buildSvgaFile(cacheKey).let { cacheFile ->
try {
cacheFile.takeIf { !it.exists() }?.createNewFile()
FileOutputStream(cacheFile).write(bytes)
} catch (e: Exception) {
LogUtils.error(TAG, "create cache file fail.", e)
cacheFile.delete()
}
}
}
}
LogUtils.info(TAG, "inflate start")
inflate(bytes)?.let {
LogUtils.info(TAG, "inflate complete")
val videoItem = SVGAVideoEntity(
MovieEntity.ADAPTER.decode(it),
File(cacheKey),
mFrameWidth,
mFrameHeight
)
LogUtils.info(TAG, "SVGAVideoEntity prepare start")
videoItem.prepare({
LogUtils.info(TAG, "SVGAVideoEntity prepare success")
this.invokeCompleteCallback(videoItem, callback, alias)
},playCallback)
} ?: this.invokeErrorCallback(
Exception("inflate(bytes) cause exception"),
callback,
alias
)
}
} ?: this.invokeErrorCallback(
Exception("readAsBytes(inputStream) cause exception"),
callback,
alias
)
} catch (e: java.lang.Exception) {
this.invokeErrorCallback(e, callback, alias)
} finally {
if (closeInputStream) {
inputStream.close()
}
LogUtils.info(TAG, "================ decode $alias from input stream end ================")
}
}
}
/**
* @deprecated from 2.4.0
*/
@Deprecated("This method has been deprecated from 2.4.0.", ReplaceWith("this.decodeFromAssets(assetsName, callback)"))
fun parse(assetsName: String, callback: ParseCompletion?) {
this.decodeFromAssets(assetsName, callback,null)
}
/**
* @deprecated from 2.4.0
*/
@Deprecated("This method has been deprecated from 2.4.0.", ReplaceWith("this.decodeFromURL(url, callback)"))
fun parse(url: URL, callback: ParseCompletion?) {
this.decodeFromURL(url, callback,null)
}
/**
* @deprecated from 2.4.0
*/
@Deprecated("This method has been deprecated from 2.4.0.", ReplaceWith("this.decodeFromInputStream(inputStream, cacheKey, callback, closeInputStream)"))
fun parse(
inputStream: InputStream,
cacheKey: String,
callback: ParseCompletion?,
closeInputStream: Boolean = false
) {
this.decodeFromInputStream(inputStream, cacheKey, callback, closeInputStream,null)
}
private fun invokeCompleteCallback(
videoItem: SVGAVideoEntity,
callback: ParseCompletion?,
alias: String?
) {
Handler(Looper.getMainLooper()).post {
LogUtils.info(TAG, "================ $alias parser complete ================")
callback?.onComplete(videoItem)
}
}
private fun invokeErrorCallback(
e: Exception,
callback: ParseCompletion?,
alias: String?
) {
e.printStackTrace()
LogUtils.error(TAG, "================ $alias parser error ================")
LogUtils.error(TAG, "$alias parse error", e)
Handler(Looper.getMainLooper()).post {
callback?.onError()
}
}
private fun decodeFromCacheKey(
cacheKey: String,
callback: ParseCompletion?,
alias: String?
) {
LogUtils.info(TAG, "================ decode $alias from cache ================")
LogUtils.debug(TAG, "decodeFromCacheKey called with cacheKey : $cacheKey")
if (mContext == null) {
LogUtils.error(TAG, "在配置 SVGAParser context 前, 无法解析 SVGA 文件。")
return
}
try {
val cacheDir = SVGACache.buildCacheDir(cacheKey)
File(cacheDir, "movie.binary").takeIf { it.isFile }?.let { binaryFile ->
try {
LogUtils.info(TAG, "binary change to entity")
FileInputStream(binaryFile).use {
LogUtils.info(TAG, "binary change to entity success")
this.invokeCompleteCallback(
SVGAVideoEntity(
MovieEntity.ADAPTER.decode(it),
cacheDir,
mFrameWidth,
mFrameHeight
),
callback,
alias
)
}
} catch (e: Exception) {
LogUtils.error(TAG, "binary change to entity fail", e)
cacheDir.delete()
binaryFile.delete()
throw e
}
}
File(cacheDir, "movie.spec").takeIf { it.isFile }?.let { jsonFile ->
try {
LogUtils.info(TAG, "spec change to entity")
FileInputStream(jsonFile).use { fileInputStream ->
ByteArrayOutputStream().use { byteArrayOutputStream ->
val buffer = ByteArray(2048)
while (true) {
val size = fileInputStream.read(buffer, 0, buffer.size)
if (size == -1) {
break
}
byteArrayOutputStream.write(buffer, 0, size)
}
byteArrayOutputStream.toString().let {
JSONObject(it).let {
LogUtils.info(TAG, "spec change to entity success")
this.invokeCompleteCallback(
SVGAVideoEntity(
it,
cacheDir,
mFrameWidth,
mFrameHeight
),
callback,
alias
)
}
}
}
}
} catch (e: Exception) {
LogUtils.error(TAG, "$alias movie.spec change to entity fail", e)
cacheDir.delete()
jsonFile.delete()
throw e
}
}
} catch (e: Exception) {
this.invokeErrorCallback(e, callback, alias)
}
}
private fun readAsBytes(inputStream: InputStream): ByteArray? {
ByteArrayOutputStream().use { byteArrayOutputStream ->
val byteArray = ByteArray(2048)
while (true) {
val count = inputStream.read(byteArray, 0, 2048)
if (count <= 0) {
break
} else {
byteArrayOutputStream.write(byteArray, 0, count)
}
}
return byteArrayOutputStream.toByteArray()
}
}
private fun inflate(byteArray: ByteArray): ByteArray? {
val inflater = Inflater()
inflater.setInput(byteArray, 0, byteArray.size)
val inflatedBytes = ByteArray(2048)
ByteArrayOutputStream().use { inflatedOutputStream ->
while (true) {
val count = inflater.inflate(inflatedBytes, 0, 2048)
if (count <= 0) {
break
} else {
inflatedOutputStream.write(inflatedBytes, 0, count)
}
}
inflater.end()
return inflatedOutputStream.toByteArray()
}
}
// 是否是 zip 文件
private fun isZipFile(bytes: ByteArray): Boolean {
return bytes.size > 4 && bytes[0].toInt() == 80 && bytes[1].toInt() == 75 && bytes[2].toInt() == 3 && bytes[3].toInt() == 4
}
// 解压
private fun unzip(inputStream: InputStream, cacheKey: String) {
LogUtils.info(TAG, "================ unzip prepare ================")
val cacheDir = SVGACache.buildCacheDir(cacheKey)
cacheDir.mkdirs()
try {
BufferedInputStream(inputStream).use {
ZipInputStream(it).use { zipInputStream ->
while (true) {
val zipItem = zipInputStream.nextEntry ?: break
if (zipItem.name.contains("../")) {
// 解压路径存在路径穿越问题,直接过滤
continue
}
if (zipItem.name.contains("/")) {
continue
}
val file = File(cacheDir, zipItem.name)
ensureUnzipSafety(file, cacheDir.absolutePath)
FileOutputStream(file).use { fileOutputStream ->
val buff = ByteArray(2048)
while (true) {
val readBytes = zipInputStream.read(buff)
if (readBytes <= 0) {
break
}
fileOutputStream.write(buff, 0, readBytes)
}
}
LogUtils.error(TAG, "================ unzip complete ================")
zipInputStream.closeEntry()
}
}
}
} catch (e: Exception) {
LogUtils.error(TAG, "================ unzip error ================")
LogUtils.error(TAG, "error", e)
SVGACache.clearDir(cacheDir.absolutePath)
cacheDir.delete()
throw e
}
}
// 检查 zip 路径穿透
private fun ensureUnzipSafety(outputFile: File, dstDirPath: String) {
val dstDirCanonicalPath = File(dstDirPath).canonicalPath
val outputFileCanonicalPath = outputFile.canonicalPath
if (!outputFileCanonicalPath.startsWith(dstDirCanonicalPath)) {
throw IOException("Found Zip Path Traversal Vulnerability with $dstDirCanonicalPath")
}
}
}

View File

@ -0,0 +1,19 @@
package com.opensource.svgaplayer
import android.content.Context
import android.util.AttributeSet
/**
* Created by cuiminghui on 2017/3/30.
* @deprecated from 2.4.0
*/
@Deprecated("This class has been deprecated from 2.4.0. We don't recommend you to use it.")
class SVGAPlayer: SVGAImageView {
constructor(context: Context) : super(context) {}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {}
}

View File

@ -0,0 +1,194 @@
package com.opensource.svgaplayer
/**
* @author Devin
*
* Created on 2/24/21.
*/
import android.media.AudioAttributes
import android.media.AudioManager
import android.media.SoundPool
import android.os.Build
import com.opensource.svgaplayer.utils.log.LogUtils
import java.io.FileDescriptor
/**
* Author : llk
* Time : 2020/10/24
* Description : svga 音频加载管理类
* SoundPool 抽取到单例里边规避 load 资源之后不回调 onLoadComplete 的问题
*
* 需要对 SVGASoundManager 进行初始化
*
* 相关文章Android SoundPool 崩溃问题研究
* https://zhuanlan.zhihu.com/p/29985198
*/
object SVGASoundManager {
private val TAG = SVGASoundManager::class.java.simpleName
private var soundPool: SoundPool? = null
private val soundCallBackMap: MutableMap<Int, SVGASoundCallBack> = mutableMapOf()
/**
* 音量设置范围在 [0, 1] 之间
*/
private var volume: Float = 1f
/**
* 音频回调
*/
internal interface SVGASoundCallBack {
// 音量发生变化
fun onVolumeChange(value: Float)
// 音频加载完成
fun onComplete()
}
fun init() {
init(20)
}
fun init(maxStreams: Int) {
LogUtils.debug(TAG, "**************** init **************** $maxStreams")
if (soundPool != null) {
return
}
soundPool = getSoundPool(maxStreams)
soundPool?.setOnLoadCompleteListener { _, soundId, status ->
LogUtils.debug(TAG, "SoundPool onLoadComplete soundId=$soundId status=$status")
if (status == 0) { //加载该声音成功
if (soundCallBackMap.containsKey(soundId)) {
soundCallBackMap[soundId]?.onComplete()
}
}
}
}
fun release() {
LogUtils.debug(TAG, "**************** release ****************")
if (soundCallBackMap.isNotEmpty()) {
soundCallBackMap.clear()
}
}
/**
* 根据当前播放实体设置音量
*
* @param volume 范围在 [0, 1]
* @param entity 根据需要控制对应 entity 音量大小若为空则控制所有正在播放的音频音量
*/
fun setVolume(volume: Float, entity: SVGAVideoEntity? = null) {
if (!checkInit()) {
return
}
if (volume < 0f || volume > 1f) {
LogUtils.error(TAG, "The volume level is in the range of 0 to 1 ")
return
}
if (entity == null) {
this.volume = volume
val iterator = soundCallBackMap.entries.iterator()
while (iterator.hasNext()) {
val e = iterator.next()
e.value.onVolumeChange(volume)
}
return
}
val soundPool = soundPool ?: return
entity.audioList.forEach { audio ->
val streamId = audio.playID ?: return
soundPool.setVolume(streamId, volume, volume)
}
}
/**
* 是否初始化
* 如果没有初始化就使用原来SvgaPlayer库的音频加载逻辑
* @return true 则已初始化 否则为 false
*/
internal fun isInit(): Boolean {
return soundPool != null
}
private fun checkInit(): Boolean {
val isInit = isInit()
if (!isInit) {
LogUtils.error(TAG, "soundPool is null, you need call init() !!!")
}
return isInit
}
private fun getSoundPool(maxStreams: Int) = if (Build.VERSION.SDK_INT >= 21) {
val attributes = AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_MEDIA)
.build()
SoundPool.Builder().setAudioAttributes(attributes)
.setMaxStreams(maxStreams)
.build()
} else {
SoundPool(maxStreams, AudioManager.STREAM_MUSIC, 0)
}
internal fun load(callBack: SVGASoundCallBack?,
fd: FileDescriptor?,
offset: Long,
length: Long,
priority: Int): Int {
if (!checkInit()) return -1
val soundId = soundPool!!.load(fd, offset, length, priority)
LogUtils.debug(TAG, "load soundId=$soundId callBack=$callBack")
if (callBack != null && !soundCallBackMap.containsKey(soundId)) {
soundCallBackMap[soundId] = callBack
}
return soundId
}
internal fun unload(soundId: Int) {
if (!checkInit()) return
LogUtils.debug(TAG, "unload soundId=$soundId")
soundPool!!.unload(soundId)
soundCallBackMap.remove(soundId)
}
internal fun play(soundId: Int): Int {
if (!checkInit()) return -1
LogUtils.debug(TAG, "play soundId=$soundId")
return soundPool!!.play(soundId, volume, volume, 1, 0, 1.0f)
}
internal fun stop(soundId: Int) {
if (!checkInit()) return
LogUtils.debug(TAG, "stop soundId=$soundId")
soundPool!!.stop(soundId)
}
internal fun resume(soundId: Int) {
if (!checkInit()) return
LogUtils.debug(TAG, "stop soundId=$soundId")
soundPool!!.resume(soundId)
}
internal fun pause(soundId: Int) {
if (!checkInit()) return
LogUtils.debug(TAG, "pause soundId=$soundId")
soundPool!!.pause(soundId)
}
}

View File

@ -0,0 +1,347 @@
package com.opensource.svgaplayer
import android.graphics.Bitmap
import android.media.AudioAttributes
import android.media.AudioManager
import android.media.SoundPool
import android.os.Build
import com.opensource.svgaplayer.bitmap.SVGABitmapByteArrayDecoder
import com.opensource.svgaplayer.bitmap.SVGABitmapFileDecoder
import com.opensource.svgaplayer.entities.SVGAAudioEntity
import com.opensource.svgaplayer.entities.SVGAVideoSpriteEntity
import com.opensource.svgaplayer.proto.AudioEntity
import com.opensource.svgaplayer.proto.MovieEntity
import com.opensource.svgaplayer.proto.MovieParams
import com.opensource.svgaplayer.utils.SVGARect
import com.opensource.svgaplayer.utils.log.LogUtils
import org.json.JSONObject
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.util.*
import kotlin.collections.ArrayList
/**
* Created by PonyCui on 16/6/18.
*/
class SVGAVideoEntity {
private val TAG = "SVGAVideoEntity"
var antiAlias = true
var movieItem: MovieEntity? = null
var videoSize = SVGARect(0.0, 0.0, 0.0, 0.0)
private set
var FPS = 15
private set
var frames: Int = 0
private set
internal var spriteList: List<SVGAVideoSpriteEntity> = emptyList()
internal var audioList: List<SVGAAudioEntity> = emptyList()
internal var soundPool: SoundPool? = null
private var soundCallback: SVGASoundManager.SVGASoundCallBack? = null
internal var imageMap = HashMap<String, Bitmap>()
private var mCacheDir: File
private var mFrameHeight = 0
private var mFrameWidth = 0
private var mPlayCallback: SVGAParser.PlayCallback?=null
private lateinit var mCallback: () -> Unit
constructor(json: JSONObject, cacheDir: File) : this(json, cacheDir, 0, 0)
constructor(json: JSONObject, cacheDir: File, frameWidth: Int, frameHeight: Int) {
mFrameWidth = frameWidth
mFrameHeight = frameHeight
mCacheDir = cacheDir
val movieJsonObject = json.optJSONObject("movie") ?: return
setupByJson(movieJsonObject)
try {
parserImages(json)
} catch (e: Exception) {
e.printStackTrace()
} catch (e: OutOfMemoryError) {
e.printStackTrace()
}
resetSprites(json)
}
private fun setupByJson(movieObject: JSONObject) {
movieObject.optJSONObject("viewBox")?.let { viewBoxObject ->
val width = viewBoxObject.optDouble("width", 0.0)
val height = viewBoxObject.optDouble("height", 0.0)
videoSize = SVGARect(0.0, 0.0, width, height)
}
FPS = movieObject.optInt("fps", 20)
frames = movieObject.optInt("frames", 0)
}
constructor(entity: MovieEntity, cacheDir: File) : this(entity, cacheDir, 0, 0)
constructor(entity: MovieEntity, cacheDir: File, frameWidth: Int, frameHeight: Int) {
this.mFrameWidth = frameWidth
this.mFrameHeight = frameHeight
this.mCacheDir = cacheDir
this.movieItem = entity
entity.params?.let(this::setupByMovie)
try {
parserImages(entity)
} catch (e: Exception) {
e.printStackTrace()
} catch (e: OutOfMemoryError) {
e.printStackTrace()
}
resetSprites(entity)
}
private fun setupByMovie(movieParams: MovieParams) {
val width = (movieParams.viewBoxWidth ?: 0.0f).toDouble()
val height = (movieParams.viewBoxHeight ?: 0.0f).toDouble()
videoSize = SVGARect(0.0, 0.0, width, height)
FPS = movieParams.fps ?: 20
frames = movieParams.frames ?: 0
}
internal fun prepare(callback: () -> Unit, playCallback: SVGAParser.PlayCallback?) {
mCallback = callback
mPlayCallback = playCallback
if (movieItem == null) {
mCallback()
} else {
setupAudios(movieItem!!) {
mCallback()
}
}
}
private fun parserImages(json: JSONObject) {
val imgJson = json.optJSONObject("images") ?: return
imgJson.keys().forEach { imgKey ->
val filePath = generateBitmapFilePath(imgJson[imgKey].toString(), imgKey)
if (filePath.isEmpty()) {
return
}
val bitmapKey = imgKey.replace(".matte", "")
val bitmap = createBitmap(filePath)
if (bitmap != null) {
imageMap[bitmapKey] = bitmap
}
}
}
private fun generateBitmapFilePath(imgName: String, imgKey: String): String {
val path = mCacheDir.absolutePath + "/" + imgName
val path1 = "$path.png"
val path2 = mCacheDir.absolutePath + "/" + imgKey + ".png"
return when {
File(path).exists() -> path
File(path1).exists() -> path1
File(path2).exists() -> path2
else -> ""
}
}
private fun createBitmap(filePath: String): Bitmap? {
return SVGABitmapFileDecoder.decodeBitmapFrom(filePath, mFrameWidth, mFrameHeight)
}
private fun parserImages(obj: MovieEntity) {
obj.images?.entries?.forEach { entry ->
val byteArray = entry.value.toByteArray()
if (byteArray.count() < 4) {
return@forEach
}
val fileTag = byteArray.slice(IntRange(0, 3))
if (fileTag[0].toInt() == 73 && fileTag[1].toInt() == 68 && fileTag[2].toInt() == 51) {
return@forEach
}
val filePath = generateBitmapFilePath(entry.value.utf8(), entry.key)
createBitmap(byteArray, filePath)?.let { bitmap ->
imageMap[entry.key] = bitmap
}
}
}
private fun createBitmap(byteArray: ByteArray, filePath: String): Bitmap? {
val bitmap = SVGABitmapByteArrayDecoder.decodeBitmapFrom(byteArray, mFrameWidth, mFrameHeight)
return bitmap ?: createBitmap(filePath)
}
private fun resetSprites(json: JSONObject) {
val mutableList: MutableList<SVGAVideoSpriteEntity> = mutableListOf()
json.optJSONArray("sprites")?.let { item ->
for (i in 0 until item.length()) {
item.optJSONObject(i)?.let { entryJson ->
mutableList.add(SVGAVideoSpriteEntity(entryJson))
}
}
}
spriteList = mutableList.toList()
}
private fun resetSprites(entity: MovieEntity) {
spriteList = entity.sprites?.map {
return@map SVGAVideoSpriteEntity(it)
} ?: listOf()
}
private fun setupAudios(entity: MovieEntity, completionBlock: () -> Unit) {
if (entity.audios == null || entity.audios.isEmpty()) {
run(completionBlock)
return
}
setupSoundPool(entity, completionBlock)
val audiosFileMap = generateAudioFileMap(entity)
//repair when audioEntity error can not callback
//如果audiosFileMap为空 soundPool?.load 不会走 导致 setOnLoadCompleteListener 不会回调 导致外层prepare不回调卡住
if (audiosFileMap.size == 0) {
run(completionBlock)
return
}
this.audioList = entity.audios.map { audio ->
return@map createSvgaAudioEntity(audio, audiosFileMap)
}
}
private fun createSvgaAudioEntity(audio: AudioEntity, audiosFileMap: HashMap<String, File>): SVGAAudioEntity {
val item = SVGAAudioEntity(audio)
val startTime = (audio.startTime ?: 0).toDouble()
val totalTime = (audio.totalTime ?: 0).toDouble()
if (totalTime.toInt() == 0) {
// 除数不能为 0
return item
}
// 直接回调文件,后续播放都不走
mPlayCallback?.let {
val fileList: MutableList<File> = ArrayList()
audiosFileMap.forEach { entity ->
fileList.add(entity.value)
}
it.onPlay(fileList)
mCallback()
return item
}
audiosFileMap[audio.audioKey]?.let { file ->
FileInputStream(file).use {
val length = it.available().toDouble()
val offset = ((startTime / totalTime) * length).toLong()
if (SVGASoundManager.isInit()) {
item.soundID = SVGASoundManager.load(soundCallback,
it.fd,
offset,
length.toLong(),
1)
} else {
item.soundID = soundPool?.load(it.fd, offset, length.toLong(), 1)
}
}
}
return item
}
private fun generateAudioFile(audioCache: File, value: ByteArray): File {
audioCache.createNewFile()
FileOutputStream(audioCache).write(value)
return audioCache
}
private fun generateAudioFileMap(entity: MovieEntity): HashMap<String, File> {
val audiosDataMap = generateAudioMap(entity)
val audiosFileMap = HashMap<String, File>()
if (audiosDataMap.count() > 0) {
audiosDataMap.forEach {
val audioCache = SVGACache.buildAudioFile(it.key)
audiosFileMap[it.key] =
audioCache.takeIf { file -> file.exists() } ?: generateAudioFile(
audioCache,
it.value
)
}
}
return audiosFileMap
}
private fun generateAudioMap(entity: MovieEntity): HashMap<String, ByteArray> {
val audiosDataMap = HashMap<String, ByteArray>()
entity.images?.entries?.forEach {
val imageKey = it.key
val byteArray = it.value.toByteArray()
if (byteArray.count() < 4) {
return@forEach
}
val fileTag = byteArray.slice(IntRange(0, 3))
if (fileTag[0].toInt() == 73 && fileTag[1].toInt() == 68 && fileTag[2].toInt() == 51) {
audiosDataMap[imageKey] = byteArray
}else if(fileTag[0].toInt() == -1 && fileTag[1].toInt() == -5 && fileTag[2].toInt() == -108){
audiosDataMap[imageKey] = byteArray
}
}
return audiosDataMap
}
private fun setupSoundPool(entity: MovieEntity, completionBlock: () -> Unit) {
var soundLoaded = 0
if (SVGASoundManager.isInit()) {
soundCallback = object : SVGASoundManager.SVGASoundCallBack {
override fun onVolumeChange(value: Float) {
SVGASoundManager.setVolume(value, this@SVGAVideoEntity)
}
override fun onComplete() {
soundLoaded++
if (soundLoaded >= entity.audios.count()) {
completionBlock()
}
}
}
return
}
soundPool = generateSoundPool(entity)
LogUtils.info("SVGAParser", "pool_start")
soundPool?.setOnLoadCompleteListener { _, _, _ ->
LogUtils.info("SVGAParser", "pool_complete")
soundLoaded++
if (soundLoaded >= entity.audios.count()) {
completionBlock()
}
}
}
private fun generateSoundPool(entity: MovieEntity): SoundPool? {
return try {
if (Build.VERSION.SDK_INT >= 21) {
val attributes = AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_MEDIA)
.build()
SoundPool.Builder().setAudioAttributes(attributes)
.setMaxStreams(12.coerceAtMost(entity.audios.count()))
.build()
} else {
SoundPool(12.coerceAtMost(entity.audios.count()), AudioManager.STREAM_MUSIC, 0)
}
} catch (e: Exception) {
LogUtils.error(TAG, e)
null
}
}
fun clear() {
if (SVGASoundManager.isInit()) {
this.audioList.forEach {
it.soundID?.let { id -> SVGASoundManager.unload(id) }
}
soundCallback = null
}
soundPool?.release()
soundPool = null
audioList = emptyList()
spriteList = emptyList()
imageMap.clear()
}
}

View File

@ -0,0 +1,33 @@
package com.opensource.svgaplayer.bitmap
import android.graphics.BitmapFactory
/**
*
* Create by im_dsd 2020/7/7 17:59
*/
internal object BitmapSampleSizeCalculator {
fun calculate(options: BitmapFactory.Options, reqWidth: Int, reqHeight: Int): Int {
// Raw height and width of image
val (height: Int, width: Int) = options.run { outHeight to outWidth }
var inSampleSize = 1
if (reqHeight <= 0 || reqWidth <= 0) {
return inSampleSize
}
if (height > reqHeight || width > reqWidth) {
val halfHeight: Int = height / 2
val halfWidth: Int = width / 2
// Calculate the largest inSampleSize value that is a power of 2 and keeps both
// height and width larger than the requested height and width.
while (halfHeight / inSampleSize >= reqHeight && halfWidth / inSampleSize >= reqWidth) {
inSampleSize *= 2
}
}
return inSampleSize
}
}

View File

@ -0,0 +1,16 @@
package com.opensource.svgaplayer.bitmap
import android.graphics.Bitmap
import android.graphics.BitmapFactory
/**
* 通过字节码解码 Bitmap
*
* Create by im_dsd 2020/7/7 17:50
*/
internal object SVGABitmapByteArrayDecoder : SVGABitmapDecoder<ByteArray>() {
override fun onDecode(data: ByteArray, ops: BitmapFactory.Options): Bitmap? {
return BitmapFactory.decodeByteArray(data, 0, data.count(), ops)
}
}

View File

@ -0,0 +1,35 @@
package com.opensource.svgaplayer.bitmap
import android.graphics.Bitmap
import android.graphics.BitmapFactory
/**
* Bitmap 解码器
*
* <T> 需要加载的数据类型
*
* Create by im_dsd 2020/7/7 17:39
*/
internal abstract class SVGABitmapDecoder<T> {
fun decodeBitmapFrom(data: T, reqWidth: Int, reqHeight: Int): Bitmap? {
return BitmapFactory.Options().run {
// 如果期望的宽高是合法的, 则开启检测尺寸模式
inJustDecodeBounds = (reqWidth > 0 && reqHeight > 0)
inPreferredConfig = Bitmap.Config.RGB_565
val bitmap = onDecode(data, this)
if (!inJustDecodeBounds) {
return bitmap
}
// Calculate inSampleSize
inSampleSize = BitmapSampleSizeCalculator.calculate(this, reqWidth, reqHeight)
// Decode bitmap with inSampleSize set
inJustDecodeBounds = false
onDecode(data, this)
}
}
abstract fun onDecode(data: T, ops: BitmapFactory.Options): Bitmap?
}

View File

@ -0,0 +1,16 @@
package com.opensource.svgaplayer.bitmap
import android.graphics.Bitmap
import android.graphics.BitmapFactory
/**
* 通过文件解码 Bitmap
*
* Create by im_dsd 2020/7/7 17:50
*/
internal object SVGABitmapFileDecoder : SVGABitmapDecoder<String>() {
override fun onDecode(data: String, ops: BitmapFactory.Options): Bitmap? {
return BitmapFactory.decodeFile(data, ops)
}
}

View File

@ -0,0 +1,53 @@
package com.opensource.svgaplayer.drawer
import android.graphics.Canvas
import android.widget.ImageView
import com.opensource.svgaplayer.SVGAVideoEntity
import com.opensource.svgaplayer.entities.SVGAVideoSpriteFrameEntity
import com.opensource.svgaplayer.utils.Pools
import com.opensource.svgaplayer.utils.SVGAScaleInfo
import kotlin.math.max
/**
* Created by cuiminghui on 2017/3/29.
*/
open internal class SGVADrawer(val videoItem: SVGAVideoEntity) {
val scaleInfo = SVGAScaleInfo()
private val spritePool = Pools.SimplePool<SVGADrawerSprite>(max(1, videoItem.spriteList.size))
inner class SVGADrawerSprite(var _matteKey: String? = null, var _imageKey: String? = null, var _frameEntity: SVGAVideoSpriteFrameEntity? = null) {
val matteKey get() = _matteKey
val imageKey get() = _imageKey
val frameEntity get() = _frameEntity!!
}
internal fun requestFrameSprites(frameIndex: Int): List<SVGADrawerSprite> {
return videoItem.spriteList.mapNotNull {
if (frameIndex >= 0 && frameIndex < it.frames.size) {
it.imageKey?.let { imageKey ->
if (!imageKey.endsWith(".matte") && it.frames[frameIndex].alpha <= 0.0) {
return@mapNotNull null
}
return@mapNotNull (spritePool.acquire() ?: SVGADrawerSprite()).apply {
_matteKey = it.matteKey
_imageKey = it.imageKey
_frameEntity = it.frames[frameIndex]
}
}
}
return@mapNotNull null
}
}
internal fun releaseFrameSprites(sprites: List<SVGADrawerSprite>) {
sprites.forEach { spritePool.release(it) }
}
open fun drawFrame(canvas : Canvas, frameIndex: Int, scaleType: ImageView.ScaleType) {
scaleInfo.performScaleType(canvas.width.toFloat(),canvas.height.toFloat(), videoItem.videoSize.width.toFloat(), videoItem.videoSize.height.toFloat(), scaleType)
}
}

View File

@ -0,0 +1,559 @@
package com.opensource.svgaplayer.drawer
import android.graphics.*
import android.os.Build
import android.text.StaticLayout
import android.text.TextUtils
import android.widget.ImageView
import com.opensource.svgaplayer.SVGADynamicEntity
import com.opensource.svgaplayer.SVGASoundManager
import com.opensource.svgaplayer.SVGAVideoEntity
import com.opensource.svgaplayer.entities.SVGAVideoShapeEntity
/**
* Created by cuiminghui on 2017/3/29.
*/
internal class SVGACanvasDrawer(videoItem: SVGAVideoEntity, val dynamicItem: SVGADynamicEntity) : SGVADrawer(videoItem) {
private val sharedValues = ShareValues()
private val drawTextCache: HashMap<String, Bitmap> = hashMapOf()
private val pathCache = PathCache()
private var beginIndexList: Array<Boolean>? = null
private var endIndexList: Array<Boolean>? = null
override fun drawFrame(canvas: Canvas, frameIndex: Int, scaleType: ImageView.ScaleType) {
super.drawFrame(canvas, frameIndex, scaleType)
playAudio(frameIndex)
this.pathCache.onSizeChanged(canvas)
val sprites = requestFrameSprites(frameIndex)
// Filter null sprites
if (sprites.count() <= 0) return
val matteSprites = mutableMapOf<String, SVGADrawerSprite>()
var saveID = -1
beginIndexList = null
endIndexList = null
// Filter no matte layer
var hasMatteLayer = false
sprites.get(0).imageKey?.let {
if (it.endsWith(".matte")) {
hasMatteLayer = true
}
}
sprites.forEachIndexed { index, svgaDrawerSprite ->
// Save matte sprite
svgaDrawerSprite.imageKey?.let {
/// No matte layer included or VERSION Unsopport matte
if (!hasMatteLayer || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
// Normal sprite
drawSprite(svgaDrawerSprite, canvas, frameIndex)
// Continue
return@forEachIndexed
}
/// Cache matte sprite
if (it.endsWith(".matte")) {
matteSprites.put(it, svgaDrawerSprite)
// Continue
return@forEachIndexed
}
}
/// Is matte begin
if (isMatteBegin(index, sprites)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
saveID = canvas.saveLayer(0f, 0f, canvas.width.toFloat(), canvas.height.toFloat(), null)
} else {
canvas.save()
}
}
/// Normal matte
drawSprite(svgaDrawerSprite, canvas, frameIndex)
/// Is matte end
if (isMatteEnd(index, sprites)) {
matteSprites.get(svgaDrawerSprite.matteKey)?.let {
drawSprite(it, this.sharedValues.shareMatteCanvas(canvas.width, canvas.height), frameIndex)
canvas.drawBitmap(this.sharedValues.sharedMatteBitmap(), 0f, 0f, this.sharedValues.shareMattePaint())
if (saveID != -1) {
canvas.restoreToCount(saveID)
} else {
canvas.restore()
}
// Continue
return@forEachIndexed
}
}
}
releaseFrameSprites(sprites)
}
private fun isMatteBegin(spriteIndex: Int, sprites: List<SVGADrawerSprite>): Boolean {
if (beginIndexList == null) {
val boolArray = Array(sprites.count()) { false }
sprites.forEachIndexed { index, svgaDrawerSprite ->
svgaDrawerSprite.imageKey?.let {
/// Filter matte sprite
if (it.endsWith(".matte")) {
// Continue
return@forEachIndexed
}
}
svgaDrawerSprite.matteKey?.let {
if (it.length > 0) {
sprites.get(index - 1)?.let { lastSprite ->
if (lastSprite.matteKey.isNullOrEmpty()) {
boolArray[index] = true
} else {
if (lastSprite.matteKey != svgaDrawerSprite.matteKey) {
boolArray[index] = true
}
}
}
}
}
}
beginIndexList = boolArray
}
return beginIndexList?.get(spriteIndex) ?: false
}
private fun isMatteEnd(spriteIndex: Int, sprites: List<SVGADrawerSprite>): Boolean {
if (endIndexList == null) {
val boolArray = Array(sprites.count()) { false }
sprites.forEachIndexed { index, svgaDrawerSprite ->
svgaDrawerSprite.imageKey?.let {
/// Filter matte sprite
if (it.endsWith(".matte")) {
// Continue
return@forEachIndexed
}
}
svgaDrawerSprite.matteKey?.let {
if (it.length > 0) {
// Last one
if (index == sprites.count() - 1) {
boolArray[index] = true
} else {
sprites.get(index + 1)?.let { nextSprite ->
if (nextSprite.matteKey.isNullOrEmpty()) {
boolArray[index] = true
} else {
if (nextSprite.matteKey != svgaDrawerSprite.matteKey) {
boolArray[index] = true
}
}
}
}
}
}
}
endIndexList = boolArray
}
return endIndexList?.get(spriteIndex) ?: false
}
private fun playAudio(frameIndex: Int) {
this.videoItem.audioList.forEach { audio ->
if (audio.startFrame == frameIndex) {
if (SVGASoundManager.isInit()) {
audio.soundID?.let { soundID ->
audio.playID = SVGASoundManager.play(soundID)
}
} else {
this.videoItem.soundPool?.let { soundPool ->
audio.soundID?.let { soundID ->
audio.playID = soundPool.play(soundID, 1.0f, 1.0f, 1, 0, 1.0f)
}
}
}
}
if (audio.endFrame <= frameIndex) {
audio.playID?.let {
if (SVGASoundManager.isInit()) {
SVGASoundManager.stop(it)
} else {
this.videoItem.soundPool?.stop(it)
}
}
audio.playID = null
}
}
}
private fun shareFrameMatrix(transform: Matrix): Matrix {
val matrix = this.sharedValues.sharedMatrix()
matrix.postScale(scaleInfo.scaleFx, scaleInfo.scaleFy)
matrix.postTranslate(scaleInfo.tranFx, scaleInfo.tranFy)
matrix.preConcat(transform)
return matrix
}
private fun drawSprite(sprite: SVGADrawerSprite, canvas: Canvas, frameIndex: Int) {
drawImage(sprite, canvas)
drawShape(sprite, canvas)
drawDynamic(sprite, canvas, frameIndex)
}
private fun drawImage(sprite: SVGADrawerSprite, canvas: Canvas) {
val imageKey = sprite.imageKey ?: return
val isHidden = dynamicItem.dynamicHidden[imageKey] == true
if (isHidden) {
return
}
val bitmapKey = if (imageKey.endsWith(".matte")) imageKey.substring(0, imageKey.length - 6) else imageKey
val drawingBitmap = (dynamicItem.dynamicImage[bitmapKey] ?: videoItem.imageMap[bitmapKey])
?: return
val frameMatrix = shareFrameMatrix(sprite.frameEntity.transform)
val paint = this.sharedValues.sharedPaint()
paint.isAntiAlias = videoItem.antiAlias
paint.isFilterBitmap = videoItem.antiAlias
paint.alpha = (sprite.frameEntity.alpha * 255).toInt()
if (sprite.frameEntity.maskPath != null) {
val maskPath = sprite.frameEntity.maskPath ?: return
canvas.save()
val path = this.sharedValues.sharedPath()
maskPath.buildPath(path)
path.transform(frameMatrix)
canvas.clipPath(path)
frameMatrix.preScale((sprite.frameEntity.layout.width / drawingBitmap.width).toFloat(), (sprite.frameEntity.layout.height / drawingBitmap.height).toFloat())
if (!drawingBitmap.isRecycled) {
canvas.drawBitmap(drawingBitmap, frameMatrix, paint)
}
canvas.restore()
} else {
frameMatrix.preScale((sprite.frameEntity.layout.width / drawingBitmap.width).toFloat(), (sprite.frameEntity.layout.height / drawingBitmap.height).toFloat())
if (!drawingBitmap.isRecycled) {
canvas.drawBitmap(drawingBitmap, frameMatrix, paint)
}
}
dynamicItem.dynamicIClickArea.let {
it.get(imageKey)?.let { listener ->
val matrixArray = floatArrayOf(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f)
frameMatrix.getValues(matrixArray)
listener.onResponseArea(imageKey, matrixArray[2].toInt()
, matrixArray[5].toInt()
, (drawingBitmap.width * matrixArray[0] + matrixArray[2]).toInt()
, (drawingBitmap.height * matrixArray[4] + matrixArray[5]).toInt())
}
}
drawTextOnBitmap(canvas, drawingBitmap, sprite, frameMatrix)
}
private fun drawTextOnBitmap(canvas: Canvas, drawingBitmap: Bitmap, sprite: SVGADrawerSprite, frameMatrix: Matrix) {
if (dynamicItem.isTextDirty) {
this.drawTextCache.clear()
dynamicItem.isTextDirty = false
}
val imageKey = sprite.imageKey ?: return
var textBitmap: Bitmap? = null
dynamicItem.dynamicText[imageKey]?.let { drawingText ->
dynamicItem.dynamicTextPaint[imageKey]?.let { drawingTextPaint ->
drawTextCache[imageKey]?.let {
textBitmap = it
} ?: kotlin.run {
textBitmap = Bitmap.createBitmap(drawingBitmap.width, drawingBitmap.height, Bitmap.Config.ARGB_8888)
val drawRect = Rect(0, 0, drawingBitmap.width, drawingBitmap.height)
val textCanvas = Canvas(textBitmap)
drawingTextPaint.isAntiAlias = true
val fontMetrics = drawingTextPaint.getFontMetrics();
val top = fontMetrics.top
val bottom = fontMetrics.bottom
val baseLineY = drawRect.centerY() - top / 2 - bottom / 2
textCanvas.drawText(drawingText, drawRect.centerX().toFloat(), baseLineY, drawingTextPaint);
drawTextCache.put(imageKey, textBitmap as Bitmap)
}
}
}
dynamicItem.dynamicBoringLayoutText[imageKey]?.let {
drawTextCache[imageKey]?.let {
textBitmap = it
} ?: kotlin.run {
it.paint.isAntiAlias = true
textBitmap = Bitmap.createBitmap(drawingBitmap.width, drawingBitmap.height, Bitmap.Config.ARGB_8888)
val textCanvas = Canvas(textBitmap)
textCanvas.translate(0f, ((drawingBitmap.height - it.height) / 2).toFloat())
it.draw(textCanvas)
drawTextCache.put(imageKey, textBitmap as Bitmap)
}
}
dynamicItem.dynamicStaticLayoutText[imageKey]?.let {
drawTextCache[imageKey]?.let {
textBitmap = it
} ?: kotlin.run {
it.paint.isAntiAlias = true
var layout = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
var lineMax = try {
val field = StaticLayout::class.java.getDeclaredField("mMaximumVisibleLineCount")
field.isAccessible = true
field.getInt(it)
} catch (e: Exception) {
Int.MAX_VALUE
}
StaticLayout.Builder
.obtain(it.text, 0, it.text.length, it.paint, drawingBitmap.width)
.setAlignment(it.alignment)
.setMaxLines(lineMax)
.setEllipsize(TextUtils.TruncateAt.END)
.build()
} else {
StaticLayout(it.text, 0, it.text.length, it.paint, drawingBitmap.width, it.alignment, it.spacingMultiplier, it.spacingAdd, false)
}
textBitmap = Bitmap.createBitmap(drawingBitmap.width, drawingBitmap.height, Bitmap.Config.ARGB_8888)
val textCanvas = Canvas(textBitmap)
textCanvas.translate(0f, ((drawingBitmap.height - layout.height) / 2).toFloat())
layout.draw(textCanvas)
drawTextCache.put(imageKey, textBitmap as Bitmap)
}
}
textBitmap?.let { textBitmap ->
val paint = this.sharedValues.sharedPaint()
paint.isAntiAlias = videoItem.antiAlias
paint.alpha = (sprite.frameEntity.alpha * 255).toInt()
if (sprite.frameEntity.maskPath != null) {
val maskPath = sprite.frameEntity.maskPath ?: return@let
canvas.save()
canvas.concat(frameMatrix)
canvas.clipRect(0, 0, drawingBitmap.width, drawingBitmap.height)
val bitmapShader = BitmapShader(textBitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT)
paint.shader = bitmapShader
val path = this.sharedValues.sharedPath()
maskPath.buildPath(path)
canvas.drawPath(path, paint)
canvas.restore()
} else {
paint.isFilterBitmap = videoItem.antiAlias
canvas.drawBitmap(textBitmap, frameMatrix, paint)
}
}
}
private fun drawShape(sprite: SVGADrawerSprite, canvas: Canvas) {
val frameMatrix = shareFrameMatrix(sprite.frameEntity.transform)
sprite.frameEntity.shapes.forEach { shape ->
shape.buildPath()
shape.shapePath?.let {
val paint = this.sharedValues.sharedPaint()
paint.reset()
paint.isAntiAlias = videoItem.antiAlias
paint.alpha = (sprite.frameEntity.alpha * 255).toInt()
val path = this.sharedValues.sharedPath()
path.reset()
path.addPath(this.pathCache.buildPath(shape))
val shapeMatrix = this.sharedValues.sharedMatrix2()
shapeMatrix.reset()
shape.transform?.let {
shapeMatrix.postConcat(it)
}
shapeMatrix.postConcat(frameMatrix)
path.transform(shapeMatrix)
shape.styles?.fill?.let {
if (it != 0x00000000) {
paint.style = Paint.Style.FILL
paint.color = it
val alpha = Math.min(255, Math.max(0, (sprite.frameEntity.alpha * 255).toInt()))
if (alpha != 255) {
paint.alpha = alpha
}
if (sprite.frameEntity.maskPath !== null) canvas.save()
sprite.frameEntity.maskPath?.let { maskPath ->
val path2 = this.sharedValues.sharedPath2()
maskPath.buildPath(path2)
path2.transform(frameMatrix)
canvas.clipPath(path2)
}
canvas.drawPath(path, paint)
if (sprite.frameEntity.maskPath !== null) canvas.restore()
}
}
shape.styles?.strokeWidth?.let {
if (it > 0) {
paint.alpha = (sprite.frameEntity.alpha * 255).toInt()
paint.style = Paint.Style.STROKE
shape.styles?.stroke?.let {
paint.color = it
val alpha = Math.min(255, Math.max(0, (sprite.frameEntity.alpha * 255).toInt()))
if (alpha != 255) {
paint.alpha = alpha
}
}
val scale = matrixScale(frameMatrix)
shape.styles?.strokeWidth?.let {
paint.strokeWidth = it * scale
}
shape.styles?.lineCap?.let {
when {
it.equals("butt", true) -> paint.strokeCap = Paint.Cap.BUTT
it.equals("round", true) -> paint.strokeCap = Paint.Cap.ROUND
it.equals("square", true) -> paint.strokeCap = Paint.Cap.SQUARE
}
}
shape.styles?.lineJoin?.let {
when {
it.equals("miter", true) -> paint.strokeJoin = Paint.Join.MITER
it.equals("round", true) -> paint.strokeJoin = Paint.Join.ROUND
it.equals("bevel", true) -> paint.strokeJoin = Paint.Join.BEVEL
}
}
shape.styles?.miterLimit?.let {
paint.strokeMiter = it.toFloat() * scale
}
shape.styles?.lineDash?.let {
if (it.size == 3 && (it[0] > 0 || it[1] > 0)) {
paint.pathEffect = DashPathEffect(floatArrayOf(
(if (it[0] < 1.0f) 1.0f else it[0]) * scale,
(if (it[1] < 0.1f) 0.1f else it[1]) * scale
), it[2] * scale)
}
}
if (sprite.frameEntity.maskPath !== null) canvas.save()
sprite.frameEntity.maskPath?.let { maskPath ->
val path2 = this.sharedValues.sharedPath2()
maskPath.buildPath(path2)
path2.transform(frameMatrix)
canvas.clipPath(path2)
}
canvas.drawPath(path, paint)
if (sprite.frameEntity.maskPath !== null) canvas.restore()
}
}
}
}
}
private val matrixScaleTempValues = FloatArray(16)
private fun matrixScale(matrix: Matrix): Float {
matrix.getValues(matrixScaleTempValues)
if (matrixScaleTempValues[0] == 0f) {
return 0f
}
var A = matrixScaleTempValues[0].toDouble()
var B = matrixScaleTempValues[3].toDouble()
var C = matrixScaleTempValues[1].toDouble()
var D = matrixScaleTempValues[4].toDouble()
if (A * D == B * C) return 0f
var scaleX = Math.sqrt(A * A + B * B)
A /= scaleX
B /= scaleX
var skew = A * C + B * D
C -= A * skew
D -= B * skew
var scaleY = Math.sqrt(C * C + D * D)
C /= scaleY
D /= scaleY
skew /= scaleY
if (A * D < B * C) {
scaleX = -scaleX
}
return if (scaleInfo.ratioX) Math.abs(scaleX.toFloat()) else Math.abs(scaleY.toFloat())
}
private fun drawDynamic(sprite: SVGADrawerSprite, canvas: Canvas, frameIndex: Int) {
val imageKey = sprite.imageKey ?: return
dynamicItem.dynamicDrawer[imageKey]?.let {
val frameMatrix = shareFrameMatrix(sprite.frameEntity.transform)
canvas.save()
canvas.concat(frameMatrix)
it.invoke(canvas, frameIndex)
canvas.restore()
}
dynamicItem.dynamicDrawerSized[imageKey]?.let {
val frameMatrix = shareFrameMatrix(sprite.frameEntity.transform)
canvas.save()
canvas.concat(frameMatrix)
it.invoke(canvas, frameIndex, sprite.frameEntity.layout.width.toInt(), sprite.frameEntity.layout.height.toInt())
canvas.restore()
}
}
class ShareValues {
private val sharedPaint = Paint()
private val sharedPath = Path()
private val sharedPath2 = Path()
private val sharedMatrix = Matrix()
private val sharedMatrix2 = Matrix()
private val shareMattePaint = Paint()
private var shareMatteCanvas: Canvas? = null
private var sharedMatteBitmap: Bitmap? = null
fun sharedPaint(): Paint {
sharedPaint.reset()
return sharedPaint
}
fun sharedPath(): Path {
sharedPath.reset()
return sharedPath
}
fun sharedPath2(): Path {
sharedPath2.reset()
return sharedPath2
}
fun sharedMatrix(): Matrix {
sharedMatrix.reset()
return sharedMatrix
}
fun sharedMatrix2(): Matrix {
sharedMatrix2.reset()
return sharedMatrix2
}
fun shareMattePaint(): Paint {
shareMattePaint.setXfermode(PorterDuffXfermode(PorterDuff.Mode.DST_IN))
return shareMattePaint
}
fun sharedMatteBitmap(): Bitmap {
return sharedMatteBitmap as Bitmap
}
fun shareMatteCanvas(width: Int, height: Int): Canvas {
if (shareMatteCanvas == null) {
sharedMatteBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ALPHA_8)
// shareMatteCanvas = Canvas(sharedMatteBitmap)
}
// val matteCanvas = shareMatteCanvas as Canvas
// matteCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR)
// return matteCanvas
return Canvas(sharedMatteBitmap)
}
}
class PathCache {
private var canvasWidth: Int = 0
private var canvasHeight: Int = 0
private val cache = HashMap<SVGAVideoShapeEntity, Path>()
fun onSizeChanged(canvas: Canvas) {
if (this.canvasWidth != canvas.width || this.canvasHeight != canvas.height) {
this.cache.clear()
}
this.canvasWidth = canvas.width
this.canvasHeight = canvas.height
}
fun buildPath(shape: SVGAVideoShapeEntity): Path {
if (!this.cache.containsKey(shape)) {
val path = Path()
path.set(shape.shapePath)
this.cache[shape] = path
}
return this.cache[shape]!!
}
}
}

View File

@ -0,0 +1,24 @@
package com.opensource.svgaplayer.entities
import com.opensource.svgaplayer.proto.AudioEntity
import java.io.FileInputStream
internal class SVGAAudioEntity {
val audioKey: String?
val startFrame: Int
val endFrame: Int
val startTime: Int
val totalTime: Int
var soundID: Int? = null
var playID: Int? = null
constructor(audioItem: AudioEntity) {
this.audioKey = audioItem.audioKey
this.startFrame = audioItem.startFrame ?: 0
this.endFrame = audioItem.endFrame ?: 0
this.startTime = audioItem.startTime ?: 0
this.totalTime = audioItem.totalTime ?: 0
}
}

View File

@ -0,0 +1,100 @@
package com.opensource.svgaplayer.entities
import android.graphics.Path
import com.opensource.svgaplayer.utils.SVGAPoint
import java.util.*
private val VALID_METHODS: Set<String> = setOf("M", "L", "H", "V", "C", "S", "Q", "R", "A", "Z", "m", "l", "h", "v", "c", "s", "q", "r", "a", "z")
class SVGAPathEntity(originValue: String) {
private val replacedValue: String = if (originValue.contains(",")) originValue.replace(",", " ") else originValue
private var cachedPath: Path? = null
fun buildPath(toPath: Path) {
cachedPath?.let {
toPath.set(it)
return
}
val cachedPath = Path()
val segments = StringTokenizer(this.replacedValue, "MLHVCSQRAZmlhvcsqraz", true)
var currentMethod = ""
while (segments.hasMoreTokens()) {
val segment = segments.nextToken()
if (segment.isEmpty()) { continue }
if (VALID_METHODS.contains(segment)) {
currentMethod = segment
if (currentMethod == "Z" || currentMethod == "z") { operate(cachedPath, currentMethod, StringTokenizer("", "")) }
}
else {
operate(cachedPath, currentMethod, StringTokenizer(segment, " "))
}
}
this.cachedPath = cachedPath
toPath.set(cachedPath)
}
private fun operate(finalPath: Path, method: String, args: StringTokenizer) {
var x0 = 0.0f
var y0 = 0.0f
var x1 = 0.0f
var y1 = 0.0f
var x2 = 0.0f
var y2 = 0.0f
try {
var index = 0
while (args.hasMoreTokens()) {
val s = args.nextToken()
if (s.isEmpty()) {continue}
if (index == 0) { x0 = s.toFloat() }
if (index == 1) { y0 = s.toFloat() }
if (index == 2) { x1 = s.toFloat() }
if (index == 3) { y1 = s.toFloat() }
if (index == 4) { x2 = s.toFloat() }
if (index == 5) { y2 = s.toFloat() }
index++
}
} catch (e: Exception) {}
var currentPoint = SVGAPoint(0.0f, 0.0f, 0.0f)
if (method == "M") {
finalPath.moveTo(x0, y0)
currentPoint = SVGAPoint(x0, y0, 0.0f)
} else if (method == "m") {
finalPath.rMoveTo(x0, y0)
currentPoint = SVGAPoint(currentPoint.x + x0, currentPoint.y + y0, 0.0f)
}
if (method == "L") {
finalPath.lineTo(x0, y0)
} else if (method == "l") {
finalPath.rLineTo(x0, y0)
}
if (method == "C") {
finalPath.cubicTo(x0, y0, x1, y1, x2, y2)
} else if (method == "c") {
finalPath.rCubicTo(x0, y0, x1, y1, x2, y2)
}
if (method == "Q") {
finalPath.quadTo(x0, y0, x1, y1)
} else if (method == "q") {
finalPath.rQuadTo(x0, y0, x1, y1)
}
if (method == "H") {
finalPath.lineTo(x0, currentPoint.y)
} else if (method == "h") {
finalPath.rLineTo(x0, 0f)
}
if (method == "V") {
finalPath.lineTo(currentPoint.x, x0)
} else if (method == "v") {
finalPath.rLineTo(0f, x0)
}
if (method == "Z") {
finalPath.close()
}
else if (method == "z") {
finalPath.close()
}
}
}

View File

@ -0,0 +1,356 @@
package com.opensource.svgaplayer.entities
import android.graphics.Color
import android.graphics.Matrix
import android.graphics.Path
import android.graphics.RectF
import com.opensource.svgaplayer.proto.ShapeEntity
import org.json.JSONArray
import org.json.JSONObject
import java.util.*
/**
* Created by cuiminghui on 2017/2/22.
*/
val sharedPath = Path()
internal class SVGAVideoShapeEntity {
enum class Type {
shape,
rect,
ellipse,
keep
}
class Styles {
var fill = 0x00000000
internal set
var stroke = 0x00000000
internal set
var strokeWidth = 0.0f
internal set
var lineCap = "butt"
internal set
var lineJoin = "miter"
internal set
var miterLimit = 0
internal set
var lineDash = FloatArray(0)
internal set
}
var type = Type.shape
private set
var args: Map<String, Any>? = null
private set
var styles: Styles? = null
private set
var transform: Matrix? = null
private set
constructor(obj: JSONObject) {
parseType(obj)
parseArgs(obj)
parseStyles(obj)
parseTransform(obj)
}
constructor(obj: ShapeEntity) {
parseType(obj)
parseArgs(obj)
parseStyles(obj)
parseTransform(obj)
}
val isKeep: Boolean
get() = type == Type.keep
var shapePath: Path? = null
private fun parseType(obj: JSONObject) {
obj.optString("type")?.let {
when {
it.equals("shape", ignoreCase = true) -> type = Type.shape
it.equals("rect", ignoreCase = true) -> type = Type.rect
it.equals("ellipse", ignoreCase = true) -> type = Type.ellipse
it.equals("keep", ignoreCase = true) -> type = Type.keep
}
}
}
private fun parseType(obj: ShapeEntity) {
obj.type?.let {
type = when (it) {
ShapeEntity.ShapeType.SHAPE -> Type.shape
ShapeEntity.ShapeType.RECT -> Type.rect
ShapeEntity.ShapeType.ELLIPSE -> Type.ellipse
ShapeEntity.ShapeType.KEEP -> Type.keep
}
}
}
private fun parseArgs(obj: JSONObject) {
val args = HashMap<String, Any>()
obj.optJSONObject("args")?.let { values ->
values.keys().forEach { key ->
values.get(key)?.let {
args.put(key, it)
}
}
this.args = args
}
}
private fun parseArgs(obj: ShapeEntity) {
val args = HashMap<String, Any>()
obj.shape?.let {
it.d?.let { args.put("d", it) }
}
obj.ellipse?.let {
args.put("x", it.x ?: 0.0f)
args.put("y", it.y ?: 0.0f)
args.put("radiusX", it.radiusX ?: 0.0f)
args.put("radiusY", it.radiusY ?: 0.0f)
}
obj.rect?.let {
args.put("x", it.x ?: 0.0f)
args.put("y", it.y ?: 0.0f)
args.put("width", it.width ?: 0.0f)
args.put("height", it.height ?: 0.0f)
args.put("cornerRadius", it.cornerRadius ?: 0.0f)
}
this.args = args
}
// 检查色域范围是否是 [0f, 1f],或者是 [0f, 255f]
private fun checkValueRange(obj: JSONArray): Float {
return if (
obj.optDouble(0) <= 1 &&
obj.optDouble(1) <= 1 &&
obj.optDouble(2) <= 1
) {
255f
} else {
1f
}
}
// 检查 alpha 的范围是否是 [0f, 1f],或者是 [0f, 255f]
private fun checkAlphaValueRange(obj: JSONArray): Float {
return if (obj.optDouble(3) <= 1) {
255f
} else {
1f
}
}
private fun parseStyles(obj: JSONObject) {
obj.optJSONObject("styles")?.let {
val styles = Styles()
it.optJSONArray("fill")?.let {
if (it.length() == 4) {
val mulValue = checkValueRange(it)
val alphaRangeValue = checkAlphaValueRange(it)
styles.fill = Color.argb(
(it.optDouble(3) * alphaRangeValue).toInt(),
(it.optDouble(0) * mulValue).toInt(),
(it.optDouble(1) * mulValue).toInt(),
(it.optDouble(2) * mulValue).toInt()
)
}
}
it.optJSONArray("stroke")?.let {
if (it.length() == 4) {
val mulValue = checkValueRange(it)
val alphaRangeValue = checkAlphaValueRange(it)
styles.stroke = Color.argb(
(it.optDouble(3) * alphaRangeValue).toInt(),
(it.optDouble(0) * mulValue).toInt(),
(it.optDouble(1) * mulValue).toInt(),
(it.optDouble(2) * mulValue).toInt()
)
}
}
styles.strokeWidth = it.optDouble("strokeWidth", 0.0).toFloat()
styles.lineCap = it.optString("lineCap", "butt")
styles.lineJoin = it.optString("lineJoin", "miter")
styles.miterLimit = it.optInt("miterLimit", 0)
it.optJSONArray("lineDash")?.let {
styles.lineDash = FloatArray(it.length())
for (i in 0 until it.length()) {
styles.lineDash[i] = it.optDouble(i, 0.0).toFloat()
}
}
this.styles = styles
}
}
// 检查色域范围是否是 [0f, 1f],或者是 [0f, 255f]
private fun checkValueRange(color: ShapeEntity.ShapeStyle.RGBAColor): Float {
return if (
(color.r ?: 0f) <= 1 &&
(color.g ?: 0f) <= 1 &&
(color.b ?: 0f) <= 1
) {
255f
} else {
1f
}
}
// 检查 alpha 范围是否是 [0f, 1f],有可能是 [0f, 255f]
private fun checkAlphaValueRange(color: ShapeEntity.ShapeStyle.RGBAColor): Float {
return if (color.a <= 1f) {
255f
} else {
1f
}
}
private fun parseStyles(obj: ShapeEntity) {
obj.styles?.let {
val styles = Styles()
it.fill?.let {
val mulValue = checkValueRange(it)
val alphaRangeValue = checkAlphaValueRange(it)
styles.fill = Color.argb(
((it.a ?: 0f) * alphaRangeValue).toInt(),
((it.r ?: 0f) * mulValue).toInt(),
((it.g ?: 0f) * mulValue).toInt(),
((it.b ?: 0f) * mulValue).toInt()
)
}
it.stroke?.let {
val mulValue = checkValueRange(it)
val alphaRangeValue = checkAlphaValueRange(it)
styles.stroke = Color.argb(
((it.a ?: 0f) * alphaRangeValue).toInt(),
((it.r ?: 0f) * mulValue).toInt(),
((it.g ?: 0f) * mulValue).toInt(),
((it.b ?: 0f) * mulValue).toInt()
)
}
styles.strokeWidth = it.strokeWidth ?: 0.0f
it.lineCap?.let {
when (it) {
ShapeEntity.ShapeStyle.LineCap.LineCap_BUTT -> styles.lineCap = "butt"
ShapeEntity.ShapeStyle.LineCap.LineCap_ROUND -> styles.lineCap = "round"
ShapeEntity.ShapeStyle.LineCap.LineCap_SQUARE -> styles.lineCap = "square"
}
}
it.lineJoin?.let {
when (it) {
ShapeEntity.ShapeStyle.LineJoin.LineJoin_BEVEL -> styles.lineJoin = "bevel"
ShapeEntity.ShapeStyle.LineJoin.LineJoin_MITER -> styles.lineJoin = "miter"
ShapeEntity.ShapeStyle.LineJoin.LineJoin_ROUND -> styles.lineJoin = "round"
}
}
styles.miterLimit = (it.miterLimit ?: 0.0f).toInt()
styles.lineDash = kotlin.FloatArray(3)
it.lineDashI?.let { styles.lineDash[0] = it }
it.lineDashII?.let { styles.lineDash[1] = it }
it.lineDashIII?.let { styles.lineDash[2] = it }
this.styles = styles
}
}
private fun parseTransform(obj: JSONObject) {
obj.optJSONObject("transform")?.let {
val transform = Matrix()
val arr = FloatArray(9)
val a = it.optDouble("a", 1.0)
val b = it.optDouble("b", 0.0)
val c = it.optDouble("c", 0.0)
val d = it.optDouble("d", 1.0)
val tx = it.optDouble("tx", 0.0)
val ty = it.optDouble("ty", 0.0)
arr[0] = a.toFloat() // a
arr[1] = c.toFloat() // c
arr[2] = tx.toFloat() // tx
arr[3] = b.toFloat() // b
arr[4] = d.toFloat() // d
arr[5] = ty.toFloat() // ty
arr[6] = 0.0.toFloat()
arr[7] = 0.0.toFloat()
arr[8] = 1.0.toFloat()
transform.setValues(arr)
this.transform = transform
}
}
private fun parseTransform(obj: ShapeEntity) {
obj.transform?.let {
val transform = Matrix()
val arr = FloatArray(9)
val a = it.a ?: 1.0f
val b = it.b ?: 0.0f
val c = it.c ?: 0.0f
val d = it.d ?: 1.0f
val tx = it.tx ?: 0.0f
val ty = it.ty ?: 0.0f
arr[0] = a
arr[1] = c
arr[2] = tx
arr[3] = b
arr[4] = d
arr[5] = ty
arr[6] = 0.0f
arr[7] = 0.0f
arr[8] = 1.0f
transform.setValues(arr)
this.transform = transform
}
}
fun buildPath() {
if (this.shapePath != null) {
return
}
sharedPath.reset()
if (this.type == Type.shape) {
(this.args?.get("d") as? String)?.let {
SVGAPathEntity(it).buildPath(sharedPath)
}
} else if (this.type == Type.ellipse) {
val xv = this.args?.get("x") as? Number ?: return
val yv = this.args?.get("y") as? Number ?: return
val rxv = this.args?.get("radiusX") as? Number ?: return
val ryv = this.args?.get("radiusY") as? Number ?: return
val x = xv.toFloat()
val y = yv.toFloat()
val rx = rxv.toFloat()
val ry = ryv.toFloat()
sharedPath.addOval(RectF(x - rx, y - ry, x + rx, y + ry), Path.Direction.CW)
} else if (this.type == Type.rect) {
val xv = this.args?.get("x") as? Number ?: return
val yv = this.args?.get("y") as? Number ?: return
val wv = this.args?.get("width") as? Number ?: return
val hv = this.args?.get("height") as? Number ?: return
val crv = this.args?.get("cornerRadius") as? Number ?: return
val x = xv.toFloat()
val y = yv.toFloat()
val width = wv.toFloat()
val height = hv.toFloat()
val cornerRadius = crv.toFloat()
sharedPath.addRoundRect(RectF(x, y, x + width, y + height), cornerRadius, cornerRadius, Path.Direction.CW)
}
this.shapePath = Path()
this.shapePath?.set(sharedPath)
}
}

View File

@ -0,0 +1,60 @@
package com.opensource.svgaplayer.entities
import com.opensource.svgaplayer.proto.SpriteEntity
import org.json.JSONObject
/**
* Created by cuiminghui on 2016/10/17.
*/
internal class SVGAVideoSpriteEntity {
val imageKey: String?
val matteKey: String?
val frames: List<SVGAVideoSpriteFrameEntity>
constructor(obj: JSONObject) {
this.imageKey = obj.optString("imageKey")
this.matteKey = obj.optString("matteKey")
val mutableFrames: MutableList<SVGAVideoSpriteFrameEntity> = mutableListOf()
obj.optJSONArray("frames")?.let {
for (i in 0 until it.length()) {
it.optJSONObject(i)?.let {
val frameItem = SVGAVideoSpriteFrameEntity(it)
if (frameItem.shapes.isNotEmpty()) {
frameItem.shapes.first().let {
if (it.isKeep && mutableFrames.size > 0) {
frameItem.shapes = mutableFrames.last().shapes
}
}
}
mutableFrames.add(frameItem)
}
}
}
frames = mutableFrames.toList()
}
constructor(obj: SpriteEntity) {
this.imageKey = obj.imageKey
this.matteKey = obj.matteKey
var lastFrame: SVGAVideoSpriteFrameEntity? = null
frames = obj.frames?.map {
val frameItem = SVGAVideoSpriteFrameEntity(it)
if (frameItem.shapes.isNotEmpty()) {
frameItem.shapes.first().let {
if (it.isKeep) {
lastFrame?.let {
frameItem.shapes = it.shapes
}
}
}
}
lastFrame = frameItem
return@map frameItem
} ?: listOf()
}
}

View File

@ -0,0 +1,94 @@
package com.opensource.svgaplayer.entities
import android.graphics.Matrix
import com.opensource.svgaplayer.proto.FrameEntity
import com.opensource.svgaplayer.utils.SVGARect
import org.json.JSONObject
/**
* Created by cuiminghui on 2016/10/17.
*/
internal class SVGAVideoSpriteFrameEntity {
var alpha: Double
var layout = SVGARect(0.0, 0.0, 0.0, 0.0)
var transform = Matrix()
var maskPath: SVGAPathEntity? = null
var shapes: List<SVGAVideoShapeEntity> = listOf()
constructor(obj: JSONObject) {
this.alpha = obj.optDouble("alpha", 0.0)
obj.optJSONObject("layout")?.let {
layout = SVGARect(it.optDouble("x", 0.0), it.optDouble("y", 0.0), it.optDouble("width", 0.0), it.optDouble("height", 0.0))
}
obj.optJSONObject("transform")?.let {
val arr = FloatArray(9)
val a = it.optDouble("a", 1.0)
val b = it.optDouble("b", 0.0)
val c = it.optDouble("c", 0.0)
val d = it.optDouble("d", 1.0)
val tx = it.optDouble("tx", 0.0)
val ty = it.optDouble("ty", 0.0)
arr[0] = a.toFloat()
arr[1] = c.toFloat()
arr[2] = tx.toFloat()
arr[3] = b.toFloat()
arr[4] = d.toFloat()
arr[5] = ty.toFloat()
arr[6] = 0.0.toFloat()
arr[7] = 0.0.toFloat()
arr[8] = 1.0.toFloat()
transform.setValues(arr)
}
obj.optString("clipPath")?.let { d ->
if (d.isNotEmpty()) {
maskPath = SVGAPathEntity(d)
}
}
obj.optJSONArray("shapes")?.let {
val mutableList: MutableList<SVGAVideoShapeEntity> = mutableListOf()
for (i in 0 until it.length()) {
it.optJSONObject(i)?.let {
mutableList.add(SVGAVideoShapeEntity(it))
}
}
shapes = mutableList.toList()
}
}
constructor(obj: FrameEntity) {
this.alpha = (obj.alpha ?: 0.0f).toDouble()
obj.layout?.let {
this.layout = SVGARect((it.x ?: 0.0f).toDouble(), (it.y
?: 0.0f).toDouble(), (it.width ?: 0.0f).toDouble(), (it.height
?: 0.0f).toDouble())
}
obj.transform?.let {
val arr = FloatArray(9)
val a = it.a ?: 1.0f
val b = it.b ?: 0.0f
val c = it.c ?: 0.0f
val d = it.d ?: 1.0f
val tx = it.tx ?: 0.0f
val ty = it.ty ?: 0.0f
arr[0] = a
arr[1] = c
arr[2] = tx
arr[3] = b
arr[4] = d
arr[5] = ty
arr[6] = 0.0f
arr[7] = 0.0f
arr[8] = 1.0f
transform.setValues(arr)
}
obj.clipPath?.takeIf { it.isNotEmpty() }?.let {
maskPath = SVGAPathEntity(it)
}
this.shapes = obj.shapes.map {
return@map SVGAVideoShapeEntity(it)
}
}
}

View File

@ -0,0 +1,258 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: svga.proto at 19:1
package com.opensource.svgaplayer.proto;
import com.squareup.wire.FieldEncoding;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.ProtoReader;
import com.squareup.wire.ProtoWriter;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.io.IOException;
import java.lang.Integer;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import okio.ByteString;
public final class AudioEntity extends Message<AudioEntity, AudioEntity.Builder> {
public static final ProtoAdapter<AudioEntity> ADAPTER = new ProtoAdapter_AudioEntity();
private static final long serialVersionUID = 0L;
public static final String DEFAULT_AUDIOKEY = "";
public static final Integer DEFAULT_STARTFRAME = 0;
public static final Integer DEFAULT_ENDFRAME = 0;
public static final Integer DEFAULT_STARTTIME = 0;
public static final Integer DEFAULT_TOTALTIME = 0;
/**
* 音频文件名
*/
@WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#STRING"
)
public final String audioKey;
/**
* 音频播放起始帧
*/
@WireField(
tag = 2,
adapter = "com.squareup.wire.ProtoAdapter#INT32"
)
public final Integer startFrame;
/**
* 音频播放结束帧
*/
@WireField(
tag = 3,
adapter = "com.squareup.wire.ProtoAdapter#INT32"
)
public final Integer endFrame;
/**
* 音频播放起始时间相对音频长度
*/
@WireField(
tag = 4,
adapter = "com.squareup.wire.ProtoAdapter#INT32"
)
public final Integer startTime;
/**
* 音频总长度
*/
@WireField(
tag = 5,
adapter = "com.squareup.wire.ProtoAdapter#INT32"
)
public final Integer totalTime;
public AudioEntity(String audioKey, Integer startFrame, Integer endFrame, Integer startTime, Integer totalTime) {
this(audioKey, startFrame, endFrame, startTime, totalTime, ByteString.EMPTY);
}
public AudioEntity(String audioKey, Integer startFrame, Integer endFrame, Integer startTime, Integer totalTime, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.audioKey = audioKey;
this.startFrame = startFrame;
this.endFrame = endFrame;
this.startTime = startTime;
this.totalTime = totalTime;
}
@Override
public Builder newBuilder() {
Builder builder = new Builder();
builder.audioKey = audioKey;
builder.startFrame = startFrame;
builder.endFrame = endFrame;
builder.startTime = startTime;
builder.totalTime = totalTime;
builder.addUnknownFields(unknownFields());
return builder;
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof AudioEntity)) return false;
AudioEntity o = (AudioEntity) other;
return unknownFields().equals(o.unknownFields())
&& Internal.equals(audioKey, o.audioKey)
&& Internal.equals(startFrame, o.startFrame)
&& Internal.equals(endFrame, o.endFrame)
&& Internal.equals(startTime, o.startTime)
&& Internal.equals(totalTime, o.totalTime);
}
@Override
public int hashCode() {
int result = super.hashCode;
if (result == 0) {
result = unknownFields().hashCode();
result = result * 37 + (audioKey != null ? audioKey.hashCode() : 0);
result = result * 37 + (startFrame != null ? startFrame.hashCode() : 0);
result = result * 37 + (endFrame != null ? endFrame.hashCode() : 0);
result = result * 37 + (startTime != null ? startTime.hashCode() : 0);
result = result * 37 + (totalTime != null ? totalTime.hashCode() : 0);
super.hashCode = result;
}
return result;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (audioKey != null) builder.append(", audioKey=").append(audioKey);
if (startFrame != null) builder.append(", startFrame=").append(startFrame);
if (endFrame != null) builder.append(", endFrame=").append(endFrame);
if (startTime != null) builder.append(", startTime=").append(startTime);
if (totalTime != null) builder.append(", totalTime=").append(totalTime);
return builder.replace(0, 2, "AudioEntity{").append('}').toString();
}
public static final class Builder extends Message.Builder<AudioEntity, Builder> {
public String audioKey;
public Integer startFrame;
public Integer endFrame;
public Integer startTime;
public Integer totalTime;
public Builder() {
}
/**
* 音频文件名
*/
public Builder audioKey(String audioKey) {
this.audioKey = audioKey;
return this;
}
/**
* 音频播放起始帧
*/
public Builder startFrame(Integer startFrame) {
this.startFrame = startFrame;
return this;
}
/**
* 音频播放结束帧
*/
public Builder endFrame(Integer endFrame) {
this.endFrame = endFrame;
return this;
}
/**
* 音频播放起始时间相对音频长度
*/
public Builder startTime(Integer startTime) {
this.startTime = startTime;
return this;
}
/**
* 音频总长度
*/
public Builder totalTime(Integer totalTime) {
this.totalTime = totalTime;
return this;
}
@Override
public AudioEntity build() {
return new AudioEntity(audioKey, startFrame, endFrame, startTime, totalTime, super.buildUnknownFields());
}
}
private static final class ProtoAdapter_AudioEntity extends ProtoAdapter<AudioEntity> {
ProtoAdapter_AudioEntity() {
super(FieldEncoding.LENGTH_DELIMITED, AudioEntity.class);
}
@Override
public int encodedSize(AudioEntity value) {
return (value.audioKey != null ? ProtoAdapter.STRING.encodedSizeWithTag(1, value.audioKey) : 0)
+ (value.startFrame != null ? ProtoAdapter.INT32.encodedSizeWithTag(2, value.startFrame) : 0)
+ (value.endFrame != null ? ProtoAdapter.INT32.encodedSizeWithTag(3, value.endFrame) : 0)
+ (value.startTime != null ? ProtoAdapter.INT32.encodedSizeWithTag(4, value.startTime) : 0)
+ (value.totalTime != null ? ProtoAdapter.INT32.encodedSizeWithTag(5, value.totalTime) : 0)
+ value.unknownFields().size();
}
@Override
public void encode(ProtoWriter writer, AudioEntity value) throws IOException {
if (value.audioKey != null) ProtoAdapter.STRING.encodeWithTag(writer, 1, value.audioKey);
if (value.startFrame != null) ProtoAdapter.INT32.encodeWithTag(writer, 2, value.startFrame);
if (value.endFrame != null) ProtoAdapter.INT32.encodeWithTag(writer, 3, value.endFrame);
if (value.startTime != null) ProtoAdapter.INT32.encodeWithTag(writer, 4, value.startTime);
if (value.totalTime != null) ProtoAdapter.INT32.encodeWithTag(writer, 5, value.totalTime);
writer.writeBytes(value.unknownFields());
}
@Override
public AudioEntity decode(ProtoReader reader) throws IOException {
Builder builder = new Builder();
long token = reader.beginMessage();
for (int tag; (tag = reader.nextTag()) != -1;) {
switch (tag) {
case 1: builder.audioKey(ProtoAdapter.STRING.decode(reader)); break;
case 2: builder.startFrame(ProtoAdapter.INT32.decode(reader)); break;
case 3: builder.endFrame(ProtoAdapter.INT32.decode(reader)); break;
case 4: builder.startTime(ProtoAdapter.INT32.decode(reader)); break;
case 5: builder.totalTime(ProtoAdapter.INT32.decode(reader)); break;
default: {
FieldEncoding fieldEncoding = reader.peekFieldEncoding();
Object value = fieldEncoding.rawProtoAdapter().decode(reader);
builder.addUnknownField(tag, fieldEncoding, value);
}
}
}
reader.endMessage(token);
return builder.build();
}
@Override
public AudioEntity redact(AudioEntity value) {
Builder builder = value.newBuilder();
builder.clearUnknownFields();
return builder.build();
}
}
}

View File

@ -0,0 +1,259 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: svga.proto at 115:1
package com.opensource.svgaplayer.proto;
import com.squareup.wire.FieldEncoding;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.ProtoReader;
import com.squareup.wire.ProtoWriter;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.io.IOException;
import java.lang.Float;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import java.util.List;
import okio.ByteString;
public final class FrameEntity extends Message<FrameEntity, FrameEntity.Builder> {
public static final ProtoAdapter<FrameEntity> ADAPTER = new ProtoAdapter_FrameEntity();
private static final long serialVersionUID = 0L;
public static final Float DEFAULT_ALPHA = 0.0f;
public static final String DEFAULT_CLIPPATH = "";
/**
* 透明度
*/
@WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float alpha;
/**
* 初始约束大小
*/
@WireField(
tag = 2,
adapter = "com.opensource.svgaplayer.proto.Layout#ADAPTER"
)
public final Layout layout;
/**
* 2D 变换矩阵
*/
@WireField(
tag = 3,
adapter = "com.opensource.svgaplayer.proto.Transform#ADAPTER"
)
public final Transform transform;
/**
* 遮罩路径使用 SVG 标准 Path 绘制图案进行 Mask 遮罩
*/
@WireField(
tag = 4,
adapter = "com.squareup.wire.ProtoAdapter#STRING"
)
public final String clipPath;
/**
* 矢量元素列表
*/
@WireField(
tag = 5,
adapter = "com.opensource.svgaplayer.proto.ShapeEntity#ADAPTER",
label = WireField.Label.REPEATED
)
public final List<ShapeEntity> shapes;
public FrameEntity(Float alpha, Layout layout, Transform transform, String clipPath, List<ShapeEntity> shapes) {
this(alpha, layout, transform, clipPath, shapes, ByteString.EMPTY);
}
public FrameEntity(Float alpha, Layout layout, Transform transform, String clipPath, List<ShapeEntity> shapes, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.alpha = alpha;
this.layout = layout;
this.transform = transform;
this.clipPath = clipPath;
this.shapes = Internal.immutableCopyOf("shapes", shapes);
}
@Override
public Builder newBuilder() {
Builder builder = new Builder();
builder.alpha = alpha;
builder.layout = layout;
builder.transform = transform;
builder.clipPath = clipPath;
builder.shapes = Internal.copyOf("shapes", shapes);
builder.addUnknownFields(unknownFields());
return builder;
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof FrameEntity)) return false;
FrameEntity o = (FrameEntity) other;
return unknownFields().equals(o.unknownFields())
&& Internal.equals(alpha, o.alpha)
&& Internal.equals(layout, o.layout)
&& Internal.equals(transform, o.transform)
&& Internal.equals(clipPath, o.clipPath)
&& shapes.equals(o.shapes);
}
@Override
public int hashCode() {
int result = super.hashCode;
if (result == 0) {
result = unknownFields().hashCode();
result = result * 37 + (alpha != null ? alpha.hashCode() : 0);
result = result * 37 + (layout != null ? layout.hashCode() : 0);
result = result * 37 + (transform != null ? transform.hashCode() : 0);
result = result * 37 + (clipPath != null ? clipPath.hashCode() : 0);
result = result * 37 + shapes.hashCode();
super.hashCode = result;
}
return result;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (alpha != null) builder.append(", alpha=").append(alpha);
if (layout != null) builder.append(", layout=").append(layout);
if (transform != null) builder.append(", transform=").append(transform);
if (clipPath != null) builder.append(", clipPath=").append(clipPath);
if (!shapes.isEmpty()) builder.append(", shapes=").append(shapes);
return builder.replace(0, 2, "FrameEntity{").append('}').toString();
}
public static final class Builder extends Message.Builder<FrameEntity, Builder> {
public Float alpha;
public Layout layout;
public Transform transform;
public String clipPath;
public List<ShapeEntity> shapes;
public Builder() {
shapes = Internal.newMutableList();
}
/**
* 透明度
*/
public Builder alpha(Float alpha) {
this.alpha = alpha;
return this;
}
/**
* 初始约束大小
*/
public Builder layout(Layout layout) {
this.layout = layout;
return this;
}
/**
* 2D 变换矩阵
*/
public Builder transform(Transform transform) {
this.transform = transform;
return this;
}
/**
* 遮罩路径使用 SVG 标准 Path 绘制图案进行 Mask 遮罩
*/
public Builder clipPath(String clipPath) {
this.clipPath = clipPath;
return this;
}
/**
* 矢量元素列表
*/
public Builder shapes(List<ShapeEntity> shapes) {
Internal.checkElementsNotNull(shapes);
this.shapes = shapes;
return this;
}
@Override
public FrameEntity build() {
return new FrameEntity(alpha, layout, transform, clipPath, shapes, super.buildUnknownFields());
}
}
private static final class ProtoAdapter_FrameEntity extends ProtoAdapter<FrameEntity> {
ProtoAdapter_FrameEntity() {
super(FieldEncoding.LENGTH_DELIMITED, FrameEntity.class);
}
@Override
public int encodedSize(FrameEntity value) {
return (value.alpha != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(1, value.alpha) : 0)
+ (value.layout != null ? Layout.ADAPTER.encodedSizeWithTag(2, value.layout) : 0)
+ (value.transform != null ? Transform.ADAPTER.encodedSizeWithTag(3, value.transform) : 0)
+ (value.clipPath != null ? ProtoAdapter.STRING.encodedSizeWithTag(4, value.clipPath) : 0)
+ ShapeEntity.ADAPTER.asRepeated().encodedSizeWithTag(5, value.shapes)
+ value.unknownFields().size();
}
@Override
public void encode(ProtoWriter writer, FrameEntity value) throws IOException {
if (value.alpha != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 1, value.alpha);
if (value.layout != null) Layout.ADAPTER.encodeWithTag(writer, 2, value.layout);
if (value.transform != null) Transform.ADAPTER.encodeWithTag(writer, 3, value.transform);
if (value.clipPath != null) ProtoAdapter.STRING.encodeWithTag(writer, 4, value.clipPath);
ShapeEntity.ADAPTER.asRepeated().encodeWithTag(writer, 5, value.shapes);
writer.writeBytes(value.unknownFields());
}
@Override
public FrameEntity decode(ProtoReader reader) throws IOException {
Builder builder = new Builder();
long token = reader.beginMessage();
for (int tag; (tag = reader.nextTag()) != -1;) {
switch (tag) {
case 1: builder.alpha(ProtoAdapter.FLOAT.decode(reader)); break;
case 2: builder.layout(Layout.ADAPTER.decode(reader)); break;
case 3: builder.transform(Transform.ADAPTER.decode(reader)); break;
case 4: builder.clipPath(ProtoAdapter.STRING.decode(reader)); break;
case 5: builder.shapes.add(ShapeEntity.ADAPTER.decode(reader)); break;
default: {
FieldEncoding fieldEncoding = reader.peekFieldEncoding();
Object value = fieldEncoding.rawProtoAdapter().decode(reader);
builder.addUnknownField(tag, fieldEncoding, value);
}
}
}
reader.endMessage(token);
return builder.build();
}
@Override
public FrameEntity redact(FrameEntity value) {
Builder builder = value.newBuilder();
if (builder.layout != null) builder.layout = Layout.ADAPTER.redact(builder.layout);
if (builder.transform != null) builder.transform = Transform.ADAPTER.redact(builder.transform);
Internal.redactElements(builder.shapes, ShapeEntity.ADAPTER);
builder.clearUnknownFields();
return builder.build();
}
}
}

View File

@ -0,0 +1,205 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: svga.proto at 27:1
package com.opensource.svgaplayer.proto;
import com.squareup.wire.FieldEncoding;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.ProtoReader;
import com.squareup.wire.ProtoWriter;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.io.IOException;
import java.lang.Float;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import okio.ByteString;
public final class Layout extends Message<Layout, Layout.Builder> {
public static final ProtoAdapter<Layout> ADAPTER = new ProtoAdapter_Layout();
private static final long serialVersionUID = 0L;
public static final Float DEFAULT_X = 0.0f;
public static final Float DEFAULT_Y = 0.0f;
public static final Float DEFAULT_WIDTH = 0.0f;
public static final Float DEFAULT_HEIGHT = 0.0f;
@WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float x;
@WireField(
tag = 2,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float y;
@WireField(
tag = 3,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float width;
@WireField(
tag = 4,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float height;
public Layout(Float x, Float y, Float width, Float height) {
this(x, y, width, height, ByteString.EMPTY);
}
public Layout(Float x, Float y, Float width, Float height, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
@Override
public Builder newBuilder() {
Builder builder = new Builder();
builder.x = x;
builder.y = y;
builder.width = width;
builder.height = height;
builder.addUnknownFields(unknownFields());
return builder;
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof Layout)) return false;
Layout o = (Layout) other;
return unknownFields().equals(o.unknownFields())
&& Internal.equals(x, o.x)
&& Internal.equals(y, o.y)
&& Internal.equals(width, o.width)
&& Internal.equals(height, o.height);
}
@Override
public int hashCode() {
int result = super.hashCode;
if (result == 0) {
result = unknownFields().hashCode();
result = result * 37 + (x != null ? x.hashCode() : 0);
result = result * 37 + (y != null ? y.hashCode() : 0);
result = result * 37 + (width != null ? width.hashCode() : 0);
result = result * 37 + (height != null ? height.hashCode() : 0);
super.hashCode = result;
}
return result;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (x != null) builder.append(", x=").append(x);
if (y != null) builder.append(", y=").append(y);
if (width != null) builder.append(", width=").append(width);
if (height != null) builder.append(", height=").append(height);
return builder.replace(0, 2, "Layout{").append('}').toString();
}
public static final class Builder extends Message.Builder<Layout, Builder> {
public Float x;
public Float y;
public Float width;
public Float height;
public Builder() {
}
public Builder x(Float x) {
this.x = x;
return this;
}
public Builder y(Float y) {
this.y = y;
return this;
}
public Builder width(Float width) {
this.width = width;
return this;
}
public Builder height(Float height) {
this.height = height;
return this;
}
@Override
public Layout build() {
return new Layout(x, y, width, height, super.buildUnknownFields());
}
}
private static final class ProtoAdapter_Layout extends ProtoAdapter<Layout> {
ProtoAdapter_Layout() {
super(FieldEncoding.LENGTH_DELIMITED, Layout.class);
}
@Override
public int encodedSize(Layout value) {
return (value.x != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(1, value.x) : 0)
+ (value.y != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(2, value.y) : 0)
+ (value.width != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(3, value.width) : 0)
+ (value.height != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(4, value.height) : 0)
+ value.unknownFields().size();
}
@Override
public void encode(ProtoWriter writer, Layout value) throws IOException {
if (value.x != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 1, value.x);
if (value.y != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 2, value.y);
if (value.width != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 3, value.width);
if (value.height != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 4, value.height);
writer.writeBytes(value.unknownFields());
}
@Override
public Layout decode(ProtoReader reader) throws IOException {
Builder builder = new Builder();
long token = reader.beginMessage();
for (int tag; (tag = reader.nextTag()) != -1;) {
switch (tag) {
case 1: builder.x(ProtoAdapter.FLOAT.decode(reader)); break;
case 2: builder.y(ProtoAdapter.FLOAT.decode(reader)); break;
case 3: builder.width(ProtoAdapter.FLOAT.decode(reader)); break;
case 4: builder.height(ProtoAdapter.FLOAT.decode(reader)); break;
default: {
FieldEncoding fieldEncoding = reader.peekFieldEncoding();
Object value = fieldEncoding.rawProtoAdapter().decode(reader);
builder.addUnknownField(tag, fieldEncoding, value);
}
}
}
reader.endMessage(token);
return builder.build();
}
@Override
public Layout redact(Layout value) {
Builder builder = value.newBuilder();
builder.clearUnknownFields();
return builder.build();
}
}
}

View File

@ -0,0 +1,265 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: svga.proto at 123:1
package com.opensource.svgaplayer.proto;
import com.squareup.wire.FieldEncoding;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.ProtoReader;
import com.squareup.wire.ProtoWriter;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.io.IOException;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import java.util.List;
import java.util.Map;
import okio.ByteString;
public final class MovieEntity extends Message<MovieEntity, MovieEntity.Builder> {
public static final ProtoAdapter<MovieEntity> ADAPTER = new ProtoAdapter_MovieEntity();
private static final long serialVersionUID = 0L;
public static final String DEFAULT_VERSION = "";
/**
* SVGA 格式版本号
*/
@WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#STRING"
)
public final String version;
/**
* 动画参数
*/
@WireField(
tag = 2,
adapter = "com.opensource.svgaplayer.proto.MovieParams#ADAPTER"
)
public final MovieParams params;
/**
* Key 是位图键名Value 是位图文件名或二进制 PNG 数据
*/
@WireField(
tag = 3,
keyAdapter = "com.squareup.wire.ProtoAdapter#STRING",
adapter = "com.squareup.wire.ProtoAdapter#BYTES"
)
public final Map<String, ByteString> images;
/**
* 元素列表
*/
@WireField(
tag = 4,
adapter = "com.opensource.svgaplayer.proto.SpriteEntity#ADAPTER",
label = WireField.Label.REPEATED
)
public final List<SpriteEntity> sprites;
/**
* 音频列表
*/
@WireField(
tag = 5,
adapter = "com.opensource.svgaplayer.proto.AudioEntity#ADAPTER",
label = WireField.Label.REPEATED
)
public final List<AudioEntity> audios;
public MovieEntity(String version, MovieParams params, Map<String, ByteString> images, List<SpriteEntity> sprites, List<AudioEntity> audios) {
this(version, params, images, sprites, audios, ByteString.EMPTY);
}
public MovieEntity(String version, MovieParams params, Map<String, ByteString> images, List<SpriteEntity> sprites, List<AudioEntity> audios, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.version = version;
this.params = params;
this.images = Internal.immutableCopyOf("images", images);
this.sprites = Internal.immutableCopyOf("sprites", sprites);
this.audios = Internal.immutableCopyOf("audios", audios);
}
@Override
public Builder newBuilder() {
Builder builder = new Builder();
builder.version = version;
builder.params = params;
builder.images = Internal.copyOf("images", images);
builder.sprites = Internal.copyOf("sprites", sprites);
builder.audios = Internal.copyOf("audios", audios);
builder.addUnknownFields(unknownFields());
return builder;
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof MovieEntity)) return false;
MovieEntity o = (MovieEntity) other;
return unknownFields().equals(o.unknownFields())
&& Internal.equals(version, o.version)
&& Internal.equals(params, o.params)
&& images.equals(o.images)
&& sprites.equals(o.sprites)
&& audios.equals(o.audios);
}
@Override
public int hashCode() {
int result = super.hashCode;
if (result == 0) {
result = unknownFields().hashCode();
result = result * 37 + (version != null ? version.hashCode() : 0);
result = result * 37 + (params != null ? params.hashCode() : 0);
result = result * 37 + images.hashCode();
result = result * 37 + sprites.hashCode();
result = result * 37 + audios.hashCode();
super.hashCode = result;
}
return result;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (version != null) builder.append(", version=").append(version);
if (params != null) builder.append(", params=").append(params);
if (!images.isEmpty()) builder.append(", images=").append(images);
if (!sprites.isEmpty()) builder.append(", sprites=").append(sprites);
if (!audios.isEmpty()) builder.append(", audios=").append(audios);
return builder.replace(0, 2, "MovieEntity{").append('}').toString();
}
public static final class Builder extends Message.Builder<MovieEntity, Builder> {
public String version;
public MovieParams params;
public Map<String, ByteString> images;
public List<SpriteEntity> sprites;
public List<AudioEntity> audios;
public Builder() {
images = Internal.newMutableMap();
sprites = Internal.newMutableList();
audios = Internal.newMutableList();
}
/**
* SVGA 格式版本号
*/
public Builder version(String version) {
this.version = version;
return this;
}
/**
* 动画参数
*/
public Builder params(MovieParams params) {
this.params = params;
return this;
}
/**
* Key 是位图键名Value 是位图文件名或二进制 PNG 数据
*/
public Builder images(Map<String, ByteString> images) {
Internal.checkElementsNotNull(images);
this.images = images;
return this;
}
/**
* 元素列表
*/
public Builder sprites(List<SpriteEntity> sprites) {
Internal.checkElementsNotNull(sprites);
this.sprites = sprites;
return this;
}
/**
* 音频列表
*/
public Builder audios(List<AudioEntity> audios) {
Internal.checkElementsNotNull(audios);
this.audios = audios;
return this;
}
@Override
public MovieEntity build() {
return new MovieEntity(version, params, images, sprites, audios, super.buildUnknownFields());
}
}
private static final class ProtoAdapter_MovieEntity extends ProtoAdapter<MovieEntity> {
private final ProtoAdapter<Map<String, ByteString>> images = ProtoAdapter.newMapAdapter(ProtoAdapter.STRING, ProtoAdapter.BYTES);
ProtoAdapter_MovieEntity() {
super(FieldEncoding.LENGTH_DELIMITED, MovieEntity.class);
}
@Override
public int encodedSize(MovieEntity value) {
return (value.version != null ? ProtoAdapter.STRING.encodedSizeWithTag(1, value.version) : 0)
+ (value.params != null ? MovieParams.ADAPTER.encodedSizeWithTag(2, value.params) : 0)
+ images.encodedSizeWithTag(3, value.images)
+ SpriteEntity.ADAPTER.asRepeated().encodedSizeWithTag(4, value.sprites)
+ AudioEntity.ADAPTER.asRepeated().encodedSizeWithTag(5, value.audios)
+ value.unknownFields().size();
}
@Override
public void encode(ProtoWriter writer, MovieEntity value) throws IOException {
if (value.version != null) ProtoAdapter.STRING.encodeWithTag(writer, 1, value.version);
if (value.params != null) MovieParams.ADAPTER.encodeWithTag(writer, 2, value.params);
images.encodeWithTag(writer, 3, value.images);
SpriteEntity.ADAPTER.asRepeated().encodeWithTag(writer, 4, value.sprites);
AudioEntity.ADAPTER.asRepeated().encodeWithTag(writer, 5, value.audios);
writer.writeBytes(value.unknownFields());
}
@Override
public MovieEntity decode(ProtoReader reader) throws IOException {
Builder builder = new Builder();
long token = reader.beginMessage();
for (int tag; (tag = reader.nextTag()) != -1;) {
switch (tag) {
case 1: builder.version(ProtoAdapter.STRING.decode(reader)); break;
case 2: builder.params(MovieParams.ADAPTER.decode(reader)); break;
case 3: builder.images.putAll(images.decode(reader)); break;
case 4: builder.sprites.add(SpriteEntity.ADAPTER.decode(reader)); break;
case 5: builder.audios.add(AudioEntity.ADAPTER.decode(reader)); break;
default: {
FieldEncoding fieldEncoding = reader.peekFieldEncoding();
Object value = fieldEncoding.rawProtoAdapter().decode(reader);
builder.addUnknownField(tag, fieldEncoding, value);
}
}
}
reader.endMessage(token);
return builder.build();
}
@Override
public MovieEntity redact(MovieEntity value) {
Builder builder = value.newBuilder();
if (builder.params != null) builder.params = MovieParams.ADAPTER.redact(builder.params);
Internal.redactElements(builder.sprites, SpriteEntity.ADAPTER);
Internal.redactElements(builder.audios, AudioEntity.ADAPTER);
builder.clearUnknownFields();
return builder.build();
}
}
}

View File

@ -0,0 +1,230 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: svga.proto at 6:1
package com.opensource.svgaplayer.proto;
import com.squareup.wire.FieldEncoding;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.ProtoReader;
import com.squareup.wire.ProtoWriter;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.io.IOException;
import java.lang.Float;
import java.lang.Integer;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import okio.ByteString;
public final class MovieParams extends Message<MovieParams, MovieParams.Builder> {
public static final ProtoAdapter<MovieParams> ADAPTER = new ProtoAdapter_MovieParams();
private static final long serialVersionUID = 0L;
public static final Float DEFAULT_VIEWBOXWIDTH = 0.0f;
public static final Float DEFAULT_VIEWBOXHEIGHT = 0.0f;
public static final Integer DEFAULT_FPS = 0;
public static final Integer DEFAULT_FRAMES = 0;
/**
* 画布宽
*/
@WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float viewBoxWidth;
/**
* 画布高
*/
@WireField(
tag = 2,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float viewBoxHeight;
/**
* 动画每秒播放帧数合法值是 [1, 2, 3, 5, 6, 10, 12, 15, 20, 30, 60] 中的任意一个
*/
@WireField(
tag = 3,
adapter = "com.squareup.wire.ProtoAdapter#INT32"
)
public final Integer fps;
/**
* 动画总帧数
*/
@WireField(
tag = 4,
adapter = "com.squareup.wire.ProtoAdapter#INT32"
)
public final Integer frames;
public MovieParams(Float viewBoxWidth, Float viewBoxHeight, Integer fps, Integer frames) {
this(viewBoxWidth, viewBoxHeight, fps, frames, ByteString.EMPTY);
}
public MovieParams(Float viewBoxWidth, Float viewBoxHeight, Integer fps, Integer frames, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.viewBoxWidth = viewBoxWidth;
this.viewBoxHeight = viewBoxHeight;
this.fps = fps;
this.frames = frames;
}
@Override
public Builder newBuilder() {
Builder builder = new Builder();
builder.viewBoxWidth = viewBoxWidth;
builder.viewBoxHeight = viewBoxHeight;
builder.fps = fps;
builder.frames = frames;
builder.addUnknownFields(unknownFields());
return builder;
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof MovieParams)) return false;
MovieParams o = (MovieParams) other;
return unknownFields().equals(o.unknownFields())
&& Internal.equals(viewBoxWidth, o.viewBoxWidth)
&& Internal.equals(viewBoxHeight, o.viewBoxHeight)
&& Internal.equals(fps, o.fps)
&& Internal.equals(frames, o.frames);
}
@Override
public int hashCode() {
int result = super.hashCode;
if (result == 0) {
result = unknownFields().hashCode();
result = result * 37 + (viewBoxWidth != null ? viewBoxWidth.hashCode() : 0);
result = result * 37 + (viewBoxHeight != null ? viewBoxHeight.hashCode() : 0);
result = result * 37 + (fps != null ? fps.hashCode() : 0);
result = result * 37 + (frames != null ? frames.hashCode() : 0);
super.hashCode = result;
}
return result;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (viewBoxWidth != null) builder.append(", viewBoxWidth=").append(viewBoxWidth);
if (viewBoxHeight != null) builder.append(", viewBoxHeight=").append(viewBoxHeight);
if (fps != null) builder.append(", fps=").append(fps);
if (frames != null) builder.append(", frames=").append(frames);
return builder.replace(0, 2, "MovieParams{").append('}').toString();
}
public static final class Builder extends Message.Builder<MovieParams, Builder> {
public Float viewBoxWidth;
public Float viewBoxHeight;
public Integer fps;
public Integer frames;
public Builder() {
}
/**
* 画布宽
*/
public Builder viewBoxWidth(Float viewBoxWidth) {
this.viewBoxWidth = viewBoxWidth;
return this;
}
/**
* 画布高
*/
public Builder viewBoxHeight(Float viewBoxHeight) {
this.viewBoxHeight = viewBoxHeight;
return this;
}
/**
* 动画每秒播放帧数合法值是 [1, 2, 3, 5, 6, 10, 12, 15, 20, 30, 60] 中的任意一个
*/
public Builder fps(Integer fps) {
this.fps = fps;
return this;
}
/**
* 动画总帧数
*/
public Builder frames(Integer frames) {
this.frames = frames;
return this;
}
@Override
public MovieParams build() {
return new MovieParams(viewBoxWidth, viewBoxHeight, fps, frames, super.buildUnknownFields());
}
}
private static final class ProtoAdapter_MovieParams extends ProtoAdapter<MovieParams> {
ProtoAdapter_MovieParams() {
super(FieldEncoding.LENGTH_DELIMITED, MovieParams.class);
}
@Override
public int encodedSize(MovieParams value) {
return (value.viewBoxWidth != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(1, value.viewBoxWidth) : 0)
+ (value.viewBoxHeight != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(2, value.viewBoxHeight) : 0)
+ (value.fps != null ? ProtoAdapter.INT32.encodedSizeWithTag(3, value.fps) : 0)
+ (value.frames != null ? ProtoAdapter.INT32.encodedSizeWithTag(4, value.frames) : 0)
+ value.unknownFields().size();
}
@Override
public void encode(ProtoWriter writer, MovieParams value) throws IOException {
if (value.viewBoxWidth != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 1, value.viewBoxWidth);
if (value.viewBoxHeight != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 2, value.viewBoxHeight);
if (value.fps != null) ProtoAdapter.INT32.encodeWithTag(writer, 3, value.fps);
if (value.frames != null) ProtoAdapter.INT32.encodeWithTag(writer, 4, value.frames);
writer.writeBytes(value.unknownFields());
}
@Override
public MovieParams decode(ProtoReader reader) throws IOException {
Builder builder = new Builder();
long token = reader.beginMessage();
for (int tag; (tag = reader.nextTag()) != -1;) {
switch (tag) {
case 1: builder.viewBoxWidth(ProtoAdapter.FLOAT.decode(reader)); break;
case 2: builder.viewBoxHeight(ProtoAdapter.FLOAT.decode(reader)); break;
case 3: builder.fps(ProtoAdapter.INT32.decode(reader)); break;
case 4: builder.frames(ProtoAdapter.INT32.decode(reader)); break;
default: {
FieldEncoding fieldEncoding = reader.peekFieldEncoding();
Object value = fieldEncoding.rawProtoAdapter().decode(reader);
builder.addUnknownField(tag, fieldEncoding, value);
}
}
}
reader.endMessage(token);
return builder.build();
}
@Override
public MovieParams redact(MovieParams value) {
Builder builder = value.newBuilder();
builder.clearUnknownFields();
return builder.build();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,202 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: svga.proto at 13:1
package com.opensource.svgaplayer.proto;
import com.squareup.wire.FieldEncoding;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.ProtoReader;
import com.squareup.wire.ProtoWriter;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.io.IOException;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import java.util.List;
import okio.ByteString;
public final class SpriteEntity extends Message<SpriteEntity, SpriteEntity.Builder> {
public static final ProtoAdapter<SpriteEntity> ADAPTER = new ProtoAdapter_SpriteEntity();
private static final long serialVersionUID = 0L;
public static final String DEFAULT_IMAGEKEY = "";
public static final String DEFAULT_MATTEKEY = "";
/**
* 元件所对应的位图键名, 如果 imageKey 含有 .vector 后缀 sprite 为矢量图层 含有 .matte 后缀 sprite 为遮罩图层
*/
@WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#STRING"
)
public final String imageKey;
/**
* 帧列表
*/
@WireField(
tag = 2,
adapter = "com.opensource.svgaplayer.proto.FrameEntity#ADAPTER",
label = WireField.Label.REPEATED
)
public final List<FrameEntity> frames;
/**
* 被遮罩图层的 matteKey 对应的是其遮罩图层的 imageKey.
*/
@WireField(
tag = 3,
adapter = "com.squareup.wire.ProtoAdapter#STRING"
)
public final String matteKey;
public SpriteEntity(String imageKey, List<FrameEntity> frames, String matteKey) {
this(imageKey, frames, matteKey, ByteString.EMPTY);
}
public SpriteEntity(String imageKey, List<FrameEntity> frames, String matteKey, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.imageKey = imageKey;
this.frames = Internal.immutableCopyOf("frames", frames);
this.matteKey = matteKey;
}
@Override
public Builder newBuilder() {
Builder builder = new Builder();
builder.imageKey = imageKey;
builder.frames = Internal.copyOf("frames", frames);
builder.matteKey = matteKey;
builder.addUnknownFields(unknownFields());
return builder;
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof SpriteEntity)) return false;
SpriteEntity o = (SpriteEntity) other;
return unknownFields().equals(o.unknownFields())
&& Internal.equals(imageKey, o.imageKey)
&& frames.equals(o.frames)
&& Internal.equals(matteKey, o.matteKey);
}
@Override
public int hashCode() {
int result = super.hashCode;
if (result == 0) {
result = unknownFields().hashCode();
result = result * 37 + (imageKey != null ? imageKey.hashCode() : 0);
result = result * 37 + frames.hashCode();
result = result * 37 + (matteKey != null ? matteKey.hashCode() : 0);
super.hashCode = result;
}
return result;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (imageKey != null) builder.append(", imageKey=").append(imageKey);
if (!frames.isEmpty()) builder.append(", frames=").append(frames);
if (matteKey != null) builder.append(", matteKey=").append(matteKey);
return builder.replace(0, 2, "SpriteEntity{").append('}').toString();
}
public static final class Builder extends Message.Builder<SpriteEntity, Builder> {
public String imageKey;
public List<FrameEntity> frames;
public String matteKey;
public Builder() {
frames = Internal.newMutableList();
}
/**
* 元件所对应的位图键名, 如果 imageKey 含有 .vector 后缀 sprite 为矢量图层 含有 .matte 后缀 sprite 为遮罩图层
*/
public Builder imageKey(String imageKey) {
this.imageKey = imageKey;
return this;
}
/**
* 帧列表
*/
public Builder frames(List<FrameEntity> frames) {
Internal.checkElementsNotNull(frames);
this.frames = frames;
return this;
}
/**
* 被遮罩图层的 matteKey 对应的是其遮罩图层的 imageKey.
*/
public Builder matteKey(String matteKey) {
this.matteKey = matteKey;
return this;
}
@Override
public SpriteEntity build() {
return new SpriteEntity(imageKey, frames, matteKey, super.buildUnknownFields());
}
}
private static final class ProtoAdapter_SpriteEntity extends ProtoAdapter<SpriteEntity> {
ProtoAdapter_SpriteEntity() {
super(FieldEncoding.LENGTH_DELIMITED, SpriteEntity.class);
}
@Override
public int encodedSize(SpriteEntity value) {
return (value.imageKey != null ? ProtoAdapter.STRING.encodedSizeWithTag(1, value.imageKey) : 0)
+ FrameEntity.ADAPTER.asRepeated().encodedSizeWithTag(2, value.frames)
+ (value.matteKey != null ? ProtoAdapter.STRING.encodedSizeWithTag(3, value.matteKey) : 0)
+ value.unknownFields().size();
}
@Override
public void encode(ProtoWriter writer, SpriteEntity value) throws IOException {
if (value.imageKey != null) ProtoAdapter.STRING.encodeWithTag(writer, 1, value.imageKey);
FrameEntity.ADAPTER.asRepeated().encodeWithTag(writer, 2, value.frames);
if (value.matteKey != null) ProtoAdapter.STRING.encodeWithTag(writer, 3, value.matteKey);
writer.writeBytes(value.unknownFields());
}
@Override
public SpriteEntity decode(ProtoReader reader) throws IOException {
Builder builder = new Builder();
long token = reader.beginMessage();
for (int tag; (tag = reader.nextTag()) != -1;) {
switch (tag) {
case 1: builder.imageKey(ProtoAdapter.STRING.decode(reader)); break;
case 2: builder.frames.add(FrameEntity.ADAPTER.decode(reader)); break;
case 3: builder.matteKey(ProtoAdapter.STRING.decode(reader)); break;
default: {
FieldEncoding fieldEncoding = reader.peekFieldEncoding();
Object value = fieldEncoding.rawProtoAdapter().decode(reader);
builder.addUnknownField(tag, fieldEncoding, value);
}
}
}
reader.endMessage(token);
return builder.build();
}
@Override
public SpriteEntity redact(SpriteEntity value) {
Builder builder = value.newBuilder();
Internal.redactElements(builder.frames, FrameEntity.ADAPTER);
builder.clearUnknownFields();
return builder.build();
}
}
}

View File

@ -0,0 +1,251 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: svga.proto at 34:1
package com.opensource.svgaplayer.proto;
import com.squareup.wire.FieldEncoding;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.ProtoReader;
import com.squareup.wire.ProtoWriter;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.io.IOException;
import java.lang.Float;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import okio.ByteString;
public final class Transform extends Message<Transform, Transform.Builder> {
public static final ProtoAdapter<Transform> ADAPTER = new ProtoAdapter_Transform();
private static final long serialVersionUID = 0L;
public static final Float DEFAULT_A = 0.0f;
public static final Float DEFAULT_B = 0.0f;
public static final Float DEFAULT_C = 0.0f;
public static final Float DEFAULT_D = 0.0f;
public static final Float DEFAULT_TX = 0.0f;
public static final Float DEFAULT_TY = 0.0f;
@WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float a;
@WireField(
tag = 2,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float b;
@WireField(
tag = 3,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float c;
@WireField(
tag = 4,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float d;
@WireField(
tag = 5,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float tx;
@WireField(
tag = 6,
adapter = "com.squareup.wire.ProtoAdapter#FLOAT"
)
public final Float ty;
public Transform(Float a, Float b, Float c, Float d, Float tx, Float ty) {
this(a, b, c, d, tx, ty, ByteString.EMPTY);
}
public Transform(Float a, Float b, Float c, Float d, Float tx, Float ty, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.tx = tx;
this.ty = ty;
}
@Override
public Builder newBuilder() {
Builder builder = new Builder();
builder.a = a;
builder.b = b;
builder.c = c;
builder.d = d;
builder.tx = tx;
builder.ty = ty;
builder.addUnknownFields(unknownFields());
return builder;
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof Transform)) return false;
Transform o = (Transform) other;
return unknownFields().equals(o.unknownFields())
&& Internal.equals(a, o.a)
&& Internal.equals(b, o.b)
&& Internal.equals(c, o.c)
&& Internal.equals(d, o.d)
&& Internal.equals(tx, o.tx)
&& Internal.equals(ty, o.ty);
}
@Override
public int hashCode() {
int result = super.hashCode;
if (result == 0) {
result = unknownFields().hashCode();
result = result * 37 + (a != null ? a.hashCode() : 0);
result = result * 37 + (b != null ? b.hashCode() : 0);
result = result * 37 + (c != null ? c.hashCode() : 0);
result = result * 37 + (d != null ? d.hashCode() : 0);
result = result * 37 + (tx != null ? tx.hashCode() : 0);
result = result * 37 + (ty != null ? ty.hashCode() : 0);
super.hashCode = result;
}
return result;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (a != null) builder.append(", a=").append(a);
if (b != null) builder.append(", b=").append(b);
if (c != null) builder.append(", c=").append(c);
if (d != null) builder.append(", d=").append(d);
if (tx != null) builder.append(", tx=").append(tx);
if (ty != null) builder.append(", ty=").append(ty);
return builder.replace(0, 2, "Transform{").append('}').toString();
}
public static final class Builder extends Message.Builder<Transform, Builder> {
public Float a;
public Float b;
public Float c;
public Float d;
public Float tx;
public Float ty;
public Builder() {
}
public Builder a(Float a) {
this.a = a;
return this;
}
public Builder b(Float b) {
this.b = b;
return this;
}
public Builder c(Float c) {
this.c = c;
return this;
}
public Builder d(Float d) {
this.d = d;
return this;
}
public Builder tx(Float tx) {
this.tx = tx;
return this;
}
public Builder ty(Float ty) {
this.ty = ty;
return this;
}
@Override
public Transform build() {
return new Transform(a, b, c, d, tx, ty, super.buildUnknownFields());
}
}
private static final class ProtoAdapter_Transform extends ProtoAdapter<Transform> {
ProtoAdapter_Transform() {
super(FieldEncoding.LENGTH_DELIMITED, Transform.class);
}
@Override
public int encodedSize(Transform value) {
return (value.a != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(1, value.a) : 0)
+ (value.b != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(2, value.b) : 0)
+ (value.c != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(3, value.c) : 0)
+ (value.d != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(4, value.d) : 0)
+ (value.tx != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(5, value.tx) : 0)
+ (value.ty != null ? ProtoAdapter.FLOAT.encodedSizeWithTag(6, value.ty) : 0)
+ value.unknownFields().size();
}
@Override
public void encode(ProtoWriter writer, Transform value) throws IOException {
if (value.a != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 1, value.a);
if (value.b != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 2, value.b);
if (value.c != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 3, value.c);
if (value.d != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 4, value.d);
if (value.tx != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 5, value.tx);
if (value.ty != null) ProtoAdapter.FLOAT.encodeWithTag(writer, 6, value.ty);
writer.writeBytes(value.unknownFields());
}
@Override
public Transform decode(ProtoReader reader) throws IOException {
Builder builder = new Builder();
long token = reader.beginMessage();
for (int tag; (tag = reader.nextTag()) != -1;) {
switch (tag) {
case 1: builder.a(ProtoAdapter.FLOAT.decode(reader)); break;
case 2: builder.b(ProtoAdapter.FLOAT.decode(reader)); break;
case 3: builder.c(ProtoAdapter.FLOAT.decode(reader)); break;
case 4: builder.d(ProtoAdapter.FLOAT.decode(reader)); break;
case 5: builder.tx(ProtoAdapter.FLOAT.decode(reader)); break;
case 6: builder.ty(ProtoAdapter.FLOAT.decode(reader)); break;
default: {
FieldEncoding fieldEncoding = reader.peekFieldEncoding();
Object value = fieldEncoding.rawProtoAdapter().decode(reader);
builder.addUnknownField(tag, fieldEncoding, value);
}
}
}
reader.endMessage(token);
return builder.build();
}
@Override
public Transform redact(Transform value) {
Builder builder = value.newBuilder();
builder.clearUnknownFields();
return builder.build();
}
}
}

View File

@ -0,0 +1,102 @@
package com.opensource.svgaplayer.utils
/**
* Helper class for creating pools of objects. An example use looks like this:
* <pre>
* public class MyPooledClass {
*
* private static final SynchronizedPool<MyPooledClass> sPool =
* new SynchronizedPool<MyPooledClass>(10);
*
* public static MyPooledClass obtain() {
* MyPooledClass instance = sPool.acquire();
* return (instance != null) ? instance : new MyPooledClass();
* }
*
* public void recycle() {
* // Clear state if needed.
* sPool.release(this);
* }
*
* . . .
* }
* </pre>
*
*/
class Pools private constructor() {
/**
* Interface for managing a pool of objects.
*
* @param <T> The pooled type.
*/
interface Pool<T> {
/**
* @return An instance from the pool if such, null otherwise.
*/
fun acquire(): T?
/**
* Release an instance to the pool.
*
* @param instance The instance to release.
* @return Whether the instance was put in the pool.
*
* @throws IllegalStateException If the instance is already in the pool.
*/
fun release(instance: T): Boolean
}
/**
* Simple (non-synchronized) pool of objects.
*
* @param maxPoolSize The max pool size.
*
* @throws IllegalArgumentException If the max pool size is less than zero.
*
* @param <T> The pooled type.
*/
open class SimplePool<T>(maxPoolSize: Int) : Pool<T> {
private val mPool: Array<Any?>
private var mPoolSize = 0
init {
require(maxPoolSize > 0) { "The max pool size must be > 0" }
mPool = arrayOfNulls(maxPoolSize)
}
@Suppress("UNCHECKED_CAST")
override fun acquire(): T? {
if (mPoolSize > 0) {
val lastPooledIndex = mPoolSize - 1
val instance = mPool[lastPooledIndex] as T?
mPool[lastPooledIndex] = null
mPoolSize--
return instance
}
return null
}
override fun release(instance: T): Boolean {
check(!isInPool(instance)) { "Already in the pool!" }
if (mPoolSize < mPool.size) {
mPool[mPoolSize] = instance
mPoolSize++
return true
}
return false
}
private fun isInPool(instance: T): Boolean {
for (i in 0 until mPoolSize) {
if (mPool[i] === instance) {
return true
}
}
return false
}
}
}

View File

@ -0,0 +1,146 @@
package com.opensource.svgaplayer.utils
import android.widget.ImageView
/**
* Created by ubt on 2018/1/19.
*/
class SVGAScaleInfo {
var tranFx : Float = 0.0f
var tranFy : Float = 0.0f
var scaleFx : Float = 1.0f
var scaleFy : Float = 1.0f
var ratio = 1.0f
var ratioX = false
private fun resetVar(){
tranFx = 0.0f
tranFy = 0.0f
scaleFx = 1.0f
scaleFy = 1.0f
ratio = 1.0f
ratioX = false
}
fun performScaleType(canvasWidth : Float, canvasHeight: Float, videoWidth : Float, videoHeight : Float, scaleType: ImageView.ScaleType) {
if (canvasWidth == 0.0f || canvasHeight == 0.0f || videoWidth == 0.0f || videoHeight == 0.0f) {
return
}
resetVar()
val canW_vidW_f = (canvasWidth - videoWidth) / 2.0f
val canH_vidH_f = (canvasHeight - videoHeight) / 2.0f
val videoRatio = videoWidth / videoHeight
val canvasRatio = canvasWidth / canvasHeight
val canH_d_vidH = canvasHeight / videoHeight
val canW_d_vidW = canvasWidth / videoWidth
when (scaleType) {
ImageView.ScaleType.CENTER -> {
tranFx = canW_vidW_f
tranFy = canH_vidH_f
}
ImageView.ScaleType.CENTER_CROP -> {
if (videoRatio > canvasRatio) {
ratio = canH_d_vidH
ratioX = false
scaleFx = canH_d_vidH
scaleFy = canH_d_vidH
tranFx = (canvasWidth - videoWidth * (canH_d_vidH)) / 2.0f
}
else {
ratio = canW_d_vidW
ratioX = true
scaleFx = canW_d_vidW
scaleFy = canW_d_vidW
tranFy = (canvasHeight - videoHeight * (canW_d_vidW)) / 2.0f
}
}
ImageView.ScaleType.CENTER_INSIDE -> {
if (videoWidth < canvasWidth && videoHeight < canvasHeight) {
tranFx = canW_vidW_f
tranFy = canH_vidH_f
}
else {
if (videoRatio > canvasRatio) {
ratio = canW_d_vidW
ratioX = true
scaleFx = canW_d_vidW
scaleFy = canW_d_vidW
tranFy = (canvasHeight - videoHeight * (canW_d_vidW)) / 2.0f
}
else {
ratio = canH_d_vidH
ratioX = false
scaleFx = canH_d_vidH
scaleFy = canH_d_vidH
tranFx = (canvasWidth - videoWidth * (canH_d_vidH)) / 2.0f
}
}
}
ImageView.ScaleType.FIT_CENTER -> {
if (videoRatio > canvasRatio) {
ratio = canW_d_vidW
ratioX = true
scaleFx = canW_d_vidW
scaleFy = canW_d_vidW
tranFy = (canvasHeight - videoHeight * (canW_d_vidW)) / 2.0f
}
else {
ratio = canH_d_vidH
ratioX = false
scaleFx = canH_d_vidH
scaleFy = canH_d_vidH
tranFx = (canvasWidth - videoWidth * (canH_d_vidH)) / 2.0f
}
}
ImageView.ScaleType.FIT_START -> {
if (videoRatio > canvasRatio) {
ratio = canW_d_vidW
ratioX = true
scaleFx = canW_d_vidW
scaleFy = canW_d_vidW
}
else {
ratio = canH_d_vidH
ratioX = false
scaleFx = canH_d_vidH
scaleFy = canH_d_vidH
}
}
ImageView.ScaleType.FIT_END -> {
if (videoRatio > canvasRatio) {
ratio = canW_d_vidW
ratioX = true
scaleFx = canW_d_vidW
scaleFy = canW_d_vidW
tranFy= canvasHeight - videoHeight * (canW_d_vidW)
}
else {
ratio = canH_d_vidH
ratioX = false
scaleFx = canH_d_vidH
scaleFy = canH_d_vidH
tranFx = canvasWidth - videoWidth * (canH_d_vidH)
}
}
ImageView.ScaleType.FIT_XY -> {
ratio = Math.max(canW_d_vidW, canH_d_vidH)
ratioX = canW_d_vidW > canH_d_vidH
scaleFx = canW_d_vidW
scaleFy = canH_d_vidH
}
else -> {
ratio = canW_d_vidW
ratioX = true
scaleFx = canW_d_vidW
scaleFy = canW_d_vidW
}
}
}
}

View File

@ -0,0 +1,11 @@
package com.opensource.svgaplayer.utils
/**
* Created by cuiminghui on 2017/3/29.
*/
class SVGAPoint(val x: Float, val y: Float, val value: Float)
class SVGARect(val x: Double, val y: Double, val width: Double, val height: Double)
class SVGARange(val location: Int, val length: Int)

View File

@ -0,0 +1,28 @@
package com.opensource.svgaplayer.utils.log
import android.util.Log
/**
* 内部默认 ILogger 接口实现
*/
class DefaultLogCat : ILogger {
override fun verbose(tag: String, msg: String) {
Log.v(tag, msg)
}
override fun info(tag: String, msg: String) {
Log.i(tag, msg)
}
override fun debug(tag: String, msg: String) {
Log.d(tag, msg)
}
override fun warn(tag: String, msg: String) {
Log.w(tag, msg)
}
override fun error(tag: String, msg: String?, error: Throwable?) {
Log.e(tag, msg, error)
}
}

Some files were not shown because too many files have changed in this diff Show More