├── .gitignore ├── LICENSE ├── README.md ├── README_ZH.md ├── ScreenShot.PNG ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── AlphaAnimation │ │ ├── aixin7.png │ │ ├── bj.jpg │ │ └── manifest.xml │ ├── DropPhysicalView │ │ ├── background.jpg │ │ ├── jinbi.png │ │ ├── manifest.xml │ │ ├── shiwu.png │ │ └── xx.png │ ├── FlipBook │ │ ├── bg1.jpg │ │ ├── bg2.jpg │ │ ├── bg3.jpg │ │ ├── front.jpg │ │ └── manifest.xml │ ├── Marquee │ │ ├── bj.jpg │ │ └── manifest.xml │ ├── MeshImage │ │ ├── background.jpg │ │ ├── manifest.xml │ │ └── part.png │ ├── Paint │ │ ├── bg.jpg │ │ ├── manifest.xml │ │ ├── part.png │ │ └── part_2.png │ ├── ParticleScatter │ │ ├── bj.jpg │ │ ├── manifest.xml │ │ └── maojiao.png │ ├── ParticleView │ │ ├── background.jpg │ │ ├── manifest.xml │ │ └── particle.png │ ├── PositionAnimation │ │ ├── bj.jpg │ │ ├── manifest.xml │ │ └── ty.png │ ├── RotateView │ │ ├── 1.jpg │ │ ├── bj.jpg │ │ └── manifest.xml │ ├── RotationAnimation │ │ ├── bj.jpg │ │ ├── manifest.xml │ │ └── ty.png │ ├── SizeAnimation │ │ ├── default_background.jpg │ │ ├── manifest.xml │ │ └── ty.png │ ├── SourcesAnimation │ │ ├── bj.jpg │ │ ├── manifest.xml │ │ ├── zuida1_1.png │ │ ├── zuida1_2.png │ │ ├── zuida1_3.png │ │ ├── zuida1_4.png │ │ └── zuida1_5.png │ └── WaterWallpaper │ │ ├── background.jpg │ │ └── manifest.xml │ ├── ic_launcher-playstore.png │ ├── java │ └── com │ │ └── huawei │ │ └── image │ │ └── render │ │ └── sample │ │ ├── activity │ │ ├── ImageKitRenderDemoActivity.java │ │ └── ImageKitRenderDemoActivity1.java │ │ └── util │ │ └── Utils.java │ └── res │ ├── layout │ ├── activity_entries.xml │ ├── activity_image_kit_demo.xml │ ├── activity_image_kit_demo_1.xml │ ├── activity_main.xml │ └── recycler_view.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── values-zh-rCN │ └── strings.xml │ └── values │ ├── arrays.xml │ ├── colors.xml │ ├── ic_launcher_background.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── render.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## HUAWEI Image Kit Render Sample for Java 2 | 3 | English | [中文](README_ZH.md) 4 | 5 | ## Table of Contents 6 | 7 | * [Introduction](#introduction) 8 | * [Getting Started](#getting-started) 9 | * [Supported Environments](#supported-environments) 10 | * [Result](#result) 11 | * [License](#license) 12 | 13 | ## Introduction 14 | The Image Render service provides basic and advanced animation effects to help you reproduce image contents in an efficient way. This sample code encapsulates APIs of the HUAWEI Image Kit Render Service, it provides a sample programs for your reference or usage. 15 | 16 | 1. Supports five basic animations and any of their combination. 17 | 18 | 2. Provides nine advanced animation effects, bringing more fun to user interactions. 19 | 20 | For details, please refer to [XML Syntax Specifications for Image Render](https://developer.huawei.com/consumer/en/doc/development/Media-Guides/xml-introduction-0000001050439245?ha_source=hms1). 21 | 22 | ## Getting Started 23 | 1. Check whether the Android studio development environment is ready. Open the sample code project directory with file "build.gradle" in Android Studio. Run TestApp on your divice or simulator which have installed latest Huawei Mobile Service(HMS). 24 | 2. Register a [HUAWEI account](https://developer.huawei.com/consumer/en/). 25 | 3. Create an app and configure the app information in AppGallery Connect. 26 | See details: [HUAWEI Image Service Development Preparation](https://developer.huawei.com/consumer/en/doc/development/Media-Guides/config-agc-0000001050199019?ha_source=hms1) 27 | 4. To build this demo, please first import the demo in the Android Studio (3.x+). 28 | 5. Run the sample on your Android device or emulator. 29 | 30 | ## Supported Environments 31 | - Android Studio 3.0 or later. 32 | 33 | - Java SDK 1.8 or later. 34 | 35 | - Android SDK version is 26 or later. 36 | 37 | - Gradle 3.3.2. 38 | 39 | - HMS Core (APK) 4.0.2.300 or later(applicable to the SDK, but not the fallback-SDK). 40 | 41 | 42 | ## Result 43 | 44 | 45 | 46 | ## Question or issues 47 | If you want to evaluate more about HMS Core, [r/HMSCore on Reddit](https://www.reddit.com/r/HuaweiDevelopers/) is for you to keep up with latest news about HMS Core, and to exchange insights with other developers. 48 | 49 | If you have questions about how to use HMS samples, try the following options: 50 | - [Stack Overflow](https://stackoverflow.com/questions/tagged/huawei-mobile-services) is the best place for any programming questions. Be sure to tag your question with 51 | `huawei-mobile-services`. 52 | - [Huawei Developer Forum](https://forums.developer.huawei.com/forumPortal/en/home?fid=0101187876626530001) HMS Core Module is great for general questions, or seeking recommendations and opinions. 53 | 54 | If you run into a bug in our samples, please submit an [issue](https://github.com/HMS-Core/hms-image-render/issues) to the Repository. Even better you can submit a [Pull Request](https://github.com/HMS-Core/hms-image-render/pulls) with a fix. 55 | 56 | ## License 57 | 58 | ImageRenderSample is licensed under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0). 59 | -------------------------------------------------------------------------------- /README_ZH.md: -------------------------------------------------------------------------------- 1 | # 华为图像服务场景动效Java示例代码 2 | 3 | [English](README.md) | 中文 4 | 5 | ## 目录 6 | 7 | * [简介](#简介) 8 | * [开发准备](#开发准备) 9 | * [环境要求](#环境要求) 10 | * [运行结果](#运行结果) 11 | * [授权许可](#授权许可) 12 | 13 | ## 简介 14 | 场景动效服务提供基础动效和高级动效,帮助您实现图片内容高效再生产。本示例代码对华为图像服务场景动效接口进行封装,包含丰富的示例程序,方便您参考或直接使用。 15 | 1. 提供5种基础动效,并支持多动效叠加使用。 16 | 17 | 2. 提供9种效果炫酷的高级动效,并支持用户交互。 18 | 19 | 更多信息请参见[场景动效xml规范说明文档](https://developer.huawei.com/consumer/cn/doc/development/Media-Guides/xml-introduction-0000001050439245?ha_source=hms1). 20 | 21 | ## 开发准备 22 | 1. 检查Android Studio开发环境是否就绪。将示例工程导入Android Studio(3.0及以上版本)中。 23 | 2. 在Android Studio中打开示例工程项目级build.gradle文件,并在您已安装最新版华为移动服务的设备或模拟器上运行测试应用。 24 | 3. 注册[华为帐号](https://developer.huawei.com/consumer/cn/)。 25 | 4. 创建应用并在AppGallery Connect中配置相关信息。具体请参考[开发准备](https://developer.huawei.com/consumer/cn/doc/development/Media-Guides/config-agc-0000001050199019?ha_source=hms1)。 26 | 5. To build this demo, please first import the demo in the Android Studio (3.x+)。 27 | 6. 在Android设备或模拟器上运行您的应用。 28 | 29 | ## 环境要求 30 | - Android Studio 3.0及以上 31 | 32 | - JDK 1.8及以上 33 | 34 | - Android SDK 26及以上 35 | 36 | - Gradle 3.3.2 37 | 38 | - HMS Core (APK) 4.0.2.300及以上(仅依赖SDK情况下需要满足此要求,fallback-SDK无此要求) 39 | 40 | 41 | ## 运行结果 42 | 43 | 44 | 45 | ## 技术支持 46 | 如果您对HMS Core还处于评估阶段,可在[Reddit社区](https://www.reddit.com/r/HuaweiDevelopers/)获取关于HMS Core的最新讯息,并与其他开发者交流见解。 47 | 48 | 如果您对使用HMS示例代码有疑问,请尝试: 49 | - 开发过程遇到问题上[Stack Overflow](https://stackoverflow.com/questions/tagged/huawei-mobile-services),在`huawei-mobile-services`标签下提问,有华为研发专家在线一对一解决您的问题。 50 | - 到[华为开发者论坛](https://developer.huawei.com/consumer/cn/forum/blockdisplay?fid=18) HMS Core板块与其他开发者进行交流。 51 | 52 | 如果您在尝试示例代码中遇到问题,请向仓库提交[issue](https://github.com/HMS-Core/hms-image-render-java/issues),也欢迎您提交[Pull Request](https://github.com/HMS-Core/hms-image-render-java/pulls)。 53 | 54 | ## 授权许可 55 | 场景动效Java示例代码经过[Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0)授权许可。 56 | -------------------------------------------------------------------------------- /ScreenShot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/ScreenShot.PNG -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.huawei.agconnect' 3 | 4 | android { 5 | dataBinding.enabled = true 6 | compileSdkVersion 28 7 | buildToolsVersion '28.0.3' 8 | defaultConfig { 9 | applicationId "com.huawei.image.render.sample" 10 | minSdkVersion 26 11 | targetSdkVersion 28 12 | versionCode 1 13 | versionName "1.0" 14 | } 15 | 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | lintOptions { 23 | abortOnError false 24 | } 25 | } 26 | repositories { 27 | flatDir { 28 | dirs 'libs' 29 | } 30 | } 31 | 32 | dependencies { 33 | implementation fileTree(dir: 'libs', include: ['*.aar']) 34 | implementation 'com.android.support:appcompat-v7:28.0.0' 35 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 36 | testImplementation 'junit:junit:4.12' 37 | implementation 'com.huawei.hms:image-render:1.0.3.301' 38 | implementation 'com.huawei.hms:image-render-fallback:1.0.3.301' 39 | } 40 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -ignorewarnings 23 | -keepattributes *Annotation* 24 | -keepattributes Exceptions 25 | -keepattributes InnerClasses 26 | -keepattributes Signature 27 | -keepattributes SourceFile,LineNumberTable 28 | -keep class com.hianalytics.android.**{*;} 29 | -keep class com.huawei.updatesdk.**{*;} 30 | -keep class com.huawei.hms.**{*;} -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/assets/AlphaAnimation/aixin7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/AlphaAnimation/aixin7.png -------------------------------------------------------------------------------- /app/src/main/assets/AlphaAnimation/bj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/AlphaAnimation/bj.jpg -------------------------------------------------------------------------------- /app/src/main/assets/AlphaAnimation/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/assets/DropPhysicalView/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/DropPhysicalView/background.jpg -------------------------------------------------------------------------------- /app/src/main/assets/DropPhysicalView/jinbi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/DropPhysicalView/jinbi.png -------------------------------------------------------------------------------- /app/src/main/assets/DropPhysicalView/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/assets/DropPhysicalView/shiwu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/DropPhysicalView/shiwu.png -------------------------------------------------------------------------------- /app/src/main/assets/DropPhysicalView/xx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/DropPhysicalView/xx.png -------------------------------------------------------------------------------- /app/src/main/assets/FlipBook/bg1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/FlipBook/bg1.jpg -------------------------------------------------------------------------------- /app/src/main/assets/FlipBook/bg2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/FlipBook/bg2.jpg -------------------------------------------------------------------------------- /app/src/main/assets/FlipBook/bg3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/FlipBook/bg3.jpg -------------------------------------------------------------------------------- /app/src/main/assets/FlipBook/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/FlipBook/front.jpg -------------------------------------------------------------------------------- /app/src/main/assets/FlipBook/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/assets/Marquee/bj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/Marquee/bj.jpg -------------------------------------------------------------------------------- /app/src/main/assets/Marquee/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/assets/MeshImage/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/MeshImage/background.jpg -------------------------------------------------------------------------------- /app/src/main/assets/MeshImage/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/assets/MeshImage/part.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/MeshImage/part.png -------------------------------------------------------------------------------- /app/src/main/assets/Paint/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/Paint/bg.jpg -------------------------------------------------------------------------------- /app/src/main/assets/Paint/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/assets/Paint/part.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/Paint/part.png -------------------------------------------------------------------------------- /app/src/main/assets/Paint/part_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/Paint/part_2.png -------------------------------------------------------------------------------- /app/src/main/assets/ParticleScatter/bj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/ParticleScatter/bj.jpg -------------------------------------------------------------------------------- /app/src/main/assets/ParticleScatter/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/assets/ParticleScatter/maojiao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/ParticleScatter/maojiao.png -------------------------------------------------------------------------------- /app/src/main/assets/ParticleView/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/ParticleView/background.jpg -------------------------------------------------------------------------------- /app/src/main/assets/ParticleView/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/assets/ParticleView/particle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/ParticleView/particle.png -------------------------------------------------------------------------------- /app/src/main/assets/PositionAnimation/bj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/PositionAnimation/bj.jpg -------------------------------------------------------------------------------- /app/src/main/assets/PositionAnimation/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/assets/PositionAnimation/ty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/PositionAnimation/ty.png -------------------------------------------------------------------------------- /app/src/main/assets/RotateView/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/RotateView/1.jpg -------------------------------------------------------------------------------- /app/src/main/assets/RotateView/bj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/RotateView/bj.jpg -------------------------------------------------------------------------------- /app/src/main/assets/RotateView/manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/assets/RotationAnimation/bj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/RotationAnimation/bj.jpg -------------------------------------------------------------------------------- /app/src/main/assets/RotationAnimation/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/assets/RotationAnimation/ty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/RotationAnimation/ty.png -------------------------------------------------------------------------------- /app/src/main/assets/SizeAnimation/default_background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/SizeAnimation/default_background.jpg -------------------------------------------------------------------------------- /app/src/main/assets/SizeAnimation/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/assets/SizeAnimation/ty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/SizeAnimation/ty.png -------------------------------------------------------------------------------- /app/src/main/assets/SourcesAnimation/bj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/SourcesAnimation/bj.jpg -------------------------------------------------------------------------------- /app/src/main/assets/SourcesAnimation/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/assets/SourcesAnimation/zuida1_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/SourcesAnimation/zuida1_1.png -------------------------------------------------------------------------------- /app/src/main/assets/SourcesAnimation/zuida1_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/SourcesAnimation/zuida1_2.png -------------------------------------------------------------------------------- /app/src/main/assets/SourcesAnimation/zuida1_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/SourcesAnimation/zuida1_3.png -------------------------------------------------------------------------------- /app/src/main/assets/SourcesAnimation/zuida1_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/SourcesAnimation/zuida1_4.png -------------------------------------------------------------------------------- /app/src/main/assets/SourcesAnimation/zuida1_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/SourcesAnimation/zuida1_5.png -------------------------------------------------------------------------------- /app/src/main/assets/WaterWallpaper/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/assets/WaterWallpaper/background.jpg -------------------------------------------------------------------------------- /app/src/main/assets/WaterWallpaper/manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-image-render-java/c2a1207e105026a4cbf048d1a864b39c3b0150f6/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/com/huawei/image/render/sample/activity/ImageKitRenderDemoActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.huawei.image.render.sample.activity; 17 | 18 | import android.Manifest; 19 | import android.app.Activity; 20 | import android.content.Intent; 21 | import android.content.pm.PackageManager; 22 | import android.os.Bundle; 23 | import android.os.Environment; 24 | import android.support.annotation.NonNull; 25 | import android.support.v4.app.ActivityCompat; 26 | import android.support.v4.content.ContextCompat; 27 | import android.util.Log; 28 | import android.view.View; 29 | import android.view.WindowManager; 30 | import android.widget.AdapterView; 31 | import android.widget.EditText; 32 | import android.widget.FrameLayout; 33 | import android.widget.Spinner; 34 | import android.widget.TextView; 35 | import android.widget.Toast; 36 | 37 | import com.huawei.hms.image.render.IBindCallBack; 38 | import com.huawei.hms.image.render.IStreamCallBack; 39 | import com.huawei.hms.image.render.ImageRender; 40 | import com.huawei.hms.image.render.ImageRenderImpl; 41 | import com.huawei.hms.image.render.RenderView; 42 | import com.huawei.hms.image.render.ResultCode; 43 | import com.huawei.image.render.sample.R; 44 | import com.huawei.image.render.sample.util.Utils; 45 | 46 | import org.json.JSONException; 47 | import org.json.JSONObject; 48 | 49 | import java.io.File; 50 | import java.io.FileOutputStream; 51 | import java.io.IOException; 52 | import java.util.HashMap; 53 | 54 | /** 55 | * The ImageRenderSample code provides examples of initializing the service, obtaining views, playing animation, pausing animation, and destroying resources. 56 | * 57 | * @author huawei 58 | * @since 5.0.0 59 | */ 60 | public class ImageKitRenderDemoActivity extends Activity { 61 | 62 | /** 63 | * TAG 64 | */ 65 | public static final String TAG = "ImageKitRenderDemo"; 66 | 67 | /** 68 | * Layout container 69 | */ 70 | private FrameLayout contentView; 71 | 72 | // imageRender object 73 | private ImageRenderImpl imageRenderAPI; 74 | 75 | /** 76 | * Resource folder, which can be set as you want. 77 | */ 78 | public static final String SOURCE_PATH = "sources"; 79 | 80 | private String sourcePath; 81 | 82 | private TextView textProgress; 83 | 84 | private String mCurrentDemo; 85 | 86 | private int marqueeVis = 1; 87 | 88 | private String hashCode; 89 | 90 | /** 91 | * requestCode for applying for permissions. 92 | */ 93 | public static final int PERMISSION_REQUEST_CODE = 0x01; 94 | 95 | @Override 96 | protected void onCreate(Bundle savedInstanceState) { 97 | super.onCreate(savedInstanceState); 98 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 99 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 100 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); 101 | setContentView(R.layout.activity_image_kit_demo); 102 | sourcePath = getFilesDir().getPath() + File.separator + SOURCE_PATH; 103 | initView(); 104 | int permissionCheck = ContextCompat.checkSelfPermission(ImageKitRenderDemoActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE); 105 | if (permissionCheck == PackageManager.PERMISSION_GRANTED) { 106 | initData(); 107 | initImageRender(); 108 | } else { 109 | ActivityCompat.requestPermissions(ImageKitRenderDemoActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE); 110 | } 111 | } 112 | 113 | 114 | /** 115 | * Initialize the view. 116 | */ 117 | private void initView() { 118 | contentView = findViewById(R.id.content); 119 | textProgress = findViewById(R.id.text_progress); 120 | final Spinner spinner = findViewById(R.id.spinner_animations); 121 | spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 122 | @Override 123 | public void onItemSelected(AdapterView parent, View view, int position, long id) { 124 | mCurrentDemo = spinner.getAdapter().getItem(position).toString(); 125 | changeAnimation(mCurrentDemo); 126 | } 127 | 128 | @Override 129 | public void onNothingSelected(AdapterView parent) { 130 | 131 | } 132 | }); 133 | } 134 | 135 | /** 136 | * change the animation which is choose in spinner 137 | * @param animationName animationName 138 | */ 139 | private void changeAnimation(String animationName) { 140 | if(!Utils.copyAssetsFilesToDirs(this, animationName, sourcePath)){ 141 | Log.e(TAG, "copy files failure, please check permissions"); 142 | return; 143 | } 144 | if (imageRenderAPI == null) { 145 | Log.e(TAG, "initRemote fail, please check kit version"); 146 | return; 147 | } 148 | if(contentView.getChildCount() > 0) { 149 | imageRenderAPI.removeRenderView(); 150 | contentView.removeAllViews(); 151 | addView(); 152 | } 153 | } 154 | 155 | /** 156 | * Create default resources. 157 | * You can compile the manifest.xml file and image resource file. The code is for reference only. 158 | */ 159 | private void initData() { 160 | // Absolute path of the resource files. 161 | 162 | if (!Utils.createResourceDirs(sourcePath)) { 163 | Log.e(TAG, "Create dirs fail, please check permission"); 164 | } 165 | 166 | if (!Utils.copyAssetsFileToDirs(this, "AlphaAnimation" + File.separator + "aixin7.png", sourcePath + File.separator + "aixin7.png")) { 167 | Log.e(TAG, "Copy resource file fail, please check permission"); 168 | } 169 | if (!Utils.copyAssetsFileToDirs(this, "AlphaAnimation" + File.separator + "bj.jpg", sourcePath + File.separator + "bj.jpg")) { 170 | Log.e(TAG, "Copy resource file fail, please check permission"); 171 | } 172 | if (!Utils.copyAssetsFileToDirs(this, "AlphaAnimation" + File.separator + "manifest.xml", sourcePath + File.separator + "manifest.xml")) { 173 | Log.e(TAG, "Copy resource file fail, please check permission"); 174 | } 175 | } 176 | 177 | /** 178 | * Use the ImageRender API. 179 | */ 180 | private void initImageRender() { 181 | // Obtain an ImageRender object. 182 | ImageRender.getInstance(this, new ImageRender.RenderCallBack() { 183 | @Override 184 | public void onSuccess(ImageRenderImpl imageRender) { 185 | Log.i(TAG, "getImageRenderAPI success"); 186 | imageRenderAPI = imageRender; 187 | useImageRender(); 188 | } 189 | 190 | @Override 191 | public void onFailure(int i) { 192 | Log.e(TAG, "getImageRenderAPI failure, errorCode = " + i); 193 | } 194 | }); 195 | } 196 | 197 | /** 198 | * The Image Render service is required. 199 | */ 200 | private void useImageRender() { 201 | if (imageRenderAPI == null) { 202 | Log.e(TAG, "initRemote fail, please check kit version"); 203 | return; 204 | } 205 | addView(); 206 | } 207 | 208 | private void addView () { 209 | // Initialize the ImageRender object. 210 | int initResult = imageRenderAPI.doInit(sourcePath, Utils.getAuthJson()); 211 | Log.i(TAG, "DoInit result == " + initResult); 212 | if (initResult == 0) { 213 | // Obtain the rendered view. 214 | RenderView renderView = imageRenderAPI.getRenderView(); 215 | if (renderView.getResultCode() == ResultCode.SUCCEED) { 216 | View view = renderView.getView(); 217 | if (null != view) { 218 | // Add the rendered view to the layout. 219 | contentView.addView(view); 220 | hashCode = String.valueOf(view.hashCode()); 221 | } else { 222 | Log.w(TAG, "GetRenderView fail, view is null"); 223 | } 224 | } else if (renderView.getResultCode() == ResultCode.ERROR_GET_RENDER_VIEW_FAILURE) { 225 | Log.w(TAG, "GetRenderView fail"); 226 | } else if (renderView.getResultCode() == ResultCode.ERROR_XSD_CHECK_FAILURE) { 227 | Log.w(TAG, "GetRenderView fail, resource file parameter error, please check resource file."); 228 | } else if (renderView.getResultCode() == ResultCode.ERROR_VIEW_PARSE_FAILURE) { 229 | Log.w(TAG, "GetRenderView fail, resource file parsing failed, please check resource file."); 230 | } else if (renderView.getResultCode() == ResultCode.ERROR_REMOTE) { 231 | Log.w(TAG, "GetRenderView fail, remote call failed, please check HMS service"); 232 | } else if (renderView.getResultCode() == ResultCode.ERROR_DOINIT) { 233 | Log.w(TAG, "GetRenderView fail, init failed, please init again"); 234 | } 235 | } else { 236 | Log.w(TAG, "Do init fail, errorCode == " + initResult); 237 | } 238 | } 239 | 240 | @Override 241 | protected void onDestroy() { 242 | // Destroy the view. 243 | if (null != imageRenderAPI) { 244 | imageRenderAPI.removeRenderView(); 245 | } 246 | super.onDestroy(); 247 | } 248 | 249 | @Override 250 | protected void onResume() { 251 | super.onResume(); 252 | Log.i(TAG, "onResume"); 253 | if (null != imageRenderAPI) { 254 | imageRenderAPI.bindRenderView(sourcePath, Utils.getAuthJson(), new IBindCallBack() { 255 | @Override 256 | public void onBind(RenderView renderView, int i) { 257 | if (renderView != null) { 258 | if (renderView.getResultCode() == ResultCode.SUCCEED) { 259 | final View view = renderView.getView(); 260 | if (null != view) { 261 | contentView.addView(view); 262 | hashCode = String.valueOf(view.hashCode()); 263 | } 264 | } 265 | } 266 | } 267 | 268 | @Override 269 | public void onParseEnd() { 270 | 271 | } 272 | }); 273 | } 274 | } 275 | 276 | /** 277 | * Play the animation. 278 | * 279 | * @param view button 280 | */ 281 | public void startAnimation(View view) { 282 | // Play the rendered view. 283 | Log.i(TAG, "Start animation"); 284 | if (null != imageRenderAPI) { 285 | int playResult = imageRenderAPI.playAnimation(); 286 | if (playResult == ResultCode.SUCCEED) { 287 | Log.i(TAG, "Start animation success"); 288 | } else { 289 | Log.i(TAG, "Start animation failure"); 290 | } 291 | } else { 292 | Log.w(TAG, "Start animation fail, please init first."); 293 | } 294 | } 295 | 296 | /** 297 | * Stop the animation. 298 | * 299 | * @param view button 300 | */ 301 | public void stopAnimation(View view) { 302 | // Stop the renderView animation. 303 | Log.i(TAG, "Stop animation"); 304 | if (null != imageRenderAPI) { 305 | int playResult = imageRenderAPI.stopAnimation(); 306 | if (playResult == ResultCode.SUCCEED) { 307 | Log.i(TAG, "Stop animation success"); 308 | } else { 309 | Log.i(TAG, "Stop animation failure"); 310 | } 311 | } else { 312 | Log.w(TAG, "Stop animation fail, please init first."); 313 | } 314 | } 315 | 316 | /** 317 | * Pause animation 318 | * 319 | * @param view button 320 | */ 321 | public void pauseAnimation(View view) { 322 | if (imageRenderAPI != null) { 323 | int result = imageRenderAPI.pauseAnimation(true); 324 | Log.d(TAG, "pauseAnimation result == " + result); 325 | } 326 | } 327 | 328 | /** 329 | * Resume animation 330 | * 331 | * @param view button 332 | */ 333 | public void resumeAnimation(View view) { 334 | if (imageRenderAPI != null) { 335 | int result = imageRenderAPI.resumeAnimation(); 336 | Log.d(TAG, "resumeAnimation result == " + result); 337 | } 338 | } 339 | 340 | /** 341 | * Set variable value 342 | * 343 | * @param view button 344 | */ 345 | public void setVariable(View view) { 346 | if ("Marquee".equals(mCurrentDemo)) { 347 | marqueeVis = 1 - marqueeVis; 348 | imageRenderAPI.setKeyValueInfo("SetVariable", "var", "" + marqueeVis); 349 | } 350 | } 351 | 352 | @Override 353 | protected void onPause() { 354 | super.onPause(); 355 | Log.i(TAG, "onPause"); 356 | if (null != imageRenderAPI) { 357 | imageRenderAPI.unBindRenderView(hashCode); 358 | } 359 | } 360 | 361 | /** 362 | * Next page 363 | * 364 | * @param view button 365 | */ 366 | public void nextPage(View view) { 367 | Intent intent = new Intent(ImageKitRenderDemoActivity.this, ImageKitRenderDemoActivity1.class); 368 | startActivity(intent); 369 | } 370 | 371 | /** 372 | * Start record. 373 | * 374 | * @param view button 375 | */ 376 | public void startRecord(View view) { 377 | Log.d("#######start record:", System.currentTimeMillis() + ""); 378 | Toast.makeText(this, "start record", Toast.LENGTH_SHORT).show(); 379 | if (null != imageRenderAPI) { 380 | final JSONObject result = getRecordInfo(); 381 | int start = imageRenderAPI.startRecord(result, new IStreamCallBack() { 382 | @Override 383 | public void onRecordSuccess(HashMap hashMap) { 384 | runOnUiThread(new Runnable() { 385 | @Override 386 | public void run() { 387 | Toast.makeText(ImageKitRenderDemoActivity.this, "record success", Toast.LENGTH_SHORT).show(); 388 | } 389 | }); 390 | saveRecordResult(hashMap); 391 | } 392 | 393 | @Override 394 | public void onRecordFailure(HashMap hashMap) { 395 | int errorCode = (int) hashMap.get("errorCode"); 396 | String errorMessage = (String) hashMap.get("errorMessage"); 397 | Log.i(TAG, "back result" + errorCode + ";back msg" + errorMessage); 398 | } 399 | 400 | // progress:{1-100} 401 | @Override 402 | public void onProgress(final int progress) { 403 | showRecordProgress(progress); 404 | } 405 | }); 406 | if (start == ResultCode.SUCCEED) { 407 | Log.i(TAG, "start record success"); 408 | } else { 409 | Log.i(TAG, "start record failure:" + start); 410 | } 411 | } else { 412 | Log.w(TAG, "start record fail, please init first."); 413 | } 414 | } 415 | 416 | private JSONObject getRecordInfo () { 417 | final JSONObject result = new JSONObject(); 418 | final String recordType = ((EditText) findViewById(R.id.recordtype)).getText().toString(); 419 | String videoScale = ((EditText) findViewById(R.id.videoscale)).getText().toString(); 420 | String videoFps = ((EditText) findViewById(R.id.videofps)).getText().toString(); 421 | String gifScale = ((EditText) findViewById(R.id.gifscale)).getText().toString(); 422 | String gifFps = ((EditText) findViewById(R.id.giffps)).getText().toString(); 423 | try { 424 | JSONObject videoJson = new JSONObject(); 425 | JSONObject gifJson = new JSONObject(); 426 | result.put("recordType", recordType); 427 | videoJson.put("videoScale", videoScale); 428 | videoJson.put("videoFps", videoFps); 429 | gifJson.put("gifScale", gifScale); 430 | gifJson.put("gifFps", gifFps); 431 | result.put("video", videoJson); 432 | result.put("gif", gifJson); 433 | } catch (JSONException e) { 434 | Log.w(TAG, e.getMessage()); 435 | } 436 | return result; 437 | } 438 | 439 | private void saveRecordResult (HashMap hashMap) { 440 | String fileName = Environment.getExternalStorageDirectory() 441 | + File.separator 442 | + "VideoAndPic"; 443 | File fileDir = new File(fileName); 444 | if (!fileDir.exists()) { 445 | if (!fileDir.mkdir()) { 446 | return; 447 | } 448 | } 449 | final String mp4Path = fileName + File.separator + System.currentTimeMillis() + ".mp4"; 450 | final String gifPath = fileName + File.separator + System.currentTimeMillis() + ".gif"; 451 | String recordType = (String) hashMap.get("recordType"); 452 | byte[] videoBytes = (byte[]) hashMap.get("videoBytes"); 453 | byte[] gifBytes = (byte[]) hashMap.get("gifBytes"); 454 | try { 455 | if (recordType.equals("1")) { 456 | if (videoBytes != null) { 457 | saveFile(videoBytes, mp4Path); 458 | } 459 | } else if (recordType.equals("2")) { 460 | if (gifBytes != null) { 461 | saveFile(gifBytes, gifPath); 462 | } 463 | } else if (recordType.equals("3")) { 464 | if (videoBytes != null) { 465 | saveFile(videoBytes, mp4Path); 466 | } 467 | 468 | if (gifBytes != null) { 469 | saveFile(gifBytes, gifPath); 470 | } 471 | } 472 | } catch (IOException e) { 473 | Log.w(TAG, e.getMessage()); 474 | } 475 | } 476 | 477 | private void saveFile (byte[] bytes, String path) throws IOException { 478 | FileOutputStream fos = new FileOutputStream(new File(path)); 479 | try { 480 | fos.write(bytes, 0, bytes.length); 481 | fos.close(); 482 | } catch (IOException e) { 483 | Log.e(TAG, e.getMessage()); 484 | } finally { 485 | try { 486 | fos.close(); 487 | } catch (IOException e) { 488 | Log.e(TAG, e.getMessage()); 489 | } 490 | } 491 | } 492 | 493 | private void showRecordProgress (final int progress) { 494 | runOnUiThread(new Runnable() { 495 | @Override 496 | public void run() { 497 | textProgress.setText("progress:" + progress + "%"); 498 | } 499 | }); 500 | } 501 | 502 | /** 503 | * Stop record. 504 | * 505 | * @param view button 506 | */ 507 | public void stopRecord(View view) { 508 | Toast.makeText(this, "stop record", Toast.LENGTH_SHORT).show(); 509 | if (null != imageRenderAPI) { 510 | int result = imageRenderAPI.stopRecord(); 511 | if (result == ResultCode.SUCCEED) { 512 | Log.i(TAG, "stop record success"); 513 | } else { 514 | Log.i(TAG, "stop record failure:" + result); 515 | } 516 | } else { 517 | Log.w(TAG, "stop record fail, please init first."); 518 | } 519 | } 520 | 521 | 522 | @Override 523 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { 524 | if (requestCode == PERMISSION_REQUEST_CODE) { 525 | if (grantResults.length > 0 526 | && grantResults[0] == PackageManager.PERMISSION_GRANTED) { 527 | // The permission is granted. 528 | initData(); 529 | initImageRender(); 530 | } else { 531 | // The permission is rejected. 532 | Log.w(TAG, "permission denied"); 533 | Toast.makeText(ImageKitRenderDemoActivity.this, "Please grant the app the permission to read the SD card", Toast.LENGTH_SHORT).show(); 534 | } 535 | } 536 | } 537 | } 538 | -------------------------------------------------------------------------------- /app/src/main/java/com/huawei/image/render/sample/activity/ImageKitRenderDemoActivity1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.huawei.image.render.sample.activity; 18 | 19 | import android.annotation.SuppressLint; 20 | import android.app.Activity; 21 | import android.os.Build; 22 | import android.os.Bundle; 23 | import android.os.Environment; 24 | import android.os.SystemClock; 25 | import android.support.annotation.RequiresApi; 26 | import android.util.Log; 27 | import android.view.View; 28 | import android.view.WindowManager; 29 | import android.widget.FrameLayout; 30 | 31 | import com.huawei.hms.image.render.IBindCallBack; 32 | import com.huawei.hms.image.render.ImageRender; 33 | import com.huawei.hms.image.render.ImageRenderImpl; 34 | import com.huawei.hms.image.render.RenderView; 35 | import com.huawei.hms.image.render.ResultCode; 36 | import com.huawei.image.render.sample.R; 37 | import com.huawei.image.render.sample.util.Utils; 38 | 39 | import java.io.File; 40 | 41 | /** 42 | * 功能描述 43 | * 44 | * @author c00511068 45 | * @since 2020-09-07 46 | */ 47 | public class ImageKitRenderDemoActivity1 extends Activity { 48 | /** 49 | * TAG 50 | */ 51 | public static final String TAG = "ImageKitRenderDemo1"; 52 | 53 | /** 54 | * 布Layout container 55 | */ 56 | private FrameLayout contentView; 57 | 58 | // imageRender object 59 | private ImageRenderImpl imageRenderAPI; 60 | 61 | // Resource folder, which can be set as you want. 62 | private String sourcePath; 63 | 64 | /** 65 | * requestCode for applying for permissions. 66 | */ 67 | public static final int PERMISSION_REQUEST_CODE = 0x01; 68 | 69 | private String hashCode; 70 | 71 | private View view; 72 | 73 | @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB) 74 | @Override 75 | protected void onCreate(Bundle savedInstanceState) { 76 | super.onCreate(savedInstanceState); 77 | Log.i(TAG, "onCreate"); 78 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 79 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 80 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); 81 | setContentView(R.layout.activity_image_kit_demo_1); 82 | sourcePath = getFilesDir().getPath() + File.separator + ImageKitRenderDemoActivity.SOURCE_PATH; 83 | initView(); 84 | initImageRender(); 85 | } 86 | 87 | 88 | /** 89 | * Initialize the view. 90 | */ 91 | @SuppressLint("ClickableViewAccessibility") 92 | private void initView() { 93 | contentView = findViewById(R.id.content); 94 | } 95 | 96 | /** 97 | * Get ImageRenderAPI 98 | */ 99 | private void initImageRender() { 100 | Log.i(TAG, "timerecorde" + SystemClock.elapsedRealtime()); 101 | Log.d(TAG, "initImageRender time = " + SystemClock.uptimeMillis()); 102 | ImageRender.getInstance(this, new ImageRender.RenderCallBack() { 103 | @Override 104 | public void onSuccess(ImageRenderImpl imageRender) { 105 | imageRenderAPI = imageRender; 106 | } 107 | 108 | @Override 109 | public void onFailure(int i) { 110 | Log.e(TAG, "Get ImageRender instance failed, errorCode:" + i); 111 | } 112 | }); 113 | } 114 | 115 | 116 | 117 | @Override 118 | protected void onResume() { 119 | super.onResume(); 120 | Log.i(TAG, "onResume"); 121 | if (null != imageRenderAPI) { 122 | imageRenderAPI.bindRenderView(sourcePath, Utils.getAuthJson(), new IBindCallBack() { 123 | @Override 124 | public void onParseEnd() { 125 | 126 | } 127 | 128 | @Override 129 | public void onBind(RenderView renderView, int i) { 130 | if (renderView != null) { 131 | if (renderView.getResultCode() == ResultCode.SUCCEED) { 132 | view = renderView.getView(); 133 | if (null != view) { 134 | hashCode = String.valueOf(view.hashCode()); 135 | contentView.addView(view); 136 | } 137 | } 138 | } 139 | } 140 | }); 141 | } 142 | } 143 | 144 | @Override 145 | protected void onDestroy() { 146 | Log.d(TAG, "onDestroy"); 147 | super.onDestroy(); 148 | } 149 | 150 | @Override 151 | protected void onPause() { 152 | super.onPause(); 153 | Log.i(TAG, "onPause"); 154 | if (null != imageRenderAPI) { 155 | imageRenderAPI.unBindRenderView(hashCode); 156 | } 157 | } 158 | 159 | /** 160 | * Start the animation 161 | * 162 | * @param view button 163 | */ 164 | public void startAnimation(View view) { 165 | Log.i(TAG, "Start animation"); 166 | if (null != imageRenderAPI) { 167 | int playResult = imageRenderAPI.playAnimation(); 168 | Log.i(TAG, "Start animation:" + playResult); 169 | } else { 170 | Log.w(TAG, "Start animation fail, please init first."); 171 | } 172 | 173 | } 174 | 175 | /** 176 | * Pause the animation 177 | * 178 | * @param view button 179 | */ 180 | public void pauseAnimation(View view) { 181 | // imageRender停止renderView动画 182 | Log.i(TAG, "Pause animation"); 183 | if (null != imageRenderAPI) { 184 | int pauseResult = imageRenderAPI.pauseAnimation(true); 185 | if (pauseResult == ResultCode.SUCCEED) { 186 | Log.i(TAG, "Pause animation success"); 187 | } else { 188 | Log.i(TAG, "Pause animation failure"); 189 | } 190 | } else { 191 | Log.w(TAG, "Pause animation fail, please init first."); 192 | } 193 | } 194 | 195 | /** 196 | * Resume the animation 197 | * 198 | * @param view button 199 | */ 200 | public void restartAnimation(View view) { 201 | Log.i(TAG, "restart animation"); 202 | if (null != imageRenderAPI) { 203 | int playResult = imageRenderAPI.resumeAnimation(); 204 | if (playResult == ResultCode.SUCCEED) { 205 | Log.i(TAG, "Restart animation success"); 206 | } else { 207 | Log.i(TAG, "Restart animation failure"); 208 | } 209 | } else { 210 | Log.w(TAG, "Restart animation fail, please init first."); 211 | } 212 | } 213 | 214 | /** 215 | * Stop the animation. 216 | * 217 | * @param view button 218 | */ 219 | public void stopAnimation(View view) { 220 | // Stop the renderView animation. 221 | Log.i(TAG, "Stop animation"); 222 | if (null != imageRenderAPI) { 223 | int playResult = imageRenderAPI.stopAnimation(); 224 | if (playResult == ResultCode.SUCCEED) { 225 | Log.i(TAG, "Stop animation success"); 226 | } else { 227 | Log.i(TAG, "Stop animation failure"); 228 | } 229 | } else { 230 | Log.w(TAG, "Stop animation fail, please init first."); 231 | } 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /app/src/main/java/com/huawei/image/render/sample/util/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.huawei.image.render.sample.util; 17 | 18 | import android.content.Context; 19 | import android.util.Log; 20 | 21 | import org.json.JSONException; 22 | import org.json.JSONObject; 23 | 24 | import java.io.File; 25 | import java.io.FileOutputStream; 26 | import java.io.IOException; 27 | import java.io.InputStream; 28 | 29 | /** 30 | * Function Description 31 | * 32 | * @since 2020-04-28 33 | */ 34 | public class Utils { 35 | 36 | /** 37 | * TAG 38 | */ 39 | private static final String TAG = "Utils"; 40 | 41 | /** 42 | * create demo dir 43 | * 44 | * @param dirPath dir path 45 | * @return result 46 | */ 47 | public static boolean createResourceDirs(String dirPath) { 48 | File dir = new File(dirPath); 49 | if (!dir.exists()) { 50 | if (dir.getParentFile().mkdir()) { 51 | return dir.mkdir(); 52 | } else { 53 | return dir.mkdir(); 54 | } 55 | } 56 | return false; 57 | } 58 | 59 | /** 60 | * copy assets folders to sdCard 61 | * @param context context 62 | * @param foldersName folderName 63 | * @param path path 64 | * @return result 65 | */ 66 | public static boolean copyAssetsFilesToDirs(Context context, String foldersName, String path){ 67 | try { 68 | String[] files = context.getAssets().list(foldersName); 69 | for (String file : 70 | files) { 71 | if (!copyAssetsFileToDirs(context, foldersName + File.separator + file, path + File.separator + file)) { 72 | Log.e(TAG, "Copy resource file fail, please check permission"); 73 | return false; 74 | } 75 | } 76 | } catch (IOException e) { 77 | Log.e(TAG, e.getMessage()); 78 | return false; 79 | } 80 | return true; 81 | } 82 | 83 | /** 84 | * copy resource file to sdCard 85 | * 86 | * @param context context 87 | * @param fileName fileName 88 | * @param path sdCard path 89 | * @return result 90 | */ 91 | public static boolean copyAssetsFileToDirs(Context context, String fileName, String path) { 92 | InputStream inputStream = null; 93 | FileOutputStream outputStream = null; 94 | try { 95 | inputStream = context.getAssets().open(fileName); 96 | File file = new File(path); 97 | outputStream = new FileOutputStream(file); 98 | byte[] temp = new byte[4096]; 99 | int n; 100 | while (-1 != (n = inputStream.read(temp))) { 101 | outputStream.write(temp, 0, n); 102 | } 103 | } catch (IOException e) { 104 | Log.e(TAG, e.getMessage()); 105 | return false; 106 | } finally { 107 | try { 108 | if (inputStream != null) { 109 | inputStream.close(); 110 | } 111 | } catch (IOException e) { 112 | Log.e(TAG, e.getMessage()); 113 | } finally { 114 | if (outputStream != null) { 115 | try { 116 | outputStream.close(); 117 | } catch (IOException e) { 118 | Log.e(TAG, e.getMessage()); 119 | } 120 | } 121 | } 122 | } 123 | return true; 124 | } 125 | 126 | /** 127 | * Add authentication parameters. 128 | * 129 | * @return JsonObject of Authentication parameters. 130 | */ 131 | public static JSONObject getAuthJson() { 132 | JSONObject authJson = new JSONObject(); 133 | try { 134 | authJson.put("projectId", "projectId-test"); 135 | authJson.put("appId", "appId-test"); 136 | authJson.put("authApiKey", "authApiKey-test"); 137 | authJson.put("clientSecret", "clientSecret-test"); 138 | authJson.put("clientId", "clientId-test"); 139 | authJson.put("token", "token-test"); 140 | } catch (JSONException e) { 141 | Log.w(TAG, "Get authJson fail, please check auth info"); 142 | } 143 | return authJson; 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_entries.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_image_kit_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 15 | 16 | 20 | 27 | 28 | 35 | 36 | 37 | 43 |