mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix(terminal): cancel last toast when TermuxActivity is destroyed
This commit is contained in:
@@ -333,7 +333,11 @@ public class TermuxActivity extends BaseIDEActivity implements ServiceConnection
|
||||
if (mIsInvalidState) return;
|
||||
|
||||
this.binding = null;
|
||||
this.mLastToast = null;
|
||||
|
||||
if (mLastToast != null) {
|
||||
mLastToast.cancel();
|
||||
}
|
||||
mLastToast = null;
|
||||
|
||||
if (mTermuxService != null) {
|
||||
// Do not leave service and session clients with references to activity.
|
||||
@@ -580,9 +584,7 @@ public class TermuxActivity extends BaseIDEActivity implements ServiceConnection
|
||||
@SuppressLint("RtlHardcoded")
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (KeyboardUtils.isSoftKeyboardVisible(this)) {
|
||||
KeyboardUtils.showSoftKeyboard(this, getTerminalView());
|
||||
} else if (getDrawer().isDrawerOpen(Gravity.LEFT)) {
|
||||
if (getDrawer().isDrawerOpen(Gravity.LEFT)) {
|
||||
getDrawer().closeDrawers();
|
||||
} else {
|
||||
finishActivityIfNotFinishing();
|
||||
|
||||
@@ -120,7 +120,6 @@ public class KeyboardUtils {
|
||||
* @param activity The Activity of the root view for which the visibility should be checked.
|
||||
* @return Returns {@code true} if soft keyboard is visible, otherwise {@code false}.
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
public static boolean isSoftKeyboardVisible(final Activity activity) {
|
||||
if (activity != null && activity.getWindow() != null) {
|
||||
WindowInsets insets = activity.getWindow().getDecorView().getRootWindowInsets();
|
||||
|
||||
Reference in New Issue
Block a user