package com.uservoice.uservoicesdk.activity;

import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.uservoice.uservoicesdk.R;
import com.uservoice.uservoicesdk.Session;
import com.uservoice.uservoicesdk.babayaga.Babayaga;
import com.uservoice.uservoicesdk.model.Article;
import com.uservoice.uservoicesdk.model.Topic;
import com.uservoice.uservoicesdk.rest.Callback;
import com.uservoice.uservoicesdk.ui.LoadAllAdapter;

public class TopicActivity extends BaseListActivity implements SearchActivity {

    @SuppressLint({"InlinedApi", "NewApi"})
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (hasActionBar()) {
            ActionBar actionBar = getActionBar();
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
            actionBar.setListNavigationCallbacks(new ArrayAdapter<Topic>(this, android.R.layout.simple_spinner_dropdown_item, Session.getInstance().getTopics()) {
                                                     @Override
                                                     public View getView(int position, View convertView, ViewGroup parent) {
                                                         View view = super.getView(position, convertView, parent);
                                                         ((TextView) view).setTextColor(Color.WHITE);
                                                         return view;
                                                     }

                                                     @Override
                                                     public View getDropDownView(int position, View convertView, ViewGroup parent) {
                                                         View view = super.getDropDownView(position, convertView, parent);
                                                         ((TextView) view).setTextColor(Color.WHITE);
                                                         return view;
                                                     }
                                                 }, new ActionBar.OnNavigationListener() {
                                                     @Override
                                                     @SuppressWarnings("unchecked")
                                                     public boolean onNavigationItemSelected(int itemPosition, long itemId) {
                                                         Topic topic = Session.getInstance().getTopics().get(itemPosition);
                                                         Session.getInstance().setTopic(topic);
                                                         ((LoadAllAdapter<Article>) getListAdapter()).reload();
                                                         return true;
                                                     }
                                                 }
            );
            actionBar.setSelectedNavigationItem(Session.getInstance().getTopics().indexOf(Session.getInstance().getTopic()));
        }

        setTitle(null);
        getListView().setDivider(null);
        setListAdapter(new LoadAllAdapter<Article>(this, R.layout.uv_text_item, new ArrayList<Article>()) {
            @Override
            protected void loadPage(int page, Callback<List<Article>> callback) {
                Topic topic = Session.getInstance().getTopic();
                if (topic == Topic.ALL_ARTICLES) {
                    Article.loadAll(callback);
                } else {
                    Article.loadForTopic(topic.getId(), callback);
                }
            }

            @Override
            protected void customizeLayout(View view, Article model) {
                TextView text = (TextView) view.findViewById(R.id.uv_text);
                TextView text2 = (TextView) view.findViewById(R.id.uv_text2);
                text.setText(model.getTitle());
                if (Session.getInstance().getTopic() == Topic.ALL_ARTICLES && model.getTopicName() != null) {
                    text2.setVisibility(View.VISIBLE);
                    text2.setText(model.getTopicName());
                } else {
                    text2.setVisibility(View.GONE);
                }
            }
        });

        getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Article article = (Article) getListAdapter().getItem(position);
                Session.getInstance().setArticle(article);
                startActivity(new Intent(TopicActivity.this, ArticleActivity.class));
            }
        });

        Babayaga.track(Babayaga.Event.VIEW_TOPIC, Session.getInstance().getTopic().getId());
    }

    @Override
    public void hideSearch() {
        super.hideSearch();
        getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.uv_portal, menu);
        setupScopedSearch(menu);
        return true;
    }

    @Override
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
        if (item.getItemId() == R.id.uv_action_contact) {
            startActivity(new Intent(this, ContactActivity.class));
            return true;
        }
        return super.onMenuItemSelected(featureId, item);
    }
}

@@ -196,39 +196,8 @@
 nt;%0A
-import android.graphics.Color;%0A
 impo
@@ -214,24 +214,24 @@
 .os.Bundle;%0A
+
 import andro
@@ -304,39 +304,8 @@
 ew;%0A
-import android.view.ViewGroup;%0A
 impo
@@ -371,16 +371,54 @@
 dapter;%0A
+import android.widget.SpinnerAdapter;%0A
 import a
@@ -1170,1286 +1170,256 @@
     
-actionBar.setListNavigationCallbacks(new ArrayAdapter%3CTopic%3E(this, android.R.layout.simple_spinner_dropdown_item, Session.getInstance().getTopics()) %7B%0A                                                     @Override%0A                                                     public View getView(int position, View convertView, ViewGroup parent) %7B%0A                                                         View view = super.getView(position, convertView, parent);%0A                                                         ((TextView) view).setTextColor(Color.WHITE);%0A                                                         return view;%0A                                                     %7D%0A%0A                                                     @Override%0A                                                     public View getDropDownView(int position, View convertView, ViewGroup parent) %7B%0A                                                         View view = super.getDropDownView(position, convertView, parent);%0A                                                         ((TextView) view).setTextColor(Color.WHITE);%0A                                                         return view;%0A                                                     %7D%0A                                                 %7D
+SpinnerAdapter topicAdapter = new ArrayAdapter%3CTopic%3E(actionBar.getThemedContext(),%0A                    android.R.layout.simple_spinner_dropdown_item, Session.getInstance().getTopics());%0A            actionBar.setListNavigationCallbacks(topicAdapter
 , ne
@@ -1459,45 +1459,8 @@
 ) %7B%0A
-                                     
     
@@ -1485,45 +1485,8 @@
 ide%0A
-                                     
     
@@ -1532,45 +1532,8 @@
 d%22)%0A
-                                     
     
@@ -1641,45 +1641,8 @@
     
-                  
-                   
 Topi
@@ -1708,45 +1708,8 @@
 n);%0A
-                                     
     
@@ -1767,45 +1767,8 @@
 c);%0A
-                                     
     
@@ -1862,176 +1862,52 @@
     
-                                     return true;%0A                                                     %7D%0A                                                 %7D%0A            
+return true;%0A                %7D%0A            %7D
 );%0A 

Remove hardcoded colors for action bar spinner