From 85bc7046bbf1064f1d527d5ea0fb8c314940196d Mon Sep 17 00:00:00 2001 From: DrKLO Date: Thu, 26 Feb 2015 17:36:15 +0300 Subject: [PATCH] Crash fixes --- TMessagesProj/build.gradle | 4 ++-- .../org/telegram/android/SecretChatHelper.java | 6 +++++- .../ui/ActionBar/ActionBarPopupWindow.java | 6 +++++- .../java/org/telegram/ui/Cells/DialogCell.java | 17 +++++++++++------ .../main/java/org/telegram/ui/ChatActivity.java | 6 +++++- .../ui/Components/ChatActivityEnterView.java | 6 +++++- .../telegram/ui/Components/PhotoFilterView.java | 2 +- .../java/org/telegram/ui/PasscodeActivity.java | 2 +- .../java/org/telegram/ui/SettingsActivity.java | 12 +++++++----- .../org/telegram/ui/WallpapersActivity.java | 4 +++- 10 files changed, 45 insertions(+), 20 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 7ecb86372..fe29254bb 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -82,7 +82,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 21 - versionCode 453 - versionName "2.5.0" + versionCode 454 + versionName "2.5.1" } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java b/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java index 1cc95296d..e9d672fc0 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java @@ -1777,6 +1777,10 @@ public class SecretChatHelper { } } }); - progressDialog.show(); + try { + progressDialog.show(); + } catch (Exception e) { + //don't promt + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarPopupWindow.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarPopupWindow.java index e67c9c640..4d3831a56 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarPopupWindow.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarPopupWindow.java @@ -200,7 +200,11 @@ public class ActionBarPopupWindow extends PopupWindow { @Override public void dismiss() { setFocusable(false); - super.dismiss(); + try { + super.dismiss(); + } catch (Exception e) { + //don't promt + } unregisterListener(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index 4c74c471a..9858f39cf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -603,14 +603,19 @@ public class DialogCell extends BaseCell { public void checkCurrentDialogIndex() { TLRPC.TL_dialog dialog = null; if (isServerOnly) { - dialog = MessagesController.getInstance().dialogsServerOnly.get(index); + if (index < MessagesController.getInstance().dialogsServerOnly.size()) { + dialog = MessagesController.getInstance().dialogsServerOnly.get(index); + } } else { - dialog = MessagesController.getInstance().dialogs.get(index); + if (index < MessagesController.getInstance().dialogs.size()) { + dialog = MessagesController.getInstance().dialogs.get(index); + } } - boolean update = true; - if (currentDialogId != dialog.id || message != null && message.messageOwner.id != dialog.top_message || unreadCount != dialog.unread_count) { - currentDialogId = dialog.id; - update(0); + if (dialog != null) { + if (currentDialogId != dialog.id || message != null && message.messageOwner.id != dialog.top_message || unreadCount != dialog.unread_count) { + currentDialogId = dialog.id; + update(0); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index adbcd76d9..cc10f3dd0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -1307,7 +1307,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not progressView.setLayoutParams(layoutParams3); ProgressBar progressBar = new ProgressBar(getParentActivity()); - progressBar.setIndeterminateDrawable(getParentActivity().getResources().getDrawable(R.drawable.loading_animation)); + try { + progressBar.setIndeterminateDrawable(getParentActivity().getResources().getDrawable(R.drawable.loading_animation)); + } catch (Exception e) { + //don't promt + } progressBar.setIndeterminate(true); AndroidUtilities.setProgressBarAnimationDuration(progressBar, 1500); progressView.addView(progressBar); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index 7c8a41843..dbf865a97 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -854,7 +854,11 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles); } if (emojiPopup != null) { - emojiPopup.dismiss(); + try { + emojiPopup.dismiss(); + } catch (Exception e) { + //don't promt + } } if (sizeNotifierRelativeLayout != null) { sizeNotifierRelativeLayout.post(new Runnable() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java index 5730ea768..140b4e248 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java @@ -1446,7 +1446,7 @@ public class PhotoFilterView extends FrameLayout { } public Bitmap getBitmap() { - return eglThread.getTexture(); + return eglThread != null ? eglThread.getTexture() : null; } private void fixLayout(int viewWidth, int viewHeight) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java index 2394d61b2..a0548ca3a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java @@ -488,7 +488,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter filterArray[0] = new InputFilter.LengthFilter(4); passwordEditText.setFilters(filterArray); passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE); - passwordEditText.setKeyListener(DigitsKeyListener.getInstance("123456789")); + passwordEditText.setKeyListener(DigitsKeyListener.getInstance("1234567890")); } else if (type == 1 && currentPasswordType == 1 || type == 2 && UserConfig.passcodeType == 1) { passwordEditText.setFilters(new InputFilter[0]); passwordEditText.setKeyListener(null); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java index b51761320..b09173af0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java @@ -972,13 +972,15 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } AvatarDrawable avatarDrawable = new AvatarDrawable(user, true); avatarDrawable.setColor(0xff5c98cd); - avatarImage.setImage(photo, "50_50", avatarDrawable); - avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); + if (avatarImage != null) { + avatarImage.setImage(photo, "50_50", avatarDrawable); + avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); - nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name)); - onlineTextView.setText(LocaleController.getString("Online", R.string.Online)); + nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name)); + onlineTextView.setText(LocaleController.getString("Online", R.string.Online)); - avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); + avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); + } } private void sendLogs() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java index 935cba2a7..9ac605040 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java @@ -419,7 +419,9 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent wallPapers.add((TLRPC.WallPaper)obj); wallpappersByIds.put(((TLRPC.WallPaper)obj).id, (TLRPC.WallPaper)obj); } - listAdapter.notifyDataSetChanged(); + if (listAdapter != null) { + listAdapter.notifyDataSetChanged(); + } if (backgroundImage != null) { processSelectedBackground(); }