Android Question B4x Gif View

Nikan99

Member
Hello to everyone.
I use B4XGifView to my project and I call it multiple times. Actually, I have a Sub that inside of it I use the SetGif command. I call multiple times that Sub and after a few times I get some white sparks in my gif.
What problem is caused when I call multiple times in a activity the setgif? Is there any way to "clean" the gif and reload it in the same activity? Note that I do not want to do Activity.Finish and also I have to load multiple gifs in that activity.

Thanks for your time!
 
Solution
Okay, I found a solution. As it seems the gif I created using Gimp was a bad idea. The gif had not good render, I think, and the problem with the white sparks/lines that appeared everywhere at any time, was at any device that I tested. On the other hand, I tried an other gif with the same code and I had no problem.
If anyone face the same problem, try to change the gif.
I created my gif using that site: https://ezgif.com/ and it works fine. Thanks for the help!

Nikan99

Member
Please upload a small project so other members can check.
That is an example of my code. It is not my actual code but it has the same logic.

B4A - Calling multiple times SetGif:
Sub Process_Globals
    Public tmr As Timer
    Public MyPicture As String = ""
End Sub

Sub Globals
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    tmr.Initialize("MyTimer", 5000)
    tmr.Enabled=True
    
    'MyPicture is a varriable that I call from different routines and change the gif'
End Sub

Sub MyGif(pos As String)
    If File.Exists(File.DirAssets, pos) = True Then
        B4XGifView1.SetGif(File.DirAssets, pos)   
        B4XGifView1.Base_Resize(100%x,100%y)
    End If
    Sleep(300)
End Sub

Sub MyTimer_Tick
    MyGif(MyPicture)
End Sub

So, as you can see " B4XGifView1.SetGif(File.DirAssets, pos) " is been called more than once time. While my app is running some times I notice some white sparks that looks very bad. They appear in a flash, they do not last longer that 1-2 secs and they are in any plase of my phone. Do I create any problem to the memory of the phone? Is there any other way to load multiple gifs over and over?
 
Upvote 0

Nikan99

Member
First step is to switch to B4XPages. This code doesn't handle the activity lifecycle correctly.
I can not use B4XPages as I work in a big project and there are a lot of activities, classes etc. @Erel as I said before, the code I wrote is an example and is not my actual code. I wrote the timer thing just to show a way of loading many gifs over and over again.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Upvote 0

Nikan99

Member
but


How do you update the value of MyPicture?

Maybe this is the issue.

The code in another module conflict with timer.

Can you remove the timer and then in another module just call YourActivity.MyGif("ChangingValue") ?
I do not use timer. The timer thing is just an example. MyPicture is changed when some events rise.
 
Upvote 0

Nikan99

Member
Okay, I found a solution. As it seems the gif I created using Gimp was a bad idea. The gif had not good render, I think, and the problem with the white sparks/lines that appeared everywhere at any time, was at any device that I tested. On the other hand, I tried an other gif with the same code and I had no problem.
If anyone face the same problem, try to change the gif.
I created my gif using that site: https://ezgif.com/ and it works fine. Thanks for the help!
 
Upvote 0
Solution
Top