diff --git a/app/src/main/kotlin/io/treehouses/remote/adapter/ViewHolderSSHAllKeyRow.kt b/app/src/main/kotlin/io/treehouses/remote/adapter/ViewHolderSSHAllKeyRow.kt index fabb79f94..356e7c2ff 100644 --- a/app/src/main/kotlin/io/treehouses/remote/adapter/ViewHolderSSHAllKeyRow.kt +++ b/app/src/main/kotlin/io/treehouses/remote/adapter/ViewHolderSSHAllKeyRow.kt @@ -38,10 +38,13 @@ class ViewHolderSSHAllKeyRow(private val binding: RowKeyBinding, private val lis } override fun onMenuItemClick(item: MenuItem): Boolean { - when (item.itemId) { - R.id.copy_public -> listener.onCopyPub(adapterPosition) - R.id.delete_key -> listener.onDelete(adapterPosition) - R.id.send_key -> listener.onSendToRaspberry(adapterPosition) + val position = bindingAdapterPosition + if (position != RecyclerView.NO_POSITION) { + when (item.itemId) { + R.id.copy_public -> listener.onCopyPub(position) + R.id.delete_key -> listener.onDelete(position) + R.id.send_key -> listener.onSendToRaspberry(position) + } } return false } diff --git a/app/src/main/kotlin/io/treehouses/remote/adapter/ViewHolderSSHRow.kt b/app/src/main/kotlin/io/treehouses/remote/adapter/ViewHolderSSHRow.kt index 5459a5dbb..42aa196cf 100644 --- a/app/src/main/kotlin/io/treehouses/remote/adapter/ViewHolderSSHRow.kt +++ b/app/src/main/kotlin/io/treehouses/remote/adapter/ViewHolderSSHRow.kt @@ -10,7 +10,10 @@ class ViewHolderSSHRow(private val binding: RowSshBinding, private val listener: fun bind(host: HostBean) { binding.title.text = host.getPrettyFormat() binding.editButton.setOnClickListener { - listener.onButtonClick(adapterPosition) + val position = bindingAdapterPosition + if (position != RecyclerView.NO_POSITION) { + listener.onButtonClick(position) + } } } diff --git a/app/src/main/kotlin/io/treehouses/remote/ssh/terminal/BaseTerminalView.kt b/app/src/main/kotlin/io/treehouses/remote/ssh/terminal/BaseTerminalView.kt index 3cf4069b4..766d8fdcd 100644 --- a/app/src/main/kotlin/io/treehouses/remote/ssh/terminal/BaseTerminalView.kt +++ b/app/src/main/kotlin/io/treehouses/remote/ssh/terminal/BaseTerminalView.kt @@ -4,7 +4,7 @@ import android.annotation.TargetApi import android.content.Context import android.content.SharedPreferences import android.graphics.* -import android.preference.PreferenceManager +import androidx.preference.PreferenceManager import android.text.ClipboardManager import android.view.KeyEvent import android.view.View