From cd282196f7049b33eb4a8677786ad5d67b7d61f7 Mon Sep 17 00:00:00 2001 From: zt515 Date: Wed, 1 Nov 2017 23:33:39 +0800 Subject: [PATCH] UI: improve forEachTab() --- .../main/java/io/neoterm/ui/term/NeoTermActivity.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt b/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt index 672853d..d73aed1 100644 --- a/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt +++ b/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt @@ -215,7 +215,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference super.onStop() // After stopped, window locations may changed // Rebind it at next time. - forEachTerminalTab { it.resetAutoCompleteStatus() } + forEachTab { it.resetAutoCompleteStatus() } EventBus.getDefault().unregister(this) } @@ -328,7 +328,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference } // When rotate the screen, extra keys may get updated. - forEachTerminalTab { it.resetStatus() } + forEachTab { it.resetStatus() } } // private fun floatTabUp(tab: TermTab) { @@ -348,7 +348,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference setSystemShellMode(false) if (!termService!!.sessions.isEmpty()) { - val lastSession = getStoredCurrentSessionOrLast(); + val lastSession = getStoredCurrentSessionOrLast() for (session in termService!!.sessions) { addNewSession(session) @@ -359,7 +359,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference addNewSession(null, false, createRevealAnimation()) } else { - switchToSession(lastSession); + switchToSession(lastSession) } } else { @@ -580,10 +580,10 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference return NeoPreference.loadBoolean(NeoPreference.KEY_SYSTEM_SHELL, true) } - private fun forEachTerminalTab(callback: (TermTab) -> Unit) { + private inline fun forEachTab(callback: (T) -> Unit) { (0 until tabSwitcher.count) .map { tabSwitcher.getTab(it) } - .filterIsInstance(TermTab::class.java) + .filterIsInstance(T::class.java) .forEach(callback) }