|
62 | 62 | import com.mogujie.tt.widget.MessageOperatePopup; |
63 | 63 | import com.mogujie.tt.widget.SpeekerToast; |
64 | 64 | import com.mogujie.widget.imageview.MGWebImageView; |
| 65 | +import com.nostra13.universalimageloader.core.ImageLoader; |
| 66 | +import com.nostra13.universalimageloader.core.assist.FailReason; |
| 67 | +import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener; |
65 | 68 | import com.squareup.picasso.Picasso.LoadedFrom; |
66 | 69 |
|
67 | 70 | /** |
@@ -510,7 +513,7 @@ public void onClick(View arg0) { |
510 | 513 | logger.d("debug#pic#found failed receiving image message"); |
511 | 514 | updateItemState(info.msgId, SysConstant.MESSAGE_STATE_UNLOAD); |
512 | 515 | } |
513 | | - |
| 516 | + |
514 | 517 | int menuType = getMenuType(info); |
515 | 518 | if (menuType > 0) { |
516 | 519 | // logger.d("debug#showMenu MessageInfo:%s", info); |
@@ -1191,13 +1194,15 @@ private void downLoadImage(MessageInfo messageInfo) { |
1191 | 1194 |
|
1192 | 1195 | final MessageInfo messageInfoFinal = messageInfo; |
1193 | 1196 |
|
1194 | | - MGWebImageView.fetchBitmap(context, smallImageUrl, new MGWebImageView.TargetCallback() { |
1195 | | - @Override |
1196 | | - public void onPrepareLoad(Drawable placeHolderDrawable) { |
1197 | | - } |
| 1197 | + ImageLoader.getInstance().loadImage(smallImageUrl, null, null, new SimpleImageLoadingListener() { |
| 1198 | + //message_image |
1198 | 1199 |
|
1199 | 1200 | @Override |
1200 | | - public void onBitmapLoaded(Bitmap bitmap, LoadedFrom from) { |
| 1201 | + public void onLoadingComplete(String imageUri, View view, |
| 1202 | + Bitmap bitmap) { |
| 1203 | + logger.d("chat#pic#icon onLoadingComplete"); |
| 1204 | + //holder.image.setImageBitmap(loadedImage); |
| 1205 | + |
1201 | 1206 | logger.d("chat#pic#onBitmapLoaded"); |
1202 | 1207 | String smallImagePath = CommonUtil.getMd5Path(smallImageUrl, SysConstant.FILE_SAVE_TYPE_IMAGE); |
1203 | 1208 | File myFile = new File(smallImagePath); |
@@ -1233,13 +1238,66 @@ public void onBitmapLoaded(Bitmap bitmap, LoadedFrom from) { |
1233 | 1238 | } |
1234 | 1239 |
|
1235 | 1240 | @Override |
1236 | | - public void onBitmapFailed(Drawable errorDrawable) { |
| 1241 | + public void onLoadingFailed(String imageUri, View view, |
| 1242 | + FailReason failReason) { |
| 1243 | + logger.d("chat#pic#icon onLoadingFailed"); |
| 1244 | + |
1237 | 1245 | logger.d("chat#pic#onBitmapFailed"); |
1238 | 1246 | updateMessageState(messageInfoFinal, SysConstant.MESSAGE_STATE_FINISH_FAILED); |
1239 | 1247 | logger.d("download failed"); |
1240 | 1248 | } |
| 1249 | + |
1241 | 1250 | }); |
1242 | 1251 |
|
| 1252 | + // MGWebImageView.fetchBitmap(context, smallImageUrl, new MGWebImageView.TargetCallback() { |
| 1253 | + // @Override |
| 1254 | + // public void onPrepareLoad(Drawable placeHolderDrawable) { |
| 1255 | + // } |
| 1256 | + // |
| 1257 | + // @Override |
| 1258 | + // public void onBitmapLoaded(Bitmap bitmap, LoadedFrom from) { |
| 1259 | + // logger.d("chat#pic#onBitmapLoaded"); |
| 1260 | + // String smallImagePath = CommonUtil.getMd5Path(smallImageUrl, SysConstant.FILE_SAVE_TYPE_IMAGE); |
| 1261 | + // File myFile = new File(smallImagePath); |
| 1262 | + // if (myFile.exists()) { |
| 1263 | + // logger.d("chat#pic#image already exists, no need to save"); |
| 1264 | + // return; |
| 1265 | + // } |
| 1266 | + // BufferedOutputStream bos = null; |
| 1267 | + // try { |
| 1268 | + // if (null != bitmap) { |
| 1269 | + // FileOutputStream fout = new FileOutputStream(myFile); |
| 1270 | + // bos = new BufferedOutputStream(fout); |
| 1271 | + // bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos); |
| 1272 | + // bos.flush(); |
| 1273 | + // bos.close(); |
| 1274 | + // bos = null; |
| 1275 | + // logger.d("chat#pic#save image ok"); |
| 1276 | + // updateMessageState(messageInfoFinal, SysConstant.MESSAGE_STATE_FINISH_SUCCESSED); |
| 1277 | + // } |
| 1278 | + // } catch (Exception e) { |
| 1279 | + // logger.e("chat#pic#downloading image got exception:%s", e.getMessage()); |
| 1280 | + // } finally { |
| 1281 | + // try { |
| 1282 | + // if (null != bos) { |
| 1283 | + // bos.flush(); |
| 1284 | + // bos.close(); |
| 1285 | + // } |
| 1286 | + // } catch (IOException e) { |
| 1287 | + // e.printStackTrace(); |
| 1288 | + // |
| 1289 | + // } |
| 1290 | + // } |
| 1291 | + // } |
| 1292 | + // |
| 1293 | + // @Override |
| 1294 | + // public void onBitmapFailed(Drawable errorDrawable) { |
| 1295 | + // logger.d("chat#pic#onBitmapFailed"); |
| 1296 | + // updateMessageState(messageInfoFinal, SysConstant.MESSAGE_STATE_FINISH_FAILED); |
| 1297 | + // logger.d("download failed"); |
| 1298 | + // } |
| 1299 | + // }); |
| 1300 | + |
1243 | 1301 | } catch (Exception e) { |
1244 | 1302 | logger.e(e.getMessage()); |
1245 | 1303 | } |
|
0 commit comments