package scorpio.findyourfate.com;
 
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;

import android.text.Html;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;

public class home  extends Activity{
	String regId; 
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	    setContentView(R.layout.home);
	    //regId = getIntent().getStringExtra("REGID");   
	        Runnable swapImage = new Runnable() {
		    @Override
		    public void run() {
		    	Intent intent = new Intent(home.this,MainActivity.class);
		    	//intent.putExtra("REGID", regId);
		    	startActivity(intent);
		    }
		    };
		    
		    getActionBar().setTitle(
		            Html.fromHtml("<font color=\"#ffffff\" size=\"25px\"><b>"+"Scorpio"+"</b></font>"));
		   
		    
	   ImageView  img = (ImageView) findViewById(R.id.imageView1);
	   img.postDelayed(swapImage, 1000); 
	   img.setOnTouchListener(new View.OnTouchListener() {
		
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			// TODO Auto-generated method stub
			Intent intent = new Intent(home.this,MainActivity.class);
			//intent.putExtra("REGID", regId);
	    	startActivity(intent);
			return true;
		}
	   });
	 	}
		@Override
			public void onBackPressed() {
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setTitle("Exit!");
			builder.setMessage("Are you sure you want to exit from Scorpio app?")
			       .setCancelable(false)
			       .setIcon(R.drawable.alert)
			       .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
			           public void onClick(DialogInterface dialog, int id) {
			        	home.this.finish();
			        	Intent intent = new Intent(Intent.ACTION_MAIN);
					    	intent.addCategory(Intent.CATEGORY_HOME);
					    	intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
					    	startActivity(intent);
			               }
			       })
			       .setNegativeButton("No", new DialogInterface.OnClickListener() {
			        public void onClick(DialogInterface dialog, int id) {
			         dialog.cancel();
			           }
			       });
			AlertDialog alert = builder.create();
			alert.show();
	}

}
