在Recycleview中更新图片
我正在使用chatapp,当用户在Recycleview中单击imageview时,我正在将图像下载到本地存储中,然后尝试重新加载毕加索,然后Recycleview跳到了另一个位置。
注意:根据我的研发,我了解Imageview在重新加载时需要重点关注。我不确定,请让我了解在特定位置在Recycleview中重新加载图像的最佳方法是什么,而不会像whatsapp如何在下载的单击时在聊天屏幕中加载图像那样。
我正在使用以下方法更新特定位置。
notifyItemChanged(position);
如果我尝试使用以下方法重新加载,那么没问题,但是从 URI
加载时可能会出现OOM(内存不足) messageImageView.setImageURI(Uri.fromFile(fileImage));
messageImageView.setImageResource(R.drawable.icn_conv_clicktodownload);
问题案例:
Picasso.get().load(fileImage).resize(viewWidth, viewHeight).
centerCrop().into(messageImageView);
答案 0 :(得分:0)
尝试一下...从此链接引用的答案。.here
import tensorflow as tf
with tf.Graph().as_default(), tf.Session() as sess:
x = tf.constant([[1., 0., 0., 2., 1., 0., 1.],
[0., 0., 0., 1., 0., 0., 0.],
[2., 0., 2., 1., 1., 3., 0.]], tf.float32)
x_sum = tf.reduce_sum(x, axis=1)
x_count = tf.cast(tf.count_nonzero(x, axis=1), x.dtype)
# Using maximum avoids problems when all elements are zero
out = x_sum / tf.maximum(x_count, 1)
print(sess.run(out))
# [1.25 1. 1.8 ]