diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-03-26 23:54:44 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-03-27 03:08:47 -0600 |
commit | 48a9fd46a679db5cc4baa0ffd03b14d006bab04a (patch) | |
tree | b0e1647a9bba066d6c6870a397d513912782fcad /ui/src/main/java/com/wireguard/android/fragment | |
parent | 8669c01eaa47a39d2c36147d4dbe2e987e0520c9 (diff) |
databinding: rewrite in kotlin
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/fragment')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt | 5 | ||||
-rw-r--r-- | ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt | 31 |
2 files changed, 19 insertions, 17 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt index 34981bd3..3bab3648 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt @@ -17,11 +17,10 @@ import com.wireguard.android.R import com.wireguard.android.databinding.AppListDialogFragmentBinding import com.wireguard.android.model.ApplicationData import com.wireguard.android.util.ErrorMessages -import com.wireguard.android.util.ObservableKeyedArrayList -import com.wireguard.android.util.ObservableKeyedList +import com.wireguard.android.databinding.ObservableKeyedArrayList class AppListDialogFragment : DialogFragment() { - private val appData: ObservableKeyedList<String, ApplicationData> = ObservableKeyedArrayList() + private val appData: ObservableKeyedArrayList<String, ApplicationData> = ObservableKeyedArrayList() private var currentlyExcludedApps = emptyList<String>() private fun loadData() { diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt index ca4b1eee..c23699eb 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt @@ -267,23 +267,26 @@ class TunnelListFragment : BaseFragment() { binding ?: return binding!!.fragment = this Application.getTunnelManager().tunnels.thenAccept { tunnels -> binding!!.tunnels = tunnels } - binding!!.rowConfigurationHandler = RowConfigurationHandler { binding: TunnelListItemBinding, tunnel: ObservableTunnel, position -> - binding.fragment = this - binding.root.setOnClickListener { - if (actionMode == null) { - selectedTunnel = tunnel - } else { + val parent = this + binding!!.rowConfigurationHandler = object : RowConfigurationHandler<TunnelListItemBinding, ObservableTunnel> { + override fun onConfigureRow(binding: TunnelListItemBinding, item: ObservableTunnel, position: Int) { + binding.fragment = parent + binding.root.setOnClickListener { + if (actionMode == null) { + selectedTunnel = item + } else { + actionModeListener.toggleItemChecked(position) + } + } + binding.root.setOnLongClickListener { actionModeListener.toggleItemChecked(position) + true } + if (actionMode != null) + (binding.root as MultiselectableRelativeLayout).setMultiSelected(actionModeListener.checkedItems.contains(position)) + else + (binding.root as MultiselectableRelativeLayout).setSingleSelected(selectedTunnel == item) } - binding.root.setOnLongClickListener { - actionModeListener.toggleItemChecked(position) - true - } - if (actionMode != null) - (binding.root as MultiselectableRelativeLayout).setMultiSelected(actionModeListener.checkedItems.contains(position)) - else - (binding.root as MultiselectableRelativeLayout).setSingleSelected(selectedTunnel == tunnel) } } |