package sunsigns2014.findyourfate.com;

import android.app.ActionBar;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemSelectedListener;
import sunsigns2014.findyourfate.com.main2020.MyAdapter;

import java.util.ArrayList;
import java.util.List;


public class spain2020 extends Activity {
	 
	 String lang="Spanish";
	  TextView aries,taurus,gemini,cancer,leo,virgo,libra,scorpio,sagg,capri,aquar,pisces;
	  String[] Languages = { "Elija El Idioma", "2020 in English", "2020 in French", "2020 in Spanish", "2020 in Hindi","2020 in Dutch", "2020 in Arabic", "2020 in Malay", 
			  "2020 in German","2020 in Chinese","2020 in Japanese","2020 in Russian","2020 in Portuguese"};
 		 
	Integer[] images = { 0, R.drawable.us, R.drawable.france,R.drawable.spanish, R.drawable.india, R.drawable.dutch, R.drawable.arabia, R.drawable.malay, R.drawable.germany, R.drawable.china, R.drawable.japanse, R.drawable.russia, R.drawable.port};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.alllang20);
		
		
		
		 aries=(TextView) findViewById(R.id.ariest);
		    taurus=(TextView) findViewById(R.id.taurust);
		    gemini=(TextView) findViewById(R.id.geminit);
		    cancer=(TextView) findViewById(R.id.cancert);
		    leo=(TextView) findViewById(R.id.leot);
		    virgo=(TextView) findViewById(R.id.virgot);
		    libra=(TextView) findViewById(R.id.librat);
		    scorpio=(TextView) findViewById(R.id.scorpt);
		    sagg=(TextView) findViewById(R.id.sagt);
		    capri=(TextView) findViewById(R.id.caprit);
		    aquar=(TextView) findViewById(R.id.aquart);
		    pisces=(TextView) findViewById(R.id.piscest);
		    
		    aries.setText("Aries");
		    taurus.setText("Tauro");
		    gemini.setText("Géminis");
		    cancer.setText("Cáncer");
		    leo.setText("León");
		    virgo.setText("Virgo");
		    libra.setText("Libra");
		    scorpio.setText("Escorpio");
		    sagg.setText("Sagitario");
		    capri.setText("Capricornio");
		    aquar.setText("Acuario");
		    pisces.setText("Piscis");
		    
		   
	          getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
		        getActionBar().setCustomView(R.layout.custombar);
		        setActiobarTitle("2020 Horóscopos");
		        final Spinner s1 = (Spinner) findViewById(R.id.year);	
			     
			   	List<String> list = new ArrayList<String>();
		    	list.add("Año >>");
		    	list.add("2019");
		    	list.add("2020");
		    	
		    	
		    	ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
		    			R.layout.spinner, list);
		    		dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		    		s1.setAdapter(dataAdapter);    
			  
		    		
		    		final AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
	 	        
	 	       s1.setOnItemSelectedListener(new OnItemSelectedListener() {

	 	    	    public void onClick(View v) {
	 	    	        // TODO Auto-generated method stub

	 	    	    }
	 	    	    @Override
	 	    	    public void onItemSelected(AdapterView<?> arg0, View view,
	 	    	            int position, long row_id) {
	 	    	        Intent intent = null;
	 	    	        switch(position){
	 	    	        case 0:
	 	    	        	break;
	 	    	            case 1:
	 	    	            	Intent in=new Intent(spain2020.this,spain2019.class);
	 			            	in.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	 			            	startActivity(in);
	 			            	break;
	 	    	            case 2:
	 	    	            	Intent inn=new Intent(spain2020.this,spain2020.class);
	 			            	inn.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	 			            	startActivity(inn);
	 	    	        }
	 	    	       

	 	    	    }

	 	    	    @Override
	 	    	    public void onNothingSelected(AdapterView<?> arg0) {
	 	    	        // TODO Auto-generated method stub

	 	    	    }
	    	});
		
		ImageView img = (ImageView) findViewById(R.id.image2015);
		img.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "Aries");			
	             startActivity(intent);
				
			}
		});
		aries.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
				
					Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
					intent.putExtra("key", "Aries");			
		             startActivity(intent);
					
				}
			});

		ImageView img2 = (ImageView) findViewById(R.id.imageView2);
		img2.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "Tauro");
	             startActivity(intent);
				
			}
		});
		
		taurus.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					
					Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
					intent.putExtra("key", "Tauro");
		             startActivity(intent);
					
				}
			});
	
	ImageView img3 = (ImageView) findViewById(R.id.imageView3);
	img3.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
			intent.putExtra("key", "Géminis");
	        startActivity(intent);
			
		}
	});
	
	gemini.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
			
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "Géminis");
		        startActivity(intent);
			
		}
		});
	
	ImageView img4 = (ImageView) findViewById(R.id.imageView4);
	img4.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
			intent.putExtra("key", "Cáncer");
	        startActivity(intent);
   	}
	});
	cancer.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "Cáncer");
		        startActivity(intent);
	   	}
		});

		
	
	ImageView img5 = (ImageView) findViewById(R.id.imageView5);
	img5.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
			intent.putExtra("key", "León");
		      startActivity(intent);
			
		}
	});
	
	leo.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "León");
			      startActivity(intent);
				
			}
		});
	
	ImageView img6 = (ImageView) findViewById(R.id.imageView6);
	img6.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			
			Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
			intent.putExtra("key", "Virgo");
			
             startActivity(intent);
			
		}
	});
	
	virgo.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "Virgo");
				
	             startActivity(intent);
				
			}
		});
   
   ImageView img7 = (ImageView) findViewById(R.id.imageView7);
	img7.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
			intent.putExtra("key", "Libra");
			
            startActivity(intent);
			
		}
	});
	libra.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "Libra");
				
	            startActivity(intent);
			}
		});	
   ImageView img8 = (ImageView) findViewById(R.id.imageView8);
	img8.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
			intent.putExtra("key", "Escorpio");
			
            startActivity(intent);
			
		}
	});
   
	scorpio.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "Escorpio");
				
	            startActivity(intent);
				
			}
		});
	
   ImageView img9 = (ImageView) findViewById(R.id.imageView9);
	img9.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
			intent.putExtra("key", "Sagitario");
			
            startActivity(intent);
		
		}
	});
   
	sagg.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "Sagitario");
				
	            startActivity(intent);
				
			}
		});
	
   ImageView img10 = (ImageView) findViewById(R.id.imageView10);
	img10.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
			intent.putExtra("key", "Capricornio");
			
            startActivity(intent);
			
		}
	});
	capri.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "Capricornio");
				
	            startActivity(intent);
				
			}
		});
	
   ImageView img11 = (ImageView) findViewById(R.id.imageView11);
	img11.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
			intent.putExtra("key", "Acuario");
			
            startActivity(intent);
			
		}
	});
	
	aquar.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "Acuario");
				
	            startActivity(intent);
				
			}
		});
  
   ImageView img12 = (ImageView) findViewById(R.id.imageView12);
	img12.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
			intent.putExtra("key", "Piscis");
			
            startActivity(intent);
			
		}
	});
   
	
	pisces.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(spain2020.this,zodiacspanish2020.class);
				intent.putExtra("key", "Piscis");
				
	            startActivity(intent);
				
			}
		});	
	  
	}
	
	private void setActiobarTitle(String title)
	{
	View v = getActionBar().getCustomView();
	  TextView titleTxtView = (TextView) v.findViewById(R.id.textView1);
	  titleTxtView.setText(" 2020 Horóscopos");
	}
	 
    @Override
    public void onBackPressed() {
         spain2020.this.finish();
	    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
   	 MenuInflater inflater = getMenuInflater();
	    inflater.inflate(R.menu.custommenu, menu);
	    RelativeLayout layout = (RelativeLayout) menu.findItem(R.id.layout_item).getActionView();
	    View v = getLayoutInflater().inflate(R.layout.ab_bottom_layout, null);
	    
	    final Spinner sp = (Spinner) v.findViewById(R.id.bottomspinner);	 
	    
	     sp.setAdapter(new MyAdapter(spain2020.this, R.layout.spinnernew,
	    		Languages));
	   		 	  
	 	       final AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
	 	        sp.setOnItemSelectedListener(new OnItemSelectedListener() {
	 	    	   public void onClick(View v) {
	 	    	    // TODO Auto-generated method stub
	 	    	   } 
	 	    	   @Override
	 	    	    public void onItemSelected(AdapterView<?> arg0, View view,
	 	    	            int position, long row_id) {
	 	    		   
	 	    	         switch(position){
	 	    	       
	 	    	                case 1:
	 	    	               
	 	    	            	Intent inn=new Intent(spain2020.this,main2020.class);
	 			            	inn.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	 			            	startActivity(inn);
	 			            	break;
	 	    	                case 2:
	 	    	            	Intent in2=new Intent(spain2020.this,french2020.class);
	 			            	in2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	 			            	startActivity(in2);
	 			            	break;
	 	    	               case 3:
		 	    	            	Intent in3=new Intent(spain2020.this,spain2020.class);
		 			            	in3.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		 			            	startActivity(in3);
		 			            	break;
	 	    	              case 4:
		 	    	            	Intent in4=new Intent(spain2020.this,hindi2020.class);
		 			            	in4.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		 			            	startActivity(in4);
		 			            	break;
	 	    	             case 5:
		 	    	            	Intent in5=new Intent(spain2020.this,dutch2020.class);
		 			            	in5.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		 			            	startActivity(in5);
		 			            	break;
	 	    	            case 6:
	 	    	            	Intent in6=new Intent(spain2020.this,arabic2020.class);
	 			            	in6.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	 			            	startActivity(in6);
	 			            	break;
	 	    	           case 7:
	 	    	            	Intent in7=new Intent(spain2020.this,malay2020.class);
	 			            	in7.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	 			            	startActivity(in7);
	 			            	break;
	 	    	          case 8:
	 	    	            	Intent in8=new Intent(spain2020.this,german2020.class);
	 			            	in8.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	 			            	startActivity(in8);
	 			            	break;
	 	    	         case 9:
	 	    	            	Intent in9=new Intent(spain2020.this,chinese2020.class);
	 			            	in9.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	 			            	startActivity(in9);
	 			            	break;
	 	    	        case 10:
	    	            	Intent in10=new Intent(spain2020.this,japanese2020.class);
			            	in10.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			            	startActivity(in10);
			            	break;
			            	
	 	    	       case 11:
	    	            	Intent in11=new Intent(spain2020.this,russian2020.class);
			            	in11.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			            	startActivity(in11);
			            	break;
			            	
	 	    	      case 12:
	    	            	Intent in12=new Intent(spain2020.this,portuguese2020.class);
			            	in12.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			            	startActivity(in12);
			            	break;
	 			         }
	  	    	    }
	    	    @Override
	 	    	    public void onNothingSelected(AdapterView<?> arg0) {
	 	    	        // TODO Auto-generated method stub
	 	    	    }
	    	   });
	    
	    
	    layout.addView(v); 

	    return super.onCreateOptionsMenu(menu);
	 
 	  }
	      
	public boolean onOptionsItemSelected(MenuItem item) {
		 
       if (item.getItemId()==android.R.id.home)
       {
   	Intent int_abt = new Intent(this,main2020.class);
       int_abt.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
       startActivity(int_abt);
       }
      
       	 
	     
       
		 else if (item.getItemId() == R.id.exit)
		  {
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			 builder.setMessage("Are you sure  want to exit from Sun Signs app?")
			      .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();
		  }
		  
		   else
		  {
			  
		  }
	            return true;
	    }
	public class MyAdapter extends ArrayAdapter {
		 
		public MyAdapter(Context context, int textViewResourceId,
		String[] objects) {
		super(context, textViewResourceId, objects);
		}
		 
		public View getCustomView(int position, View convertView,
		ViewGroup parent) {
		 
		// Inflating the layout for the custom Spinner
		LayoutInflater inflater = getLayoutInflater();
		View layout = inflater.inflate(R.layout.spinnernew, parent, false);
		 
	  	TextView tvLanguage = (TextView) layout
		.findViewById(R.id.spintext);
		 
	 	tvLanguage.setText(Languages[position]);
		 
	 	ImageView img = (ImageView) layout.findViewById(R.id.sspin);
		 
	 	img.setImageResource(images[position]);
		 
	 	if (position == 0) {
	 	img.setVisibility(View.GONE);
	 //	tvLanguage.setTextColor(Color.BLACK);
 	  	}
		 
		return layout;
		}
		 
		// It gets a View that displays in the drop down popup the data at the specified position
		@Override
		public View getDropDownView(int position, View convertView,
		ViewGroup parent) {
		return getCustomView(position, convertView, parent);
		}
		 
		// It gets a View that displays the data at the specified position
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
		return getCustomView(position, convertView, parent);
		}
		}
}
 