ozodrukh/CircularReveal

createCircularReveal makes square reveal on API16

Opened this issue · 4 comments

Description of the problem:

I've been using the library since 1.3.1
I figured I'd try updating to the latest version today, so I updated it to 2.0.1, tweaked the code so it works with the new APIs (looks like you use a native Animator instead of the included SupportAnimator now), and it worked fine when I tested it on a Pixel with API26 (Oreo), but my app is backwards compatible to API16 (Jellybean), and the circular reveal seems to turn into a square now. I reverted back and it works on 1.3.1, but not with 2.0.1

Which library version are you using?
2.0.1

Which phone/tablet are you using, and which Android version does it run? (e.g. Samsung Galaxy S5,
Android 5.0)

Nexus 4, Android 4.2.2, stock

Does the same happen on other devices or an emulator?
Yes

Can you reproduce the issue in the sample project included with the library? If not, can you
provide your own sample project or sample code that produces this error?

Animator anim
anim = io.codetail.animation.ViewAnimationUtils
                    .createCircularReveal(childBG, cx, cy, 0, finalRadius);
anim.setDuration(ANIMATION_LENGTH);
anim.setInterpolator(new AccelerateDecelerateInterpolator());
anim.start();

Also worth noting, I Googled the issue and found at least one other person running into this from May 8th:
https://stackoverflow.com/questions/28544800/create-circular-reveal-for-pre-lollipop-devices-android#comment74732182_28604515

Hi fellow,

It feels like you may using setOutlineProvider on new API, if so this causes a problem.

If it is not an answer to your question. Could your provide sample app, so i could investigate on this issues.

Thanks ;)

I got the same on a Samsung Galaxy S4 Mini running version 4.4.2 (KitKat).
Everything works fine except that it's a quadratic reveal instead of a circular reveal.

On the contrary the animation works fine on a Nexus 4 emulator running version 4.4.

I have not explicitly used "setOutlineProvider" at least.

Here's my code for starting the reveal animation:

fun View.enterWithCircularReveal(centerX: Int = this.pivotX.toInt(),
                                 centerY: Int = this.pivotY.toInt(),
                                 revealDuration: Long = 500) {
    val v = this
    v.visibility = View.INVISIBLE

    if (v.viewTreeObserver.isAlive) {
        v.viewTreeObserver.
                addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
                    override fun onGlobalLayout() {
                        v.viewTreeObserver.removeOnGlobalLayoutListener(this)

                        // Transition with the reveal animation
                        val finalRadius = maxOf(v.width, v.height)

                        // create the animator for this view (the start radius is zero)
                        val anim = createCircularReveal(
                                v, centerX, centerY, 0f, finalRadius.toFloat())
                        anim.duration = revealDuration

                        // make the view visible and start the animation
                        v.visibility = View.VISIBLE
                        anim.start()
                    }
                })
    }
}

I also have this problem in API < 19. I just copy/paste the example in README.md. I was solved by changing layerType to Software in root layout (RevealViewGroup)

True, hardware acceleration might be root of this issue