-
Notifications
You must be signed in to change notification settings - Fork 0
/
SplashScreenActivity.java
99 lines (79 loc) · 3.29 KB
/
SplashScreenActivity.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
94
95
96
97
98
99
package com.binary;
import androidx.appcompat.app.AppCompatActivity;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
public class SplashScreenActivity extends AppCompatActivity {
TextView textView;
ImageView imageView;
int index;
CharSequence charSequence;
long delay = 200;
Handler handler = new Handler();
Runnable runnable = new Runnable() {
@Override
public void run() {
textView.setText(charSequence.subSequence(0,index++));
if(index <= charSequence.length()){
handler.postDelayed(runnable,delay);
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
textView = findViewById(R.id.textView);
imageView = findViewById(R.id.imageView);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide();
//Fetching id from shared preferences
SharedPreferences sharedPreferences;
sharedPreferences =getSharedPreferences(constant.SHARED_PREF_NAME, Context.MODE_PRIVATE);
String getUserLogin = sharedPreferences.getString(constant.HOME_PAGE, "");
animatText("Binary");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if(getUserLogin.equals("0")){
Intent intent = new Intent(getApplicationContext(),BinaryToTextActivity.class);
startActivity(intent);
}else{
if(getUserLogin.equals("")){
//Creating a shared preference
SharedPreferences sp = getSharedPreferences(constant.SHARED_PREF_NAME, Context.MODE_PRIVATE);
//Creating editor to store values to shared preferences
SharedPreferences.Editor editor = sp.edit();
//Adding values to editor
editor.putString(constant.HOME_PAGE, "1");
//Saving values to editor
editor.apply();
Intent intent = new Intent(getApplicationContext(),TextToBinaryActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}else{
Intent intent = new Intent(getApplicationContext(),TextToBinaryActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
}
}
},4000);
}
public void animatText(CharSequence cs){
charSequence = cs;
index = 0;
textView.setText("");
handler.removeCallbacks(runnable);
handler.postDelayed(runnable,delay);
}
}