KeyboardTabView.java 4.06 KB
package com.bitstrips.imoji.keyboard;

import android.content.Context;
import android.content.res.Resources;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import java.util.ArrayList;
import java.util.List;

public class KeyboardTabView
  extends LinearLayout
  implements ViewPager.OnPageChangeListener, View.OnClickListener
{
  private ViewPager a;
  private List<ImageButton> b;
  private OnKeyboardTabButtonPress c;
  
  public KeyboardTabView(Context paramContext)
  {
    super(paramContext);
    setUp(paramContext);
  }
  
  public KeyboardTabView(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    setUp(paramContext);
  }
  
  public KeyboardTabView(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    setUp(paramContext);
  }
  
  private void setFocus(int paramInt)
  {
    int j = 0;
    if (j < 7)
    {
      int i;
      if (j == 0) {
        if (paramInt == j) {
          i = 2130837748;
        }
      }
      for (;;)
      {
        ((ImageButton)this.b.get(j)).setImageResource(i);
        j += 1;
        break;
        i = 2130837747;
        continue;
        if (paramInt == j) {
          i = getDrawableIdFromName("tab_" + (j - 1) + "_sel");
        } else {
          i = getDrawableIdFromName("tab_" + (j - 1));
        }
      }
    }
  }
  
  private void setUp(Context paramContext)
  {
    setOrientation(0);
    setBackgroundColor(getResources().getColor(2131624039));
    this.b = new ArrayList();
    paramContext = (LayoutInflater)paramContext.getSystemService("layout_inflater");
    int i = 0;
    while (i < 7)
    {
      ImageButton localImageButton = (ImageButton)paramContext.inflate(2130903175, null);
      localImageButton.setTag(Integer.valueOf(i));
      localImageButton.setOnClickListener(this);
      this.b.add(localImageButton);
      addButton(localImageButton);
      i += 1;
    }
    setFocus(0);
  }
  
  public void addButton(ImageButton paramImageButton)
  {
    addView(paramImageButton);
    LinearLayout.LayoutParams localLayoutParams = (LinearLayout.LayoutParams)paramImageButton.getLayoutParams();
    localLayoutParams.weight = 1.0F;
    localLayoutParams.width = 0;
    paramImageButton.setLayoutParams(localLayoutParams);
  }
  
  public void changeIcon(int paramInt1, int paramInt2)
  {
    ((ImageButton)this.b.get(paramInt1)).setImageResource(paramInt2);
  }
  
  public int getDrawableIdFromName(String paramString)
  {
    return getContext().getResources().getIdentifier(paramString, "drawable", getContext().getPackageName());
  }
  
  public void onClick(View paramView)
  {
    if (this.a == null) {}
    int i;
    do
    {
      return;
      i = ((Integer)paramView.getTag()).intValue();
      if (this.a.getCurrentItem() == i) {
        setFocus(i);
      }
      this.a.setCurrentItem(i, true);
    } while (this.c == null);
    this.c.onPress(i, (ImageButton)paramView);
  }
  
  public void onPageScrollStateChanged(int paramInt) {}
  
  public void onPageScrolled(int paramInt1, float paramFloat, int paramInt2) {}
  
  public void onPageSelected(int paramInt)
  {
    setFocus(paramInt);
  }
  
  public void setTabButtonPress(OnKeyboardTabButtonPress paramOnKeyboardTabButtonPress)
  {
    this.c = paramOnKeyboardTabButtonPress;
  }
  
  public void setupWithViewPager(ViewPager paramViewPager)
  {
    this.a = paramViewPager;
    this.a.setOnPageChangeListener(this);
  }
  
  public static abstract interface OnKeyboardTabButtonPress
  {
    public abstract void onPress(int paramInt, ImageButton paramImageButton);
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/keyboard/KeyboardTabView.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */