/*
 * This file is part of the Anime Detour Android application
 *
 * Copyright (c) 2015 Anime Twin Cities, Inc.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
package com.animedetour.android.schedule.serach;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.SearchView.OnQueryTextListener;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ListView;
import butterknife.InjectView;
import com.animedetour.android.R;
import com.animedetour.android.schedule.EventViewBinder;
import com.animedetour.android.schedule.PanelView;
import com.animedetour.api.sched.api.model.Event;
import com.inkapplications.android.logger.LogName;
import com.inkapplications.android.widget.listview.ItemAdapter;
import prism.framework.Layout;

import javax.inject.Inject;

/**
 * Search page for quickly finding events.
 *
 * This has a search bar for the user to type in and filters down the events
 * by their search criteria.
 *
 * @author Maxwell Vandervelde (Max@MaxVandervelde.com)
 */
@LogName("Event Search")
@Layout(R.layout.event_search)
final public class EventSearchActivity extends ActionBarActivity
{
    @InjectView(R.id.event_search_action_bar)
    Toolbar actionBar;

    @InjectView(R.id.event_search_bar)
    SearchView searchBar;

    @InjectView(R.id.event_search_results)
    ListView results;

    @InjectView(R.id.search_empty_view)
    View emptyView;

    @Inject
    EventViewBinder viewBinder;

    @Inject
    QueryListenerFactory queryListenerFactory;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        this.setSupportActionBar(this.actionBar);
        this.actionBar.setTitle("");
    }

    @Override
    protected void onStart()
    {
        super.onStart();
        this.searchBar.setIconifiedByDefault(false);
        this.searchBar.requestFocusFromTouch();
        ItemAdapter<PanelView, Event> adapter = new ItemAdapter<>(this.viewBinder);
        this.results.setAdapter(adapter);

        OnQueryTextListener queryListener = this.queryListenerFactory.create(adapter, emptyView);
        this.searchBar.setOnQueryTextListener(queryListener);
    }
}

@@ -517,16 +517,46 @@
 oolbar;%0A
+import android.view.MenuItem;%0A
 import a
@@ -1921,16 +1921,84 @@
 le(%22%22);%0A
+        this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);%0A
     %7D%0A%0A 
@@ -2463,11 +2463,283 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public boolean onOptionsItemSelected(MenuItem item) %7B%0A        switch (item.getItemId()) %7B%0A            case android.R.id.home:%0A                this.finish();%0A                return true;%0A        %7D%0A%0A        return super.onOptionsItemSelected(item);%0A    %7D
 %0A%7D%0A

Add back button to search activity.