// Path: app/src/main/java/uk/ac/horizon/artcodes/adapter/ExperienceAdapter.java
// public abstract class ExperienceAdapter extends GridAdapter<ExperienceCardBinding> implements LoadCallback<List<String>>
// {
// 	final ArtcodeServer server;
// 
// 	ExperienceAdapter(Context context, final ArtcodeServer server)
// 	{
// 		super(context);
// 		this.server = server;
// 	}
// 
// 	@Override
// 	public void bind(final int position, final ExperienceCardBinding binding)
// 	{
// 		final Experience experience = getExperience(position);
// 		binding.setExperience(experience);
// 		binding.getRoot().setOnClickListener(v -> ExperienceActivity.start(context, experience));
// 		binding.scanButton.setOnClickListener(v -> ArtcodeActivity.start(context, experience));
// 	}
// 
// 	protected abstract Experience getExperience(int position);
// 
// 	@Override
// 	public ExperienceCardBinding createBinding(final ViewGroup parent, final int viewType)
// 	{
// 		return ExperienceCardBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
// 	}
// 
// 	@Override
// 	public void error(Throwable e)
// 	{
// 		loadFinished();
// 		showError(context.getString(R.string.connection_error));
// 	}
// }
// 
// Path: app/src/main/java/uk/ac/horizon/artcodes/adapter/ExperienceListAdapter.java
// public class ExperienceListAdapter extends ExperienceAdapter
// {
// 	private final SparseArray<Experience> experiences = new SparseArray<>();
// 
// 	public ExperienceListAdapter(Context context, ArtcodeServer server)
// 	{
// 		super(context, server);
// 	}
// 
// 	@Override
// 	public int getViewCount()
// 	{
// 		return experiences.size();
// 	}
// 
// 	@Override
// 	public Experience getExperience(final int position)
// 	{
// 		return experiences.valueAt(position);
// 	}
// 
// 	@Override
// 	public void loaded(final List<String> item)
// 	{
// 		experiences.clear();
// 		adapter.notifyDataSetChanged();
// 		showEmpty();
// 		for (int index = 0; index < item.size(); index++)
// 		{
// 			final int experienceIndex = index;
// 			final String uri = item.get(index);
// 			loadStarted();
// 			server.loadExperience(uri, new LoadCallback<Experience>()
// 			{
// 				@Override
// 				public void loaded(Experience item)
// 				{
// 					loadFinished();
// 					experiences.put(experienceIndex, item);
// 					adapter.notifyItemInserted(experiences.indexOfValue(item));
// 				}
// 
// 				@Override
// 				public void error(Throwable e)
// 				{
// 					showError(context.getString(R.string.connection_error));
// 					loadFinished();
// 				}
// 			});
// 		}
// 		loadFinished();
// 	}
// }


import android.os.Bundle;
import androidx.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import uk.ac.horizon.artcodes.R;
import uk.ac.horizon.artcodes.adapter.ExperienceAdapter;
import uk.ac.horizon.artcodes.adapter.ExperienceListAdapter;
import uk.ac.horizon.artcodes.databinding.ListBinding;
	@Override
	public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
	{
		final ListBinding binding = ListBinding.inflate(inflater, container, false);
		adapter = new ExperienceListAdapter(getActivity(), getServer());
		adapter.setEmptyIcon(R.drawable.ic_search_144dp);
		binding.setAdapter(adapter);
		return binding.getRoot();
	}

	@Override
	public void onResume()
	{
		super.onResume();
		if (getArguments() != null)
		{
			String query = getArguments().getString("query");
			if (query != null)
			{
				search(query);
			}
		}
		//getActivity().setTitle(R.string.nav_recent);
	}

	public void search(String query)
	{
		if (query != null)
		{
			final String queryString = query.trim();
// Path: app/src/main/java/uk/ac/horizon/artcodes/adapter/ExperienceAdapter.java
// public abstract class ExperienceAdapter extends GridAdapter<ExperienceCardBinding> implements LoadCallback<List<String>>
// {
// 	final ArtcodeServer server;
// 
// 	ExperienceAdapter(Context context, final ArtcodeServer server)
// 	{
// 		super(context);
// 		this.server = server;
// 	}
// 
// 	@Override
// 	public void bind(final int position, final ExperienceCardBinding binding)
// 	{
// 		final Experience experience = getExperience(position);
// 		binding.setExperience(experience);
// 		binding.getRoot().setOnClickListener(v -> ExperienceActivity.start(context, experience));
// 		binding.scanButton.setOnClickListener(v -> ArtcodeActivity.start(context, experience));
// 	}
// 
// 	protected abstract Experience getExperience(int position);
// 
// 	@Override
// 	public ExperienceCardBinding createBinding(final ViewGroup parent, final int viewType)
// 	{
// 		return ExperienceCardBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
// 	}
// 
// 	@Override
// 	public void error(Throwable e)
// 	{
// 		loadFinished();
// 		showError(context.getString(R.string.connection_error));
// 	}
// }
// 
// Path: app/src/main/java/uk/ac/horizon/artcodes/adapter/ExperienceListAdapter.java
// public class ExperienceListAdapter extends ExperienceAdapter
// {
// 	private final SparseArray<Experience> experiences = new SparseArray<>();
// 
// 	public ExperienceListAdapter(Context context, ArtcodeServer server)
// 	{
// 		super(context, server);
// 	}
// 
// 	@Override
// 	public int getViewCount()
// 	{
// 		return experiences.size();
// 	}
// 
// 	@Override
// 	public Experience getExperience(final int position)
// 	{
// 		return experiences.valueAt(position);
// 	}
// 
// 	@Override
// 	public void loaded(final List<String> item)
// 	{
// 		experiences.clear();
// 		adapter.notifyDataSetChanged();
// 		showEmpty();
// 		for (int index = 0; index < item.size(); index++)
// 		{
// 			final int experienceIndex = index;
// 			final String uri = item.get(index);
// 			loadStarted();
// 			server.loadExperience(uri, new LoadCallback<Experience>()
// 			{
// 				@Override
// 				public void loaded(Experience item)
// 				{
// 					loadFinished();
// 					experiences.put(experienceIndex, item);
// 					adapter.notifyItemInserted(experiences.indexOfValue(item));
// 				}
// 
// 				@Override
// 				public void error(Throwable e)
// 				{
// 					showError(context.getString(R.string.connection_error));
// 					loadFinished();
// 				}
// 			});
// 		}
// 		loadFinished();
// 	}
// }


// Path: app/src/main/java/uk/ac/horizon/artcodes/fragment/ExperienceSearchFragment.java
import android.os.Bundle;
import androidx.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import uk.ac.horizon.artcodes.R;
import uk.ac.horizon.artcodes.adapter.ExperienceAdapter;
import uk.ac.horizon.artcodes.adapter.ExperienceListAdapter;
import uk.ac.horizon.artcodes.databinding.ListBinding;

	@Override
	public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
	{
		final ListBinding binding = ListBinding.inflate(inflater, container, false);
		adapter = new ExperienceListAdapter(getActivity(), getServer());
		adapter.setEmptyIcon(R.drawable.ic_search_144dp);
		binding.setAdapter(adapter);
		return binding.getRoot();
	}

	@Override
	public void onResume()
	{
		super.onResume();
		if (getArguments() != null)
		{
			String query = getArguments().getString("query");
			if (query != null)
			{
				search(query);
			}
		}
		//getActivity().setTitle(R.string.nav_recent);
	}

	public void search(String query)
	{
		if (query != null)
		{
			final String queryString = query.trim();
			if (!queryString.isEmpty() && (this.query == null || !this.query.equals(queryString)))