Hello all,
I was looking for a single row vertically scrolling preview image picker on the forum, I couldn't find one so I spent about 30 minutes or so creating V1.00 of this library for myself. After Joanne my lovely partner saw it, she said I should put it on the forum for others to use, so here it is. The preview image picker will display jpg, png and bmp images.
Please note that if you are going to be using EXTERNAL_STORAGE etc then you MUST add RuntimePermissions.
Type Sub [Space > TAB] to find the correct event sub call PreviewImagePicker.
Basic instructions:
Select SS_PreviewImagePicker from the libraries manager tab.
Screen shot
29/09/2018 V1.00
- Initial release.
V1.01
- Removed blank square spaces for files that are not jpg, png or bmp.
V1.02
- Added ShowDivider parameter to display a divider line.
V1.03
- Added DividerColor parameter so that developers can change the divider line color.
- The title text color is no longer LightTheme dependent.
- Removed logs.
01/10/2018 V1.04
- Rewrote populate image list routine for faster image population.
- Recalculated divider line position by a couple of dips.
- Initialize method - Moved some parameters from this method to the OpenImagePicker method.
- OpenImagePicker method - Added some parameters to this method from the Initialize method.
- Added LowerList parameter to start the top of the preview list at 10%y instead of 5%y for 'ACToolBar...'.
- Optimised previewer images to make them smaller in memory size for preview list.
- Added ToLowerCase to make sure that no images are missed whilst populating.
03/10/2018 V1.05
- Fixed bug where if the selected folder is empty, the picker wouldn't close correctly.
This is a simple library to use.
SS_PreviewImagePicker
Author: Peter Simpson
Version: 1.05
Let me know if it's useful to you, I've also uploaded an example apk file
Enjoy...
I was looking for a single row vertically scrolling preview image picker on the forum, I couldn't find one so I spent about 30 minutes or so creating V1.00 of this library for myself. After Joanne my lovely partner saw it, she said I should put it on the forum for others to use, so here it is. The preview image picker will display jpg, png and bmp images.
Please note that if you are going to be using EXTERNAL_STORAGE etc then you MUST add RuntimePermissions.
Type Sub [Space > TAB] to find the correct event sub call PreviewImagePicker.
Basic instructions:
Select SS_PreviewImagePicker from the libraries manager tab.
B4X:
Sub Globals
Private ImagePicker As PreviewImagePicker
End Sub
Sub Activity_Create(FirstTime As Boolean)
ImagePicker.Initialize(Me, Activity, "Logo")
ImagePicker.OpenImagePicker("Select an image", Folder, 4dip, 7dip, 300, True, Colors.LightGray, False)
End Sub
Sub Logo_Click(ImageFolder As String, FileName As String)
Log($"Folder = ${ImageFolder}, Image = ${FileName}"$)
ImagePicker.CloseImagePicker
End Sub
Screen shot
29/09/2018 V1.00
- Initial release.
V1.01
- Removed blank square spaces for files that are not jpg, png or bmp.
V1.02
- Added ShowDivider parameter to display a divider line.
V1.03
- Added DividerColor parameter so that developers can change the divider line color.
- The title text color is no longer LightTheme dependent.
- Removed logs.
01/10/2018 V1.04
- Rewrote populate image list routine for faster image population.
- Recalculated divider line position by a couple of dips.
- Initialize method - Moved some parameters from this method to the OpenImagePicker method.
- OpenImagePicker method - Added some parameters to this method from the Initialize method.
- Added LowerList parameter to start the top of the preview list at 10%y instead of 5%y for 'ACToolBar...'.
- Optimised previewer images to make them smaller in memory size for preview list.
- Added ToLowerCase to make sure that no images are missed whilst populating.
03/10/2018 V1.05
- Fixed bug where if the selected folder is empty, the picker wouldn't close correctly.
This is a simple library to use.
SS_PreviewImagePicker
Author: Peter Simpson
Version: 1.05
- PreviewImagePicker
- Events:
- Click (ImageFolder As String, ImageFile As String)
- Functions:
- CloseImagePicker As String
Close the image picker folder
- Initialize (Callback As Object, Parent As Activity, EventName As String) As String
Initialize the preview image picker
Example: Initialize(Me, Activity, "Logo")
- IsInitialized As Boolean
Tests whether the object has been initialized. - OpenImagePicker (Title As String, ImageFolder As String, Elevation As Int, CornerRadius As Int, AnimationDuration As Int, ShowDivider As Boolean, DividerColor As Int, LowerList As Boolean) As String
Open the image picker folder
Example: OpenImagePicker("Select your logo", File.DirAssets, 4dip, 7dip, 300, True, Colors.LightGray, True)
- CloseImagePicker As String
- Events:
Let me know if it's useful to you, I've also uploaded an example apk file
Enjoy...
Attachments
Last edited: