Search in sources :

Example 11 with HoloTextView

use of com.klinker.android.twitter.views.text.HoloTextView in project Talon-for-Twitter by klinker24.

the class MainDrawerArrayAdapter method getView.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    View rowView = convertView;
    String settingName = text.get(position);
    if (rowView == null) {
        LayoutInflater inflater = context.getLayoutInflater();
        rowView = inflater.inflate(R.layout.drawer_list_item, null);
        ViewHolder viewHolder = new ViewHolder();
        viewHolder.name = (HoloTextView) rowView.findViewById(R.id.title);
        viewHolder.icon = (ImageView) rowView.findViewById(R.id.icon);
        rowView.setTag(viewHolder);
    }
    ViewHolder holder = (ViewHolder) rowView.getTag();
    holder.name.setText(settingName);
    holder.name.setTextSize(18);
    try {
        if (text.get(position).equals(context.getResources().getString(R.string.timeline))) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.timelineItem });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getResources().getString(R.string.mentions)) || text.get(position).equals(AppSettings.getInstance(context).secondScreenName)) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.mentionItem });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getResources().getString(R.string.direct_messages))) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.directMessageItem });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getResources().getString(R.string.retweets))) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.retweetButton });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getResources().getString(R.string.favorite_tweets)) || text.get(position).equals(context.getResources().getString(R.string.saved_tweets))) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.favoritedButton });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getResources().getString(R.string.favorite_users)) || text.get(position).equals(context.getString(R.string.favorite_users_tweets))) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.favUser });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getResources().getString(R.string.discover)) || text.get(position).equals(context.getString(R.string.world_trends)) || text.get(position).equals(context.getString(R.string.local_trends))) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.links });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getResources().getString(R.string.search))) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.search_icon });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getResources().getString(R.string.lists))) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.listIcon });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getResources().getString(R.string.saved_searches)) || pageTypes.get(position) == AppSettings.PAGE_TYPE_SAVED_SEARCH) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.search_icon });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getResources().getString(R.string.links))) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.links });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getResources().getString(R.string.pictures))) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.picturePlaceholder });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else if (text.get(position).equals(context.getString(R.string.activity))) {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.notification_button });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        } else {
            TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.listIcon });
            int resource = a.getResourceId(0, 0);
            a.recycle();
            holder.icon.setImageResource(resource);
        }
    } catch (OutOfMemoryError e) {
    }
    if (highlightedCurrent == position) {
        if (!DrawerActivity.settings.addonTheme) {
            holder.icon.setColorFilter(context.getResources().getColor(R.color.app_color));
            holder.name.setTextColor(context.getResources().getColor(R.color.app_color));
        } else {
            holder.icon.setColorFilter(DrawerActivity.settings.accentInt);
            holder.name.setTextColor(DrawerActivity.settings.accentInt);
        }
    } else {
        TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.textColor });
        int resource = a.getResourceId(0, 0);
        holder.icon.setColorFilter(context.getResources().getColor(resource));
        holder.name.setTextColor(context.getResources().getColor(resource));
    }
    return rowView;
}
Also used : LayoutInflater(android.view.LayoutInflater) TypedArray(android.content.res.TypedArray) ImageView(android.widget.ImageView) HoloTextView(com.klinker.android.twitter.views.text.HoloTextView) View(android.view.View)

Aggregations

HoloTextView (com.klinker.android.twitter.views.text.HoloTextView)11 View (android.view.View)6 NetworkedCacheableImageView (com.klinker.android.twitter.views.NetworkedCacheableImageView)6 Handler (android.os.Handler)5 Intent (android.content.Intent)4 TypedArray (android.content.res.TypedArray)3 Point (android.graphics.Point)3 Editable (android.text.Editable)3 TextWatcher (android.text.TextWatcher)3 ViewConfiguration (android.view.ViewConfiguration)3 ImageView (android.widget.ImageView)3 IOException (java.io.IOException)3 Field (java.lang.reflect.Field)3 AsyncListView (org.lucasr.smoothie.AsyncListView)3 BitmapLruCache (uk.co.senab.bitmapcache.BitmapLruCache)3 AlertDialog (android.app.AlertDialog)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 LayoutInflater (android.view.LayoutInflater)2 TextView (android.widget.TextView)2 MainActivity (com.klinker.android.twitter.activities.MainActivity)2