use of com.juns.wechat.chat.ShowBigImage in project wechat by motianhuo.
the class MessageAdapter method showImageView.
/**
* load image into image view
*
* @param thumbernailPath
* @param iv
* @param position
* @return the image exists or not
*/
private boolean showImageView(final String thumbernailPath, final ImageView iv, final String localFullSizePath, String remoteDir, final EMMessage message) {
// String imagename =
// localFullSizePath.substring(localFullSizePath.lastIndexOf("/") + 1,
// localFullSizePath.length());
// final String remote = remoteDir != null ? remoteDir+imagename :
// imagename;
final String remote = remoteDir;
EMLog.d("###", "local = " + localFullSizePath + " remote: " + remote);
// first check if the thumbnail image already loaded into cache
Bitmap bitmap = ImageCache.getInstance().get(thumbernailPath);
if (bitmap != null) {
// thumbnail image is already loaded, reuse the drawable
iv.setImageBitmap(bitmap);
iv.setClickable(true);
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO 查看大图
System.err.println("image view on click");
Intent intent = new Intent(activity, ShowBigImage.class);
File file = new File(localFullSizePath);
if (file.exists()) {
Uri uri = Uri.fromFile(file);
intent.putExtra("uri", uri);
System.err.println("here need to check why download everytime");
} else {
// The local full size pic does not exist yet.
// ShowBigImage needs to download it from the server
// first
// intent.putExtra("", message.get);
ImageMessageBody body = (ImageMessageBody) message.getBody();
intent.putExtra("secret", body.getSecret());
intent.putExtra("remotepath", remote);
}
if (message != null && message.direct == EMMessage.Direct.RECEIVE && !message.isAcked && message.getChatType() != ChatType.GroupChat) {
try {
EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
message.isAcked = true;
} catch (Exception e) {
e.printStackTrace();
}
}
activity.startActivity(intent);
}
});
return true;
} else {
new LoadImageTask().execute(thumbernailPath, localFullSizePath, remote, message.getChatType(), iv, activity, message);
return true;
}
}
Aggregations