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

Support animated GiF-Images #9

Merged
merged 10 commits into from
Jun 14, 2016
Merged

Support animated GiF-Images #9

merged 10 commits into from
Jun 14, 2016

Conversation

AndyScherzinger
Copy link
Member

Add functionality to show animated gif files in slideshow (image preview)

rebased original PR done by @tobiasKaminsky so all kudos belongs to him.
Please review @tobiasKaminsky @przybylski

// https://android.googlesource.com/platform/frameworks/base/+/034de6b1ec561797a2422314e6ef03e3cd3e08e0;
//
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

super.onDraw(canvas);
if(mGifMovie == null){
super.onDraw(canvas);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that not calling onDraw in this case would lead to some instability on different vendors? ImageView and View might do some low level calls to hardware to invoke redrawing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather keep calls to super unless you are absolutely sure that it is safe to avoid those.

@tobiasKaminsky
Copy link
Member

@przybylski thanks for the code review.
I have commented/implemented your ideas

canvas.getWidth() / movie.width());
}

return scale;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't be afraid of early return ;)

@AndyScherzinger AndyScherzinger added this to the Nextcloud App 1.1.0 milestone Jun 13, 2016
mBitmapWidth = bm.getWidth();
mBitmapHeight = bm.getHeight();
super.setImageBitmap(bm);
}

public void setGIFImage(OCFile file) {
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some inconsistency here, setGIFImage takes OCFile and setImageBitmap takes bitmap. Latter is fine but former not quite. Altho I am not sure what would be the best way to resolve it.
Maybe setGIFImageFromPath(String) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change it to setGIFImageFromStoragePath(String storagePath) if that is fine with you

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@przybylski @tobiasKaminsky DONE, see d00cf73 I also reformatted the (new) code and added some javaDoc

@AndyScherzinger
Copy link
Member Author

I'll test it now on my device...

@przybylski
Copy link
Member

LGTM

@tobiasKaminsky
Copy link
Member

After a final test by @AndyScherzinger it LGTM

@AndyScherzinger
Copy link
Member Author

AndyScherzinger commented Jun 14, 2016

@tobiasKaminsky I found one small issue which might not be related to the animated gif itself. When I view animated gifs that are way smaller than my display resolution I can see the image_fail.png in the background behind the gif itself. Any idea as to why that happens? try for example the following gif.
giphy2

which gets displayed like this:
device-2016-06-14-092731

@przybylski
Copy link
Member

This is probably related with calling super.onDraw

@przybylski
Copy link
Member

What I mean by that is because ImageViewCustom extends ImageView so it requires image to be set if image is suppose to be displayed. If image is unavailable then ImageView sees that as an error, so the natural thing in onDraw is to draw image_fail resource no canvas

@AndyScherzinger
Copy link
Member Author

AndyScherzinger commented Jun 14, 2016

Hah! You are right! So I removed it.

@przybylski
Copy link
Member

@AndyScherzinger you probably don't see a problem here but try to open any non gif image

@przybylski
Copy link
Member

Haha :D it made this pull request as looks good to me even without telling it :D

@AndyScherzinger
Copy link
Member Author

Ouch.. Can see anything anymore...

@przybylski
Copy link
Member

przybylski commented Jun 14, 2016

The ideal implementation would so something like:

  • extend View not ImageView
  • mimic few additional methods to support transformations from extending classes
  • don't scale, inheriting classess should handle them (or allow scaling as an option)
  • draw only bitmap or gif frame

but the current code is good enough, just call super.onDraw when mGifMovie is null

@AndyScherzinger
Copy link
Member Author

Thanks @przybylski added what you described abe2b24

but the current code is good enough, just call super.onDraw when mGifMovie is null

anyone fancying opening an issue (maybe plus PR) to work on the proposed solution by @przybylski ?

@AndyScherzinger
Copy link
Member Author

@tobiasKaminsky It's yours to hit the merge button :)

@tobiasKaminsky tobiasKaminsky merged commit 704ffb4 into master Jun 14, 2016
@tobiasKaminsky tobiasKaminsky deleted the animatedGif branch June 14, 2016 19:21
@tobiasKaminsky
Copy link
Member

🎉 my first merge, thanks for this great feeling 👍

@AndyScherzinger
Copy link
Member Author

AndyScherzinger commented Jun 14, 2016

Well, you very much deserved it! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants