
package birthnumerology.findyourfate.com;

import com.firebase.client.Firebase; 

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
 

public class home extends Activity {
	
	
	 
	
	@SuppressLint("NewApi") 
	@Override
	
		protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.home);
	
	 Firebase.setAndroidContext(this);
	 Firebase ref = new Firebase(Config.FIREBASE_URL);
     ref.child("Description").setValue("Description");
	 
	   Intent intent = getIntent();
	    String action = intent.getAction();
	    Uri data = intent.getData();
	    
	    
	TextView textview=(TextView) findViewById(R.id.textv);
    textview.setPaintFlags(textview.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    textview.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view)
        {
            Uri adress= Uri.parse("http://www.findyourfate.com");  
            Intent browser= new Intent(Intent.ACTION_VIEW, adress);  
            startActivity(browser);  
        }
    });
    Runnable swapImage = new Runnable() {
	    @Override
	    public void run() {
	    	Intent intent = new Intent(home.this,MainActivity.class);
	    	startActivity(intent);
	    }
    };
   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);
	    	startActivity(intent);
			return true;
		   }
	    });
	}

 
	
	   
	@Override
    public void onBackPressed() {
		 AlertDialog.Builder builder = new AlertDialog.Builder(this);
		    builder.setMessage("Are you sure want to exit from Birthday Numerology?")
		           .setCancelable(false)
		           .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
		               public void onClick(DialogInterface dialog, int id) {
		               	   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();	
   }
	
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.homemain, menu);
	  return true;    
	}
	
	public boolean onOptionsItemSelected(MenuItem item) {
	    switch (item.getItemId()) {
	   	   	case R.id.start:
	    	Intent inte= new Intent(this,MainActivity.class);
	    	inte.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	        startActivity(inte);
	        return true;
	   	 	default:
	            return super.onOptionsItemSelected(item);
	 	    }
	}
}
