B4A Library [Library] B4aGridView v3.80



Hi guys, B4AGridView is updated to v3.70.


1: GridView Demo
1: Library
1: PDF Explanations



A big thanks goes to ( Sergey Tarasevich - author of Universal Image Loader )

A thanks is always appreciated.


B4AGridView
Author:
Giuseppe Salvi
Version: 3.7

  • Fields:
    • Default As Typeface
      The default NORMAL typeface object.
    • Default_Bold As Typeface
      The default BOLD typeface object.
    • Monospace As Typeface
      The NORMAL style of the default monospace typeface.
    • Sans_Serif As Typeface
      The NORMAL style of the default sans serif typeface.
    • Serif As Typeface
      The NORMAL style of the default serif typeface.
    • Style_Bold As Int
      The default BOLD style int.
    • Style_Bold_Italic As Int
      The default BOLD ITALIC style int.
    • Style_Italic As Int
      The default ITALIC style int.
    • Style_Normal As Int
      The default NORMAL style int.
    Methods:
    • LoadFontFromAssets (file As String) As Typeface
      Create a new typeface from the specified font data from assets.
    • LoadFontFromFile (file As String) As Typeface
      Create a new typeface from the specified font data from sdcard.

  • Fields:
    • Center As ScaleType
      Center the image in the view, but perform no scaling.
    • Center_Crop As ScaleType
      Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image
      will be equal to or larger than the corresponding dimension of the view (minus padding).
    • Center_Inside As ScaleType
      Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image
      will be equal to or less than the corresponding dimension of the view (minus padding).
    • Fit_Center As ScaleType
      Scale the image using CENTER.
    • Fit_End As ScaleType
      Scale the image using END.
    • Fit_Start As ScaleType
      Scale the image using START.
    • Fit_XY As ScaleType
      Scale the image using FILL.
    • Matrix As ScaleType
      Scale using the image matrix when drawing.

  • Fields:
    • CARDS As Int
      CARDS Effect = 2
    • CURL As Int
      CURL Effect = 3
    • FADE As Int
      FADE Effect = 12
    • FAN As Int
      FAN Effect = 9
    • FLIP As Int
      FLIP Effect = 5
    • FLY As Int
      FLY Effect = 6
    • GROW As Int
      GROW Effect = 1
    • HELIX As Int
      HELIX Effect = 8
    • PUZZLE As Int
      PUZZLE Effect = 16
    • REVERSE_FLY As Int
      REVERSE_FLY Effect = 7
    • REVERSE_TWIRL As Int
      REVERSE_TWIRL Effect = 15
    • SLIDE_IN As Int
      SLIDE_IN Effect = 14
    • STANDARD As Int
      Standard Effect = 0
    • TILT As Int
      TILT Effect = 10
    • TWIRL As Int
      TWIRL Effect = 13
    • WAVE As Int
      WAVE Effect = 4
    • ZIPPER As Int
      ZIPPER Effect = 11

  • Fields:
    • Text_Bottom_Inside As GravityEnum
      Text Bottom InSide
    • Text_Bottom_OutSide As GravityEnum
      Text Bottom OutSide
    • Text_Center_Inside As GravityEnum
      Text Center InSide
    • Text_Top_Inside As GravityEnum
      Text Top InSide
    • Text_Top_OutSide As GravityEnum
      Text Top OutSide

  • Fields:
    • AUTO_FIT As Int
      Creates as many columns as can fit on screen.
    • NO_STRETCH As Int
      Disables stretching.
    • STRETCH_COLUMN_WIDTH As Int
      Stretches the spacing between columns.
    • STRETCH_SPACING As Int
      Stretches columns.
    • STRETCH_SPACING_UNIFORM As Int
      Stretches the spacing between columns.

  • Fields:
    • Compress_Format_JPG As CompressFormat
      Compression Format JPG
    • Compress_Format_PNG As CompressFormat
      Compression Format PNG

  • PhotoGridView
    Events:
    • ItemClick (Position As Int, Value As Object)
    • ItemLongClick (Position As Int, Value As Object)
    • Ready ( As )
    • ShareItemClick (Value As Object)
    Methods:
    • AddImage (dir As String, file As String)
      Add an image from sdcard or AssetsDir at the end of the GridView
    • AddImageAt (index As Int, dir As String, file As String)
      Add an image from sdcard or AssetsDir to the desired position in the GridView
    • AddImageFromWeb (address As String)
      Add an image from web at the end of the GridView
    • AddImageFromWebAt (index As Int, address As String)
      Add an image from Web to the desired position in the GridView
    • AddThisView
      Adds view to this activity 100%x,100%y
    • ClearDiskCache
      Clears disk cache.
    • ClearMemoryCache
      Clears memory cache
    • DestroyEngine
      Stops ImageLoader and clears current configuration. Use this option on exit app.
    • GetArrayList As List
      Gets array.
    • GetCacheDir As String
      Returns application cache directory. Cache directory will be created on SD card
      <i>("/Android/data/[app_package_name]/cache")</i> if card is mounted and app has appropriate permission. Else -
      Android defines cache directory on device's file system.
      Return type: @return:Cache {@link File directory}.<br />
      <b>NOTE:</b> Can be null in some unpredictable cases (if SD card is unmounted)
    • GetImageListFromAssets (path As String, sort As Boolean) As List
      Get entire list of images stored in assets or sub-folder
      Examples:
      <code>
      Dim lv as ListView
      Dim l as list
      l.Initialize
      lv.Initialize("lv")
      Sub Menu_Click
      Activity.AddView(lv,0,0,100%x,100%y)
      l = GridView.GetImageListFromAssets("Here the Images folder stored in Assets")
      or
      l = GridView.GetImageListFromAssets(File.DirAssets)
      or
      l = GridView.GetImageListFromAssets("")
      For n = 0 To l.Size-1
      lv.AddSingleLine(l.Get(n))
      next
      End Sub
      </code>
    • GetIndividualCacheDir As String
      Returns individual application cache directory (for only image caching from ImageLoader). Cache directory will be
      created on SD card <i>("/Android/data/[app_package_name]/cache/b4AGridview-Images")</i> if card is mounted and app has
      appropriate permission. Else - Android defines cache directory on device's file system.
    • GetItem (position As Int) As String
      Returns Item
      Example:
      i.Bitmap=LoadBitmap("",g.GetItem(Position))
    • GetRealImagePath (filename As String) As String
      Returns the real path of the image
    • GoToWebsite (url As String)
      Go to web site by given an address
      Example:
      GoToWebsite("www.example.com")
      url:
    • Initialize (EventName As String)
      Initialize the object
    • Initialize2 (EventName As String, withCacheName As String)
      Initialize the object and set own cache directory
    • InitializeFromLayout (EventName As String, container As ViewGroup, Layout As String, LayoutID As String)
      Initialize the object from layout
    • PauseEngine
      Pause ImageLoader. All new load and display tasks won't be executed until ImageLoader is resumed.
      Already running tasks are not paused.
    • ResumeEngine
      Resumes waiting load and display tasks
    • SetArrayList (array As ArrayList)
      Sets array.
    • SetText (text As String)
      Sets the string value of the TextView.
    • SetText2 (index As Int, text As String)
      Sets the string value of the TextView.
    • ShareItemsTo (appName As String, item As String, subJect As String, message As String, shareTo As String)
      Share any items to ?
      app: name
      item:
      subJect:
      message:
      shareTo:
    • ShareTextUrlTo (subject As String, text As String, message As String, shareTo As String)
      Share any text to ?
      subject:
      text:
      message:
      shareTo:
    • ShowActionBarToShare (icons() As String)
      Sets the icons on action bar
      Example:
      Dim icons() As String = Array As String("gmail.png","email.png","gmx.png","dropbox.png","facebook.png","twitter.png","telegram.png","line.png")
      icons: as array
    • ShowFromAssets (path As String, sort As Boolean)
      Populate GridView from assets or assets/sub-folder
    • ShowFromBucket (path As String, sort As Boolean)
      Populate GridView from sdcard
    • ShowFromMediaStore (sort As Boolean)
      Populate GridView from media store images
    • ShowFromSdCard (dir As String, path As String, sort As Boolean)
      Populate GridView from sdcard
    • ShowFromWeb (webStrings() As String, sort As Boolean)
      Populate GridView from web
    • StopEngine
      Cancels all running and scheduled display image tasks.
      <b>NOTE:</b> This method doesn't shutdown if you set them.

      ImageLoader still can be used after calling this method.
    • TextBackGroundColor (red As Int, green As Int, blue As Int)
      Sets the background color for this view.
      <b>by default red = 0</b>
      <b>by default green = 0</b>
      <b>by default blue = 0</b>
    • TextColor2 (alpha As Int, red As Int, green As Int, blue As Int)
      Get or Sets Text Color - by default White
    • isPauseOnFling As Boolean
      Whether pause ImageLoader during fling
    • isPauseOnScroll As Boolean
      Whether pause ImageLoader during touch scrolling
    Permissions:
    • android.permission.INTERNET
    • android.permission.READ_EXTERNAL_STORAGE
    • android.permission.WRITE_EXTERNAL_STORAGE
    Properties:
    • CacheInMemory As Boolean [write only]
      Sets whether loaded image will be cached in memory.
    • CacheOnDisk As Boolean [write only]
      Sets whether loaded image will be cached on disk.
    • ColumnWidth As Int
      Get or Sets Specifies the fixed width for each column.
    • CompressFormat As BitmaCompression
      Get or Sets the known formats a bitmap can be compressed into [ JPG or PNG ]Sets the quality of a bitmap, that can be compressed. [ 0 = low -> 100 = high ]
      by default PNG
    • CompressQuality As Int
      Get or Sets the quality of a bitmap, that can be compressed. [ 0 = low -> 100 = high ]
      by default 100
    • DelayBeforeLoading As Int [write only]
      Sets delay time before starting loading task. Default - no delay.
    • FadeInTime As Int [write only]
      Duration of "fade-in" animation (in milliseconds)
      Whether animation should be played if image is loaded from network
      Whether animation should be played if image is loaded from disk cache
      Whether animation should be played if image is loaded from memory cache
    • Friction As Boolean
      Get or Sets the amount of friction applied to flings.
    • Gravity As Int [write only]
      Specifies the gravity within each cell.
    • HorizontalSpacing As Int [write only]
      Defines the default horizontal spacing between columns..
    • ItemHeight As Int
      Get or Sets the the size of the images will be displayed in thumbnail by default size is 480x320
    • ItemWidth As Int
      Get or Sets the the size of the images will be displayed in thumbnail by default size is 480x320
    • Length As Int [read only]
      Returns length
    • LoadFontFromAssets As String [write only]
      Loads a new Typeface from the specified font data.
    • LoadFontFromFile As String [write only]
      Loads a new Typeface from the specified font data.
    • MaxAnimationVelocity As Int
      Get or Sets max animation velocity.
    • NumColumns As Int
      Get or Sets the number of columns in the grid.
    • PauseOnFling As Boolean [write only]
      Whether pause ImageLoader during fling
    • PauseOnScroll As Boolean [write only]
      Whether pause ImageLoader during touch scrolling
    • ProgressBarIndeterminate As Boolean [write only]
      Change the indeterminate mode for this progress bar.
    • ProgressBarVisible As Boolean [write only]
      Set the enabled state of this view. - by default is trueChange the indeterminate mode for this progress bar.
    • RemoveAt As Int [write only]
      Removes the item at the specified location from this list.
    • ResetViewBeforeLoading As Boolean [write only]
      Sets whether image view will be reset before image loading start
    • RoundedBitmap As Boolean [write only]
      Can display bitmap with rounded corners. - by default is false
    • ScaleType As PhotoScaleTypes
      Controls how the image should be resized or moved to match the size of this ImageView.
      by default ScaleTypeFIT_XY
    • ScaleTypeForRounded As ScaleType [write only]
      Controls how the RoundedBitmap should be resized or moved to match the size of this ImageView.
      by default ScaleType.FIT_CENTER
    • Selection As Int
      Get or Sets the currently selected item.
    • SetBorderColor As Int [write only]
      Set the border Color - by default is transparent
    • SetBorderWidth As Int [write only]
      Set the border Width - by default is 0
    • SetCornerRadius As Int [write only]
      Set the corner Radius - by default is 0
    • SetImageOnFail As String [write only]
      Sets own icon on fail
    • SetImageOnLoading As String [write only]
      Sets own icon on loading
    • SetNoEffect As Boolean [write only]
      Can display bitmap with rounded corners.
      Show thumbnails with corner radius or oval. - by default is true
    • ShouldOnlyAnimateFling As Boolean
      Get or Sets should only animate fling.
    • ShouldOnlyAnimateNewItems As Boolean
      Get or Sets should only animate new item.
    • ShowMessageError As Boolean [write only]
      Set to true if you want to display an error message.
    • SimulateGridWithList As Boolean
      Get or Sets simulate grid with list.
    • SmoothScrollbarEnabled As Boolean [write only]
      When smooth scrollbar is enabled, the position and size of the scrollbar thumb is computed based on the number of visible pixels in the visible items.
    • StretchMode As StretchModeEnum
      Defines how columns should stretch to fill the available empty space, if any.
      Examples:
      GridView.StretchMode = GridView.StretchMode.STRETCH_SPACING
    • Tag As Object
      Get or Sets this view's tag.
    • TextBackGroundAlpha As Int
      Get or Sets alpha property of the view, as a value between 0 (completely transparent) and 255 (completely opaque).
      <b>by default alpha = 0</b>
    • TextBackGroundColor2 As String [write only]
      Sets the background color for this view.
      Example:
      TextBackGroundColor2("#88666666")
    • TextColor As Int
      Get or Sets Text Color - by default White
    • TextGravity As Int
      Get or Sets the horizontal alignment of the text that will be used.
    • TextLines As Int
      Get or Sets the TextView exactly this many lines tall.
    • TextPosition As TextPositionEnum
      Get or Sets the position alignment of the text that will be used.
      <b>param Text_Top_OutSide</b>
      <b>param Text_Top_Inside</b>
      <b>param Text_Center_Inside</b>
      <b>param Text_Bottom_Inside</b>
    • TextSize As Int
      Get or Sets Text Size - by default 14
    • TextStyle As Int [write only]
      Sets the style in which the text should be displayed.
    • TextTypeFace As TypefaceUtils
      Get or Sets the typeface and style in which the text should be displayed.
      Note that not all Typeface families actually have bold and italic variants,
      so you may need to use TextStyle(style) to get the appearance that you actually want.
    • TextVisible As Boolean
      Get or Sets the visibility of the text - by default is hide
    • TransitionDuration As Int
      Get or Sets transition duration.
    • TransitionEffect As TransitionEffect
      Get or Sets the desired transition effect.
    • Version As String [read only]
      Version of the library
    • VerticalSpacing As Int [write only]
      Defines the default vertical spacing between rows.
 

Attachments

  • GridView.jpg
    GridView.jpg
    92.4 KB · Views: 4,415
  • gridview.jpg
    gridview.jpg
    80.3 KB · Views: 3,962
  • B4AGridView_v3.70_Demo.zip
    337.7 KB · Views: 1,309
  • B4AGridView_v3.70_Lib.zip
    461.2 KB · Views: 930
  • B4AGridView_v3.70.pdf
    102.2 KB · Views: 1,017
  • B4AGridView_Lib_v3.80.zip
    408.7 KB · Views: 981
  • B4AGridView_Lib_v3.80_Fix.zip
    409.4 KB · Views: 1,369
Last edited:

Dave O

Well-Known Member
Licensed User
Longtime User
Hi there,

Any plans to add drag-and-drop to your gridview library?
 

Dave O

Well-Known Member
Licensed User
Longtime User
Moved from North America to Wellington 8 years ago, and love it here. Our daughters grew up here before going to Vancouver for uni.

Will keep an eye on your gridview, thanks!
 

Serinter

Member
Licensed User
Longtime User
I think this grid and your work is very impressive.
I tested it and have some issues about it:

1. I have read in this thread that this library should work with android 2 or higher
I tried with ZTE Skate android Custom ROM v.2.3.7 and apk is unbootable.

LG-P970 android v. 4.0.3 and Google ASUS Nexus7 android v. 5.0.2 works well, but I have problems with setText
and SetText2

2. You should update sample code for the latest version of the library.
With the example of version 3.20 and the latest version (3.50), several things must be changed to avoid errors.

3. If I set .ShowText = True in Activity_Create or before populate the grid, the
apk throws an error and suddenly stops

4. I could not find a method to empty the grid, or operate any attempt proposed in this same thread.
There should be a method as "Gridview.Clear".
Without it, I think the grid loses much functionality and is not very useful.

5. In all devices I have problems with this library when trying to put text to images.

I want to add text to images, but the problem is that every time I scroll
both upwards and downwards, the texts are incorrect and unexplained change in each scroll.


I'm doing something wrong or is it an error?

Modifying the example to suit the latest version of the library:
(For example, in d_Click Sub, but same in others subs)

B4X:
Sub d_Click

    GridView.ShowFromMediaStore(False)
'    GridView.Selection = posSelected
    Activity.Title = "G.Salvi - Items = " & GridView.Length & " -  Width = " & GridView.ItemWidth&" | Height = "&GridView.ItemHeight

    Dim x As Int
    For x=0 To GridView.Length-1
        GridView.SetText2(x,"Picture " & (x+1))
    Next

    GridView.ShowText = True
End Sub

Try it and see text changes...

Adding items in loop by .AddImage, .AddImageAt, .AddImageFromWeb, .AddImageFromWebAt does not work either.

I tried changing caches boolean values, and nothing changes at all.

Can anybody help me, please? A working sample?

I apologize for my bad english. Thanks in advance.
 
Last edited:

lonleystar

Well-Known Member
Licensed User
Longtime User
I think this grid and your work is very impressive.
I tested it and have some issues about it:

1. I have read in this thread that this library should work with android 2 or higher
I tried with ZTE Skate android Custom ROM v.2.3.7 and apk is unbootable.

LG-P970 android v. 4.0.3 and Google ASUS Nexus7 android v. 5.0.2 works well, but I have problems with setText
and SetText2

2. You should update sample code for the latest version of the library.
With the example of version 3.20 and the latest version (3.50), several things must be changed to avoid errors.

3. If I set .ShowText = True in Activity_Create or before populate the grid, the
apk throws an error and suddenly stops

4. I could not find a method to empty the grid, or operate any attempt proposed in this same thread.
There should be a method as "Gridview.Clear".
Without it, I think the grid loses much functionality and is not very useful.

5. In all devices I have problems with this library when trying to put text to images.

I want to add text to images, but the problem is that every time I scroll
both upwards and downwards, the texts are incorrect and unexplained change in each scroll.


I'm doing something wrong or is it an error?

Modifying the example to suit the latest version of the library:
(For example, in d_Click Sub, but same in others subs)

B4X:
Sub d_Click

    GridView.ShowFromMediaStore(False)
'    GridView.Selection = posSelected
    Activity.Title = "G.Salvi - Items = " & GridView.Length & " -  Width = " & GridView.ItemWidth&" | Height = "&GridView.ItemHeight

    Dim x As Int
    For x=0 To GridView.Length-1
        GridView.SetText2(x,"Picture " & (x+1))
    Next

    GridView.ShowText = True
End Sub

Try it and see text changes...

Adding items in loop by .AddImage, .AddImageAt, .AddImageFromWeb, .AddImageFromWebAt does not work either.

I tried changing caches boolean values, and nothing changes at all.

Can anybody help me, please? A working sample?

I apologize for my bad english. Thanks in advance.


Hi Serinter, the library work fine with android 2.3.6 just tested it on my old tab 7.

The commands AddImage, AddImageAt, AddImageFromWeb, AddImageFromWebAt also tested and work fine.

U've to use ShowText = True before to populate the text like below.

Let me know.


B4X:
Sub d_Click
    GridView.ShowText = True

    GridView.ShowFromMediaStore(False)

    Activity.Title = "G.Salvi - Items = " & GridView.Length & " -  Width = " & GridView.ItemWidth&" | Height = "&GridView.ItemHeight

    Dim x As Int

    For x=0 To GridView.Length-1

        GridView.SetText2(x,"Picture " & (x+1))

    Next
End Sub
 

Serinter

Member
Licensed User
Longtime User
Hi again lonleystar.

ZTE Skate (android 2.3.7) unbooteable app log:

LogCat connected to: skate
--------- beginning of /dev/log/system


--------- beginning of /dev/log/main


** Activity (main) Create, isFirst = true **


library.core.GridViewActivityWrapperInitialize2 (java line: 132)
java.lang.NoSuchMethodError: android.widget.AbsListView.setAdapter
at it.giuseppe.salvi.gridview.library.core.GridViewActivityWrapper.Initialize2(GridViewActivityWrapper.java:132)
at it.giuseppe.salvi.gridview.library.core.GridViewActivityWrapper.Initialize(GridViewActivityWrapper.java:115)
at it.giuseppe.salvi.gridview.main._activity_create(main.java:372)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at it.giuseppe.salvi.gridview.main.afterFirstLayout(main.java:100)
at it.giuseppe.salvi.gridview.main.access$100(main.java:17)
at it.giuseppe.salvi.gridview.main$WaitForLayout.run(main.java:78)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)


at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)

On Doogee DG350 Pixels (android v. 4.2.9), LG P970 (android v. 4.0.3) and Nexus 7 (android v. 5.1 updated today) I'm still having problems trying to add text to images.

Attached screenshots shows the problem:

First Screen, attached Image 1 apparently shows ok.
test1.png


Scrolling down, In attached Image 2:
Picture 7 shows "Picture 1", Picture 9 shows "Picture 2" and Picture 10 shows "Picture 1"
test2.png


Scrolling up, In attached Image 3:
Picture 1 shows "Picture 6", Picture 2 shows "Picture 1" and so on...
test3.png


Everytime I scroll up or down, text changes and don't match with their corresponding picture.

I'm getting crazy and don't figure out where the problem is or what I'm doing wrong...

Any clue? I need advice / help, please!
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi guys, B4AGridView is updated to v3.60 What's new:

Update the engine.

------------------------------

Fix:

GridView.CompressFormat -> PNG work well now.

------------------------------

Added Event:

ShareItemClick

------------------------------

Added:

TransitionEffect
Get or sets an effect

Example:

TransitionEffect = TransitionEffect.CARDS

STANDARD -> is flat effect

Effects:

STANDARD, GROW, CARDS, CURL
WAVE, FLIP, FLY, REVERSE_FLY
HELIX, FAN, TILT, ZIPPER
FADE, TWIRL, SLIDE_IN
REVERSE_TWIRL, PUZZLE

------------------------------
Added:

TransitionDuration
Give the duration in milliseconds to the animation

------------------------------

Added:

MaxAnimationVelocity

Give maximum speed in milliseconds for animation

------------------------------

Added:

ShouldOnlyAnimateNewItems

Animate the item only Once
value true : false

------------------------------

Added:

ShouldOnlyAnimateFling

Animate flayng
value true : false

------------------------------

Added:

SimulateGridWithList

Simulate grid with list
value true : false

------------------------------

Added:

ShowActionBarToShare -> Min sdk 11

Example:
B4X:
Sub Activity_Create(FirstTime As Boolean)


   'give exactly these names to png stored in assets as described in the array below.

   'The png size must be Min 64x64 or Max 128x128

   Dim icons() As String = Array As String("gmail.png","email.png","gmx.png","dropbox.png","facebook.png","twitter.png","telegram.png","line.png")

   GridView.ShowActionBarToShare(icons)

End Sub
------------------------------

Added:

ShareItemsTo -> [ ShareItemsTo(appName,item,"Subject Here","Message Here","Title Here") ]

Share any items to android-gmail, twitter, facebook, telegram, line, whatsapp, android-mail, dropbox, gmx-mail for Deutsch, etc,etc.

Click on any item and then choose from actionbar which one you'd like to share.

Example:
B4X:
Sub Globals

   Dim posSelected As Int

End Sub

Sub GridView_ItemClick(Position As Int, Value As Object)

   posSelected = Position

End Sub

Sub GridView_ShareItemClick(Value As Object)


   Dim share As String = GridView.GetItem(posSelected)  -> From sdcard, assets, web

   ShareItemsTo(Value,share,"Subject Here","Message Here","Title Here")

   or

   ShareItemsTo("",share,"Subject Here","Message Here","Title Here")


End Sub
------------------------------

Added:

ShareTextUrlTo

Share any text or URL

Example:
B4X:
Sub Button1_Click

   Share any URL

   GridView.ShareTextUrlTo("Subject Here","http://www.salvigiuseppe.altervista.org","Message Here","Title Here")

   GridView.ShareTextUrlTo("Subject Here","https://lh4.googleusercontent.com/-Z4zGiC5nWdc/URqvBdEwivI/AAAAAAAAAbs/ZRZR1VJ84QA/s1024/Sin%252520Lights.jpg","Message Here","Title Here")

   Share any Text

   GridView.ShareTextUrlTo("Subject Here","Any text U wish to share here","Message Here","Title Here")

End Sub
------------------------------

Added:

GoToWebsite

Opens the browser giving it an address
B4X:
Sub Button1_Click

   GridView.GoToWebsite("http://www.salvigiuseppe.altervista.org")

End Sub
------------------------------

Added:

GetIndividualCacheDir

Returns individual application cache directory (for only image caching from ImageLoader).
Cache directory will be created on SD card ("/Android/data/[app_package_name]/cache/b4AGridview-Images").

B4X:
ToastMessageShow(GridView.GetIndividualCacheDir,True)

------------------------------

Added:

GetCacheDir

Returns application cache directory.
Cache directory will be created on SD card ("/Android/data/[app_package_name]/cache").
B4X:
ToastMessageShow(GridView.GetCacheDir,True)
------------------------------

Added:

GetRealImagePath

Returns the exact path of the image.
B4X:
Sub GridView_ItemClick(Position As Int, Value As Object)
   Dim item As String = GridView.GetItem(Position)
   ToastMessageShow(GridView.GetRealImagePath(item),True)
End Sub


the library is comiled with jdk1.7.0_80 and android-22 platform

I'm sorry i forgot to upload the icons

put the icons in files folder
 

Attachments

  • ICONS_PNG.zip
    154.8 KB · Views: 371
Last edited:

Scott Bartgis

Member
Licensed User
Longtime User
Hi everyone... using 3.60, my extremely simple test app is hanging on GridView.Initialize("GV").

My code:
Log("A")
GridView.Initialize("GV")
Log("B")

I get "A", but never get "B". The unfilered logs show:

A
threadid=1: stack overflow on call to Ljava/util/AbstractList;.<init>:V
method requires 4+20+4=28 bytes, fp is 0x57061318 (24 left)
expanding stack end (0x57061300 to 0x57061000)
Shrank stack (to 0x57061300, curFrame is 0x570613b8)
Exception thrown (Ljava/lang/StackOverflowError;) while throwing internal exception (Ljava/io/FileNotFoundException;)

I'm not sure what file it is looking for.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi everyone... using 3.60, my extremely simple test app is hanging on GridView.Initialize("GV").

My code:
Log("A")
GridView.Initialize("GV")
Log("B")

I get "A", but never get "B". The unfilered logs show:

A
threadid=1: stack overflow on call to Ljava/util/AbstractList;.<init>:V
method requires 4+20+4=28 bytes, fp is 0x57061318 (24 left)
expanding stack end (0x57061300 to 0x57061000)
Shrank stack (to 0x57061300, curFrame is 0x570613b8)
Exception thrown (Ljava/lang/StackOverflowError;) while throwing internal exception (Ljava/io/FileNotFoundException;)

I'm not sure what file it is looking for.


Hi Scott, can U post a little example because I dont understand thi A and B. Would be better little example to find the error U get.
 

Scott Bartgis

Member
Licensed User
Longtime User
I did include some code, but I did not tag it. The use of "A" and "B" is a debugging technique to show where a program hangs. The system is logging the A and executing the Initialize, but not ever logging the B. That means the Initialize is hanging because execution never gets to log the "B". That is the entire content of the Sub Activity_Create.

I believe the main error is:
Exception thrown (Ljava/lang/StackOverflowError while throwing internal exception (Ljava/io/FileNotFoundException)

B4X:
Sub Globals
   Dim GridView As PhotoGridView
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Log("A")
   GridView.Initialize("GV")
   Log("B")
End Sub
 

Scott Bartgis

Member
Licensed User
Longtime User
Also, if it helps, I get the same error and crash of the program from B4APhotoPager and B4AGalleryView. Extremely simple program:

Exception thrown (Ljava/lang/StackOverflowError) while throwing internal exception (Ljava/io/FileNotFoundException)

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim PP As PhotoPager
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    PP.Initialize("")

End Sub
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Also, if it helps, I get the same error and crash of the program from B4APhotoPager and B4AGalleryView. Extremely simple program:



B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim PP As PhotoPager
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    PP.Initialize("")

End Sub



Hi Scott, U'd use PP.Initialize("PP") instead of PP.Initialize("").
 

Scott Bartgis

Member
Licensed User
Longtime User
I wondered if you might say that, but it does not appear to make any difference. I wouldn't expect a problem since the string compare won't throw an error for FileNotFound.

Even with PP.Initialize("PP") it is the same result. It always dies/crashes with the FileNotFound error. Even your examples crash instantly with the error. The device is a Sibo (WonderMedia) 7" In-Wall Tablet used for home automation. Android 4.1.1.

http://geekland.co/7-Android-40-Wall-Mounted-Tablet-with-POE-GK-VIA-E002.htm
 

lonleystar

Well-Known Member
Licensed User
Longtime User
I wondered if you might say that, but it does not appear to make any difference. I wouldn't expect a problem since the string compare won't throw an error for FileNotFound.

Even with PP.Initialize("PP") it is the same result. It always dies/crashes with the FileNotFound error. Even your examples crash instantly with the error. The device is a Sibo (WonderMedia) 7" In-Wall Tablet used for home automation. Android 4.1.1.

http://geekland.co/7-Android-40-Wall-Mounted-Tablet-with-POE-GK-VIA-E002.htm


Hi Scott, I really dont know. Itested it old Tab 2.3.6, Tab2 4.1.2, Tab Note 2 10.1 and S4 5.0.2 and work well.

The Example is to old and doesnt support the new GridView.

Can U post Your code or send via email so I give a look and try to find the problem?
 

Shahid Saeed

Active Member
Licensed User
Longtime User
Hi @lonleystar, I have tried the version 3.60 and getting the following error:

B4X:
java.lang.StackOverflowError


    at java.util.AbstractList.<init>(AbstractList.java:376)
    at java.util.ArrayList.<init>(ArrayList.java:81)
    at java.lang.Throwable.<init>(Throwable.java:66)
    at java.lang.Throwable.<init>(Throwable.java:94)
    at java.lang.Exception.<init>(Exception.java:47)
    at java.io.IOException.<init>(IOException.java:44)
    at java.io.FileNotFoundException.<init>(FileNotFoundException.java:42)
    at android.content.res.AssetManager.openAsset(Native Method)
    at android.content.res.AssetManager.open(AssetManager.java:315)
    at android.content.res.AssetManager.open(AssetManager.java:289)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:310)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)


    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
Message longer than Log limit (4000). Message was truncated.
 

Scott Bartgis

Member
Licensed User
Longtime User
I have posted the .b4a file. As I said, it is extremely simple. The routine fails on GridView.Initialize("GridView") with a file not found error.

Shahid has the FileNotFound exception as well, though he has some further logging which may be useful.

Does the library call for any files to exist in particular locations? Some assets maybe?
 

Attachments

  • GridView_3.60_Test.zip
    1.1 KB · Views: 259

lonleystar

Well-Known Member
Licensed User
Longtime User
I have posted the .b4a file. As I said, it is extremely simple. The routine fails on GridView.Initialize("GridView") with a file not found error.

Shahid has the FileNotFound exception as well, though he has some further logging which may be useful.

Does the library call for any files to exist in particular locations? Some assets maybe?

Hi Scott, with my simple demo work fine i get no error not with initialize and not with anything else.

anyway I'll make a video and post it to show that it work fine.
 

Scott Bartgis

Member
Licensed User
Longtime User
I believe you that it is working on your devices, but what about the same FileNotFound error Shahid reported?
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi @lonleystar, I have tried the version 3.60 and getting the following error:

B4X:
java.lang.StackOverflowError


    at java.util.AbstractList.<init>(AbstractList.java:376)
    at java.util.ArrayList.<init>(ArrayList.java:81)
    at java.lang.Throwable.<init>(Throwable.java:66)
    at java.lang.Throwable.<init>(Throwable.java:94)
    at java.lang.Exception.<init>(Exception.java:47)
    at java.io.IOException.<init>(IOException.java:44)
    at java.io.FileNotFoundException.<init>(FileNotFoundException.java:42)
    at android.content.res.AssetManager.openAsset(Native Method)
    at android.content.res.AssetManager.open(AssetManager.java:315)
    at android.content.res.AssetManager.open(AssetManager.java:289)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:310)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)


    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
Message longer than Log limit (4000). Message was truncated.


Hi Shahid, did U put in the Files folder the icons ICONS_PNG.zip I posted in to the post #288? if not download it and put it in the Files folder this icons is used when U call ShowActionBarToShare.
 
Top