#Day13 of #100DaysOfCode
Share on Twitter: https://twitter.com/henna_dev/status/1495170877184483328
Share on Twitter: https://twitter.com/henna_dev/status/1495170877184483328
Share on Twitter: https://twitter.com/henna_dev/status/1495548266922053633
It was a tiring day today but I am happy I still made some progress and in turn discovered more errors…
Share on Twitter: https://twitter.com/henna_dev/status/1495908425141735424
Cheers
Today was a long day but it was fun. I am pretty much happy and satisfied with how the work is going oh GOSH!!, I was missing development soo much , so glad to be back at it…
This app idea may turn into an article once I am finished with it and may write a full-fledged piece rather than broken into days as it is currently
Share on Twitter: https://twitter.com/henna_dev/status/1496235660516241416
Today was a long day, the second half was full of meetings, something I have started to dislike lately… My head is zooming out in the zoom
Share on Twitter: https://twitter.com/henna_dev/status/1496631546715021315
Today was a mix of Flexbox and Realm Sync. I am still struggling to make a 3 * 3 square matrix I wish I was good at maths but there is a new Realm Byte today…
Share on Twitter: https://twitter.com/henna_dev/status/1496965241724600320
Worked on my BookLog Application trying to resolve some more errors that lead to more… Phew
Share on Twitter: https://twitter.com/henna_dev/status/1497358898625499147
I made good progress on BookLog App and also made some more bugs I was finally able to sync my schema from Mobile to Atlas… although I am still in process of testing queries…
I am absolutely enjoying the process of discovery, understanding the concepts in more detail. More on the blog
Twitter : https://twitter.com/henna_dev/status/1497705605217280002
Today was a fun day because it was Sunday Playstation, Cross-Stitch, and some coding. I managed to fix the errors I was stuck on for a while in both BookLog and Flashcards Project…
Twitter : https://twitter.com/henna_dev/status/1498075039085645827
Today was a loooonnggg day. I took a break from BookLog Application and came back to my Flashcards Project which I am pretty excited to finish. Although I am very poor at designing I am still excited to create this Quiz =D I created an HTML Form CheatSheet today
Twitter: https://twitter.com/henna_dev/status/1498444729482162190
Today was a tiring day… Lots of things to do and soo little time to do it… Do you also feel there should be more than 24 hours a day… I wish I had better overlap with my favorite people…
I cant get enough of them… Today I continued with the Flashcard Project… I am really looking forward to completing my quiz project
Twitter: https://twitter.com/henna_dev/status/1498804742927048720
Today was fun and yet another tiring day… I had a good start… I walked in the rain to a cafe… Had my favorite breakfast and attended two office meetings and came back in the rain…
I had a late start to work and ended up finishing late but experimenting with Query API was fun…
Twitter: https://twitter.com/henna_dev/status/1499169601350995973
Today was a good day full of good food… visa appointments… bug bashing and light reading on HTML Lists…
Twitter: https://twitter.com/henna_dev/status/1499533773582573571
Excellent coding streak @henna.s! You’ve just unlocked the Committed Coder badge (which you can also use as a title in the forum):
Committed CoderParticipate in #100DaysOfCode challenge and share your daily learnings for 25 consecutive days. |
Regards,
Stennie
Today was a tiring day… I am not as young as I once was and that hurts…(oooffff) lol but I still feel like a child inside
I decided to come back to my BookLog App and finish it completely by tomrow, only if there were fewer bugs to fix
Twitter: https://twitter.com/henna_dev/status/1499893476720320515
Today I had a great start to my day, went for a morning walk close to the sea, had a good breakfast and then cycled to the library and spent some good hours there…
Edit: Me at the Sea
Twitter: https://twitter.com/henna_dev/status/1500261523998007302
Sunday rhymes with Funday and so eggjactly that way it was Food Market Fun and Evening with a Fren
Twitter: https://twitter.com/henna_dev/status/1500616573609984000
Today was full of meetings… I could not get a lot done and the day did not end with a happy note. I spent time solving the error I was stuck at for a while…
I got some suggestions from a Senior Developer, but I could not implement them in the app until late evening and the code did not work. Realm Queries is a little harder to understand I will understand them soon…
I made some changes in the Add Book Fragment, I was suggested not to use transactions in Read queries, so I removed transaction code from all of them.
private fun openDialogBox(nameList: ArrayList<Author>) {
val builder: AlertDialog.Builder = AlertDialog.Builder(requireContext())
builder.setTitle("Select Author/s")
val selectedAuthors = BooleanArray(nameList.size)
val stringAuthorList = nameList.map{it.name}.toTypedArray()
builder.setMultiChoiceItems(stringAuthorList, selectedAuthors) { dialog, which, isChecked ->
if (isChecked) {
//when checkbox selected, add position
selectedItems.add(which)
} else if (selectedItems.contains(which)) {
//when checkbox unselected
//remove pos from list
selectedItems.remove(which)
}
}
builder.setPositiveButton("OK") { dialog, which ->
selectedItems.forEach{
Timber.d("Authors, ${stringAuthorList[it]}")
nameList.forEach {author ->
if(stringAuthorList[it] == author.name){
bookObject.authors.add(author)
}
}
// realmClass.executeTransactionAsync({ realm ->
// realm.where(Author::class.java).equalTo("name", nameList[it]).findAll()
// .map{addAuthor ->
// bookObject.authors.add(addAuthor)
// }
// }, {
// Timber.d("Author added successfully")
// }, { throwable ->
// Timber.d("Error adding the author %s", throwable.localizedMessage)
// })
}
}
.setNegativeButton("Cancel", DialogInterface.OnClickListener{ dialog, id ->
dialog.dismiss()
})
builder.create().show()
}
I didn’t feel like deleting the code, so I commented it I changed the way I was processing the selected Authors, I used copyFromRealm
to get the AuthorList in form of ArrayList that I passed to openDialogBox
The loadAuthors
is called when I click on Text Button to add Book Author, it reads the list of authors in the database and displays it on a dialog for the user to select shown in above code.
private fun loadAuthors() {
var nameList = ArrayList<Author>()
realmClass.executeTransactionAsync({
val authorList = it.where(Author::class.java).sort("name").findAll()
nameList = it.copyFromRealm(authorList) as ArrayList<Author>
// 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()
})
}
Once the user selects the author index, it searches the list for a name that was selected and saves that to the bookObject.
When submit button is pressed, click listeners get called and save the book to realm database. The last part is giving errors and I have no clue how to solve, so I will continue tomorrow.
2022-03-07 22:42:42.517 14699-14699/? D/AddBookFragment: Error adding the bookObject to Database 'BookRealm' has a primary key, use 'createObject(Class<E>, Object)' instead.
I changed the code after above error to following
addBinding!!.buttonAddBook.setOnClickListener{
realmClass.executeTransactionAsync ({realm ->
val booktoAdd = realm.createObject(BookRealm::class.java, ObjectId())
booktoAdd.name = bookObject.name
booktoAdd.isRead = bookObject.isRead
booktoAdd.authors = realm.copyToRealm(bookObject.authors) as RealmList<Author>
}, {
Timber.d("Book Object Added Successfuly")
}, {throwError ->
Timber.d("Error adding the bookObject to Database %s", throwError.localizedMessage)
})
}
And this gives me a different error that I cannot solve
2022-03-07 23:42:34.721 5257-5257/? D/AddBookFragment: Error adding the bookObject to Database Attempting to create an object of type 'Author' with an existing primary key value '621a992338d6fd61a1126414'.
My Add BookFragment screen is as below:
Until Tomorrow…
I cracked the error that I was stuck at for a long time, now finally the puzzle pieces are complete. I drafted part one on our forums, Stay Tuned for part two
Twitter: https://twitter.com/henna_dev/status/1501342938785329155
Today I went to the office and we had loads of fun with colleagues… It was a day spent well
I continued with my BookLog application and talked about errors I faced and how I resolved them
Until tomorrow…