QuickWizardListActivity -> jetpack
This commit is contained in:
parent
7e0be475f8
commit
c3878de916
2 changed files with 32 additions and 31 deletions
|
@ -11,6 +11,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||
import info.nightscout.androidaps.databinding.OverviewQuickwizardlistActivityBinding
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventQuickWizardChange
|
||||
|
@ -20,10 +21,10 @@ import info.nightscout.androidaps.utils.extensions.plusAssign
|
|||
import info.nightscout.androidaps.utils.wizard.QuickWizard
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.overview_quickwizardlist_activity.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
||||
|
||||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var quickWizard: QuickWizard
|
||||
|
@ -31,6 +32,8 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
private lateinit var binding: OverviewQuickwizardlistActivityBinding
|
||||
|
||||
private inner class RecyclerViewAdapter(var fragmentManager: FragmentManager) : RecyclerView.Adapter<RecyclerViewAdapter.QuickWizardEntryViewHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QuickWizardEntryViewHolder {
|
||||
|
@ -47,6 +50,7 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
|||
override fun getItemCount(): Int = quickWizard.size()
|
||||
|
||||
private inner class QuickWizardEntryViewHolder(itemView: View, var fragmentManager: FragmentManager) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
val buttonText: TextView = itemView.findViewById(R.id.overview_quickwizard_item_buttonText)
|
||||
val carbs: TextView = itemView.findViewById(R.id.overview_quickwizard_item_carbs)
|
||||
val from: TextView = itemView.findViewById(R.id.overview_quickwizard_item_from)
|
||||
|
@ -73,13 +77,14 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.overview_quickwizardlist_activity)
|
||||
binding = OverviewQuickwizardlistActivityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
overview_quickwizardactivity_recyclerview?.setHasFixedSize(true)
|
||||
overview_quickwizardactivity_recyclerview?.layoutManager = LinearLayoutManager(this)
|
||||
overview_quickwizardactivity_recyclerview?.adapter = RecyclerViewAdapter(supportFragmentManager)
|
||||
binding.recyclerview.setHasFixedSize(true)
|
||||
binding.recyclerview.layoutManager = LinearLayoutManager(this)
|
||||
binding.recyclerview.adapter = RecyclerViewAdapter(supportFragmentManager)
|
||||
|
||||
overview_quickwizardactivity_add_button.setOnClickListener {
|
||||
binding.addButton.setOnClickListener {
|
||||
val manager = supportFragmentManager
|
||||
val editQuickWizardDialog = EditQuickWizardDialog()
|
||||
editQuickWizardDialog.show(manager, "EditQuickWizardDialog")
|
||||
|
@ -93,7 +98,7 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
|||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
val adapter = RecyclerViewAdapter(supportFragmentManager)
|
||||
overview_quickwizardactivity_recyclerview?.swapAdapter(adapter, false)
|
||||
binding.recyclerview.swapAdapter(adapter, false)
|
||||
}, { fabricPrivacy.logException(it) })
|
||||
}
|
||||
|
||||
|
|
|
@ -1,36 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout 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"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context=".plugins.general.overview.activities.QuickWizardListActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="15dp"
|
||||
android:text="@string/quickwizard"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large" />
|
||||
|
||||
<TextView
|
||||
android:text="@string/quickwizard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large"
|
||||
android:textAlignment="center"
|
||||
android:paddingBottom="15dp" />
|
||||
<Button
|
||||
android:id="@+id/add_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/overview_editquickwizardlistactivity_add" />
|
||||
|
||||
<Button
|
||||
android:text="@string/overview_editquickwizardlistactivity_add"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/overview_quickwizardactivity_add_button" />
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/overview_quickwizardactivity_recyclerview" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in a new issue