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