This repository has been archived by the owner on Aug 24, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
MainActivityJava.java
60 lines (51 loc) · 2 KB
/
MainActivityJava.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
/*
* Copyright © Marc Auberer 2021. All rights reserved
*/
package com.chillibits.splashscreenexample;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.chillibits.splashscreen.SplashScreenBuilder;
public class MainActivityJava extends AppCompatActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.activity_main);
// Setup relaunch button
Button relaunchButton = findViewById(R.id.relaunchApp);
relaunchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startSplashScreen();
}
});
// Start splash screen
startSplashScreen();
}
private void startSplashScreen() {
SplashScreenBuilder.getInstance(this)
.setVideo(R.raw.splash_animation)
.setVideoDark(R.raw.splash_animation_dark)
.setImage(R.drawable.app_icon)
.setTitle(R.string.app_name)
.setSubtitle(R.string.powered_by)
.show();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SplashScreenBuilder.SPLASH_SCREEN_FINISHED) {
if (resultCode == Activity.RESULT_OK) {
Toast.makeText(this, "SplashScreen finished", Toast.LENGTH_SHORT).show();
} else if (resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(this, "SplashScreen finished, but canceled", Toast.LENGTH_SHORT).show();
}
}
}
}