use of uk.co.senab.bitmapcache.CacheableBitmapDrawable in project Talon-for-Twitter by klinker24.
the class NotificationUtils method getIcon.
public static Bitmap getIcon(Context context, int[] unreadCount, String screenname) {
int homeTweets = unreadCount[0];
int mentionsTweets = unreadCount[1];
int dmTweets = unreadCount[2];
boolean customPic = (mentionsTweets == 1 && homeTweets == 0 && dmTweets == 0) || (dmTweets == 1 && homeTweets == 0 && mentionsTweets == 0);
if (screenname != null && customPic) {
BitmapLruCache mCache = App.getInstance(context).getBitmapCache();
Log.v("notifications_talon", "in screenname");
String url;
try {
url = Utils.getTwitter(context, AppSettings.getInstance(context)).showUser(screenname).getBiggerProfileImageURL();
CacheableBitmapDrawable wrapper = mCache.get(url + "_notification");
Log.v("notifications_talon", "got wrapper");
if (wrapper == null) {
Log.v("notifications_talon", "wrapper null");
URL mUrl = new URL(url);
Bitmap image = BitmapFactory.decodeStream(mUrl.openConnection().getInputStream());
image = ImageUtils.notificationResize(context, image);
mCache.put(url + "_notification", image);
return image;
} else {
return wrapper.getBitmap();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_stat_icon);
}
Aggregations