Skip to content

Commit 7855560

Browse files
committed
[TF][FIX] fix memory leaks
1 parent 6ace02d commit 7855560

12 files changed

Lines changed: 16 additions & 9 deletions

TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ public void run() {
14631463
image = MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, opts);
14641464
}
14651465
}
1466-
if (image == null) {
1466+
if (!mediaIsVideo && image == null) {
14671467
if (image == null) {
14681468
FileInputStream is;
14691469
if (secureDocumentKey != null) {

TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogsRequestedEmptyCell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected void onAttachedToWindow() {
134134
@Override
135135
protected void onDetachedFromWindow() {
136136
super.onDetachedFromWindow();
137-
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.diceStickersDidLoad);
137+
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.diceStickersDidLoad);
138138
}
139139

140140
@Override

TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ public void onFragmentDestroy() {
419419
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
420420
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetNewWallpapper);
421421
notificationsLocker.unlock();
422+
Bulletin.removeDelegate(this);
422423
}
423424

424425
private void updateEmptyPlaceholder() {

TMessagesProj/src/main/java/org/telegram/ui/ChannelColorActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ public void onFragmentDestroy() {
269269
getNotificationCenter().removeObserver(this, NotificationCenter.boostByChannelCreated);
270270
getNotificationCenter().removeObserver(this, NotificationCenter.chatWasBoostedByUser);
271271
getNotificationCenter().removeObserver(this, NotificationCenter.dialogDeleted);
272+
Bulletin.removeDelegate(this);
272273
}
273274

274275
public ChannelColorActivity(long dialogId) {

TMessagesProj/src/main/java/org/telegram/ui/ChatBackgroundDrawable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public void onAttachedToWindow(View view) {
256256
}
257257

258258
public void onDetachedFromWindow(View view) {
259-
if (!attachedViews.contains(view)) {
259+
if (attachedViews.contains(view)) {
260260
attachedViews.remove(view);
261261
}
262262
if (isAttached() && !attached) {

TMessagesProj/src/main/java/org/telegram/ui/Components/MediaActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.telegram.ui.ActionBar.SimpleTextView;
5454
import org.telegram.ui.ActionBar.Theme;
5555
import org.telegram.ui.ActionBar.ThemeDescription;
56+
import org.telegram.ui.Components.Bulletin;
5657
import org.telegram.ui.Components.FloatingDebug.FloatingDebugController;
5758
import org.telegram.ui.Components.FloatingDebug.FloatingDebugProvider;
5859
import org.telegram.ui.Components.Paint.ShapeDetector;
@@ -147,6 +148,9 @@ public void onFragmentDestroy() {
147148
getNotificationCenter().removeObserver(this, NotificationCenter.userInfoDidLoad);
148149
getNotificationCenter().removeObserver(this, NotificationCenter.currentUserPremiumStatusChanged);
149150
getNotificationCenter().removeObserver(this, NotificationCenter.storiesEnabledUpdate);
151+
Bulletin.removeDelegate(this);
152+
sharedMediaPreloader.onDestroy(this);
153+
sharedMediaPreloader.removeDelegate(this);
150154
if (applyBulletin != null) {
151155
Runnable runnable = applyBulletin;
152156
applyBulletin = null;

TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ChatCustomReactionsEditActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public boolean onFragmentCreate() {
137137
checkMaxCustomReactions(false);
138138
}
139139
});
140-
getNotificationCenter().addObserver(this, NotificationCenter.reactionsDidLoad);
140+
//getNotificationCenter().addObserver(this, NotificationCenter.reactionsDidLoad);
141141
allAvailableReactions.addAll(getMediaDataController().getEnabledReactionsList());
142142
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.stopAllHeavyOperations, 512);
143143
getNotificationCenter().addObserver(this, NotificationCenter.dialogDeleted);

TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6808,7 +6808,7 @@ protected void onDestroy() {
68086808
getOnBackInvokedDispatcher().unregisterOnBackInvokedCallback((OnBackAnimationCallback) onBackAnimationCallback);
68096809
}
68106810
} else if (Build.VERSION.SDK_INT >= 33) {
6811-
if (onBackAnimationCallback instanceof OnBackInvokedCallback) {
6811+
if (onBackInvokedCallback instanceof OnBackInvokedCallback) {
68126812
getOnBackInvokedDispatcher().unregisterOnBackInvokedCallback((OnBackInvokedCallback) onBackInvokedCallback);
68136813
}
68146814
}

TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4971,7 +4971,7 @@ protected void onDetachedFromWindow() {
49714971
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.groupStickersDidLoad);
49724972
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiLoaded);
49734973
if (type == TYPE_EMOJI_STATUS || type == TYPE_EMOJI_STATUS_TOP) {
4974-
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.starUserGiftsLoaded);
4974+
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.starUserGiftsLoaded);
49754975
}
49764976

49774977
if (scrimDrawable != null) {

TMessagesProj/src/main/java/org/telegram/ui/SelectChatUserSheet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ public void attach() {
536536
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.chatInfoDidLoad);
537537
}
538538
public void detach() {
539-
if (attached) return;
539+
if (!attached) return;
540540
attached = false;
541541
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.chatInfoDidLoad);
542542

0 commit comments

Comments
 (0)