viewmodel: port to kotlin

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld
2020-03-21 03:06:56 -06:00
parent 55849cad65
commit 902a1ce46e
8 changed files with 505 additions and 674 deletions
@@ -83,7 +83,7 @@ class TunnelEditorFragment : BaseFragment(), AppExclusionListener {
override fun onExcludedAppsSelected(excludedApps: List<String>) {
requireNotNull(binding) { "Tried to set excluded apps while no view was loaded" }
binding!!.config!!.getInterface().excludedApplications.apply {
binding!!.config!!.`interface`.excludedApplications.apply {
clear()
addAll(excludedApps)
}
@@ -125,12 +125,12 @@ class TunnelEditorFragment : BaseFragment(), AppExclusionListener {
tunnel == null -> {
Log.d(TAG, "Attempting to create new tunnel " + binding!!.name)
val manager = Application.getTunnelManager()
manager.create(binding!!.name, newConfig)
manager.create(binding!!.name!!, newConfig)
.whenComplete(this::onTunnelCreated)
}
tunnel!!.name != binding!!.name -> {
Log.d(TAG, "Attempting to rename tunnel to " + binding!!.name)
tunnel!!.setName(binding!!.name)
tunnel!!.setName(binding!!.name!!)
.whenComplete { _, t -> onTunnelRenamed(tunnel!!, newConfig, t) }
}
else -> {
@@ -147,7 +147,7 @@ class TunnelEditorFragment : BaseFragment(), AppExclusionListener {
@Suppress("UNUSED_PARAMETER")
fun onRequestSetExcludedApplications(view: View?) {
if (binding != null) {
val excludedApps = ArrayList(binding!!.config!!.getInterface().excludedApplications)
val excludedApps = ArrayList(binding!!.config!!.`interface`.excludedApplications)
val fragment = AppListDialogFragment.newInstance(excludedApps, this)
fragment.show(parentFragmentManager, null)
}