Fix scroll with image chat

This commit is contained in:
Margaux Clerc 2015-09-03 11:44:12 +02:00
parent b3da0fac2e
commit 21ff92cb9f
5 changed files with 31 additions and 31 deletions

View file

@ -12,16 +12,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageView
android:id="@+id/image"
android:visibility="gone"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxWidth="250dp"
android:maxHeight="250dp" />
<ImageView
android:id="@+id/image"
android:visibility="gone"
android:layout_width="150dp"
android:layout_height="150dp"
android:scaleType="center"
android:maxWidth="250dp"
android:maxHeight="250dp" />
<Button
android:id="@+id/download"

View file

@ -32,14 +32,15 @@
android:textColor="@android:color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/image"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="250dp"
android:maxHeight="250dp" />
<ImageView
android:id="@+id/image"
android:visibility="gone"
android:layout_width="150dp"
android:layout_height="150dp"
android:scaleType="center"
android:maxWidth="250dp"
android:maxHeight="250dp" />
<Button
android:id="@+id/download"

View file

@ -17,9 +17,9 @@
<ImageView
android:id="@+id/image"
android:visibility="gone"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="150dp"
android:layout_height="150dp"
android:scaleType="center"
android:maxWidth="250dp"
android:maxHeight="250dp" />

View file

@ -19,9 +19,9 @@
<ImageView
android:id="@+id/image"
android:visibility="gone"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="150dp"
android:layout_height="150dp"
android:scaleType="center"
android:maxWidth="250dp"
android:maxHeight="250dp" />

View file

@ -105,6 +105,7 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
private Context mContext;
private static final int SIZE_MAX = 512;
private ProgressBar spinner;
private Bitmap defaultBitmap;
@SuppressLint("InflateParams")
public BubbleChat(final Context context, LinphoneChatMessage message) {
@ -122,6 +123,8 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
view.setBackgroundResource(R.drawable.chat_bubble_incoming);
}
defaultBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.chat_photo_default);
view.setId(message.getStorageId());
spinner = (ProgressBar) view.findViewById(R.id.spinner);
@ -133,7 +136,8 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
ImageView imageView = (ImageView) view.findViewById(R.id.image);
String appData = message.getAppData();
if (appData == null || (! LinphoneManager.getInstance().isMessagePending(nativeMessage) && appData.contains(context.getString(R.string.temp_photo_name_with_date).split("%s")[0]))) {
if (appData == null || (!LinphoneManager.getInstance().isMessagePending(nativeMessage) &&
!nativeMessage.isOutgoing() && appData.contains(context.getString(R.string.temp_photo_name_with_date).split("%s")[0]))) {
LinphoneManager.addListener(this);
download.setVisibility(View.VISIBLE);
download.setOnClickListener(new OnClickListener() {
@ -313,7 +317,6 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
public void loadBitmap(String path, ImageView imageView) {
if (cancelPotentialWork(path, imageView)) {
BitmapWorkerTask task = new BitmapWorkerTask(imageView);
Bitmap defaultBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.chat_photo_default);
final AsyncBitmap asyncBitmap = new AsyncBitmap(mContext.getResources(), defaultBitmap, task);
imageView.setImageDrawable(asyncBitmap);
task.execute(path);
@ -350,11 +353,7 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
}
if (bm != null) {
if (bm.getWidth() >= bm.getHeight() && bm.getWidth() > SIZE_MAX) {
bm = ThumbnailUtils.extractThumbnail(bm, SIZE_MAX, (SIZE_MAX * bm.getHeight()) / bm.getWidth());
} else if (bm.getHeight() >= bm.getWidth() && bm.getHeight() > SIZE_MAX) {
bm = ThumbnailUtils.extractThumbnail(bm, (SIZE_MAX * bm.getWidth()) / bm.getHeight(), SIZE_MAX);
}
bm = ThumbnailUtils.extractThumbnail(bm, SIZE_MAX, SIZE_MAX);
}
return bm;
}
@ -371,6 +370,7 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
if (this == bitmapWorkerTask && imageView != null) {
imageView.setImageBitmap(bitmap);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setTag(path);
imageView.setOnClickListener(new OnClickListener() {
@Override