BookLogApplication: Connecting the dots with more logic

#buildTogether Day16/100

Today has been a long day and I realized I put my head into stuff where I can avoid :P Lol…. Although I am absolutely happy with where this app is heading and more than that I am feeling a weird sense of satisfaction of getting back to development again ❤

So, I was stuck with a few questions yesterday and with some collaborative discussions, I realized I did not structure it correctly.

(Telling you again to join me in this awesome journey of discipline, excitement, and habit-forming ;))

Some improvements to my Author and Book class as well as the fragment layouts.

So I removed Input for the book from Add Author screen as the author model has a backlink to books and that does not require user input

Add Author Screen

The Add Author Fragment code is as below, simple code, getting author value from UI, verifying it's not empty. Opening a Sync Realm and adding the object to the realm and closing it.

A slight change to the Book model, as I had forgotten to add the partition key. As I mentioned before partition key is important

open class Book(
var _id: ObjectId = ObjectId(),

var name: String = "",

var isRead: Boolean = false,

var _partition: String ="PUBLIC",

var authors: RealmList<Author> = RealmList()
) : RealmObject() {}

The Add Book UI looks like below. The logic I am struggling to implement here is to select multiple choices for authors as a book can have multiple authors.

I tried using AlertDialog.Builder.setMultiChoiceItems() but it’s not accepting the typed array. I may go ahead and write a custom adapter to display the list of authors that users can select.

The Add Book screen is different, if the author is not available, you would need to add Author first.

Add Book Screen

Since my add book fragment logic is still incomplete, I will not be posting it.

I further added Recycler View to the BookList Fragment and am using RealmRecyclerView Adapter to display the books. Ohh yes, Realm provides that.. Awesome, Right!!!!

Take a look at RealmAdapter, if you wanna give it a shot.

And also, nav graph error that I was facing yesterday, I made a stupid mistake of not renaming my class to AddAuthor, it was still showing AddOwner, not from the directory window that shows packages and class names, but the project window where you type the code..😹

So I am left with 2 things now and hopefully I will have a fully functional app tomorrow

  1. Adding code for BookList Display
  2. Making multiple selection choices for author to select from

Once, this is complete, my app can be run and schema will be populated to Atlas.

Let's see, what day 17/100 holds… Until tomorrow.. 👋




Technical Speaker and an aspiring writer with avid addiction to gadgets, meet-up groups, Kotlin and paper crafts.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Known vs Unknown Framework

5 Reasons to Launch an eCommerce Website as an Agile Project

Flip-flops in computer architecture

Handling unmodified requests in REST API

How to download automatically mp3 files with the Python scraping module BeautifulSoup

Pair Programming — Initial Inspiration

Live Virtual Mobile App Workshop

Recruitment for DPK Global Community Admins

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Henna Singh

Henna Singh

Technical Speaker and an aspiring writer with avid addiction to gadgets, meet-up groups, Kotlin and paper crafts.

More from Medium

Introducing Android 12

Room Database using ViewModel and live data-Kotlin-Part 2.

Asynchronous Android : Kotlin Coroutines

View Binding in Android