B4A Library Image Slider wrapper (daimajia.AndroidImageSlider)

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

Just sharing some information.

As per my tests, this library when used along with the Library Spinner Wheel - Vertical and Horizontal https://www.b4x.com/android/forum/t...izontal-1-feb-new-lib-files-in-post-17.62723/
Gives the following compilation error due to the incompatibility in the nineoldandroids used.
B4X:
B4A version: 5.80
Parsing code.    (0.12s)
Compiling code.    (0.36s)
Compiling layouts code.    (0.02s)
Generating R file.    (0.90s)
Compiling generated Java code.    (2.45s)
Convert byte code - optimized dex.    Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/nineoldandroids/animation/Animator$AnimatorListener;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
    at com.android.dx.command.dexer.Main.processClass(Main.java:615)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:570)
    at com.android.dx.command.dexer.Main.access$2(Main.java:546)
    at com.android.dx.command.dexer.Main$2.processFileBytes(Main.java:514)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:537)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:449)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:236)
    at com.android.dx.command.dexer.Main.run(Main.java:206)
    at com.android.dx.command.dexer.Main.main(Main.java:179)
    at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting

Both the libraries cannot be used together in a project. Individually both the libs works fine, the problem occurs only when both the libs are used together in a project.

I had posted the error message in another thread in the Questions section and the following is the reply from Erel

The library author should update the library and move out the nineoldandroids classes to a jar which will then be referenced with @DependsOn.


Regards
Anser[/QUOTE]
 

frenkipi

Member
Licensed User
Longtime User
Hello, is there a way to use image slider combined with picasso library (link)? When I combine these two... I add another picasso.jar and picasso.xml in library folder and I get this error


I have created image slider and picasso imageviewer in separate project and they all works.

Regards!
 

desof

Well-Known Member
Licensed User
Longtime User
Is it possible to insert into an existing layout already with other controls?
How is it possible ?
 

Asim A Baki

Active Member
Licensed User
Longtime User
Is it possible to insert into an existing layout already with other controls?
How is it possible ?
yes you can

B4X:
Dim Slider As Slider
    Slider.Initialize("Slider")
  
    Activity.AddView(Slider,0dip,0dip,50%x,50%y)
 

desof

Well-Known Member
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Activity.LoadLayout("1")
     Slider.Initialize("Slider")
  
    Activity.AddView(Slider,0dip,0dip,100%x,100%y)
'  
    Slider.AddSlide("Hannibal", "http://static2.hypable.com/wp-content/uploads/2013/12/hannibal-season-2-release-date.jpg")
    Slider.AddSlide("Big Bang Theory", "http://tvfiles.alphacoders.com/100/hdclearart-10.png")
    Slider.AddSlide("House of Cards", "http://cdn3.nflximg.net/images/3093/2043093.jpg")
    Slider.AddSlide("Game of Thrones", "http://images.boomsbeat.com/data/images/full/19640/game-of-thrones-season-4-jpg.jpg")
  
    Dim filelist As List = File.ListFiles(File.DirDefaultExternal  )
  
    For Each fi As String In filelist
        Dim path As String =File.Combine(File.DirDefaultExternal  , fi)
        If fi.LastIndexOf (".JPG")>0 Or fi.LastIndexOf (".png")>0  Then       
            Slider.AddSlide(fi , "file:" & path )
           
        End If
      
    Next
    Slider.SetTransition(Slider.SLIDER_TRANSITION_Fade)
    Slider.Delay=5000
    Slider.Start
End Sub

And what would be the burden to do it through files not from the WEB?
 

Asim A Baki

Active Member
Licensed User
Longtime User
I'm not sure if I understand your point but maybe this is your requirement

Slider.AddSlide(fi , "file:" & path )
 

peacemaker

Expert
Licensed User
Longtime User
Is it possible do not start playing ? Just start for manual sliding.
After Start - the first image is slided very fast, and then long loading the next one, that is for test is the same as the first one. Never loaded the second the same one...
But how to just slide manually ?
 

peacemaker

Expert
Licensed User
Longtime User
Is it possible to manually set the needed slide ?
 

peacemaker

Expert
Licensed User
Longtime User
Clear... So, here all depends on the original JAR lib that is wrapped ?
And no additional possibility to control the slides (only manual sliding, set needed one, click) ?
 

peacemaker

Expert
Licensed User
Longtime User
When some Java lib is wrapped for B4A - can new functions be added into the B4A lib ?
For this one lib "manual sliding from the needed position; image tap event" are interesting.
 

peacemaker

Expert
Licensed User
Longtime User
This means that it needs to find some alternative slider lib...
Thanks, Don.
 

Alexander Stolte

Expert
Licensed User
Longtime User
Hey, my head is steaming...

How can i create Slider via Loop?

In my example is only one picture of 3 in the Slider.

B4X:
Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("frm_diashow")
    Slider.Initialize("Slider")
   Activity.AddView(Slider,0,0,100%x,100%y)
  
    picsize  = chat.picture.Size
   For i = 0 To picsize -1
        Dim filename As String = "mypicture.jpg"
        Dim dir As String = File.DirDefaultExternal
        'Main.reqManager.BytesToImage(chat.picture.Get(0))
        SavePictureToFile(chat.picture.Get( i), dir, filename)
      Dim bm2 As BitmapExtended
        Dim bm As Bitmap
        Dim bm3 As Object
        bm =   LoadBitmapSample(File.DirDefaultExternal,   "mypicture.jpg",    100%x,100%y)
      Dim path As String =File.Combine(File.DirDefaultExternal  , "mypicture.jpg" )

        bm=bm2.rotateBitmap(bm,90)
  
        bm3 = Main.reqManager.ImageToBytes( bm)
        Dim filename As String = "mypicture.jpg"
        Dim dir As String = File.DirDefaultExternal
    
        SavePictureToFile(bm3, dir, filename)

       Slider.AddSlide("Momentcat"  , "file:" & path )
  
    Next
  
    Slider.SetTransition(Slider.SLIDER_TRANSITION_FlipHorizontal)
    'SLIDER_TRANSITION_FlipHorizontal
    '.SLIDER_TRANSITION_Tablet
    Slider.Delay=2000
    Slider.Start
            End Sub
 

robsonRC

New Member
Licensed User
Longtime User
Hi there is an error occurring when initializing the Slider.Initialize ("Slider")


B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 35 (Main)
android.view.InflateException: Binary XML file line #61: Error inflating class com.daimajia.slider.library.Tricks.InfiniteViewPager
    at android.view.LayoutInflater.createView(LayoutInflater.java:633)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
    at com.daimajia.slider.library.SliderLayout.<init>(SliderLayout.java:173)
    at com.daimajia.slider.library.SliderLayout.<init>(SliderLayout.java:167)
    at com.daimajia.slider.library.SliderLayout.<init>(SliderLayout.java:163)
    at AndroidSlider.SliderLibrary.Slider.innerInitialize(Slider.java:145)
    at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:65)
    at AndroidSlider.SliderLibrary.Slider.Initialize(Slider.java:134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    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:739)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…