A Mix of BookLog and Flashcards

Henna Singh
2 min readFeb 27, 2022

--

#BuildTogether Day21/100

Sunday’s are always fun with multiple activities. Today was a bit of cross-stitch, PlayStation Games, morning cafe visit, and coding.

Finally, I was able to fix my error with Dialog.Builder.setMultiChoiceItems implementation and was able to run the app. As I mentioned before, typecasting ArrayList<String>toCharSequence did not work so I did a TypedArray conversion again in the method call and that worked.

There is no comparison to the pleasure you get after fixing an error you are stuck at for a long time 💃🏽…

The updated code is as below:

Another error that I ran into after I play the app was:

Caused by: java.lang.RuntimeException: Can't create handler inside thread Thread[pool-2-thread-2,5,main] that has not called Looper.prepare()

so this happened because my call to OpenDialog was happening inside the Realm write transaction which is not allowed because I was opening a UI element from inside a background process and that does not work.

So this error was fixed by using Asynchronous API I again. Modified code is now:

private fun loadAuthors() {
val nameList = ArrayList<String>()
realmClass.executeTransactionAsync({
val authorList = it.where(Author::class.java).sort("name").findAll()
authorList.toTypedArray().map { obj ->
nameList.add(obj.name)
}
}
, {
if(nameList.size>0) openDialogBox(nameList)
else {
Toast.makeText(context, "Author List is empty, please add Author Name first", Toast.LENGTH_LONG).show()
}
}, {
Timber.d("Error happened while reading Author List %s", it.localizedMessage)
Toast.makeText(context, "Error happened while reading List, ${it.localizedMessage}", Toast.LENGTH_LONG).show()
})
}

I only want to open it if the list is greater than 0.

Now when I run my app, it shows me a dialog box with the list of author/s (currently 1) to select from 🤘🏽

The next step is to get rid of the keyboard that opens up and let only the dialog box open and also finish the rest of the logic of BookFragment and persist the book to the database.

Flashcard Project with Flexbox Layout

I was stuck on this project for a while before I moved to Realm Relationships and started with BookLog App, I managed to finish this as well :D

I used CSS Grid Layout to display 3*3 square matrix and updated my codepen here — https://codepen.io/hennasingh04/pen/zYPpJLB

I got help from an amazing friend Elad Shechter who as you see is a CSS expert ;) He suggested some layouts are easier with Grid than Flexbox :D

Will continue more tomorrow. Thanks for reading :)

--

--

Henna Singh
Henna Singh

Written by Henna Singh

Technical Speaker and an aspiring writer with avid addiction to gadgets, meet-up groups, and paper crafts. Currently doing Full Stack Diploma at Code Institute

No responses yet