B4A Library [B4Xlib] SD: GridImage

This library adds a view that displays images loaded from local or from the internet (by entering only the url) and arranges them in a grid.
The clicked image is displayed in double size. The basic size of each cell can be established

sd_gridimage

Author:
Version:
0.04
  • GridImage
    • Events:
      • LongClick (ID As String, Open As Boolean)
      • Select (ID As String, Open As Boolean)
    • Fields:
      • KeepAspectRatio As Boolean
      • mBase As B4XView
      • MovTime As Int
        Animation duration
      • Tag As Object
    • Functions:
      • AddImage (ID As String, bmp As B4XBitmap)
      • AddUrlImage (ID As String, url As String)
      • Clear
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
        Base type must be Object
      • GetID (Position As Int) As String
      • GetImageID (ID As String) As B4XBitmap
        Returns the image associated with the ID
      • GetOpenID As String
        Returns the ID of the image that is stretched, null if all are closed
      • Initialize (Callback As Object, EventName As String)
      • Invalidate
    • Properties:
      • ImageWidth As Int
        Height/Width image
      • Size As Int [read only]
        Number of images

ezgif.com-optimize.gif
 

Attachments

  • jSample.zip
    2.2 KB · Views: 376
  • iSample.zip
    2.4 KB · Views: 359
  • aSample.zip
    9.2 KB · Views: 469
  • SD_GridImage.B4xLib
    2.6 KB · Views: 489
Last edited:

jahswant

Well-Known Member
Licensed User
Longtime User
Any clue about this issue ?
ERROR:
** Activity (pagesactivity) Pause event (activity is not paused). **
** Service (starter) Destroy (ignored)**
** Service (httputils2service) Destroy **
*** Service (starter) Create ***
Using FileProvider? true
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httpsendingservice) Create ***
** Service (httpsendingservice) Start **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Service (httpsendingservice) Destroy **
** Activity (main) Pause, UserClosed = true **
** Activity (pagesactivity) Create, isFirst = true **
** Activity (pagesactivity) Resume **
NonQuery: true
NonQuery: true
1
true
1
false
Error occurred on line: 183 (GridImage)
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.B4XViewWrapper.SetLayoutAnimated(int, int, int, int, int)' on a null object reference
    at tc.rndt.lereveil.gridimage._invalidate(gridimage.java:211)
    at tc.rndt.lereveil.gridimage._event(gridimage.java:599)
    at tc.rndt.lereveil.gridimage._image_click(gridimage.java:730)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:7156)
    at android.view.View.performClickInternal(View.java:7129)
    at android.view.View.access$3500(View.java:803)
    at android.view.View$PerformClick.run(View.java:27543)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:264)
    at android.app.ActivityThread.main(ActivityThread.java:7510)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)
** Activity (pagesactivity) Pause event (activity is not paused). **
** Service (starter) Destroy (ignored)**
** Service (httputils2service) Destroy **
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.04 Fix bug
 

jahswant

Well-Known Member
Licensed User
Longtime User
You can implement the event and get the id that will be used to get other images
 

Star-Dust

Expert
Licensed User
Longtime User

Star-Dust

Expert
Licensed User
Longtime User
very nice , what if we want when we click on any photo show in another form or other image
Each clicked image raises the Select event.
If the touch caused the image to enlarge the value of open is true.

If he clicked the same image again, it will rase select event and the open value will be false.

If you click one image and then another you will have raised the Select event with the value open for each image. But no event is generated for the reduction.
 

alas

Member
Each clicked image raises the Select event.
If the touch caused the image to enlarge the value of open is true.

If he clicked the same image again, it will rase select event and the open value will be false.

If you click one image and then another you will have raised the Select event with the value open for each image. But no event is generated for the reduction.
i see , but i want when i click on any image to be shown in imageview
could you please make small code

thanks
 

Star-Dust

Expert
Licensed User
Longtime User
i see , but i want when i click on any image to be shown in imageview
could you please make small code

thanks
Do you mean that when you click it opens an external view above the grid that displays the image?
 

Star-Dust

Expert
Licensed User
Longtime User
Put an imageView on top of the grid, so that it covers it all, setting it Visible = False
Upon clicking, the ImageView appears and displays the Image.

ImageMap is a Map variable, it could contain in the Chiae the image ID in the value you can put B4xBitmap.

B4X:
SD_GridImage1_Select (ID As String, Open As Boolean)
    IF Open Then
       ImageView1.Visible=True
       ImageVire.SetImage(ImageMap.Get(ID))
    End If
End Sub
To close the image you can do it by the Click event in the ImageView which set the view Visible = False
 

alas

Member
Put an imageView on top of the grid, so that it covers it all, setting it Visible = False
Upon clicking, the ImageView appears and displays the Image.

ImageMap is a Map variable, it could contain in the Chiae the image ID in the value you can put B4xBitmap.

B4X:
SD_GridImage1_Select (ID As String, Open As Boolean)
    IF Open Then
       ImageView1.Visible=True
       ImageVire.SetImage(ImageMap.Get(ID))
    End If
End Sub
To close the image you can do it by the Click event in the ImageView which set the view Visible = False
i did this it is not working , i am updating your example which you made with the component
 

Star-Dust

Expert
Licensed User
Longtime User
Maybe you did something wrong with the implementation.

In any case, what you want to do is different from the purpose of the library. You're trying to do something it's not designed for.

Try this example from Erel, I think it suits what you are looking for.
 
Top