Wednesday, November 1, 2017

Kotlin 101

I finished my initial conversion of the app into Kotlin.  On the whole, it went really well.  Kotlin is very easy to pick up.  My only stumbling block was getting use to some of the syntax changes.  The ones that took me the longest to get used to was the method and constructor changes, but even those were really minor stumbling blocks.  I pretty much just followed along with the official language documentation at https://kotlinlang.org/.

I did bring in to Kotlin libraries up front: KotterKnife and Anko Sqlite.  KotterKnife is the kotlin version of ButterKnife.  Since I am a big fan of ButterKnife, it was a gimme to try KotterKnife.  It was a little tricky to bring in but I found the answer at https://github.com/JakeWharton/kotterknife/issues/15.  Follow the directions listed and it should work.

I may try the full Anko in my next iteration, but the is for the future.   The Anko Sqlite solved a lot of my questions about how I was going to do my Database management stuff. 

I was able to remove a lot of stuff or simplify my utilities do to the very useful ability called extensions. This lets you add methods to a class without need to extend it.  That is like having a sonic screwdriver in the toolbox.  

This is my initial attempt at Kotlin for Android so it is a little clumsy.   I will slowly improve it over the next few weeks.

Before I forget I also brought in ContentProviders instead of having a single database manipulation utility class.  I will talk about them in my next post.  I also did a few minor UI tweaks in favor simplifying the interactions.

I have not fixed any of the tests yet.   I plan on doing those after I figure out more about Anko.

As usual, the repository can be found at https://github.com/fsk-software/mynotes.

Monday, October 9, 2017

Change of Pace

First off, let me apologize for the lack of activity for so long.  I was unusually busy until late August.  I have been vacation for September, but I wanted to take a full month off from doing any development or programming.  It is nice to just take a break for awhile and focus on all the little errands that need to be done around the house and yard.  My break is now over and it is time to get back to development. 

On that note, before summer I modified my whole project to use Content Providers and some other fun features.  Unfortunately.  I didn't commit the changes and tried to clean up my computer.  Long story short, I was a little over ambitious and deleted some folders that I shouldn't have.   In other words, I lost the changes.   The moral of this story is Commit Early and Commit Often. 

 It is okay though because I realized that I really didn't want to publish My Notes.  What I really liked is showcasing how to do interesting things.   I have thought for awhile how to go about doing that.  I still like the idea of using a full-fledged app for the examples.   A lot of examples I look at give a very good overview of the specific item being discussed, but don't show the full interaction in an app.  In other words:  how to handle the issues that pop-up when the app is trying to do something other than just showcase the item under discussion. 

I took a long break from the blog to think about how to go about doing that and to enjoy summer and some free time away from coding.  When you do 8-10 hours of Android for several years, sometimes the last thing you want to do at home is more development.  Don't get me wrong, I love problem-solving and Android, but the brain and hands need a break sometimes.

So getting back to my original problem of how to the examples, I think I finally found a solution.  I am still going to use the full My Notes app, but I am going to modify it for the showcase and check each showcased modification of the app into it's own GitHub repo.  My first big mod is going to be refactoring the existing app with Kotlin.  I am going to check that mod into the existing repo since I may want to use that as the base for the other repos.  I will do my level best to keep each repo up to date with the latest and greatest in Android.  Nothing sucks worse than hunting for a solution to a problem and finally finding it, only to discover it is out-of-date and doesn't work anymore.