package com.example.TreballFiGrau;

import android.app.Activity;
import android.content.Context;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class CercaTags extends Activity {
	TextView afegirTag;
	TextView llistaTags;
	TextView textViewLlistaTagsCerca;
	EditText editTextCercaTags;
	
	String tags;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.cerca_tags);
	    Log.d("aki", "dintre cerca   tags");
	    editTextCercaTags = (EditText) findViewById(R.id.editTextCercaTags);
	    editTextCercaTags.setMaxWidth(editTextCercaTags.getWidth());
    	
	    textViewLlistaTagsCerca = (TextView) findViewById(R.id.textViewLlistaTagsCerca);
	    listener();
	}
	
	@Override
	protected void onStart() {
		super.onStart();
		tags="";

	}
	
	public void listener(){
		Button button1 =(Button) findViewById(R.id.buttonCercaTags);
        button1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	Log.d("aki", "dintre boto 1 cerca tags");
            	Llista_AdapterNoticies.reiniciarLlista();
            	Log.d("aki", tags);
            	new CargarNoticiesTags().execute(tags);
                //Intent intent = new Intent(MainActivity.this, GoogleMaps.class);
                //startActivity(intent);
            	finish();
            	//mPager.setCurrentItem(0);
            	
            }
        });
        
        afegirTag= (TextView) findViewById(R.id.textViewAfegirTagCerca);
		afegirTag.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				String cosa = editTextCercaTags.getText().toString();
				String anterior = textViewLlistaTagsCerca.getText().toString();
				textViewLlistaTagsCerca.setText(anterior + cosa + ",");
				editTextCercaTags.setText("");
				tags= anterior + cosa + ", " ;
				
			}
		
		
		});
	}
}
