// Path: QuestionApp/src/ca/ualberta/cs/cmput301f14t14/questionapp/data/Callback.java
// public interface Callback<T> {
// 	/**
// 	 * Run by the onPostExecute method of a Task
// 	 * @param object
// 	 */
// 	public void run(T object);
// }
// 
// Path: QuestionApp/src/ca/ualberta/cs/cmput301f14t14/questionapp/data/GenericSearchItem.java
// public class GenericSearchItem {
// 	private UUID id;
// 	private String title;
// 	private String body;
// 	private Date date;
// 	private Location location;
// 	private String type;
// 	
// 	public UUID getId() {
// 		return id;
// 	}
// 	
// 	public void setId(UUID id) {
// 		this.id = id;
// 	}
// 
// 	public String getTitle() {
// 		return title;
// 	}
// 	
// 	public void setTitle(String title) {
// 		this.title = title;
// 	}
// 	
// 	public String getBody() {
// 		return body;
// 	}
// 	
// 	public void setBody(String body) {
// 		this.body = body;
// 	}
// 	
// 	public Date getDate() {
// 		return date;
// 	}
// 	
// 	public void setDate(Date date) {
// 		this.date = date;
// 	}
// 	
// 	public Location getLocation() {
// 		return location;
// 	}
// 	
// 	public void setLocation(Location location) {
// 		this.location = location;
// 	}
// 	
// 	public String getType() {
// 		return type;
// 	}
// 	
// 	public void setType(String type) {
// 		this.type = type;
// 	}
// }
// 
// Path: QuestionApp/src/ca/ualberta/cs/cmput301f14t14/questionapp/data/threading/ESSearchTask.java
// public class ESSearchTask extends AbstractDataManagerTask<String, Void, List<GenericSearchItem>> {
// 	private Context context;
// 	public ESSearchTask(Context c) {
// 		super(c);
// 		context = c;
// 	}
// 
// 	@Override
// 	protected List<GenericSearchItem> doInBackground(String... arg0) {
// 		
// 		String query = arg0[0];
// 		List<GenericSearchItem> gSIList = null;
// 		ESSearch es = new ESSearch(context);
// 		try{
// 			gSIList = es.search(query);
// 		}catch(IOException e){
// 			Log.e("ESSearch", "Failed to get search results");
// 			gSIList = new ArrayList<GenericSearchItem>();
// 		}
// 		return gSIList;
// 	}
// 	
// 	@Override
// 	protected void onPostExecute(List<GenericSearchItem> la) {
// 		if (callback == null){
// 			return;
// 		}
// 		callback.run(la);
// 	}
// 
// }
// 
// Path: QuestionApp/src/ca/ualberta/cs/cmput301f14t14/questionapp/view/GenericSearchItemAdapter.java
// public class GenericSearchItemAdapter extends ArrayAdapter<GenericSearchItem> implements IView {
// 
// 	public GenericSearchItemAdapter(Context context, int resource, List<GenericSearchItem> objects) {
// 		super(context, resource, objects);
// 	}
// 	
// 	public View getView(int position, View convertView, ViewGroup parent){
// 		if(convertView == null){
// 			convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_generic, parent, false);
// 		}
// 		GenericSearchItem item = getItem(position);
// 		ClientData cd = new ClientData(getContext());
// 
// 		if(!cd.getFavorites().contains(item.getId())){
// 			((ImageView)convertView.findViewById(R.id.question_favourite)).setVisibility(View.INVISIBLE);
// 		}
// 		else{
// 			((ImageView)convertView.findViewById(R.id.question_favourite)).setVisibility(View.VISIBLE);
// 		}
// 		//Fill views with data
// 		TextView gType = (TextView) convertView.findViewById(R.id.generic_type); 
// 		TextView gText = (TextView) convertView.findViewById(R.id.generic_body);
// 		TextView gLocation = (TextView) convertView.findViewById(R.id.generic_location);
// 		TextView gDate = (TextView) convertView.findViewById(R.id.generic_date);
// 		gType.setText(item.getTitle() + " <" + item.getType() + ">");
// 		gText.setText(item.getBody());
// 		gLocation.setText("near: " + DataManager.getInstance(getContext()).getCityFromLocation(item.getLocation()));
// 		
// 		gDate.setText(item.getDate().toString());
// 		return convertView;
// 		
// 	}
// 
// 	@Override
// 	public void update() {
// 		notifyDataSetChanged();
// 	}
// 
// }


import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import ca.ualberta.cs.cmput301f14t14.questionapp.data.Callback;
import ca.ualberta.cs.cmput301f14t14.questionapp.data.GenericSearchItem;
import ca.ualberta.cs.cmput301f14t14.questionapp.data.threading.ESSearchTask;
import ca.ualberta.cs.cmput301f14t14.questionapp.view.GenericSearchItemAdapter;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
package ca.ualberta.cs.cmput301f14t14.questionapp;



public class SearchActivity extends Activity {

	public static final String ARG_QUERY_STRING = "QUERY_STRING";

	private GenericSearchItemAdapter listAdapter = null;
	private List<GenericSearchItem> searchResult = null;
	private String query;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_search);
		Intent intent = getIntent();
		query = intent.getStringExtra(ARG_QUERY_STRING);

		searchResult = new ArrayList<GenericSearchItem>();
// Path: QuestionApp/src/ca/ualberta/cs/cmput301f14t14/questionapp/data/Callback.java
// public interface Callback<T> {
// 	/**
// 	 * Run by the onPostExecute method of a Task
// 	 * @param object
// 	 */
// 	public void run(T object);
// }
// 
// Path: QuestionApp/src/ca/ualberta/cs/cmput301f14t14/questionapp/data/GenericSearchItem.java
// public class GenericSearchItem {
// 	private UUID id;
// 	private String title;
// 	private String body;
// 	private Date date;
// 	private Location location;
// 	private String type;
// 	
// 	public UUID getId() {
// 		return id;
// 	}
// 	
// 	public void setId(UUID id) {
// 		this.id = id;
// 	}
// 
// 	public String getTitle() {
// 		return title;
// 	}
// 	
// 	public void setTitle(String title) {
// 		this.title = title;
// 	}
// 	
// 	public String getBody() {
// 		return body;
// 	}
// 	
// 	public void setBody(String body) {
// 		this.body = body;
// 	}
// 	
// 	public Date getDate() {
// 		return date;
// 	}
// 	
// 	public void setDate(Date date) {
// 		this.date = date;
// 	}
// 	
// 	public Location getLocation() {
// 		return location;
// 	}
// 	
// 	public void setLocation(Location location) {
// 		this.location = location;
// 	}
// 	
// 	public String getType() {
// 		return type;
// 	}
// 	
// 	public void setType(String type) {
// 		this.type = type;
// 	}
// }
// 
// Path: QuestionApp/src/ca/ualberta/cs/cmput301f14t14/questionapp/data/threading/ESSearchTask.java
// public class ESSearchTask extends AbstractDataManagerTask<String, Void, List<GenericSearchItem>> {
// 	private Context context;
// 	public ESSearchTask(Context c) {
// 		super(c);
// 		context = c;
// 	}
// 
// 	@Override
// 	protected List<GenericSearchItem> doInBackground(String... arg0) {
// 		
// 		String query = arg0[0];
// 		List<GenericSearchItem> gSIList = null;
// 		ESSearch es = new ESSearch(context);
// 		try{
// 			gSIList = es.search(query);
// 		}catch(IOException e){
// 			Log.e("ESSearch", "Failed to get search results");
// 			gSIList = new ArrayList<GenericSearchItem>();
// 		}
// 		return gSIList;
// 	}
// 	
// 	@Override
// 	protected void onPostExecute(List<GenericSearchItem> la) {
// 		if (callback == null){
// 			return;
// 		}
// 		callback.run(la);
// 	}
// 
// }
// 
// Path: QuestionApp/src/ca/ualberta/cs/cmput301f14t14/questionapp/view/GenericSearchItemAdapter.java
// public class GenericSearchItemAdapter extends ArrayAdapter<GenericSearchItem> implements IView {
// 
// 	public GenericSearchItemAdapter(Context context, int resource, List<GenericSearchItem> objects) {
// 		super(context, resource, objects);
// 	}
// 	
// 	public View getView(int position, View convertView, ViewGroup parent){
// 		if(convertView == null){
// 			convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_generic, parent, false);
// 		}
// 		GenericSearchItem item = getItem(position);
// 		ClientData cd = new ClientData(getContext());
// 
// 		if(!cd.getFavorites().contains(item.getId())){
// 			((ImageView)convertView.findViewById(R.id.question_favourite)).setVisibility(View.INVISIBLE);
// 		}
// 		else{
// 			((ImageView)convertView.findViewById(R.id.question_favourite)).setVisibility(View.VISIBLE);
// 		}
// 		//Fill views with data
// 		TextView gType = (TextView) convertView.findViewById(R.id.generic_type); 
// 		TextView gText = (TextView) convertView.findViewById(R.id.generic_body);
// 		TextView gLocation = (TextView) convertView.findViewById(R.id.generic_location);
// 		TextView gDate = (TextView) convertView.findViewById(R.id.generic_date);
// 		gType.setText(item.getTitle() + " <" + item.getType() + ">");
// 		gText.setText(item.getBody());
// 		gLocation.setText("near: " + DataManager.getInstance(getContext()).getCityFromLocation(item.getLocation()));
// 		
// 		gDate.setText(item.getDate().toString());
// 		return convertView;
// 		
// 	}
// 
// 	@Override
// 	public void update() {
// 		notifyDataSetChanged();
// 	}
// 
// }


// Path: QuestionApp/src/ca/ualberta/cs/cmput301f14t14/questionapp/SearchActivity.java
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import ca.ualberta.cs.cmput301f14t14.questionapp.data.Callback;
import ca.ualberta.cs.cmput301f14t14.questionapp.data.GenericSearchItem;
import ca.ualberta.cs.cmput301f14t14.questionapp.data.threading.ESSearchTask;
import ca.ualberta.cs.cmput301f14t14.questionapp.view.GenericSearchItemAdapter;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

package ca.ualberta.cs.cmput301f14t14.questionapp;



public class SearchActivity extends Activity {

	public static final String ARG_QUERY_STRING = "QUERY_STRING";

	private GenericSearchItemAdapter listAdapter = null;
	private List<GenericSearchItem> searchResult = null;
	private String query;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_search);
		Intent intent = getIntent();
		query = intent.getStringExtra(ARG_QUERY_STRING);

		searchResult = new ArrayList<GenericSearchItem>();
		listAdapter = new GenericSearchItemAdapter(