use of uk.co.senab.bitmapcache.CacheableBitmapDrawable in project Talon-for-Twitter by klinker24.
the class CursorListLoader method loadItem.
@Override
public CacheableBitmapDrawable loadItem(String url) {
CacheableBitmapDrawable wrapper = mCache.get(url);
if (wrapper == null) {
try {
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
InputStream is = new BufferedInputStream(conn.getInputStream());
Bitmap image = decodeSampledBitmapFromResourceMemOpt(is, 500, 500);
try {
is.close();
} catch (Exception e) {
}
try {
conn.disconnect();
} catch (Exception e) {
}
if (circleImages) {
image = ImageUtils.getCircle(image, context);
}
wrapper = mCache.put(url, image);
} catch (Exception e) {
}
}
return wrapper;
}
use of uk.co.senab.bitmapcache.CacheableBitmapDrawable in project Talon-for-Twitter by klinker24.
the class TimelineArrayAdapter method bindView.
public void bindView(final View view, Status status, int position) {
final ViewHolder holder = (ViewHolder) view.getTag();
if (holder.expandArea.getVisibility() == View.VISIBLE) {
removeExpansionNoAnimation(holder);
}
Status thisStatus;
String retweeter;
final long time = status.getCreatedAt().getTime();
long originalTime = 0;
if (status.isRetweet()) {
retweeter = status.getUser().getScreenName();
thisStatus = status.getRetweetedStatus();
originalTime = thisStatus.getCreatedAt().getTime();
} else {
retweeter = "";
thisStatus = status;
}
final long fOriginalTime = originalTime;
User user = thisStatus.getUser();
holder.tweetId = thisStatus.getId();
final long id = holder.tweetId;
final String profilePic = user.getOriginalProfileImageURL();
String tweetTexts = thisStatus.getText();
final String name = user.getName();
final String screenname = user.getScreenName();
String[] html = TweetLinkUtils.getLinksInStatus(thisStatus);
final String tweetText = html[0];
final String picUrl = html[1];
holder.picUrl = picUrl;
final String otherUrl = html[2];
final String hashtags = html[3];
final String users = html[4];
final boolean inAConversation = thisStatus.getInReplyToStatusId() != -1;
holder.gifUrl = TweetLinkUtils.getGIFUrl(status, otherUrl);
if (holder.isAConversation != null) {
if (inAConversation) {
if (holder.isAConversation.getVisibility() != View.VISIBLE) {
holder.isAConversation.setVisibility(View.VISIBLE);
}
} else {
if (holder.isAConversation.getVisibility() != View.GONE) {
holder.isAConversation.setVisibility(View.GONE);
}
}
}
if (!settings.reverseClickActions) {
final String fRetweeter = retweeter;
holder.background.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
String link;
boolean hasGif = holder.gifUrl != null && !holder.gifUrl.isEmpty();
boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube") && !(hasGif);
if (displayPic) {
link = holder.picUrl;
} else {
link = otherUrl.split(" ")[0];
}
Log.v("tweet_page", "clicked");
Intent viewTweet = new Intent(context, TweetPager.class);
viewTweet.putExtra("name", name);
viewTweet.putExtra("screenname", screenname);
viewTweet.putExtra("time", time);
viewTweet.putExtra("tweet", tweetText);
viewTweet.putExtra("retweeter", fRetweeter);
viewTweet.putExtra("webpage", link);
viewTweet.putExtra("other_links", otherUrl);
viewTweet.putExtra("picture", displayPic);
viewTweet.putExtra("tweetid", holder.tweetId);
viewTweet.putExtra("proPic", profilePic);
viewTweet.putExtra("users", users);
viewTweet.putExtra("hashtags", hashtags);
viewTweet.putExtra("animated_gif", holder.gifUrl);
context.startActivity(viewTweet);
return true;
}
});
holder.background.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (holder.preventNextClick) {
holder.preventNextClick = false;
return;
}
if (holder.expandArea.getVisibility() == View.GONE) {
addExpansion(holder, screenname, users, otherUrl.split(" "), holder.picUrl, id);
} else {
removeExpansionWithAnimation(holder);
removeKeyboard(holder);
}
}
});
} else {
final String fRetweeter = retweeter;
holder.background.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (holder.preventNextClick) {
holder.preventNextClick = false;
return;
}
String link;
boolean hasGif = holder.gifUrl != null && !holder.gifUrl.isEmpty();
boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube") && !(hasGif);
if (displayPic) {
link = holder.picUrl;
} else {
link = otherUrl.split(" ")[0];
}
Log.v("tweet_page", "clicked");
Intent viewTweet = new Intent(context, TweetPager.class);
viewTweet.putExtra("name", name);
viewTweet.putExtra("screenname", screenname);
viewTweet.putExtra("time", time);
viewTweet.putExtra("tweet", tweetText);
viewTweet.putExtra("retweeter", fRetweeter);
viewTweet.putExtra("webpage", link);
viewTweet.putExtra("other_links", otherUrl);
viewTweet.putExtra("picture", displayPic);
viewTweet.putExtra("tweetid", holder.tweetId);
viewTweet.putExtra("proPic", profilePic);
viewTweet.putExtra("users", users);
viewTweet.putExtra("hashtags", hashtags);
viewTweet.putExtra("animated_gif", holder.gifUrl);
context.startActivity(viewTweet);
}
});
holder.background.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
if (holder.expandArea.getVisibility() == View.GONE) {
addExpansion(holder, screenname, users, otherUrl.split(" "), holder.picUrl, id);
} else {
removeExpansionWithAnimation(holder);
removeKeyboard(holder);
}
return true;
}
});
}
if (!screenname.equals(username)) {
holder.profilePic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent viewProfile = new Intent(context, ProfilePager.class);
viewProfile.putExtra("name", name);
viewProfile.putExtra("screenname", screenname);
viewProfile.putExtra("proPic", profilePic);
viewProfile.putExtra("tweetid", holder.tweetId);
viewProfile.putExtra("retweet", holder.retweeter.getVisibility() == View.VISIBLE);
viewProfile.putExtra("long_click", false);
context.startActivity(viewProfile);
}
});
holder.profilePic.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
Intent viewProfile = new Intent(context, ProfilePager.class);
viewProfile.putExtra("name", name);
viewProfile.putExtra("screenname", screenname);
viewProfile.putExtra("proPic", profilePic);
viewProfile.putExtra("tweetid", holder.tweetId);
viewProfile.putExtra("retweet", holder.retweeter.getVisibility() == View.VISIBLE);
viewProfile.putExtra("long_click", true);
context.startActivity(viewProfile);
return false;
}
});
} else {
// need to clear the click listener so it isn't left over from another profile
holder.profilePic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
holder.profilePic.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
return true;
}
});
}
if (talonLayout == AppSettings.LAYOUT_FULL_SCREEN || (settings.nameAndHandleOnTweet && settings.addonTheme)) {
if (holder.screenTV.getVisibility() == View.GONE) {
holder.screenTV.setVisibility(View.VISIBLE);
}
holder.screenTV.setText("@" + screenname);
holder.name.setText(name);
} else {
if (!settings.showBoth) {
holder.name.setText(settings.displayScreenName ? "@" + screenname : name);
} else {
if (holder.screenTV.getVisibility() == View.GONE) {
holder.screenTV.setVisibility(View.VISIBLE);
}
holder.name.setText(name);
holder.screenTV.setText("@" + screenname);
}
}
if (!settings.absoluteDate) {
holder.time.setText(Utils.getTimeAgo(time, context));
} else {
Date date = new Date(time);
holder.time.setText(timeFormatter.format(date).replace("24:", "00:") + ", " + dateFormatter.format(date));
}
holder.tweet.setText(tweetText);
boolean picture = false;
if (settings.inlinePics) {
if (holder.picUrl.equals("")) {
if (holder.image.getVisibility() != View.GONE) {
holder.image.setVisibility(View.GONE);
}
if (holder.playButton.getVisibility() == View.VISIBLE) {
holder.playButton.setVisibility(View.GONE);
}
} else {
if (holder.picUrl.contains("youtube") || (holder.gifUrl != null && !android.text.TextUtils.isEmpty(holder.gifUrl))) {
if (holder.playButton.getVisibility() == View.GONE) {
holder.playButton.setVisibility(View.VISIBLE);
}
final String fRetweeter = retweeter;
holder.image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String link;
boolean hasGif = holder.gifUrl != null && !holder.gifUrl.isEmpty();
boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube") && !(hasGif);
if (displayPic) {
link = holder.picUrl;
} else {
link = otherUrl.split(" ")[0];
}
Intent viewTweet = new Intent(context, TweetPager.class);
viewTweet.putExtra("name", name);
viewTweet.putExtra("screenname", screenname);
viewTweet.putExtra("time", time);
viewTweet.putExtra("tweet", tweetText);
viewTweet.putExtra("retweeter", fRetweeter);
viewTweet.putExtra("webpage", link);
viewTweet.putExtra("other_links", otherUrl);
viewTweet.putExtra("picture", displayPic);
viewTweet.putExtra("tweetid", holder.tweetId);
viewTweet.putExtra("proPic", profilePic);
viewTweet.putExtra("users", users);
viewTweet.putExtra("hashtags", hashtags);
viewTweet.putExtra("clicked_youtube", true);
viewTweet.putExtra("animated_gif", holder.gifUrl);
context.startActivity(viewTweet);
}
});
holder.image.setImageDrawable(transparent);
picture = true;
} else {
holder.image.setImageDrawable(transparent);
picture = true;
if (holder.playButton.getVisibility() == View.VISIBLE) {
holder.playButton.setVisibility(View.GONE);
}
holder.image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (holder.picUrl.contains(" ")) {
context.startActivity(new Intent(context, ViewPictures.class).putExtra("pictures", holder.picUrl));
} else {
context.startActivity(new Intent(context, PhotoViewerActivity.class).putExtra("url", holder.picUrl));
}
}
});
}
if (holder.image.getVisibility() == View.GONE) {
holder.image.setVisibility(View.VISIBLE);
}
}
}
if (type == NORMAL) {
if (retweeter.length() > 0) {
holder.retweeter.setText(context.getResources().getString(R.string.retweeter) + retweeter);
holder.retweeterName = retweeter;
holder.retweeter.setVisibility(View.VISIBLE);
} else if (holder.retweeter.getVisibility() == View.VISIBLE) {
holder.retweeter.setVisibility(View.GONE);
}
} else if (type == RETWEET) {
int count = status.getRetweetCount();
if (count > 1) {
holder.retweeter.setText(status.getRetweetCount() + " " + context.getResources().getString(R.string.retweets_lower));
holder.retweeter.setVisibility(View.VISIBLE);
} else if (count == 1) {
holder.retweeter.setText(status.getRetweetCount() + " " + context.getResources().getString(R.string.retweet_lower));
holder.retweeter.setVisibility(View.VISIBLE);
}
}
if (picture) {
CacheableBitmapDrawable wrapper = mCache.getFromMemoryCache(holder.picUrl);
if (wrapper != null) {
holder.image.setImageDrawable(wrapper);
picture = false;
}
}
final boolean hasPicture = picture;
mHandler[currHandler].removeCallbacksAndMessages(null);
mHandler[currHandler].postDelayed(new Runnable() {
@Override
public void run() {
if (holder.tweetId == id) {
if (hasPicture) {
loadImage(context, holder, holder.picUrl, mCache, id);
}
if (settings.useEmoji && (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || EmojiUtils.ios)) {
String text = holder.tweet.getText().toString();
if (EmojiUtils.emojiPattern.matcher(text).find()) {
final Spannable span = EmojiUtils.getSmiledText(context, Html.fromHtml(tweetText));
holder.tweet.setText(span);
}
}
holder.tweet.setSoundEffectsEnabled(false);
holder.tweet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!TouchableMovementMethod.touched) {
// absorbs the click on the background
if (!holder.preventNextClick) {
holder.background.getBackground().setState(new int[] { android.R.attr.state_pressed });
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
holder.background.getBackground().setState(new int[] { android.R.attr.state_empty });
}
}, 25);
}
holder.background.performClick();
}
}
});
holder.tweet.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
if (!TouchableMovementMethod.touched) {
holder.background.performLongClick();
holder.preventNextClick = true;
}
return false;
}
});
if (holder.retweeter.getVisibility() == View.VISIBLE) {
holder.retweeter.setSoundEffectsEnabled(false);
holder.retweeter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!TouchableMovementMethod.touched) {
if (!holder.preventNextClick) {
holder.background.getBackground().setState(new int[] { android.R.attr.state_pressed });
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
holder.background.getBackground().setState(new int[] { android.R.attr.state_empty });
}
}, 25);
}
holder.background.performClick();
}
}
});
holder.retweeter.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
if (!TouchableMovementMethod.touched) {
holder.background.performLongClick();
holder.preventNextClick = true;
}
return false;
}
});
}
TextUtils.linkifyText(context, holder.tweet, holder.background, true, otherUrl, false);
TextUtils.linkifyText(context, holder.retweeter, holder.background, true, "", false);
}
}
}, 400);
currHandler++;
if (currHandler == 10) {
currHandler = 0;
}
if (openFirst && position == 0) {
holder.background.performClick();
}
}
use of uk.co.senab.bitmapcache.CacheableBitmapDrawable in project Talon-for-Twitter by klinker24.
the class PicturesGridAdapter method getView.
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.picture, null);
AbsListView.LayoutParams params = new AbsListView.LayoutParams(gridWidth, gridWidth);
convertView.setLayoutParams(params);
ViewHolder holder = new ViewHolder();
holder.iv = (NetworkedCacheableImageView) convertView.findViewById(R.id.picture);
convertView.setTag(holder);
}
final ViewHolder holder = (ViewHolder) convertView.getTag();
Status status = statuses.get(position);
String url = text.get(position);
Status thisStatus;
String retweeter;
final long time = status.getCreatedAt().getTime();
long originalTime = 0;
if (status.isRetweet()) {
retweeter = status.getUser().getScreenName();
thisStatus = status.getRetweetedStatus();
originalTime = thisStatus.getCreatedAt().getTime();
} else {
retweeter = "";
thisStatus = status;
}
final String fRetweeter = retweeter;
final long fOriginalTime = originalTime;
User user = thisStatus.getUser();
final long id = thisStatus.getId();
final String profilePic = user.getBiggerProfileImageURL();
String tweetTexts = thisStatus.getText();
final String name = user.getName();
final String screenname = user.getScreenName();
String[] html = TweetLinkUtils.getLinksInStatus(thisStatus);
final String tweetText = html[0];
final String picUrl = html[1];
final String otherUrl = html[2];
final String hashtags = html[3];
final String users = html[4];
if (url.contains(" ")) {
url = url.split(" ")[0];
}
holder.url = url;
holder.iv.loadImage(url, false, new NetworkedCacheableImageView.OnImageLoadedListener() {
@Override
public void onImageLoaded(CacheableBitmapDrawable result) {
holder.iv.setBackgroundDrawable(null);
}
});
holder.iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setPics();
Intent viewImage = new Intent(context, PhotoPagerActivity.class);
viewImage.putExtra("url", pics);
viewImage.putExtra("start_page", position);
context.startActivity(viewImage);
}
});
holder.iv.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
String link;
boolean displayPic = !picUrl.equals("");
if (displayPic) {
link = picUrl;
} else {
link = otherUrl.split(" ")[0];
}
Log.v("tweet_page", "clicked");
Intent viewTweet = new Intent(context, TweetPager.class);
viewTweet.putExtra("name", name);
viewTweet.putExtra("screenname", screenname);
viewTweet.putExtra("time", time);
viewTweet.putExtra("tweet", tweetText);
viewTweet.putExtra("retweeter", fRetweeter);
viewTweet.putExtra("webpage", link);
viewTweet.putExtra("other_links", otherUrl);
viewTweet.putExtra("picture", displayPic);
viewTweet.putExtra("tweetid", id);
viewTweet.putExtra("proPic", profilePic);
viewTweet.putExtra("users", users);
viewTweet.putExtra("hashtags", hashtags);
context.startActivity(viewTweet);
return false;
}
});
return convertView;
}
use of uk.co.senab.bitmapcache.CacheableBitmapDrawable in project Talon-for-Twitter by klinker24.
the class PicturesArrayAdapter method bindView.
public void bindView(final View view, Context mContext, final String url) {
final ViewHolder holder = (ViewHolder) view.getTag();
holder.iv.loadImage(url, false, new NetworkedCacheableImageView.OnImageLoadedListener() {
@Override
public void onImageLoaded(CacheableBitmapDrawable result) {
holder.iv.setBackgroundDrawable(null);
}
});
holder.iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent viewImage = new Intent(context, PhotoViewerActivity.class);
viewImage.putExtra("url", url);
context.startActivity(viewImage);
}
});
}
use of uk.co.senab.bitmapcache.CacheableBitmapDrawable in project Talon-for-Twitter by klinker24.
the class PicturesArrayAdapter method bindView.
public void bindView(final View view, Context mContext, final String url, final Status status) {
final ViewHolder holder = (ViewHolder) view.getTag();
Log.v("talon_picture", "text: " + status.getText());
Status thisStatus;
String retweeter;
final long time = status.getCreatedAt().getTime();
long originalTime = 0;
if (status.isRetweet()) {
retweeter = status.getUser().getScreenName();
thisStatus = status.getRetweetedStatus();
originalTime = thisStatus.getCreatedAt().getTime();
} else {
retweeter = "";
thisStatus = status;
}
final String fRetweeter = retweeter;
final long fOriginalTime = originalTime;
User user = thisStatus.getUser();
final long id = thisStatus.getId();
final String profilePic = user.getBiggerProfileImageURL();
String tweetTexts = thisStatus.getText();
final String name = user.getName();
final String screenname = user.getScreenName();
String[] html = TweetLinkUtils.getLinksInStatus(thisStatus);
final String tweetText = html[0];
final String picUrl = html[1];
final String otherUrl = html[2];
final String hashtags = html[3];
final String users = html[4];
holder.url = url;
holder.iv.loadImage(url, false, new NetworkedCacheableImageView.OnImageLoadedListener() {
@Override
public void onImageLoaded(CacheableBitmapDrawable result) {
holder.iv.setBackgroundDrawable(null);
}
});
holder.iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String link;
boolean displayPic = !picUrl.equals("");
if (displayPic) {
link = picUrl;
} else {
link = otherUrl.split(" ")[0];
}
Log.v("tweet_page", "clicked");
Intent viewTweet = new Intent(context, TweetPager.class);
viewTweet.putExtra("name", name);
viewTweet.putExtra("screenname", screenname);
viewTweet.putExtra("time", time);
viewTweet.putExtra("tweet", tweetText);
viewTweet.putExtra("retweeter", fRetweeter);
viewTweet.putExtra("webpage", link);
viewTweet.putExtra("other_links", otherUrl);
viewTweet.putExtra("picture", displayPic);
viewTweet.putExtra("tweetid", id);
viewTweet.putExtra("proPic", profilePic);
viewTweet.putExtra("users", users);
viewTweet.putExtra("hashtags", hashtags);
context.startActivity(viewTweet);
}
});
}
Aggregations