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