mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Fixed null pointer exceptions
This commit is contained in:
parent
0aea8f1532
commit
2f191225b7
5 changed files with 48 additions and 11 deletions
|
@ -82,7 +82,7 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 8
|
minSdkVersion 8
|
||||||
targetSdkVersion 19
|
targetSdkVersion 19
|
||||||
versionCode 225
|
versionCode 226
|
||||||
versionName "1.4.10"
|
versionName "1.4.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,6 +376,9 @@ public class MessageObject {
|
||||||
}
|
}
|
||||||
} else if (attach instanceof TLRPC.PhotoSize) {
|
} else if (attach instanceof TLRPC.PhotoSize) {
|
||||||
TLRPC.PhotoSize photo = (TLRPC.PhotoSize)attach;
|
TLRPC.PhotoSize photo = (TLRPC.PhotoSize)attach;
|
||||||
|
if (photo.location == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return photo.location.volume_id + "_" + photo.location.local_id + ".jpg";
|
return photo.location.volume_id + "_" + photo.location.local_id + ".jpg";
|
||||||
} else if (attach instanceof TLRPC.Audio) {
|
} else if (attach instanceof TLRPC.Audio) {
|
||||||
TLRPC.Audio audio = (TLRPC.Audio)attach;
|
TLRPC.Audio audio = (TLRPC.Audio)attach;
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
private int photoWidth;
|
private int photoWidth;
|
||||||
private int photoHeight;
|
private int photoHeight;
|
||||||
private PhotoObject currentPhotoObject;
|
private PhotoObject currentPhotoObject;
|
||||||
|
private String currentUrl;
|
||||||
private String currentPhotoFilter;
|
private String currentPhotoFilter;
|
||||||
private ImageReceiver photoImage;
|
private ImageReceiver photoImage;
|
||||||
private ProgressView progressView;
|
private ProgressView progressView;
|
||||||
|
@ -274,19 +275,33 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private boolean isPhotoDataChanged(MessageObject object) {
|
||||||
protected boolean isUserDataChanged() {
|
if (object.type == 4) {
|
||||||
return currentPhotoObject == null || super.isUserDataChanged();
|
if (currentUrl == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
double lat = object.messageOwner.media.geo.lat;
|
||||||
|
double lon = object.messageOwner.media.geo._long;
|
||||||
|
String url = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int)Math.ceil(Utilities.density)), lat, lon);
|
||||||
|
if (!url.equals(currentUrl)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (currentPhotoObject == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMessageObject(MessageObject messageObject) {
|
public void setMessageObject(MessageObject messageObject) {
|
||||||
if (currentMessageObject != messageObject || isUserDataChanged()) {
|
if (currentMessageObject != messageObject || isPhotoDataChanged(messageObject) || isUserDataChanged()) {
|
||||||
super.setMessageObject(messageObject);
|
super.setMessageObject(messageObject);
|
||||||
|
|
||||||
progressVisible = false;
|
progressVisible = false;
|
||||||
buttonState = -1;
|
buttonState = -1;
|
||||||
gifDrawable = null;
|
gifDrawable = null;
|
||||||
|
currentPhotoObject = null;
|
||||||
|
currentUrl = null;
|
||||||
|
|
||||||
if (messageObject.type == 8) {
|
if (messageObject.type == 8) {
|
||||||
gifDrawable = MediaController.getInstance().getGifDrawable(this, false);
|
gifDrawable = MediaController.getInstance().getGifDrawable(this, false);
|
||||||
|
@ -321,8 +336,8 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
|
|
||||||
double lat = messageObject.messageOwner.media.geo.lat;
|
double lat = messageObject.messageOwner.media.geo.lat;
|
||||||
double lon = messageObject.messageOwner.media.geo._long;
|
double lon = messageObject.messageOwner.media.geo._long;
|
||||||
String url = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int)Math.ceil(Utilities.density)), lat, lon);
|
currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int)Math.ceil(Utilities.density)), lat, lon);
|
||||||
photoImage.setImage(url, null, messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable);
|
photoImage.setImage(currentUrl, null, messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable);
|
||||||
} else {
|
} else {
|
||||||
photoWidth = (int) (Math.min(Utilities.displaySize.x, Utilities.displaySize.y) * 0.7f);
|
photoWidth = (int) (Math.min(Utilities.displaySize.x, Utilities.displaySize.y) * 0.7f);
|
||||||
photoHeight = photoWidth + Utilities.dp(100);
|
photoHeight = photoWidth + Utilities.dp(100);
|
||||||
|
|
|
@ -1468,13 +1468,21 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||||
TLRPC.FileLocation newPhoto = null;
|
TLRPC.FileLocation newPhoto = null;
|
||||||
int placeHolderId = 0;
|
int placeHolderId = 0;
|
||||||
if (currentUser != null) {
|
if (currentUser != null) {
|
||||||
currentUser = MessagesController.getInstance().users.get(currentUser.id);
|
TLRPC.User user = MessagesController.getInstance().users.get(currentUser.id);
|
||||||
|
if (user == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
currentUser = user;
|
||||||
if (currentUser.photo != null) {
|
if (currentUser.photo != null) {
|
||||||
newPhoto = currentUser.photo.photo_small;
|
newPhoto = currentUser.photo.photo_small;
|
||||||
}
|
}
|
||||||
placeHolderId = Utilities.getUserAvatarForId(currentUser.id);
|
placeHolderId = Utilities.getUserAvatarForId(currentUser.id);
|
||||||
} else if (currentChat != null) {
|
} else if (currentChat != null) {
|
||||||
currentChat = MessagesController.getInstance().chats.get(currentChat.id);
|
TLRPC.Chat chat = MessagesController.getInstance().chats.get(currentChat.id);
|
||||||
|
if (chat == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
currentChat = chat;
|
||||||
if (currentChat.photo != null) {
|
if (currentChat.photo != null) {
|
||||||
newPhoto = currentChat.photo.photo_small;
|
newPhoto = currentChat.photo.photo_small;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,6 +172,14 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
|
||||||
timeTextView.setVisibility(View.INVISIBLE);
|
timeTextView.setVisibility(View.INVISIBLE);
|
||||||
localPagerAdapter = new LocalPagerAdapter(arr);
|
localPagerAdapter = new LocalPagerAdapter(arr);
|
||||||
} else if (messagesArr != null) {
|
} else if (messagesArr != null) {
|
||||||
|
MessageObject object = null;
|
||||||
|
for (MessageObject messageObject : messagesArr) {
|
||||||
|
if (messageObject.messageOwner.dialog_id != 0 || messageObject.messageOwner.to_id != null) {
|
||||||
|
object = messageObject;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<MessageObject> imagesArr = new ArrayList<MessageObject>();
|
ArrayList<MessageObject> imagesArr = new ArrayList<MessageObject>();
|
||||||
HashMap<Integer, MessageObject> imagesByIds = new HashMap<Integer, MessageObject>();
|
HashMap<Integer, MessageObject> imagesByIds = new HashMap<Integer, MessageObject>();
|
||||||
imagesArr.addAll(messagesArr);
|
imagesArr.addAll(messagesArr);
|
||||||
|
@ -181,10 +189,13 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
|
||||||
}
|
}
|
||||||
index = imagesArr.size() - index - 1;
|
index = imagesArr.size() - index - 1;
|
||||||
|
|
||||||
MessageObject object = imagesArr.get(0);
|
|
||||||
if (object.messageOwner.dialog_id != 0) {
|
if (object.messageOwner.dialog_id != 0) {
|
||||||
currentDialog = object.messageOwner.dialog_id;
|
currentDialog = object.messageOwner.dialog_id;
|
||||||
} else {
|
} else {
|
||||||
|
if (object.messageOwner.to_id == null) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
if (object.messageOwner.to_id.chat_id != 0) {
|
if (object.messageOwner.to_id.chat_id != 0) {
|
||||||
currentDialog = -object.messageOwner.to_id.chat_id;
|
currentDialog = -object.messageOwner.to_id.chat_id;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue