B4A Class [custom view] GifViewer

Better implementation: https://www.b4x.com/android/forum/threads/b4x-b4xgifview-cross-platform-animated-gif-view.118550/

SS-2017-07-26_17.24.05.png


Simple view that shows an animated gif. Based on agraham's GifDecoder library.

The animated gifs included in this example are from giphy.com. I'm not sure whether they can be used commercially or not.

Tip: B4J ImageView supports animated gifs.

V1.20 - Images are cached once loaded. You need to add the following variable to the Main module:
B4X:
Sub Process_Globals
   Public GifsCache As Map
End Sub
 

Attachments

  • GifViewer.zip
    249.9 KB · Views: 2,249
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Copying updated assets files (4)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:882)
at android.graphics.Bitmap.createBitmap(Bitmap.java:906)
at anywheresoftware.b4a.agraham.gifdecoder.GifDecoder.SetPixels(GifDecoder.java:298)
at anywheresoftware.b4a.agraham.gifdecoder.GifDecoder.SetPixels(GifDecoder.java:396)
at anywheresoftware.b4a.agraham.gifdecoder.GifDecoder.ReadImage(GifDecoder.java:805)
at anywheresoftware.b4a.agraham.gifdecoder.GifDecoder.ReadContents(GifDecoder.java:672)
at anywheresoftware.b4a.agraham.gifdecoder.GifDecoder.Read(GifDecoder.java:559)
at anywheresoftware.b4a.agraham.gifdecoder.GifDecoder.Load(GifDecoder.java:211)
at b4a.example.gifviewer._setgif(gifviewer.java:64)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at b4a.example.main.afterFirstLayout(main.java:102)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **


Tablet, 7.70 Gb free (your first example).
 

omarruben

Active Member
Licensed User
Longtime User
Is it possible to create ,by code, a new gifviewer object from the cache???, I have already load a few gifs, then I want to create a random gifviewer-objects without loading again from the file.
 

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, someone knows whats the problem here?
i jsut copied the class and loaded my gif


Error occurred on line: 63 (Main)
java.lang.RuntimeException: Class instance was not initialized (gifviewer)
at anywheresoftware.b4a.debug.Debug.shouldDelegate(Debug.java:241)
at b4a.example.gifviewer._setgif(gifviewer.java:59)
at b4a.example.main._activity_create(main.java:450)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:735)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:360)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:6020)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:936)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:797)
 
Top