openMF / mifos-mobile

Repository for the Mifos Mobile Banking App for clients
https://openmf.github.io/mobileapps.github.io/
Mozilla Public License 2.0
270 stars 674 forks source link

Fixed: #2395 Added SDK Checks for Deprecated Parcelable and Serializable Functions #2515

Closed SekhGulamMainuddin closed 6 months ago

SekhGulamMainuddin commented 6 months ago

Fixes: #2395

Added SDK Checks for the Deprecated Parcelable and Serializable Functions.

Made an Object Class ParcelableAndSerializableUtils to do all the work to reduce redundancy in the code and refactored the activities and fragments containing the deprecated Parcelable and Serializable Functions.

object ParcelableAndSerializableUtils {

    fun <T> Bundle.getCheckedArrayListFromParcelable(classType: Class<T>, key: String): List<T>? {
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            this.getParcelableArrayList(key, classType)
        } else {
            this.getParcelableArrayList(key)
        }
    }

    fun <T> Bundle.getCheckedParcelable(classType: Class<T>, key: String): T? {
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            this.getParcelable(key, classType)
        } else {
            this.getParcelable(key)
        }
    }

    fun <T : Serializable> Bundle.getCheckedSerializable(classType: Class<T>, key: String): Any? {
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            this.getSerializable(key, classType)
        } else {
            this.getSerializable(key)
        }
    }

}
SekhGulamMainuddin commented 6 months ago

Hi @therajanmaurya I have reopened the PR for this issue by resolving all the merge conflicts and with the latest pull from the development branch.