Last active
March 2, 2020 09:14
-
-
Save pratheeshrussell/f382e9e582e1b41e4ce00a170db1ee71 to your computer and use it in GitHub Desktop.
native animated splash screen Splash Screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//android\app\src\main\java\com\example\native_splash\CustomSplashScreen.java | |
//package name will differ based on projects | |
package com.example.native_splash; | |
import android.content.Context; | |
import android.os.Bundle; | |
import android.view.View; | |
import androidx.annotation.NonNull; | |
import androidx.annotation.Nullable; | |
import io.flutter.embedding.android.SplashScreen; | |
public class CustomSplashScreen implements SplashScreen { | |
private CustomSplashScreenView splashView; | |
@Nullable | |
public View createSplashView(@NonNull Context context, @Nullable Bundle bundle) { | |
if (splashView == null) { | |
splashView = new CustomSplashScreenView(context); | |
splashView.restoreSplashState(bundle); | |
} | |
return splashView; | |
} | |
//closing the splash | |
public void transitionToFlutter(Runnable onTransitionComplete) { | |
if (splashView != null) { | |
splashView.animateAway(onTransitionComplete); | |
} | |
else { | |
onTransitionComplete.run(); | |
} | |
} | |
//state saving | |
@Override | |
public boolean doesSplashViewRememberItsTransition() { | |
return true; | |
} | |
@Override | |
@Nullable | |
public Bundle saveSplashScreenState() { | |
if (splashView != null) { | |
return splashView.saveSplashState(); | |
} else { | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment