package example.com.velezguiatour;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;

import com.google.android.gms.maps.model.LatLng;

public class RestaurantFullDescription extends Activity {
	String[] restaurantAddress = {
			"Merendero El Pollo Benajarafe \n"+
			        "952 51 39 09\n",
			"RESTAURANTE MESÓN LOS LOBOS \n" +
					"952 550 094\n" ,
			"Restaurante Pippo \n"+
					"952 55 13 80 \n",
			"Meson La Bohemia\n" +
					"Bar de tapas y restaurante\n"+
					"622 68 96 71\n",
			"Restaurante La Sastrería\n"+
					"95 254 91 64\n",
			"La Gamba Dorada\n" +
					"Restaurante\n",
			        "952 50 14 69\n",
			"Bar El Rubio EL RUBIO, TU RESTAURANTE, TU BAR DE TAPAS\n"+
					"952 50 12 13 – 619884839\n"
			};
	LatLng[] latLangs = {
							new LatLng(36.715890,-4.196727),
							new LatLng(36.754364,-4.052332),
							new LatLng(36.746205,-4.053390),
							new LatLng(36.782251,-4.105513),
							new LatLng(36.783023,-4.101809),
							new LatLng(36.782754,-4.107827),
			                new LatLng(36.781305,-4.108786)

						};
	
	String[] url = {
			"https://www.facebook.com/merendero.elpollo/",
			"https://www.facebook.com/pages/Restaurante-Meson-Los-Lobos-Algarrobo/554254587933339",
			"https://www.facebook.com/Restaurante.Pippo.Algarrobo.Costa/",
			"https://www.facebook.com/Meson-La-Bohemia-450310791774232/?fref=ts",
			"http://lasastreriaasador.es/",
			"https://www.facebook.com/pages/La-Gamba-Dorada/186482801382034",
			"http://restaurantebarelrubio.es/"

	};
	final String[] phones = {
			"952513909",
			"952550094",
			"952551380",
			"622689671",
			"952549164",
			"952501469",
			"952501213"

	};
	
	VideoView vidio;
    MediaController mc;
    Uri uri;
    
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_restaurant_full_description);
		final int posistion = getIntent().getExtras().getInt("id");

		TextView address = (TextView) findViewById(R.id.txtViewRestaurantAddress);
		address.setText(restaurantAddress[posistion]);
		Button btnmap = (Button) findViewById(R.id.btnmap);
		int index = getIntent().getExtras().getInt("index");;
		Button call = (Button) findViewById(R.id.btncall);
		
		ImageButton btnurl = (ImageButton) findViewById(R.id.url);
		
		btnurl.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url[posistion]));
				startActivity(i);
			}
		});
		index = getIntent().getExtras().getInt("index");
		final TextView phone = (TextView) findViewById(R.id.txtTextPhone);
		phone.setText(phones[index]);
		call.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				String sPhone = phone.getText().toString();
				if ("".equals(sPhone)) {
					Toast.makeText(RestaurantFullDescription.this,
							"Phone number cannot be blank", Toast.LENGTH_LONG)
							.show();
				} else {
					String sCall = "tel:" + sPhone;
					Intent callIntent = new Intent(Intent.ACTION_CALL);
					callIntent.setData(Uri.parse(sCall));
					startActivity(callIntent);
				}
			}
		});
		
		
		
		btnmap.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent i = new Intent(RestaurantFullDescription.this, MyMapp.class);
				i.putExtra("latlang", latLangs[posistion]);
				startActivity(i);
			}
		});
			

			RestaurantImageAdapter imageAdapter = new RestaurantImageAdapter(this);
			ImageView imageview = (ImageView) findViewById(R.id.fullImageView);
			imageview.setImageResource(imageAdapter.images[posistion]);			

		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.menu_main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
