Commit 7e54d858 authored by iman Fauzi's avatar iman Fauzi

fix splash screen

parent fbb8e58e
......@@ -6,16 +6,21 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.textview.MaterialTextView;
public class SplashScreen extends AppCompatActivity {
ImageView img;
MaterialTextView textView;
SharedPreferences sharedPreferences;
public static final String MY_SHARED_PREFERENCES = "my_shared_preferences";
public static final String SESSION = "session";
......@@ -29,13 +34,23 @@ public class SplashScreen extends AppCompatActivity {
setContentView(R.layout.activity_splash);
img = findViewById(R.id.image_splash);
textView = findViewById(R.id.messer_id);
// Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.zoom_in);
// img.startAnimation(animation);
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.translate);
img.startAnimation(animation);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
textView.setVisibility(View.VISIBLE);
Animation txt = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_in);
textView.startAnimation(txt);
}
}, 700);
sharedPreferences = getSharedPreferences(MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
session = sharedPreferences.getBoolean(SESSION, false);
new Handler(Looper.getMainLooper()).postDelayed(()->{
if (session){
startActivity(new Intent(SplashScreen.this, MainActivity.class));
......@@ -44,6 +59,6 @@ public class SplashScreen extends AppCompatActivity {
startActivity(new Intent(SplashScreen.this, LoginActivity.class));
finish();
}
}, 3000);
}, 3500);
}
}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="2000"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="700"
android:fromYDelta="50%"
android:toYDelta="1%" />
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="0.5"
android:toXScale="2.0"
android:fromYScale="0.5"
android:toYScale="2.0"
android:duration="3000"
android:pivotX="50%"
android:pivotY="50%" >
</scale>
</set>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
......@@ -7,12 +8,24 @@
<ImageView
android:id="@+id/image_splash"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/ic_meser_icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/messer_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/poppins_bold"
android:visibility="gone"
android:text="messer.id"
android:textColor="@color/colorWhite"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/image_splash" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment