Photo viewer bug fixes

This commit is contained in:
DrKLO 2014-06-11 04:22:42 +04:00
parent 512aeaf2bb
commit db64b2f698
8 changed files with 64 additions and 7 deletions

View file

@ -61,6 +61,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
private ProgressView progressView; private ProgressView progressView;
public int downloadPhotos = 0; public int downloadPhotos = 0;
private boolean progressVisible = false; private boolean progressVisible = false;
private boolean photoNotSet = false;
private int TAG; private int TAG;
@ -290,6 +291,12 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
} }
} else if (currentPhotoObject == null) { } else if (currentPhotoObject == null) {
return true; return true;
} else if (currentPhotoObject != null && photoNotSet) {
String fileName = MessageObject.getAttachFileName(currentPhotoObject.photoOwner);
File cacheFile = new File(Utilities.getCacheDir(), fileName);
if (cacheFile.exists()) {
return true;
}
} }
return false; return false;
} }
@ -304,6 +311,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
gifDrawable = null; gifDrawable = null;
currentPhotoObject = null; currentPhotoObject = null;
currentUrl = null; currentUrl = null;
photoNotSet = false;
if (messageObject.type == 8) { if (messageObject.type == 8) {
gifDrawable = MediaController.getInstance().getGifDrawable(this, false); gifDrawable = MediaController.getInstance().getGifDrawable(this, false);
@ -405,6 +413,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable, currentPhotoObject.photoOwner.size); photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable, currentPhotoObject.photoOwner.size);
} }
} else { } else {
photoNotSet = true;
if (messageObject.imagePreview != null) { if (messageObject.imagePreview != null) {
photoImage.setImageBitmap(messageObject.imagePreview); photoImage.setImageBitmap(messageObject.imagePreview);
} else { } else {
@ -597,6 +606,9 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
if (currentMessageObject.type == 8 && lastDownloadedGifMessage != null && lastDownloadedGifMessage.messageOwner.id == currentMessageObject.messageOwner.id && buttonState == 2) { if (currentMessageObject.type == 8 && lastDownloadedGifMessage != null && lastDownloadedGifMessage.messageOwner.id == currentMessageObject.messageOwner.id && buttonState == 2) {
didPressedButton(); didPressedButton();
} }
if (photoNotSet) {
setMessageObject(currentMessageObject);
}
} }
@Override @Override

View file

@ -3371,6 +3371,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
return null; return null;
} }
@Override
public void willHidePhotoViewer() {
updateVisibleRows();
}
private class ChatAdapter extends BaseAdapter { private class ChatAdapter extends BaseAdapter {
private Context mContext; private Context mContext;

View file

@ -367,6 +367,11 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
return null; return null;
} }
@Override
public void willHidePhotoViewer() {
}
public void didReceivedNotification(int id, Object... args) { public void didReceivedNotification(int id, Object... args) {
if (id == MessagesController.updateInterfaces) { if (id == MessagesController.updateInterfaces) {
int mask = (Integer)args[0]; int mask = (Integer)args[0];

View file

@ -293,8 +293,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
} }
} }
return null; return null;
// NotificationCenter.getInstance().addToMemCache(54, messages); TODO }
// NotificationCenter.getInstance().addToMemCache(55, i);
@Override
public void willHidePhotoViewer() {
} }

View file

@ -199,7 +199,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
public static interface PhotoViewerProvider { public static interface PhotoViewerProvider {
public abstract PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation); public PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation);
public void willHidePhotoViewer();
} }
private static class FrameLayoutTouchListener extends FrameLayout { private static class FrameLayoutTouchListener extends FrameLayout {
@ -737,17 +738,30 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(message.messageOwner.action.photo.sizes, 800, 800); TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(message.messageOwner.action.photo.sizes, 800, 800);
if (sizeFull != null) { if (sizeFull != null) {
size[0] = sizeFull.size; size[0] = sizeFull.size;
if (size[0] == 0) {
size[0] = -1;
}
return sizeFull.location; return sizeFull.location;
} else {
size[0] = -1;
} }
} }
} else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && message.messageOwner.media.photo != null) { } else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && message.messageOwner.media.photo != null) {
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, 800, 800); TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, 800, 800);
if (sizeFull != null) { if (sizeFull != null) {
size[0] = sizeFull.size; size[0] = sizeFull.size;
if (size[0] == 0) {
size[0] = -1;
}
return sizeFull.location; return sizeFull.location;
} else {
size[0] = -1;
} }
} else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaVideo && message.messageOwner.media.video != null && message.messageOwner.media.video.thumb != null) { } else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaVideo && message.messageOwner.media.video != null && message.messageOwner.media.video.thumb != null) {
size[0] = message.messageOwner.media.video.thumb.size; size[0] = message.messageOwner.media.video.thumb.size;
if (size[0] == 0) {
size[0] = -1;
}
return message.messageOwner.media.video.thumb.location; return message.messageOwner.media.video.thumb.location;
} }
} }
@ -1088,7 +1102,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, size[0]); imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, size[0]);
} else { } else {
imageReceiver.setImageBitmap((Bitmap)null); imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
} }
} else { } else {
Bitmap placeHolder = null; Bitmap placeHolder = null;
@ -1101,7 +1115,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, size[0]); imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, size[0]);
} }
} else { } else {
imageReceiver.setImageBitmap((Bitmap)null); if (size[0] == 0) {
imageReceiver.setImageBitmap((Bitmap) null);
} else {
imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
}
} }
} }
@ -1357,11 +1375,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
private void onPhotoClosed(PlaceProviderObject object) { private void onPhotoClosed(PlaceProviderObject object) {
placeProvider = null; disableShowCheck = true;
currentMessageObject = null; currentMessageObject = null;
currentFileLocation = null; currentFileLocation = null;
currentThumb = null; currentThumb = null;
animatingImageView.setImageBitmap(null);
centerImage.setImageBitmap((Bitmap)null); centerImage.setImageBitmap((Bitmap)null);
leftImage.setImageBitmap((Bitmap) null); leftImage.setImageBitmap((Bitmap) null);
rightImage.setImageBitmap((Bitmap)null); rightImage.setImageBitmap((Bitmap)null);
@ -1371,10 +1388,16 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
containerView.post(new Runnable() { containerView.post(new Runnable() {
@Override @Override
public void run() { public void run() {
animatingImageView.setImageBitmap(null);
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.removeView(containerView); wm.removeView(containerView);
} }
}); });
if (placeProvider != null) {
placeProvider.willHidePhotoViewer();
}
placeProvider = null;
disableShowCheck = false;
} }
public boolean isVisible() { public boolean isVisible() {

View file

@ -444,6 +444,11 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
return null; return null;
} }
@Override
public void willHidePhotoViewer() {
}
public void performAskAQuestion() { public void performAskAQuestion() {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
int uid = preferences.getInt("support_id", 0); int uid = preferences.getInt("support_id", 0);

View file

@ -485,6 +485,11 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
return null; return null;
} }
@Override
public void willHidePhotoViewer() {
}
private void createActionBarMenu() { private void createActionBarMenu() {
ActionBarMenu menu = actionBarLayer.createMenu(); ActionBarMenu menu = actionBarLayer.createMenu();
menu.clearItems(); menu.clearItems();

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B