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;
}
Aggregations