Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

SekhGulamMainuddin
Copy link
Contributor

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
Copy link
Contributor Author

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.

@therajanmaurya therajanmaurya merged commit fcf3917 into openMF:development Feb 15, 2024
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SDK Checks to Deprecated Parcelable and Serializable functions
2 participants