Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PerfActivity.java
Go to the documentation of this file.
1package org.skia.skottie;
2
3import android.app.Activity;
4import android.content.Intent;
5import android.os.Bundle;
6import android.view.Window;
7import android.view.WindowManager;
8
9import com.airbnb.lottie.LottieAnimationView;
10import com.airbnb.lottie.LottieDrawable;
11import com.airbnb.lottie.RenderMode;
12
13public class PerfActivity extends Activity {
14
15 int rawAssets[] = {
16 R.raw.star, R.raw.movie_loading, R.raw.uk, R.raw.white_material_wave_loading,
17 R.raw.check_animation, R.raw.confetti, R.raw.gears,
18 R.raw.hand_sanitizer, R.raw.heart_preloader, R.raw.i_was_scared_after_that_brouhaha,
19 R.raw.im_thirsty, R.raw.true_will, R.raw.workout_monkey_stay_healthy,
20 R.raw.ripple_loading_animation, R.raw.signature, R.raw.asdasd, R.raw.celebration,
21 R.raw.check
22 };
23
24 @Override
25 protected void onCreate(Bundle savedInstanceState) {
26 //Remove title bar
27 this.requestWindowFeature(Window.FEATURE_NO_TITLE);
28
29 //Remove notification bar
30 this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
31 WindowManager.LayoutParams.FLAG_FULLSCREEN);
32
33 super.onCreate(savedInstanceState);
34 // Run activity with:
35 // adb shell am start -n org.skia.skottie/.PerfActivity --ei renderer 0 --ei file 0
36 // renderer is 0 to 2, file is 0 to 14
37 Intent intent = getIntent();
38 int renderer = intent.getIntExtra("renderer", 0);
39 int file = intent.getIntExtra("file", 0);
40 if (file < 0 || file >= rawAssets.length) {
41 return;
42 }
43 switch (renderer) {
44 case 0:
45 // render with airbnb hardware lottie player
46 runLottie(rawAssets[file], true);
47 break;
48 case 1:
49 // render with airbnb software lottie player
50 runLottie(rawAssets[file], false);
51 break;
52 case 2:
53 // render with skottie player
54 runSkottie(rawAssets[file]);
55 break;
56 default:
57 break;
58 }
59
60 }
61
62 void runSkottie(int id) {
63 SkottieView view = new SkottieView(this);
64 view.setSource(getResources().openRawResource(id));
65 view.start();
66 setContentView(view);
67 }
68
69 void runLottie(int id, boolean useHardware) {
70 LottieAnimationView lottie = new LottieAnimationView(this);
71 lottie.setAnimation(id);
72 if (useHardware) {
73 lottie.setRenderMode(RenderMode.HARDWARE);
74 } else {
75 lottie.setRenderMode(RenderMode.SOFTWARE);
76 }
77 lottie.setRepeatMode(LottieDrawable.RESTART);
78 lottie.setRepeatCount(LottieDrawable.INFINITE);
79 lottie.playAnimation();
80 setContentView(lottie);
81 }
82}
void onCreate(Bundle savedInstanceState)
void runLottie(int id, boolean useHardware)
void setSource(InputStream inputStream)
#define R(r)