BookLog Application: Joining the Puzzle Pieces

Henna Singh
2 min readMar 6, 2022
#BuildTogether Day 27/100

The day started on a good note, A sea-side walk, 🌊a good breakfast, some more walks towards the harbor, some cycling, and a few good hours in the local library 📚 which I visited for the first time and it was a total treasure hunt..

Today, I continued with BookLog Application and joined some more puzzle pieces. The issue I had yesterday “Error inflating the fragment class” gave me some tough hours but I was able to figure it out on my own.

Puzzle Piece 01:

I got some help from the article, when I realised I am trying to access resources before the fragment view is created. I changed some more code in all classes.

Puzzle Piece 02:

I added view binding to Library Activity as well which I had not added earlier and I replaced Frame Layout in the layout with Fragment Container View.

//declare a variable
private lateinit var binding: ActivityLibraryBinding
//in onCreate() method
binding = ActivityLibraryBinding.inflate(layoutInflater)
setContentView(binding.root)

Joining these two puzzle pieces fixed that inflate fragment error. Now I was left with implementing logic to the Add Book Fragment and that took few good hours to figure out.

I had implemented below code to retrieve list of authors to display it to the Dialog Box

Puzzle Piece 03:

The next puzzle piece to figure out was how to cast the string list of authors back to Author Object, so I implemented some more mode in the dialogBox method call.

I declared two global variables which I used in the method

var bookObject = Book()
private val authorsToAdd: RealmList<Author> = RealmList()

This code worked and Author got added successfully.

The next step was to add clickListener to Add Book button to collect inputs from all components and I implemented below:

Now, the last puzzle piece that left my app hanging is coming from click listener on the button, its not able to add the bookObject successfully and throwing below:

D/AddBookFragment: Error adding the bookObject to Database Object is no longer valid to operate on. Was it deleted by another thread?

The code is not deleting the object anywhere, I wonder whats causing it… Last piece to figure out tomorrow.. :)

PS: Please feel free to read “My journey of 100 days” at MongoDB Community Forums ❤

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

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

Write a response