-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstruction.java
93 lines (79 loc) · 2.91 KB
/
Instruction.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package com.lud.root.jetfighter;
import android.app.ActivityManager;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.drawable.AnimationDrawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.VideoView;
public class Instruction extends AppCompatActivity implements View.OnClickListener{
private AnimationDrawable tap, collision;
private VideoView imv1, imv3;
private LinearLayout ll;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.gc();
setContentView(R.layout.activity_instruction);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
ll = (LinearLayout)findViewById(R.id.instruction);
ll.setOnClickListener(this);
imv1 = (VideoView) findViewById(R.id.instruction_imv1);
imv3 = (VideoView) findViewById(R.id.instruction_imv3);
// Load and start the movie
Uri video1 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.touch);
imv1.setVideoURI(video1);
imv1.start();
imv1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
Uri video2 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.collision);
imv3.setVideoURI(video2);
imv3.start();
imv3.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
}
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
startActivity(new Intent(this, MyActivity.class));
return true;
}
return super.onTouchEvent(event);
}
@Override
public void onClick(View v) {
startActivity(new Intent(this, MyActivity.class));
}
@Override
protected void onDestroy() {
super.onDestroy();
unbindDrawables(findViewById(R.id.instruction));
System.gc();
}
private void unbindDrawables(View view) {
if (view.getBackground() != null) {
view.getBackground().setCallback(null);
}
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
unbindDrawables(((ViewGroup) view).getChildAt(i));
}
((ViewGroup) view).removeAllViews();
}
}
}