shosetsuorg / shosetsu

An android application for reading light novels. Moved to https://gitlab.com/shosetsuorg/shosetsu
https://shosetsu.app
GNU General Public License v3.0
584 stars 34 forks source link

Disallow opening duplicate FILTER pop-ups #168

Closed khonkhortisan closed 2 years ago

khonkhortisan commented 2 years ago

Fixes #167 I'm not sure I did this right, but seems to work.

//Lazy loading prevented me from initializing it immediately, so it's null.
private var bsg: BottomSheetDialog? = null
⋮
if (bsg == null)
    //I create a single BottomSheetDialog to edit the contents of and show
    //one for the library, one for the list of extensions, one for an extension's catalog
    bsg = BottomSheetDialog(binding.root.context)
//For the list of extensions filter, it fills the dialog with an empty Languages group, then later it fills in en jp zn pt ar es. If I allow running .apply every time I hit FILTER, it'll crash the second time it tries to fill in the Languages on the single pop-up it shows.
//I want to invert isShowing but the type is null or boolean and null can't be inverted, so I just check for false. I don't think it can actually be null by this point.
if (bsg?.isShowing() == false) {
    //Because it starts null, I have to use ?. instead of .
    bsg?.apply {
        //It gets created once, modified multiple times
        setContentView(getBottomMenuView())
    }?.show()
}