SmsCommunicatorOtpActivity -> jetpack
This commit is contained in:
parent
2e58bfc829
commit
026d6039dc
2 changed files with 42 additions and 25 deletions
|
@ -7,6 +7,7 @@ import android.view.ViewGroup
|
||||||
import android.widget.ScrollView
|
import android.widget.ScrollView
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.databinding.TidepoolFragmentBinding
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader
|
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.EventTidepoolDoUpload
|
||||||
|
@ -29,16 +30,23 @@ class TidepoolFragment : DaggerFragment() {
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
private var _binding: TidepoolFragmentBinding? = null
|
||||||
return inflater.inflate(R.layout.tidepool_fragment, container, false)
|
|
||||||
|
// This property is only valid between onCreateView and
|
||||||
|
// onDestroyView.
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
_binding = TidepoolFragmentBinding.inflate(inflater, container, false)
|
||||||
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
tidepool_login.setOnClickListener { tidepoolUploader.doLogin(false) }
|
binding.login.setOnClickListener { tidepoolUploader.doLogin(false) }
|
||||||
tidepool_uploadnow.setOnClickListener { rxBus.send(EventTidepoolDoUpload()) }
|
binding.uploadnow.setOnClickListener { rxBus.send(EventTidepoolDoUpload()) }
|
||||||
tidepool_removeall.setOnClickListener { rxBus.send(EventTidepoolResetData()) }
|
binding.removeall.setOnClickListener { rxBus.send(EventTidepoolResetData()) }
|
||||||
tidepool_resertstart.setOnClickListener { sp.putLong(R.string.key_tidepool_last_end, 0) }
|
binding.resertstart.setOnClickListener { sp.putLong(R.string.key_tidepool_last_end, 0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
@ -48,11 +56,12 @@ class TidepoolFragment : DaggerFragment() {
|
||||||
.toObservable(EventTidepoolUpdateGUI::class.java)
|
.toObservable(EventTidepoolUpdateGUI::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({
|
.subscribe({
|
||||||
|
if (_binding == null) return@subscribe
|
||||||
tidepoolPlugin.updateLog()
|
tidepoolPlugin.updateLog()
|
||||||
tidepool_log?.text = tidepoolPlugin.textLog
|
binding.log.text = tidepoolPlugin.textLog
|
||||||
tidepool_status?.text = tidepoolUploader.connectionStatus.name
|
binding.status.text = tidepoolUploader.connectionStatus.name
|
||||||
tidepool_log?.text = tidepoolPlugin.textLog
|
binding.log.text = tidepoolPlugin.textLog
|
||||||
tidepool_logscrollview?.fullScroll(ScrollView.FOCUS_DOWN)
|
binding.logscrollview.fullScroll(ScrollView.FOCUS_DOWN)
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, { fabricPrivacy.logException(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,4 +70,12 @@ class TidepoolFragment : DaggerFragment() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
disposable.clear()
|
disposable.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
override fun onDestroyView() {
|
||||||
|
super.onDestroyView()
|
||||||
|
_binding = null
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tidepool_status"
|
android:id="@+id/status"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="1dp"
|
android:layout_marginStart="1dp"
|
||||||
|
@ -15,45 +15,45 @@
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/tidepool_login"
|
android:id="@+id/login"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:text="Login"
|
android:text="Login"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tidepool_status" />
|
app:layout_constraintTop_toBottomOf="@+id/status" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/tidepool_uploadnow"
|
android:id="@+id/uploadnow"
|
||||||
android:layout_width="113dp"
|
android:layout_width="113dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:text="Upload now"
|
android:text="Upload now"
|
||||||
app:layout_constraintStart_toEndOf="@+id/tidepool_login"
|
app:layout_constraintStart_toEndOf="@+id/login"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tidepool_status" />
|
app:layout_constraintTop_toBottomOf="@+id/status" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/tidepool_removeall"
|
android:id="@+id/removeall"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginStart="4dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:text="Remove all"
|
android:text="Remove all"
|
||||||
app:layout_constraintStart_toEndOf="@+id/tidepool_uploadnow"
|
app:layout_constraintStart_toEndOf="@+id/uploadnow"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tidepool_status" />
|
app:layout_constraintTop_toBottomOf="@+id/status" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/tidepool_resertstart"
|
android:id="@+id/resertstart"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginStart="4dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:text="Reset start"
|
android:text="Reset start"
|
||||||
app:layout_constraintStart_toEndOf="@+id/tidepool_removeall"
|
app:layout_constraintStart_toEndOf="@+id/removeall"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tidepool_status" />
|
app:layout_constraintTop_toBottomOf="@+id/status" />
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/tidepool_logscrollview"
|
android:id="@+id/logscrollview"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
|
@ -61,11 +61,11 @@
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tidepool_login"
|
app:layout_constraintTop_toBottomOf="@+id/login"
|
||||||
app:layout_constraintVertical_bias="0.023">
|
app:layout_constraintVertical_bias="0.023">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tidepool_log"
|
android:id="@+id/log"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="-- logs --" />
|
android:text="-- logs --" />
|
||||||
|
|
Loading…
Reference in a new issue