cortinico / slidetoact

A simple 'Slide to Unlock' Material widget for Android, written in Kotlin 📱🎨🦄
MIT License
1.19k stars 161 forks source link

complete_icon attribute requires String not Drawable! #153

Open doohab opened 3 years ago

doohab commented 3 years ago

XML layout:

app:complete_icon="@drawable/slidetoact_animated_ic_check"

It asks for String not drawable. Also, setting this in code not working, no animation at slide completed:

slide.completeIcon = R.drawable.slidetoact_animated_ic_check

Details

doohab commented 3 years ago

I needed to call invalidate(), although this just shows the checkmark suddenly not animating it, but better than nothing :), I guess this should be mentioned ..

https://user-images.githubusercontent.com/43655526/110595003-8dd7c780-818e-11eb-9a2c-df548693e2a3.mp4

Kotlin: binding.slider.onSlideCompleteListener = object : SlideToActView.OnSlideCompleteListener { override fun onSlideComplete(view: SlideToActView) { view.invalidate() } }

cortinico commented 3 years ago

It asks for String not drawable.

What you mean "it asks for String"? The type of this attribute is set the reference so it will work correctly if you set it as:

<com.ncorti.slidetoact.SlideToActView
            android:id="@+id/slide_custom_icon"
            app:complete_icon="@drawable/custom_complete_animated"/>

Also, setting this in code not working, no animation at slide completed:

Can you provide a reproducer? The sample app has exactly this code and it works fine:

https://github.com/cortinico/slidetoact/blob/fca28ddbedcea55a8d79c6a40e491bd71857f855/example/src/main/java/com/ncorti/slidetoact/example/SampleActivity.java#L79

I needed to call invalidate(), although this just shows the checkmark suddenly not animating it, but better than nothing :), I guess this should be mentioned ..

The checkmark is shown "by default", you should not set anything special to let it show. Can you please take a look at the examples in this repo to see how to configure the slider?

doohab commented 3 years ago

The checkmark is shown "by default", you should not set anything special to let it show

Not in my case :( . If I don't set complete_icon in the xml layout file and in code, the checkmark is not showing at all at completion:

https://user-images.githubusercontent.com/43655526/111016375-91519580-83be-11eb-8019-d604ceb7fb6c.mp4

When I set @drawable/slidetoact_animated_ic_check to complete_icon, the checkmark also not showing and I get this error:

Screen Shot 2021-03-13 at 5 43 25 AM

As for sample app, I just copied and pasted the part I need, so Android Studio convert it from Java to Koltin to be:

binding.cartSliderProceed.onSlideCompleteListener = object : SlideToActView.OnSlideCompleteListener {
            override fun onSlideComplete(view: SlideToActView) {
// When I set completeIcon here, it shows but not animated
                binding.cartSliderProceed.completeIcon = R.drawable.slidetoact_animated_ic_check // or view.completeIcon = ...
                view.invalidate()
...
... }
}

I love your work btw, but I can't make it work the way you did in the example. I miss something somewhere.

cortinico commented 3 years ago

Not in my case :( . If I don't set complete_icon in the xml layout file and in code, the checkmark is not showing at all at completion:

Have you tried in a emulator? Can you try to run the example app in this repo in your device?

I'm trying to understand if this is a problem of your device or of your configuration.

doohab commented 3 years ago

Have you tried in a emulator?

It works perfect on the emulator, both my app and the expample app

Can you try to run the example app in this repo in your device?

the example app not playing complete animation on my Huawei. But if I close the app and run it again, the checkmark is there.

So, it seems my phone is the problem.

cortinico commented 3 years ago

I don't really know how to reproduce this at this point. It seems like a problem with the Huawei phone and the handling of AnimatedVectorDrawables

doohab commented 3 years ago

It seems like a problem with the Huawei phone and the handling of AnimatedVectorDrawables

I don't think this is the case, because I have an animated drawable on another activity as a background for an ImageView, cast it as Animator and calling start() without problem.