-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplashScreen.java
More file actions
66 lines (57 loc) · 1.87 KB
/
SplashScreen.java
File metadata and controls
66 lines (57 loc) · 1.87 KB
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
/*
Created by Abhishek Kachhwaha for Grievance system on 1/10/2019
*/
package com.example.grievancesystem;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
public class SplashScreen extends AppCompatActivity {
private FirebaseAuth mAuth;
private FirebaseUser mCurrentuser;
Handler mHandler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
init(); // init Alias of intialise()
}
/*
The function intialises the all the instances and is called at creation of the activity
*/
private void init() {
mAuth = FirebaseAuth.getInstance();
mHandler = new Handler();
}
/*
The function is called everytime when the activity starts ,it overrides the normal behaviour of the application flow
*/
@Override
public void onStart() {
super.onStart();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mCurrentuser = mAuth.getCurrentUser();
if (mCurrentuser == null) {
sendToStart();
} else {
Intent sendtomainpage = new Intent(SplashScreen.this, MainPage.class);
mHandler.removeCallbacksAndMessages(null);
startActivity(sendtomainpage);
}
finish();
}
}, 2000); // 2000 millisecond = 2 seconds
}
/*
Function to send intent to log in page
*/
private void sendToStart() {
Intent i = new Intent(SplashScreen.this, MainPage.class);
startActivity(i);
finish();
}
}