package net.tasksnow.view.slidingmenu; import android.app.Fragment; import android.content.Context; import android.graphics.Typeface; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; import net.tasksnow.R; import net.tasksnow.util.ColorUtil; /** * @author LuMa * @since 14:39:56 - 24.03.2013 * @project TasksNow */ public class MenuSubItems extends AbstractMenuItem { // =========================================================== // Constants // =========================================================== public static final int ITEM_TYPE = 2; // =========================================================== // Fields // =========================================================== private final String text; private final String number; private final Fragment execFragment; private Typeface robotoThin; // =========================================================== // Constructors // =========================================================== public MenuSubItems(String text, String number, Fragment execFragment) { this.text = text; this.number = number; this.execFragment = execFragment; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public int getType() { return ITEM_TYPE; } @Override public View getListItemView(View convertView, Context context) { if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.menu_sub_item, null); if (this.robotoThin == null) robotoThin = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Thin.ttf"); TextView numberLabel = (TextView) convertView.findViewById(R.id.number_label); numberLabel.setTypeface(robotoThin); } TextView title = (TextView) convertView.findViewById(R.id.row_title); title.setText(this.text); View selector = convertView.findViewById(R.id.selectionHandler); if (number != null) { TextView numberLabel = (TextView) convertView.findViewById(R.id.number_label); numberLabel.setText(this.number); } if (this.isSelected()) { selector.setVisibility(View.VISIBLE); convertView.setBackgroundColor(ColorUtil.setAlpha(ColorUtil.darkerColor(R.color.menuselector_background), 95)); } else { selector.setVisibility(View.INVISIBLE); convertView.setBackgroundDrawable(null);//TODO } return convertView; } @Override public Object onExecuteAction() { this.setSelected(true); return this.execFragment; } // =========================================================== // Methods // =========================================================== // =========================================================== // Getter & Setter // =========================================================== public String getText() { return this.text; } // =========================================================== // Inner and Anonymous Classes // =========================================================== }