Wednesday, August 10, 2016

When I started to code in kotlin, one of the libraries that I found that was really useful is PaperParcel. PaperParcel is a library that would generate Parcelable using annotation. The good thing about it, is that it will reduce the amount of code and mistake you could make if you manually create those classes. Having said that, the library is not purely for Kotlin and it could be used in Java Android project.

To use it in kotlin
You will need to add these to your app build gradle dependencies

Thats about it, you can use QuoteImage to pass around Activities or Fragment or use it with your custom class.

Two things you have to remember is that your data class name must be supplied in PaperParcelable.Creator and every time you make changes to this data class (atleast for me) you have to do rebuild project.

If this interest you then have a check on the kotlin usage section of their github page.

Wednesday, August 3, 2016

As an Android developer, findViewById is probably one of the most annoying code piece you will keep using. However there are libraries that ease this daunting task, one of which I constantly use in Java is ButterKnife. Where you would have something like

Now in kotlin, there are different options that I had encountered so far.
One of which is KotterKnife which is also from Jake Wharton, the creator of ButterKnife. The library has the same awesomeness as ButterKnife, just check out the example on its github page

Another method is anko's find method, I previously blogged about Anko in Android and how you can use it to create UI in code, but anko is more than that. It has a lot of awesome helper functions and one of it is find, which is a shortform for findViewById and the code would look like this

Lastly most probably the lazies solution, but might be not be the most readable one is by using Kotlin Android Extensions. It will automatically bind the views to a class which you will just have to import. To configure it, open your app's gradle file and add on the top

apply plugin: 'kotlin-android-extensions'

Then say you have a layout named activity_main.xml with table_layout and add_btn on it. On your kotlin activity, fragment or custom class just add

Thursday, June 2, 2016

Announcing my first kotlin android app Conference Developer Videos. It features videos from different languages and technologies, it also have lists for you to add videos into. Please help rate the app. Thank you in advance :)

I created a patreon page to those who are willing to help/donate, my plan is that I want it to be my full time job as there are tons of features to include like notifications, make an ios app and a lot more. Help support the site