Skip to content

Commit 31705c9

Browse files
committed
fix(app): fix IllegalStateException by ensuring UI thread adapter notifications
Fix crash caused by modifying or notifying ListView adapter changes from background threads.
1 parent fc5b6f9 commit 31705c9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎termux/termux-app/src/main/java/com/termux/app/TermuxActivity.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.os.Build;
1010
import android.os.Bundle;
1111
import android.os.IBinder;
12+
import android.os.Looper;
1213
import android.view.ContextMenu;
1314
import android.view.ContextMenu.ContextMenuInfo;
1415
import android.view.Gravity;
@@ -973,7 +974,12 @@ public boolean isTerminalToolbarTextInputViewSelected() {
973974

974975

975976
public void termuxSessionListNotifyUpdated() {
976-
TermuxExecutor.executeOnMain(() -> mTermuxSessionListViewController.notifyDataSetChanged());
977+
if (mTermuxSessionListViewController == null) return;
978+
if (Looper.myLooper() == Looper.getMainLooper()) {
979+
mTermuxSessionListViewController.notifyDataSetChanged();
980+
} else {
981+
TermuxExecutor.executeOnMain(mTermuxSessionListViewController::notifyDataSetChanged);
982+
}
977983
}
978984

979985
public boolean isVisible() {

0 commit comments

Comments
 (0)