mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 18:55:31 +08:00
Fix "Duplicate finish request for ActivityRecord" errors
This commit is contained in:
@@ -414,7 +414,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
public void onSessionFinished(final TerminalSession finishedSession) {
|
public void onSessionFinished(final TerminalSession finishedSession) {
|
||||||
if (mTermService.mWantsToStop) {
|
if (mTermService.mWantsToStop) {
|
||||||
// The service wants to stop as soon as possible.
|
// The service wants to stop as soon as possible.
|
||||||
finish();
|
finishActivityIfNotFinishing();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mIsVisible && finishedSession != getCurrentTermSession()) {
|
if (mIsVisible && finishedSession != getCurrentTermSession()) {
|
||||||
@@ -550,7 +550,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// The service connected while not in foreground - just bail out.
|
// The service connected while not in foreground - just bail out.
|
||||||
finish();
|
finishActivityIfNotFinishing();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
@@ -586,8 +586,15 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
// Respect being stopped from the TermuxService notification action.
|
// Respect being stopped from the TermuxService notification action.
|
||||||
|
finishActivityIfNotFinishing();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finishActivityIfNotFinishing() {
|
||||||
|
// prevent duplicate calls to finish() if called from multiple places
|
||||||
|
if (!TermuxActivity.this.isFinishing()) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
TerminalSession getCurrentTermSession() {
|
TerminalSession getCurrentTermSession() {
|
||||||
@@ -627,7 +634,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
if (getDrawer().isDrawerOpen(Gravity.LEFT)) {
|
if (getDrawer().isDrawerOpen(Gravity.LEFT)) {
|
||||||
getDrawer().closeDrawers();
|
getDrawer().closeDrawers();
|
||||||
} else {
|
} else {
|
||||||
finish();
|
finishActivityIfNotFinishing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -989,7 +996,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
mListViewAdapter.notifyDataSetChanged();
|
mListViewAdapter.notifyDataSetChanged();
|
||||||
if (mTermService.getSessions().isEmpty()) {
|
if (mTermService.getSessions().isEmpty()) {
|
||||||
// There are no sessions to show, so finish the activity.
|
// There are no sessions to show, so finish the activity.
|
||||||
finish();
|
finishActivityIfNotFinishing();
|
||||||
} else {
|
} else {
|
||||||
if (index >= service.getSessions().size()) {
|
if (index >= service.getSessions().size()) {
|
||||||
index = service.getSessions().size() - 1;
|
index = service.getSessions().size() - 1;
|
||||||
|
Reference in New Issue
Block a user