SmsCommunicatorOtpActivity -> jetpack

This commit is contained in:
Milos Kozak 2021-02-02 20:48:03 +01:00
parent 2078962057
commit 2e58bfc829
2 changed files with 28 additions and 18 deletions

View file

@ -5,7 +5,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.SmscommunicatorFragmentBinding
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.smsCommunicator.events.EventSmsCommunicatorUpdateGui
import info.nightscout.androidaps.utils.DateUtil
@ -14,22 +14,30 @@ import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.androidaps.utils.extensions.plusAssign
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.smscommunicator_fragment.*
import java.util.*
import javax.inject.Inject
import kotlin.math.max
class SmsCommunicatorFragment : DaggerFragment() {
@Inject lateinit var fabricPrivacy : FabricPrivacy
@Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
@Inject lateinit var dateUtil: DateUtil
private val disposable = CompositeDisposable()
private var _binding: SmscommunicatorFragmentBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.smscommunicator_fragment, container, false)
savedInstanceState: Bundle?): View {
_binding = SmscommunicatorFragmentBinding.inflate(inflater, container, false)
return binding.root
}
@Synchronized
@ -48,8 +56,15 @@ class SmsCommunicatorFragment : DaggerFragment() {
disposable.clear()
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
fun updateGui() {
if (_binding == null) return
class CustomComparator : Comparator<Sms> {
override fun compare(object1: Sms, object2: Sms): Int {
return (object1.date - object2.date).toInt()
}
@ -74,6 +89,6 @@ class SmsCommunicatorFragment : DaggerFragment() {
}
}
}
smscommunicator_log?.text = HtmlHelper.fromHtml(logText)
binding.log.text = HtmlHelper.fromHtml(logText)
}
}

View file

@ -1,18 +1,13 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".plugins.general.smsCommunicator.SmsCommunicatorFragment">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/smscommunicator_log"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text=""/>
</ScrollView>
android:id="@+id/log"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
</FrameLayout>
</ScrollView>