SplashScreen.java :  » Blog-Twitter » peer2tweet » edu » unipd » p2t » core » Android Open Source

Android Open Source » Blog Twitter » peer2tweet 
peer2tweet » edu » unipd » p2t » core » SplashScreen.java
package edu.unipd.p2t.core;

import edu.unipd.p2t.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ProgressBar;

public class SplashScreen extends Activity {
    private static final int STOPSPLASH = 0;
    private static final long SPLASHTIME = 2000;
    private ProgressBar myProgressBar;
    private int myProgress = 0;
    private static final int PROGRESSSPLASH = 1;

    private Handler splashHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case STOPSPLASH:
                    //remove SplashScreen from view
                    Intent intent = new Intent(SplashScreen.this, MainActivity.class);
                    startActivity(intent);
                    break;
                case PROGRESSSPLASH:
                  myProgress=myProgress+25;
                    myProgressBar.setProgress(myProgress); 
                  break;
            }
            super.handleMessage(msg);
        }
    };
 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        
        myProgressBar=(ProgressBar)findViewById(R.id.progressbar_Horizontal);
        
        Message msg = new Message();// il message di android non quello definito in questa app
        msg.what = STOPSPLASH;
        splashHandler.sendMessageDelayed(msg, SPLASHTIME);
        Message msg1 = new Message();// il message di android non quello definito in questa app
        msg1.what = PROGRESSSPLASH;
        splashHandler.sendMessageDelayed(msg1, 500);
        Message msg2 = new Message();// il message di android non quello definito in questa app
        msg2.what = PROGRESSSPLASH;
        splashHandler.sendMessageDelayed(msg2, 1000);
        Message msg3 = new Message();// il message di android non quello definito in questa app
        msg3.what = PROGRESSSPLASH;
        splashHandler.sendMessageDelayed(msg3, 1500);
        Message msg4 = new Message();// il message di android non quello definito in questa app
        msg4.what = PROGRESSSPLASH;
        splashHandler.sendMessageDelayed(msg4, 2000);

    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.