do not extend alertdialog.builder at dialogs

This commit is contained in:
tibbi 2016-11-13 23:33:05 +01:00
parent 4f8bf649f7
commit 83a1c707e0
2 changed files with 7 additions and 8 deletions

View File

@ -9,16 +9,15 @@ import com.simplemobiletools.notes.Config
import com.simplemobiletools.notes.R import com.simplemobiletools.notes.R
import com.simplemobiletools.notes.databases.DBHelper import com.simplemobiletools.notes.databases.DBHelper
class OpenNoteDialog(val activity: Activity) : AlertDialog.Builder(activity), RadioGroup.OnCheckedChangeListener { class OpenNoteDialog(val activity: Activity) : RadioGroup.OnCheckedChangeListener {
val dialog: AlertDialog? val dialog: AlertDialog?
init { init {
val config = Config.newInstance(context) val config = Config.newInstance(activity)
val view = activity.layoutInflater.inflate(R.layout.dialog_radio_group, null) as RadioGroup val view = activity.layoutInflater.inflate(R.layout.dialog_radio_group, null) as RadioGroup
view.setOnCheckedChangeListener(this) view.setOnCheckedChangeListener(this)
val db = DBHelper.newInstance(context) val notes = DBHelper.newInstance(activity).notes
val notes = db.notes
notes.forEach { notes.forEach {
val radioButton = activity.layoutInflater.inflate(R.layout.radio_button, null) as RadioButton val radioButton = activity.layoutInflater.inflate(R.layout.radio_button, null) as RadioButton
radioButton.apply { radioButton.apply {
@ -34,7 +33,7 @@ class OpenNoteDialog(val activity: Activity) : AlertDialog.Builder(activity), Ra
.setView(view) .setView(view)
.create() .create()
dialog?.show() dialog!!.show()
} }
override fun onCheckedChanged(group: RadioGroup, checkedId: Int) { override fun onCheckedChanged(group: RadioGroup, checkedId: Int) {

View File

@ -9,16 +9,16 @@ import com.simplemobiletools.notes.Config
import com.simplemobiletools.notes.R import com.simplemobiletools.notes.R
import com.simplemobiletools.notes.databases.DBHelper import com.simplemobiletools.notes.databases.DBHelper
class WidgetNoteDialog(val activity: Activity) : AlertDialog.Builder(activity), RadioGroup.OnCheckedChangeListener { class WidgetNoteDialog(val activity: Activity) : RadioGroup.OnCheckedChangeListener {
val dialog: AlertDialog? val dialog: AlertDialog?
var mConfig: Config var mConfig: Config
init { init {
mConfig = Config.newInstance(context) mConfig = Config.newInstance(activity)
val view = activity.layoutInflater.inflate(R.layout.dialog_radio_group, null) as RadioGroup val view = activity.layoutInflater.inflate(R.layout.dialog_radio_group, null) as RadioGroup
view.setOnCheckedChangeListener(this) view.setOnCheckedChangeListener(this)
val db = DBHelper.newInstance(context) val db = DBHelper.newInstance(activity)
val notes = db.notes val notes = db.notes
notes.forEach { notes.forEach {
val radioButton = activity.layoutInflater.inflate(R.layout.radio_button, null) as RadioButton val radioButton = activity.layoutInflater.inflate(R.layout.radio_button, null) as RadioButton