Refactoring and cleanup

To have the best possible code after conversion, we must perform refactoring and cleanup. We will adapt our code base to conform Kotlin standards and idioms. For that purpose, you must read it whole. Only when this is done, we can consider our migration done!

Open your classes and read the code. There is a lot of space for improvements! After you do some work, you should get something like this:

The MigrationActivity code is as follows:

    ... 
    override fun onResume() = super.onResume() 
    ... 

As you can see, there is not too much work for MigrationActivity (and MigrationActivity2). Both classes are really small. A bigger effort is expected for classes such as Dummy and Dummy2:

        package com.journaler.model 
 
        class Dummy( 
          var title: String, 
          var content: String 
          ) { 
 
            constructor(title: String) : this(title, "") { 
            this.title = title 
           } 
 
       } 
        package com.journaler.model 
 
        import android.os.Parcel 
        import android.os.Parcelable 
 
        class Dummy2( 
          private var count: Int 
        ) : Parcelable { 
 
          companion object { 
            val CREATOR: Parcelable.Creator<Dummy2> 
= object : Parcelable.Creator<Dummy2> { override fun createFromParcel(`in`: Parcel):
Dummy2 = Dummy2(`in`) override fun newArray(size: Int): Array<Dummy2?> =
arrayOfNulls(size) } } private var result: Float = (count * 100).toFloat() constructor(`in`: Parcel) : this(`in`.readInt()) override fun writeToParcel(parcel: Parcel, i: Int) { parcel.writeInt(count) } override fun describeContents() = 0 }

These two class versions are now drastically improved after refactoring compared to their first Kotlin versions after the conversion. Try to compare the current versions with the original Java code we had. What do you think?