diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-11-10 18:53:50 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-12-10 12:55:06 +0000 |
| commit | 0a968d31292700f1f89b42d515b8d43ff1ffa7ec (patch) | |
| tree | 04c3aa169d3f246f83c953eb2666066dc1e41cdf /android/src | |
| parent | dbc32bdba3b31da352310878cca597924cd3819e (diff) | |
| download | mullvadvpn-0a968d31292700f1f89b42d515b8d43ff1ffa7ec.tar.xz mullvadvpn-0a968d31292700f1f89b42d515b8d43ff1ffa7ec.zip | |
Replace boolean flag with `editingPosition` field
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt index 218b2f597c..a8dd24528a 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt @@ -21,7 +21,7 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>( private val inetAddressValidator = InetAddressValidator.getInstance() private val jobTracker = JobTracker() - private var enteringNewServer = false + private var editingPosition: Int? = null private var activeCustomDnsServers by observable<List<InetAddress>>(emptyList()) { _, _, servers -> @@ -65,16 +65,14 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>( override fun getItemViewType(position: Int): Int { val count = getItemCount() val footer = count - 1 - val addServerOrNewServer = count - 2 + val addServer = count - 2 if (position == footer) { return ViewTypes.FOOTER.ordinal - } else if (position == addServerOrNewServer) { - if (enteringNewServer) { - return ViewTypes.EDIT_SERVER.ordinal - } else { - return ViewTypes.ADD_SERVER.ordinal - } + } else if (position == editingPosition) { + return ViewTypes.EDIT_SERVER.ordinal + } else if (position == addServer) { + return ViewTypes.ADD_SERVER.ordinal } else { return ViewTypes.SHOW_SERVER.ordinal } @@ -120,7 +118,7 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>( if (enabled) { val count = getItemCount() - enteringNewServer = true + editingPosition = count - 2 notifyItemChanged(count - 2) } @@ -142,7 +140,7 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>( } if (added) { - enteringNewServer = false + editingPosition = null val count = getItemCount() |
