Back to project page Test-SimpleTwitterClient.
The source code is released under:
This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...
If you think the Android project Test-SimpleTwitterClient listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.Twitter_Android.Fragments.Adapters; /*from w w w .j a v a 2s . co m*/ import android.app.Activity; import android.graphics.Bitmap; import android.preference.PreferenceManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.example.Twitter_Android.AppActivity.SettingsActivity; import com.example.Twitter_Android.AsynkTasks.ImageDownloader; import com.example.Twitter_Android.Logic.DataCache; import com.example.Twitter_Android.Logic.Person; import com.example.Twitter_Android.R; import java.util.List; public class FollowingsListAdapter extends TimelineAdapter<Person> { private final LayoutInflater layoutInflater; private final ImageDownloader imageDownloader; private final DataCache cache; public static final String TAG = "FOLLOWING_LIST_ADAPTER"; private boolean isImagesLoadingAllowed; //------------------------------------------------------------------------------------------------------------------ private static class ViewHolder { TextView name; TextView screenName; TextView from; TextView text; ImageView avatar; } //------------------------------------------------------------------------------------------------------------------ public FollowingsListAdapter(Activity activity, List<Person> persons, String tag) { super(persons, tag); layoutInflater = LayoutInflater.from(activity); imageDownloader = new ImageDownloader(); cache = DataCache.getInstance(); isImagesLoadingAllowed = PreferenceManager.getDefaultSharedPreferences(activity) .getBoolean(SettingsActivity.ALLOW_IMAGE_LOADING, true); } //------------------------------------------------------------------------------------------------------------------ @Override public int getItemViewType(int position) { return 0; } //------------------------------------------------------------------------------------------------------------------ @Override public int getViewTypeCount() { return 1; } @Override public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; final Person person = getItem(position); if (convertView == null) { convertView = layoutInflater.inflate(R.layout.single_friend_layout, null); holder = new ViewHolder(); holder.avatar = (ImageView) convertView.findViewById(R.id.friend_avatar_imageview); holder.name = (TextView) convertView.findViewById(R.id.friend_name_textview); holder.screenName = (TextView) convertView.findViewById(R.id.friend_screen_name_textview); holder.from = (TextView) convertView.findViewById(R.id.friend_from_textview); holder.text = (TextView) convertView.findViewById(R.id.friend_info_textview); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.name.setText(person.getName()); holder.screenName.setText("@" + person.getScreenName()); holder.from.setText("From: " + person.getLocation()); holder.text.setText(person.getDescription()); if (isImagesLoadingAllowed) { Bitmap bitmapAvatar = cache.getImage(person.getProfileImage()); if (bitmapAvatar == null) { imageDownloader.loadBitmap(person.getProfileImage(), holder.avatar); } else { holder.avatar.setImageBitmap(bitmapAvatar); } } return convertView; } //------------------------------------------------------------------------------------------------------------------ @Override public void updateContext(Activity context) { } }