Fix scroll with image chat
This commit is contained in:
parent
b3da0fac2e
commit
21ff92cb9f
5 changed files with 31 additions and 31 deletions
|
@ -12,16 +12,15 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:adjustViewBounds="true"
|
android:layout_width="150dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="150dp"
|
||||||
android:layout_height="wrap_content"
|
android:scaleType="center"
|
||||||
android:layout_weight="1"
|
android:maxWidth="250dp"
|
||||||
android:maxWidth="250dp"
|
android:maxHeight="250dp" />
|
||||||
android:maxHeight="250dp" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/download"
|
android:id="@+id/download"
|
||||||
|
|
|
@ -32,14 +32,15 @@
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:adjustViewBounds="true"
|
android:visibility="gone"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="150dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="150dp"
|
||||||
android:maxWidth="250dp"
|
android:scaleType="center"
|
||||||
android:maxHeight="250dp" />
|
android:maxWidth="250dp"
|
||||||
|
android:maxHeight="250dp" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/download"
|
android:id="@+id/download"
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:adjustViewBounds="true"
|
android:layout_width="150dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="150dp"
|
||||||
android:layout_height="wrap_content"
|
android:scaleType="center"
|
||||||
android:maxWidth="250dp"
|
android:maxWidth="250dp"
|
||||||
android:maxHeight="250dp" />
|
android:maxHeight="250dp" />
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:adjustViewBounds="true"
|
android:layout_width="150dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="150dp"
|
||||||
android:layout_height="wrap_content"
|
android:scaleType="center"
|
||||||
android:maxWidth="250dp"
|
android:maxWidth="250dp"
|
||||||
android:maxHeight="250dp" />
|
android:maxHeight="250dp" />
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private static final int SIZE_MAX = 512;
|
private static final int SIZE_MAX = 512;
|
||||||
private ProgressBar spinner;
|
private ProgressBar spinner;
|
||||||
|
private Bitmap defaultBitmap;
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
public BubbleChat(final Context context, LinphoneChatMessage message) {
|
public BubbleChat(final Context context, LinphoneChatMessage message) {
|
||||||
|
@ -122,6 +123,8 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
view.setBackgroundResource(R.drawable.chat_bubble_incoming);
|
view.setBackgroundResource(R.drawable.chat_bubble_incoming);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defaultBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.chat_photo_default);
|
||||||
|
|
||||||
view.setId(message.getStorageId());
|
view.setId(message.getStorageId());
|
||||||
|
|
||||||
spinner = (ProgressBar) view.findViewById(R.id.spinner);
|
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);
|
ImageView imageView = (ImageView) view.findViewById(R.id.image);
|
||||||
|
|
||||||
String appData = message.getAppData();
|
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);
|
LinphoneManager.addListener(this);
|
||||||
download.setVisibility(View.VISIBLE);
|
download.setVisibility(View.VISIBLE);
|
||||||
download.setOnClickListener(new OnClickListener() {
|
download.setOnClickListener(new OnClickListener() {
|
||||||
|
@ -313,7 +317,6 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
public void loadBitmap(String path, ImageView imageView) {
|
public void loadBitmap(String path, ImageView imageView) {
|
||||||
if (cancelPotentialWork(path, imageView)) {
|
if (cancelPotentialWork(path, imageView)) {
|
||||||
BitmapWorkerTask task = new BitmapWorkerTask(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);
|
final AsyncBitmap asyncBitmap = new AsyncBitmap(mContext.getResources(), defaultBitmap, task);
|
||||||
imageView.setImageDrawable(asyncBitmap);
|
imageView.setImageDrawable(asyncBitmap);
|
||||||
task.execute(path);
|
task.execute(path);
|
||||||
|
@ -350,11 +353,7 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bm != null) {
|
if (bm != null) {
|
||||||
if (bm.getWidth() >= bm.getHeight() && bm.getWidth() > SIZE_MAX) {
|
bm = ThumbnailUtils.extractThumbnail(bm, SIZE_MAX, 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return bm;
|
return bm;
|
||||||
}
|
}
|
||||||
|
@ -371,6 +370,7 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
|
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
|
||||||
if (this == bitmapWorkerTask && imageView != null) {
|
if (this == bitmapWorkerTask && imageView != null) {
|
||||||
imageView.setImageBitmap(bitmap);
|
imageView.setImageBitmap(bitmap);
|
||||||
|
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||||
imageView.setTag(path);
|
imageView.setTag(path);
|
||||||
imageView.setOnClickListener(new OnClickListener() {
|
imageView.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue