Skip to content

Commit

Permalink
ssh: smoother configuration (fixes #2047) (#2155)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Nov 26, 2024
1 parent 2bb00e4 commit 25cbdb9
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions app/src/main/kotlin/io/treehouses/remote/bases/BaseSSHConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,36 @@ open class BaseSSHConfig: BaseFragment(), RVButtonClickListener, OnHostStatusCha
}

protected fun setUpAdapter() {
pastHosts = SaveUtils.getAllHosts(requireContext()).reversed()
if (!isVisible) return
if (pastHosts.isEmpty()) {
bind.noHosts.visibility = View.VISIBLE
bind.pastHosts.visibility = View.GONE
}
adapter = object : RecyclerView.Adapter<ViewHolderSSHRow>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolderSSHRow {
val holderBinding = RowSshBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ViewHolderSSHRow(holderBinding, this@BaseSSHConfig)
if (context != null) {
pastHosts = SaveUtils.getAllHosts(requireContext()).reversed()
if (!isVisible) return
if (pastHosts.isEmpty()) {
bind.noHosts.visibility = View.VISIBLE
bind.pastHosts.visibility = View.GONE
}
adapter = object : RecyclerView.Adapter<ViewHolderSSHRow>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolderSSHRow {
val holderBinding = RowSshBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ViewHolderSSHRow(holderBinding, this@BaseSSHConfig)
}

override fun getItemCount(): Int { return pastHosts.size }
override fun getItemCount(): Int {
return pastHosts.size
}

override fun onBindViewHolder(holder: ViewHolderSSHRow, position: Int) {
val host = pastHosts[position]
holder.bind(host)
if (bound?.mHostBridgeMap?.get(host)?.get() != null) holder.setConnected(true) else holder.setConnected(false)
override fun onBindViewHolder(holder: ViewHolderSSHRow, position: Int) {
val host = pastHosts[position]
holder.bind(host)
if (bound?.mHostBridgeMap?.get(host)?.get() != null) {
holder.setConnected(true)
} else {
holder.setConnected(false)
}
}
}
bind.pastHosts.adapter = adapter
addItemTouchListener()
}
bind.pastHosts.adapter = adapter
addItemTouchListener()
}

private fun addItemTouchListener() {
Expand Down

0 comments on commit 25cbdb9

Please sign in to comment.