Hi guys i am using touchimageview, photopager and a bitmap which i use to make a gallery that a user and show or hide inside a loop i am using this code to generate that
it is working although a bit of slow, however when i try to open and close this module for around 4 to 5 times (i use it to change the images for different customer data), my app suddenly closes without getting any error in the logs. When i view the logs without filtering, i saw that it ends in this particular error:
What could be the culprit? as i am not that well verse in java
B4X:
For intA = 0 To menuMain.Length - 1
DoEvents
If menuMain(intA).Trim.Length > 4 Then
Dim strPrefix As String = menuMain(intA).Trim.SubString2(menuMain(intA).Length - 4,menuMain(intA).Length)
If strPrefix = ".jpg" Or strPrefix = ".png" Then
Dim p As Panel
p.Initialize("")
p.Color = Colors.ARGB(100,0,0,0)
Dim TouchImageView1 As TouchImageView
TouchImageView1.Initialize("TouchImageView1")
Dim Bitmap1 As Bitmap
Bitmap1.InitializeMutable(Activity.Width,Activity.Height)
Bitmap1 = il.loadimgSync(menuMain(intA))
If Activity.Width > 480 Then
Log("a " & Bitmap1.IsInitialized)
If Bitmap1.IsInitialized = False Then
Bitmap1 = Null
Dim Bitmap1 As Bitmap
Bitmap1.InitializeMutable(Activity.Width,Activity.Height)
Bitmap1 = il.loadimgSync(menuMain(intA))
End If
' Log("b " & Bitmap1.IsInitialized)
p.AddView(TouchImageView1, 50%x - (Bitmap1.Width/2), 20dip, 140%x, 140%y)
Else
p.AddView(TouchImageView1,10dip, 20dip, 140%x, 140%y)
End If
TouchImageView1.MinScale=0.25 ' default is 0.5
TouchImageView1.MaxScale=2 ' default is 1.5
TouchImageView1.TranslatePadding=128dip
'TouchImageView1.Gravity=Gravity.FILL
TouchImageView1.SetBitmap(Bitmap1)
If FirstTime Or (TouchImageViewRect.IsInitialized = False) Or (SourceImageRect.IsInitialized = False) Then
' Rect parameters are: left, top, right, bottom
SourceImageRect.Initialize(0, 0, Bitmap1.Width, Bitmap1.Height)
If Activity.Width > 480 Then
TouchImageViewRect.Initialize(50%x - (Bitmap1.Width/2) , 20dip, TouchImageView1.Width, TouchImageView1.Height)
Else
TouchImageViewRect.Initialize(10dip, 20dip, TouchImageView1.Width, TouchImageView1.Height)
End If
End If
TouchImageView1.ScaleSrcRectToDestRect(SourceImageRect, TouchImageViewRect, "CENTER") ' make string a static constant in library
vp.AddView(p)
End If
End If
Next
it is working although a bit of slow, however when i try to open and close this module for around 4 to 5 times (i use it to change the images for different customer data), my app suddenly closes without getting any error in the logs. When i view the logs without filtering, i saw that it ends in this particular error:
B4X:
** Activity (market_detail) Resume **
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.shell.Shell.stopProgram(Shell.java:175)
at anywheresoftware.b4a.shell.Shell.handleIncomingData(Shell.java:189)
at anywheresoftware.b4a.shell.ShellConnector.readControlData(ShellConnector.java:204)
at anywheresoftware.b4a.shell.ShellConnector.connect(ShellConnector.java:185)
at anywheresoftware.b4a.shell.ShellConnector.run(ShellConnector.java:119)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NullPointerException
at manila.fun.main.killProgram(main.java:378)
... 8 more
What could be the culprit? as i am not that well verse in java