B4i Library Gif View

Haris Hafeez

Active Member
Licensed User
Hello All,

Continuing to have a a bit of fun with libraries, I'm making a GIF View available for your use.

The goal of GIF View is to allow you to embed animated GIF in your apps. As things stand, I couldn't find any over here so I wrapped up a popular library that does this for us. This library is authored by Flipboard guys and is very robust and efficient(or so its fame is). One of my main design goals is to make the GIF View as similar to the standard ImageView that you guys would have used in B4i as possible.

The usage is pretty simple:
B4X:
Dim hh As HHAnimatedGifView
hh.Initialize("gif")
iv = hh.GetAnimatedGifView("http://raphaelschaad.com/static/nyan.gif")

Page1.RootPanel.AddView(iv, 10,10, 300, 300)
Currently, the HHAnimatedGifView object doesn't support click events but am going to update this library so watch this space for updates. I need to do a bit of work so that it works exactly like the standard ImageView click event.

Attached is the zip containing the library files. Copy the .h and .a files in your local mac builder's Libs folder and copy the .xml file to your B4i Libraries folder on your Windows box. A sample project is also attached.


EDIT: Version 1.1 adds another method that takes as input the file name(without .gif) of the GIF file. This is required because loading gifs using the file:// URL doesn't work in release. See posts 7 onward for details

Cheers,
Harris
 

Attachments

Last edited:

JohnC

Well-Known Member
Licensed User
Excellent! This could add some really cool looking animations to our apps.
 

Albi

Active Member
Licensed User
This is very cool! Is there also a way to use local files instead of urls?
I tried
B4X:
iv = hh.GetAnimatedGifView(file.Combine(file.DirAssets, "giftest.gif"))
but that didn't work...
 

Albi

Active Member
Licensed User
In debug mode it works fine from a local file, but not in release mode. Any idea why this would be?
I've attached an example (it's just that line above modified from your example)
 

Attachments

Haris Hafeez

Active Member
Licensed User
Thanks for highlighting this. I have also just checked that this doesn't show anything when the app is built in release mode. I will tinker with things a bit and revert. At the moment, I'm not too sure what's causing this behaviour.
 

Haris Hafeez

Active Member
Licensed User
So I spent a bit of time last night and I've got some good news and bad news.
The good news is that I managed to get the animated gif work in a release app when I added a new method to the library.
The bad news is that with this method, the gif does not show in debug mode.

I think the issue here is that there is a difference between how B4i handles local file paths when it is using a shell app for debugging and when it generates ios app in release. Of course, I'm not a B4i expert and will have to receive some input on this from our boss, Erel :)

I will start a new thread for discussing this issue so we can keep this thread for library updates and usage questions.

We can use conditional compilation to use the right method but I will rather try to find a proper solution first so watch this space for updates.
 

Albi

Active Member
Licensed User
wow, thanks very much. working in release mode and not debug mode is pretty much just good news!
I really appreciate your help and time. I'll test it out later today and just edit this to confirm that it has worked for me...

edit1: i assume i need to wait for Erel to upload new library files to the hosted builder?
 

Haris Hafeez

Active Member
Licensed User
I have updated the first post. The updated library contains another method GetAnimatedGifViewForFile that takes as parameter the name of the local file(without the .gif extension). I have also uploaded an updated sample project that uses conditional compilation to check which method to call based on whether you are working in DEBUG or RELEASE.

Note you may not be able to use the library immediately if you're using hosted builder as you will have to wait for Erel(or one of the admins) to upload the updated library files to the hosted builder. You can of course download the lib and set it up if you're using local builder.

Have fun!
 

Albi

Active Member
Licensed User
amazing, thanks. I shall wait for an admin to upload the files, (or perhaps send an email asking them to check this thread when they have a chance....)

edit: just to confirm for anyone else reading this, the hosted builder is updated and the library works in debug and release modes. woop woop.
 
Last edited:
Top