mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Finish activity before restarting it
The current activity needs to be finished before calling startActivity. Otherwise, activities with launchMode singleTask (ConversationListActivity) will receive a new Intent instead of getting restarted. And in response to the new Intent, they will run onResume once again and trigger a second restart. Fixes #1292
This commit is contained in:
parent
023d776e96
commit
1cb4d479f1
@ -21,16 +21,13 @@ public class DynamicLanguage {
|
|||||||
|
|
||||||
public void onResume(Activity activity) {
|
public void onResume(Activity activity) {
|
||||||
if (!currentLocale.equals(getSelectedLocale(activity))) {
|
if (!currentLocale.equals(getSelectedLocale(activity))) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
activity.recreate();
|
||||||
|
} else {
|
||||||
Intent intent = activity.getIntent();
|
Intent intent = activity.getIntent();
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
|
||||||
|
|
||||||
activity.startActivity(intent);
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
|
||||||
OverridePendingTransition.invoke(activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
activity.finish();
|
activity.finish();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
OverridePendingTransition.invoke(activity);
|
||||||
|
activity.startActivity(intent);
|
||||||
OverridePendingTransition.invoke(activity);
|
OverridePendingTransition.invoke(activity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,19 +21,15 @@ public class DynamicTheme {
|
|||||||
|
|
||||||
public void onResume(Activity activity) {
|
public void onResume(Activity activity) {
|
||||||
if (currentTheme != getSelectedTheme(activity)) {
|
if (currentTheme != getSelectedTheme(activity)) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
activity.recreate();
|
||||||
|
} else {
|
||||||
Intent intent = activity.getIntent();
|
Intent intent = activity.getIntent();
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
|
||||||
|
|
||||||
activity.startActivity(intent);
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
|
||||||
OverridePendingTransition.invoke(activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
activity.finish();
|
activity.finish();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
OverridePendingTransition.invoke(activity);
|
||||||
|
activity.startActivity(intent);
|
||||||
OverridePendingTransition.invoke(activity);
|
OverridePendingTransition.invoke(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user