mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15: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
|
public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
implements ConversationFragment.ConversationFragmentListener,
|
implements ConversationFragment.ConversationFragmentListener,
|
||||||
AttachmentManager.AttachmentListener
|
AttachmentManager.AttachmentListener,
|
||||||
|
RecipientModifiedListener
|
||||||
{
|
{
|
||||||
private static final String TAG = ConversationActivity.class.getSimpleName();
|
private static final String TAG = ConversationActivity.class.getSimpleName();
|
||||||
|
|
||||||
@ -232,6 +233,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
saveDraft();
|
saveDraft();
|
||||||
|
recipients.removeListener(this);
|
||||||
unregisterReceiver(securityUpdateReceiver);
|
unregisterReceiver(securityUpdateReceiver);
|
||||||
unregisterReceiver(groupUpdateReceiver);
|
unregisterReceiver(groupUpdateReceiver);
|
||||||
MemoryCleaner.clean(masterSecret);
|
MemoryCleaner.clean(masterSecret);
|
||||||
@ -764,13 +766,13 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
distributionType = getIntent().getIntExtra(DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
|
distributionType = getIntent().getIntExtra(DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
|
||||||
masterSecret = getIntent().getParcelableExtra(MASTER_SECRET_EXTRA);
|
masterSecret = getIntent().getParcelableExtra(MASTER_SECRET_EXTRA);
|
||||||
|
|
||||||
recipients.addListener(new RecipientModifiedListener() {
|
recipients.addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onModified(Recipient recipient) {
|
public void onModified(Recipient recipient) {
|
||||||
initializeTitleBar();
|
initializeTitleBar();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeReceivers() {
|
private void initializeReceivers() {
|
||||||
securityUpdateReceiver = new BroadcastReceiver() {
|
securityUpdateReceiver = new BroadcastReceiver() {
|
||||||
|
@ -64,6 +64,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
||||||
|
|
||||||
private MasterSecret masterSecret;
|
private MasterSecret masterSecret;
|
||||||
|
private boolean paused;
|
||||||
|
|
||||||
private View loadingView;
|
private View loadingView;
|
||||||
private TextView errorText;
|
private TextView errorText;
|
||||||
@ -114,13 +115,14 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
} else {
|
} else {
|
||||||
relativeTimeSpan = null;
|
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);
|
getSupportActionBar().setSubtitle(relativeTimeSpan);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
paused = false;
|
||||||
dynamicLanguage.onResume(this);
|
dynamicLanguage.onResume(this);
|
||||||
if (recipient != null) recipient.addListener(this);
|
if (recipient != null) recipient.addListener(this);
|
||||||
initializeMedia();
|
initializeMedia();
|
||||||
@ -129,6 +131,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
paused = true;
|
||||||
if (recipient != null) recipient.removeListener(this);
|
if (recipient != null) recipient.removeListener(this);
|
||||||
cleanupMedia();
|
cleanupMedia();
|
||||||
}
|
}
|
||||||
@ -140,7 +143,6 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
setIntent(intent);
|
setIntent(intent);
|
||||||
initializeResources();
|
initializeResources();
|
||||||
initializeActionBar();
|
initializeActionBar();
|
||||||
initializeMedia();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeViews() {
|
private void initializeViews() {
|
||||||
@ -211,8 +213,12 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Bitmap bitmap) {
|
protected void onPostExecute(Bitmap bitmap) {
|
||||||
loadingView.setVisibility(View.GONE);
|
if (paused) {
|
||||||
|
if (bitmap != null) bitmap.recycle();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadingView.setVisibility(View.GONE);
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
errorText.setText(R.string.MediaPreviewActivity_cant_display);
|
errorText.setText(R.string.MediaPreviewActivity_cant_display);
|
||||||
errorText.setVisibility(View.VISIBLE);
|
errorText.setVisibility(View.VISIBLE);
|
||||||
|
Loading…
Reference in New Issue
Block a user