Skip to content
Permalink
Browse files
CB-9538 Implementing FadeSplashScreen feature for Android
  • Loading branch information
Philipp Grosswiler authored and daserge committed Jan 11, 2016
1 parent 3b2e9e5 commit 34bc1dbf160f2d3b5b11a86ddb1a992661510587
Showing 1 changed file with 36 additions and 3 deletions.
@@ -30,6 +30,9 @@ Licensed to the Apache Software Foundation (ASF) under one
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AlphaAnimation;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;

@@ -197,9 +200,39 @@ private void removeSplashScreen() {
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
if (splashDialog != null && splashDialog.isShowing()) {
splashDialog.dismiss();
splashDialog = null;
splashImageView = null;
if (preferences.getBoolean("FadeSplashScreen", true)) {
final int splashscreenDuration = (int)(preferences.getDouble("FadeSplashScreenDuration", 2) * 1000);

AlphaAnimation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setInterpolator(new DecelerateInterpolator()); //add this
fadeOut.setDuration(splashscreenDuration);

splashImageView.setAnimation(fadeOut);
splashImageView.startAnimation(fadeOut);

fadeOut.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}

@Override
public void onAnimationEnd(Animation animation) {
if (splashDialog != null && splashDialog.isShowing()) {
splashDialog.dismiss();
splashDialog = null;
splashImageView = null;
}
}

@Override
public void onAnimationRepeat(Animation animation) {
}
});
} else {
splashDialog.dismiss();
splashDialog = null;
splashImageView = null;
}
}
}
});

0 comments on commit 34bc1db

Please sign in to comment.