This repository was archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 497
/
Copy pathAnimationFromAssetsActivity.java
73 lines (61 loc) · 2.38 KB
/
AnimationFromAssetsActivity.java
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.example.ponycui_home.svgaplayer;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
public class AnimationFromAssetsActivity extends Activity {
int currentIndex = 0;
SVGAImageView animationView = null;
SVGAParser parser = new SVGAParser(this);
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
animationView = new SVGAImageView(this);
animationView.setBackgroundColor(Color.BLACK);
animationView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
animationView.stepToFrame(currentIndex++, false);
}
});
// animationView.setImageDrawable(getResources().getDrawable(R.drawable.icon_lock_screen_arrow));
loadAnimation();
setContentView(animationView);
}
private void loadAnimation() {
parser.decodeFromAssets("mic_up_count_down.svga", new SVGAParser.ParseCompletion() {
// parser.decodeFromAssets("roomlist_ranking.svga", new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NotNull SVGAVideoEntity videoItem) {
animationView.setVideoItem(videoItem);
animationView.stepToFrame(0, true);
}
@Override
public void onError() {
}
});
}
private ArrayList<String> samples = new ArrayList();
private String randomSample() {
if (samples.size() == 0) {
samples.add("gradientBorder.svga");
samples.add("Goddess.svga");
samples.add("Rocket.svga");
samples.add("angel.svga");
samples.add("alarm.svga");
samples.add("EmptyState.svga");
samples.add("heartbeat.svga");
samples.add("posche.svga");
samples.add("rose_2.0.0.svga");
samples.add("test.svga");
samples.add("test2.svga");
}
return samples.get((int) Math.floor(Math.random() * samples.size()));
}
}