Skip to content

Crashes when loading animation #155

Description

@vovkab

Looks like library is not loading animation correctly which leads to loading a wrong resource, i.e. it can try to load "dimen" as animation. As a result it crashes since it can't load other resource as animation.

Steps to reproduce:

  1. Remove any animation from style:
<style name="ToolTipAnimation">
    <item name="android:windowExitAnimation">@anim/ttlm_tooltip_anim_exit</item>
</style>
  1. Run the app and observer that animation is no longer working correctly. Even though it should have fallback to 0 and ignored if missing.

As I can see the issue is that we are using incorrect indexes when loading resources:

val typedArray = context.theme.obtainStyledAttributes(mAnimationStyleResId, intArrayOf(android.R.attr.windowEnterAnimation, android.R.attr.windowExitAnimation))
mEnterAnimation = typedArray.getResourceId(typedArray.getIndex(0), 0)
mExitAnimation = typedArray.getResourceId(typedArray.getIndex(1), 0)
typedArray.recycle()

According to documentation:

The indices used to retrieve values from this structure correspond to the positions of the attributes given to obtainStyledAttributes.
https://developer.android.com/reference/android/content/res/TypedArray

We should be passing index from the array, for example:

val typedArray = context.theme.obtainStyledAttributes(mAnimationStyleResId, intArrayOf(android.R.attr.windowEnterAnimation, android.R.attr.windowExitAnimation))
mEnterAnimation = typedArray.getResourceId(0, 0)
mExitAnimation = typedArray.getResourceId(1, 0)
typedArray.recycle()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions