UI: improve forEachTab()
This commit is contained in:
parent
db7d6ebd29
commit
cd282196f7
@ -215,7 +215,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
|||||||
super.onStop()
|
super.onStop()
|
||||||
// After stopped, window locations may changed
|
// After stopped, window locations may changed
|
||||||
// Rebind it at next time.
|
// Rebind it at next time.
|
||||||
forEachTerminalTab { it.resetAutoCompleteStatus() }
|
forEachTab<TermTab> { it.resetAutoCompleteStatus() }
|
||||||
EventBus.getDefault().unregister(this)
|
EventBus.getDefault().unregister(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
|||||||
}
|
}
|
||||||
|
|
||||||
// When rotate the screen, extra keys may get updated.
|
// When rotate the screen, extra keys may get updated.
|
||||||
forEachTerminalTab { it.resetStatus() }
|
forEachTab<TermTab> { it.resetStatus() }
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun floatTabUp(tab: TermTab) {
|
// private fun floatTabUp(tab: TermTab) {
|
||||||
@ -348,7 +348,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
|||||||
setSystemShellMode(false)
|
setSystemShellMode(false)
|
||||||
|
|
||||||
if (!termService!!.sessions.isEmpty()) {
|
if (!termService!!.sessions.isEmpty()) {
|
||||||
val lastSession = getStoredCurrentSessionOrLast();
|
val lastSession = getStoredCurrentSessionOrLast()
|
||||||
|
|
||||||
for (session in termService!!.sessions) {
|
for (session in termService!!.sessions) {
|
||||||
addNewSession(session)
|
addNewSession(session)
|
||||||
@ -359,7 +359,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
|||||||
addNewSession(null,
|
addNewSession(null,
|
||||||
false, createRevealAnimation())
|
false, createRevealAnimation())
|
||||||
} else {
|
} else {
|
||||||
switchToSession(lastSession);
|
switchToSession(lastSession)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -580,10 +580,10 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
|||||||
return NeoPreference.loadBoolean(NeoPreference.KEY_SYSTEM_SHELL, true)
|
return NeoPreference.loadBoolean(NeoPreference.KEY_SYSTEM_SHELL, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun forEachTerminalTab(callback: (TermTab) -> Unit) {
|
private inline fun <reified T> forEachTab(callback: (T) -> Unit) {
|
||||||
(0 until tabSwitcher.count)
|
(0 until tabSwitcher.count)
|
||||||
.map { tabSwitcher.getTab(it) }
|
.map { tabSwitcher.getTab(it) }
|
||||||
.filterIsInstance(TermTab::class.java)
|
.filterIsInstance(T::class.java)
|
||||||
.forEach(callback)
|
.forEach(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user