LogSettingActivity -> jetpack
This commit is contained in:
parent
a6449a7578
commit
36d3182b1b
2 changed files with 13 additions and 9 deletions
|
@ -7,37 +7,41 @@ import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||||
|
import info.nightscout.androidaps.databinding.ActivityLogsettingBinding
|
||||||
import info.nightscout.androidaps.logging.L
|
import info.nightscout.androidaps.logging.L
|
||||||
import kotlinx.android.synthetic.main.activity_logsetting.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LogSettingActivity : NoSplashAppCompatActivity() {
|
class LogSettingActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
@Inject lateinit var l: L
|
@Inject lateinit var l: L
|
||||||
|
|
||||||
|
private lateinit var binding: ActivityLogsettingBinding
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_logsetting)
|
binding = ActivityLogsettingBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
|
||||||
createViewsForSettings()
|
createViewsForSettings()
|
||||||
|
|
||||||
logsettings_reset.setOnClickListener {
|
binding.reset.setOnClickListener {
|
||||||
l.resetToDefaults()
|
l.resetToDefaults()
|
||||||
createViewsForSettings()
|
createViewsForSettings()
|
||||||
}
|
}
|
||||||
ok.setOnClickListener { finish() }
|
binding.ok.setOnClickListener { finish() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createViewsForSettings() {
|
private fun createViewsForSettings() {
|
||||||
logsettings_placeholder.removeAllViews()
|
binding.placeholder.removeAllViews()
|
||||||
for (element in l.getLogElements()) {
|
for (element in l.getLogElements()) {
|
||||||
val logViewHolder = LogViewHolder(element)
|
val logViewHolder = LogViewHolder(element)
|
||||||
logsettings_placeholder.addView(logViewHolder.baseView)
|
binding.placeholder.addView(logViewHolder.baseView)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal inner class LogViewHolder(element: L.LogElement) {
|
internal inner class LogViewHolder(element: L.LogElement) {
|
||||||
|
|
||||||
@Suppress("InflateParams")
|
@Suppress("InflateParams")
|
||||||
var baseView = layoutInflater.inflate(R.layout.logsettings_item, null) as LinearLayout
|
var baseView = layoutInflater.inflate(R.layout.logsettings_item, null) as LinearLayout
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
android:padding="5dp" />
|
android:padding="5dp" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/logsettings_placeholder"
|
android:id="@+id/placeholder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical" />
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
android:paddingBottom="8dp">
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/logsettings_reset"
|
android:id="@+id/reset"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
|
Loading…
Reference in a new issue