package com.averi.worldscribe.views;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;

import com.averi.worldscribe.Category;
import com.averi.worldscribe.R;
import com.averi.worldscribe.activities.ArticleListActivity;

import com.averi.worldscribe.utilities.IntentFields;
import com.averi.worldscribe.utilities.AttributeGetter;

public class BottomBar extends RelativeLayout {

    private LayoutInflater inflater;
    private BottomBarActivity activity;

    public BottomBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.activity = (BottomBarActivity) context;

        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.activity_bottom_bar, this, true);

        this.findViewById(R.id.peopleButton).setOnClickListener(peopleOnClickListener);
        this.findViewById(R.id.groupsButton).setOnClickListener(groupsOnClickListener);
        this.findViewById(R.id.placesButton).setOnClickListener(placesOnClickListener);
        this.findViewById(R.id.itemsButton).setOnClickListener(itemsOnClickListener);
        this.findViewById(R.id.conceptsButton).setOnClickListener(conceptsOnClickListener);
    }

    private OnClickListener peopleOnClickListener = new OnClickListener() {
        public void onClick(View view) {
            activity.respondToBottomBarButton(Category.Person);
        }
    };

    private OnClickListener groupsOnClickListener = new OnClickListener() {
        public void onClick(View view) {
            activity.respondToBottomBarButton(Category.Group);
        }
    };

    private OnClickListener placesOnClickListener = new OnClickListener() {
        public void onClick(View view) {
            activity.respondToBottomBarButton(Category.Place);
        }
    };

    private OnClickListener itemsOnClickListener = new OnClickListener() {
        public void onClick(View view) {
            activity.respondToBottomBarButton(Category.Item);
        }
    };

    private OnClickListener conceptsOnClickListener = new OnClickListener() {
        public void onClick(View view) {
            activity.respondToBottomBarButton(Category.Concept);
        }
    };

    public void highlightCategoryButton(Context context, Category category) {
        ImageButton categoryButton;

        unhighlightAllButtons(context);

        switch (category) {
            case Person:
                categoryButton = (ImageButton) findViewById(R.id.peopleButton);
                break;
            case Group:
                categoryButton = (ImageButton) findViewById(R.id.groupsButton);
                break;
            case Place:
                categoryButton = (ImageButton) findViewById(R.id.placesButton);
                break;
            case Item:
                categoryButton = (ImageButton) findViewById(R.id.itemsButton);
                break;
            case Concept:
            default:
                categoryButton = (ImageButton) findViewById(R.id.conceptsButton);
        }

        int selectedButtonColor = AttributeGetter.getColorAttribute(context, R.attr.colorPrimaryDark);
        categoryButton.setBackgroundColor(selectedButtonColor);
    }

    /**
     * Changes the background color of all buttons to their normal, unhighlighted color.
     * @param context The Context containing this BottomBar.
     */
    private void unhighlightAllButtons(Context context) {
        int normalButtonColor = AttributeGetter.getColorAttribute(context, R.attr.colorPrimary);
        (findViewById(R.id.peopleButton)).setBackgroundColor(normalButtonColor);
        (findViewById(R.id.groupsButton)).setBackgroundColor(normalButtonColor);
        (findViewById(R.id.placesButton)).setBackgroundColor(normalButtonColor);
        (findViewById(R.id.itemsButton)).setBackgroundColor(normalButtonColor);
        (findViewById(R.id.conceptsButton)).setBackgroundColor(normalButtonColor);
    }

}
@@ -754,16 +754,53 @@
 attrs);%0A
+        if (!(isInEditMode())) %7B%0A    
         
@@ -845,32 +845,36 @@
 ntext;%0A%0A        
+ 
+   
 inflater = (Layo
@@ -944,32 +944,36 @@
 RVICE);%0A        
+    
 inflater.inflate
@@ -1017,32 +1017,36 @@
 true);%0A%0A        
+   
+ 
 this.findViewByI
@@ -1101,32 +1101,36 @@
 ClickListener);%0A
+    
         this.fin
@@ -1193,32 +1193,36 @@
 ClickListener);%0A
+    
         this.fin
@@ -1293,32 +1293,36 @@
 tener);%0A        
+    
 this.findViewByI
@@ -1375,32 +1375,36 @@
 ClickListener);%0A
+    
         this.fin
@@ -1475,24 +1475,34 @@
 kListener);%0A
+        %7D%0A
     %7D%0A%0A    p

Check isInEditMode for BottomBar