mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
prevent recipient listener Activity context leak
Resolves #2372 Resolves #2425 // FREEBIE
This commit is contained in:
parent
f38677794a
commit
b88e470594
@ -126,7 +126,8 @@ import static org.whispersystems.textsecure.internal.push.PushMessageProtos.Push
|
||||
*/
|
||||
public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
implements ConversationFragment.ConversationFragmentListener,
|
||||
AttachmentManager.AttachmentListener
|
||||
AttachmentManager.AttachmentListener,
|
||||
RecipientModifiedListener
|
||||
{
|
||||
private static final String TAG = ConversationActivity.class.getSimpleName();
|
||||
|
||||
@ -232,6 +233,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
saveDraft();
|
||||
recipients.removeListener(this);
|
||||
unregisterReceiver(securityUpdateReceiver);
|
||||
unregisterReceiver(groupUpdateReceiver);
|
||||
MemoryCleaner.clean(masterSecret);
|
||||
@ -764,12 +766,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
distributionType = getIntent().getIntExtra(DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
|
||||
masterSecret = getIntent().getParcelableExtra(MASTER_SECRET_EXTRA);
|
||||
|
||||
recipients.addListener(new RecipientModifiedListener() {
|
||||
@Override
|
||||
public void onModified(Recipient recipient) {
|
||||
initializeTitleBar();
|
||||
}
|
||||
});
|
||||
recipients.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModified(Recipient recipient) {
|
||||
initializeTitleBar();
|
||||
}
|
||||
|
||||
private void initializeReceivers() {
|
||||
|
@ -64,6 +64,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
||||
|
||||
private MasterSecret masterSecret;
|
||||
private boolean paused;
|
||||
|
||||
private View loadingView;
|
||||
private TextView errorText;
|
||||
@ -114,13 +115,14 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
||||
} else {
|
||||
relativeTimeSpan = null;
|
||||
}
|
||||
getSupportActionBar().setTitle(recipient == null ? getString(R.string.MediaPreviewActivity_you) : recipient.getName());
|
||||
getSupportActionBar().setTitle(recipient == null ? getString(R.string.MediaPreviewActivity_you) : recipient.toShortString());
|
||||
getSupportActionBar().setSubtitle(relativeTimeSpan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
paused = false;
|
||||
dynamicLanguage.onResume(this);
|
||||
if (recipient != null) recipient.addListener(this);
|
||||
initializeMedia();
|
||||
@ -129,6 +131,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
paused = true;
|
||||
if (recipient != null) recipient.removeListener(this);
|
||||
cleanupMedia();
|
||||
}
|
||||
@ -140,7 +143,6 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
||||
setIntent(intent);
|
||||
initializeResources();
|
||||
initializeActionBar();
|
||||
initializeMedia();
|
||||
}
|
||||
|
||||
private void initializeViews() {
|
||||
@ -154,9 +156,9 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
||||
final long recipientId = getIntent().getLongExtra(RECIPIENT_EXTRA, -1);
|
||||
|
||||
masterSecret = getIntent().getParcelableExtra(MASTER_SECRET_EXTRA);
|
||||
mediaUri = getIntent().getData();
|
||||
mediaType = getIntent().getType();
|
||||
date = getIntent().getLongExtra(DATE_EXTRA, -1);
|
||||
mediaUri = getIntent().getData();
|
||||
mediaType = getIntent().getType();
|
||||
date = getIntent().getLongExtra(DATE_EXTRA, -1);
|
||||
|
||||
if (recipientId > -1) {
|
||||
recipient = RecipientFactory.getRecipientForId(this, recipientId, true);
|
||||
@ -211,8 +213,12 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap bitmap) {
|
||||
loadingView.setVisibility(View.GONE);
|
||||
if (paused) {
|
||||
if (bitmap != null) bitmap.recycle();
|
||||
return;
|
||||
}
|
||||
|
||||
loadingView.setVisibility(View.GONE);
|
||||
if (bitmap == null) {
|
||||
errorText.setText(R.string.MediaPreviewActivity_cant_display);
|
||||
errorText.setVisibility(View.VISIBLE);
|
||||
|
Loading…
Reference in New Issue
Block a user