package com.classicharmony.speechzilla; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.view.animation.AccelerateInterpolator; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.widget.ImageView; import com.classicharmony.speechzilla.utils.DUtils; public class Splash extends Activity { private ImageView imageView_logo; private Splash mContext; private SharedPreferences prefs; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_splash); imageView_logo = (ImageView) findViewById(R.id.imageView_logo); mContext = Splash.this; prefs = getSharedPreferences("PREFS", 0); if (DUtils.isOnline(mContext)) { // Application has internet start_app(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(R.string.first_time_requires_internet) .setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); finish(); } }); AlertDialog alert = builder.create(); alert.setTitle(R.string.app_name); alert.show(); } } private void start_app() { Animation fadeOut = new AlphaAnimation(1, 0); fadeOut.setInterpolator(new AccelerateInterpolator()); fadeOut.setDuration(1000); imageView_logo.startAnimation(fadeOut); fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { imageView_logo.setVisibility(View.INVISIBLE); Intent intent = new Intent(mContext, VoiceActivity.class); startActivity(intent); } @Override public void onAnimationRepeat(Animation animation) { } }); } }