The Journey of #100DaysOfCode (@henna_dev)

#Day13 of #100DaysOfCode

Share on Twitter: https://twitter.com/henna_dev/status/1495170877184483328

3 Likes

#Day14 of #100DaysofCode

Share on Twitter: https://twitter.com/henna_dev/status/1495548266922053633

3 Likes

It was a tiring day today but I am happy I still made some progress and in turn discovered more errors… :stuck_out_tongue:

#Day15 of #100DaysOfCode

Share on Twitter: https://twitter.com/henna_dev/status/1495908425141735424

Cheers :performing_arts:

3 Likes

#Day16 of #100DaysOfCode

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 :orange_heart:, 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 :wink:

Share on Twitter: https://twitter.com/henna_dev/status/1496235660516241416

4 Likes

#Day17 of #100DaysOfCode

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 :stuck_out_tongue:

Share on Twitter: https://twitter.com/henna_dev/status/1496631546715021315

4 Likes

#Day18 of #100DaysOfCode

Today was a mix of Flexbox and Realm Sync. I am still struggling to make a 3 * 3 square matrix :frowning: I wish I was good at maths :stuck_out_tongue: but there is a new Realm Byte today…

Share on Twitter: https://twitter.com/henna_dev/status/1496965241724600320

3 Likes

#Day19 of #100DaysOfCode

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

2 Likes

#Day20 of #100DaysOfCode

I made good progress on BookLog App and also made some more bugs :stuck_out_tongue: 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 :smiley:

:sparkles: Twitter : https://twitter.com/henna_dev/status/1497705605217280002

2 Likes

#Day21 of #100DaysOfCode

Today was a fun day because it was Sunday :wink: 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… :sunglasses:

:sparkles: Twitter : https://twitter.com/henna_dev/status/1498075039085645827

2 Likes

#Day22 of #100DaysOfCode

Today was a loooonnggg day. I took a break from BookLog Application :face_with_peeking_eye: and came back to my Flashcards Project which I am pretty excited to finish. Although I am very poor at designing :grimacing: I am still excited to create this Quiz =D I created an HTML Form CheatSheet today

:sparkles: Twitter: https://twitter.com/henna_dev/status/1498444729482162190

3 Likes

#Day23 of #100DaysOfCode

Today was a tiring day… Lots of things to do and soo little time to do it… :upside_down_face: 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… :face_with_open_eyes_and_hand_over_mouth: Today I continued with the Flashcard Project… I am really looking forward to completing my quiz project

:sparkles: Twitter: https://twitter.com/henna_dev/status/1498804742927048720

3 Likes

#Day24 of #100DaysOfCode

Today was fun and yet another tiring day… I had a good start… I walked in the rain :cloud_with_rain: to a cafe… Had my favorite breakfast :avocado: :coffee: and attended two office meetings :technologist: and came back in the rain… :cloud_with_rain:
I had a late start to work and ended up finishing late but experimenting with Query API was fun… :smiley:

:sparkles: Twitter: https://twitter.com/henna_dev/status/1499169601350995973

3 Likes

#Day25 of #100DaysOfCode

Today was a good day full of good food… visa appointments… bug bashing and light reading on HTML Lists… :heart_eyes:

:sparkles: Twitter: https://twitter.com/henna_dev/status/1499533773582573571

4 Likes

:tada: 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 Coder

Participate in #100DaysOfCode challenge and share your daily learnings for 25 consecutive days.

Regards,
Stennie

4 Likes

#Day26 of #100DaysOfCode

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 :stuck_out_tongue:
I decided to come back to my BookLog App and finish it completely by tomrow, only if there were fewer bugs to fix :wink:

:sparkles: Twitter: https://twitter.com/henna_dev/status/1499893476720320515

2 Likes

#Day27 of #100DaysOfCode

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… :two_hearts:

Edit: Me at the Sea :smiley:

:sparkles: Twitter: https://twitter.com/henna_dev/status/1500261523998007302

2 Likes

#Day28 of #100DaysOfCode

Sunday rhymes with Funday and so eggjactly that way it was :stuck_out_tongue: Food Market Fun and Evening with a Fren

:sparkles: Twitter: https://twitter.com/henna_dev/status/1500616573609984000

2 Likes

#Day29 of #100DaysOfCode

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… :slight_smile:

I got some suggestions from a Senior Developer, but I could not implement them in the app until late evening :unamused: :unamused: and the code did not work. Realm Queries is a little harder to understand :stuck_out_tongue: 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 :smiley: 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… :performing_arts:

2 Likes

#Day30 of #100DaysOfCode

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 :wink:

:sparkles: Twitter: https://twitter.com/henna_dev/status/1501342938785329155

2 Likes

#Day31 of #100DaysOfCode

Today I went to the office and we had loads of fun with colleagues… It was a day spent well :heart_eyes:
I continued with my BookLog application and talked about errors I faced and how I resolved them

Until tomorrow… :performing_arts:

3 Likes