Incomplete TidepoolFragment with kotlin-android-extension.

This commit is contained in:
Johannes Mockenhaupt 2019-06-14 18:42:08 +02:00
parent 1b0d6ff413
commit ab96e62ded
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -4,25 +4,30 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ScrollView
import com.squareup.otto.Subscribe
import info.nightscout.androidaps.R
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.common.SubscriberFragment
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI
import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolDoUpload
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolResetData
import info.nightscout.androidaps.utils.SP
import kotlinx.android.synthetic.main.tidepool_fragment.*
class TidepoolFragment : SubscriberFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.tidepool_fragment, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.tidepool_fragment, container, false)
}
tidepool_login.setOnClickListener {
TidepoolUploader.doLogin()
}
tidepool_removeall.setOnClickListener { }
tidepool_uploadnow.setOnClickListener { }
return view
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
tidepool_login.setOnClickListener { TidepoolUploader.doLogin(false) }
tidepool_uploadnow.setOnClickListener { RxBus.send(EventTidepoolDoUpload()) }
tidepool_removeall.setOnClickListener { RxBus.send(EventTidepoolResetData()) }
tidepool_resertstart.setOnClickListener { SP.putLong(R.string.key_tidepool_last_end, 0) }
}
@Subscribe
@ -31,10 +36,12 @@ class TidepoolFragment : SubscriberFragment() {
}
override fun updateGUI() {
val activity = activity
activity?.runOnUiThread {
// TidepoolPlugin.updateLog()
// tidepool_log.text = TidepoolPlugin.textLog
this.activity?.runOnUiThread {
TidepoolPlugin.updateLog()
tidepool_log.text = TidepoolPlugin.textLog
tidepool_status.text = TidepoolUploader.connectionStatus.name
tidepool_log.text = TidepoolPlugin.textLog
tidepool_logscrollview.fullScroll(ScrollView.FOCUS_DOWN)
}
}