flavioarfaria / KenBurnsView

Android ImageViews animated by Ken Burns Effect
Apache License 2.0
2.73k stars 435 forks source link

RandomTransitionGenerator gets outside of image's content sometimes, or does too much zooming sometimes #4

Closed AndroidDeveloperLB closed 8 years ago

AndroidDeveloperLB commented 10 years ago

I'm trying to have a POC project that has the following features:

here's the project: https://drive.google.com/file/d/0B_nrUhQ0MIgwUGZ3cjJwZVpVbkU/

the problem is that even though everything works , the RandomTransitionGenerator sometimes go outside of the content of the image being shown, so empty area is shown too. Also, sometimes, the zoom factor gets really large. of course, I had to change some stuff on both libraries in order for this to work, but most of the code remained intact.

flavioarfaria commented 10 years ago

Hi AndroidDeveloperLB,

Thank you for your report.This lib wasn't at first intended to be used with images that are dynamically resized. On the other hand, this makes perfect sense for what you're trying to achieve. Now I'm considering to implement a few changes in order to support dynamic resizing without affecting the ongoing transition.

AndroidDeveloperLB commented 10 years ago

Oh, I see. Could you please inform me about it (you can write here) ? Also, is there any workaround for this? Have you tried the project?

flavioarfaria commented 10 years ago

You are already following this issue you created, unless you have clicked on Unsubscribe on the right panel of this page. So, you'll be receiving an e-mail when it's done and I close it. Unfortunately, there's no easy workaround to make it work. I hope I can fix it soon.

AndroidDeveloperLB commented 10 years ago

ok . sorry for that.

AndroidDeveloperLB commented 10 years ago

@flavioarfaria do you have any news on this? I've tried to change the code myself, but so far I've failed to make it work... :(

flavioarfaria commented 10 years ago

Well, I still haven't time to solve it. Sorry for that. It's not very trivial to solve it because when your view gets resized, it changes its aspect ratio. When that happens, the new viewport may not fit the current transition anymore, because the transition was created based on the old viewport size and ratio. As a workaround, you can create your own TransitionGenerator that creates transitions which move around in a more careful way, preventing themselves from getting too close to the borders of the drawable.

AndroidDeveloperLB commented 10 years ago

What if, instead of change the size of the view and set animations on it, you do the animation of the content itself? This means, you already have the bitmap, and when drawing, you decide which rectangle of the bitmap to show. The animation would be on the values of the rectangle to show. This way, the size of the imageViews will always stay the same, as they act as a "window" to look at the content, instead of letting the content decide the size of the imageViews...

Wouldn't it solve everything? It might even be easier to understand, as you choose 2 rectangles from the bitmap to transition from&to.

flavioarfaria commented 10 years ago

What you're suggesting is just exactly how it already works today. But what I mean is that the problem you are having is probably due to the fact that your implementation of the ActionBar resizes the view when the user scrolls, doesn't it?

AndroidDeveloperLB commented 10 years ago

No, it occurs even without scrolling and changing the size of the container. If what I wrote is how it works, it shouldn't change the size of the views when you give them new bitmaps, no matter the width and height (and aspect ratio) of the given bitmap would be.

Also, as others have noticed, there are some rare crashes with the current transition mechanism.

flavioarfaria commented 10 years ago

I took a look at the example you sent in your first message, but it was hard to deep down into the issue you're having, since there are two libs involved. Can you please try to make the smallest changes possible to the sample project of this repo to reproduce your issue? That will make my life much simpler. ;)

Yes, a few crashes happen, but all of them do in situations where the view is resized during a transition. This is often common when the Activity window is resized when the soft input mode is shown due to android:windowSoftInputMode="adjustResize". These crashes are about to be fixed. If you're experiencing crashes in different situations, let me know.

AndroidDeveloperLB commented 10 years ago

This library was supposed to be used in a project I work for a company. Because of lack of time, we didn't fix it and just use simple transitions instead. I don't remember what I did on the project I've published here.

Anyway, in order to make a minimal project, just make an interface that expects to get a bitmap based on some key (an integer for example), and let your library use it to always show the next bitmap when the transition ends. Maybe let the library start loading the next bitmap using this interface (in the background) when a previous transition (between the imageViews) ends, and only when both the KenBurns effect and the loading finish, do a new transition.

The second phase (when this one works), is to check what happens when it's inside an action bar.

flavioarfaria commented 10 years ago

So, you mean you'd like to use multiple images with the same view? I'm working on a solution to support that (see commit aa45a95118ed01618e8eea2bd455940eacd2446c).

Since there are a couple of weeks that I wrote this commit, I don't remember if it's already working and ready for release. You can try it yourself by building it from the dev branch.

AndroidDeveloperLB commented 10 years ago

Thank you. I will ask if I can check it out when I get back to the office.

AndreiHarasemiuc commented 9 years ago

hello

I'm not having the problem with getting out of the image's bounds. However, I'm having the problem with WAY too much zoom.

You guys have any idea how I can fix that?

AndroidDeveloperLB commented 9 years ago

Sorry, I didn't return to this issue. I don't use this library anymore.

Nomane commented 9 years ago

Hello,

Some news about this récurrent issue, it seems to occurs when view is used with multiple image downloaded from URL (Picasso in my case) and dynamically resized

Thanks Nomane

flavioarfaria commented 8 years ago

I haven't seen it happening after https://github.com/flavioarfaria/KenBurnsView/pull/34. Closing for now.

kishorecs commented 5 years ago

There is another issue with Samsung galaxy S8.. I'll share the log

Fatal Exception: java.lang.RuntimeException: Canvas: trying to draw too large(124367104bytes) bitmap. at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:229) at android.view.RecordingCanvas.drawBitmap(RecordingCanvas.java:97) at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:529) at android.widget.ImageView.onDraw(ImageView.java:1367) at android.view.View.draw(View.java:20352) at android.view.View.updateDisplayListIfDirty(View.java:19297) at android.view.View.draw(View.java:20075) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19288) at android.view.View.draw(View.java:20075) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.support.constraint.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023) at android.view.View.updateDisplayListIfDirty(View.java:19288) at android.view.View.draw(View.java:20075) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1426) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19288) at android.view.View.draw(View.java:20075) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19288) at android.view.View.draw(View.java:20075) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19288) at android.view.View.draw(View.java:20075) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19288) at android.view.View.draw(View.java:20075) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19288) at android.view.View.draw(View.java:20075) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.draw(View.java:20355) at com.android.internal.policy.DecorView.draw(DecorView.java:979) at android.view.View.updateDisplayListIfDirty(View.java:19297) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:686) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:692) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:800) at android.view.ViewRootImpl.draw(ViewRootImpl.java:3488) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3275) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2810) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1779) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7810) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:723) at android.view.Choreographer.doFrame(Choreographer.java:658) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)