1. #32. limited peer list by 10 lines

This commit is contained in:
vadym 2020-12-09 14:54:37 +02:00
parent 664c39d315
commit e60238271c
2 changed files with 12 additions and 1 deletions

View File

@ -8,7 +8,7 @@ android {
applicationId "io.github.chronosx88.yggdrasil" applicationId "io.github.chronosx88.yggdrasil"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 30 targetSdkVersion 30
versionCode 15 versionCode 16
versionName "1.6" versionName "1.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", project.getParent().name+"-"+versionName) setProperty("archivesBaseName", project.getParent().name+"-"+versionName)

View File

@ -107,6 +107,17 @@ class MainActivity : AppCompatActivity() {
) )
val adapter = PeerInfoListAdapter(this, currentPeers.sortedWith(compareBy { it.ping })) val adapter = PeerInfoListAdapter(this, currentPeers.sortedWith(compareBy { it.ping }))
peersListView.adapter = adapter peersListView.adapter = adapter
if (adapter.count > 10) {
val item = adapter.getView(0, null, peersListView)
item.measure(0, 0)
val params = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
(10 * item.measuredHeight).toInt()
)
peersListView.layoutParams = params
}
if(isStarted && this.currentPeers.isEmpty()) { if(isStarted && this.currentPeers.isEmpty()) {
updatePeers() updatePeers()
} }