iOS Question ImageDownloader Module dont work in b4i 5.0

Ali Alsaedi

Member
Licensed User
Longtime User
Hi
when use ImageDownloader Module in url
https://www.b4x.com/android/forum/threads/class-imagedownloader.51862/#content

in b4i version 5.0

i get error but this module worked correctly in b4i 4.3

use this module like
B4X:
Private Downloader As ImageDownloader
Downloader.Initialize
Downloader.addJob2(imageview1,"my image url",True)


screenshot from error

2018_09_04_20_41_37_alhikma_B4i.png
 

Attachments

  • 2018-09-04 20_41_37-alhikma - B4i.png
    2018-09-04 20_41_37-alhikma - B4i.png
    12 KB · Views: 223

Ali Alsaedi

Member
Licensed User
Longtime User
1. Please post the error message as text instead of screenshot.

2. Can you upload a small project that demonstrates this issue?

log message :


Application_Start
Application_Active
SignalHandler 11
Error occurred on line: 89 (ImageDownloader)
Signal - 11
Stack Trace: (
"0 B4i Example SignalHandler + 119",
"1 libsystem_platform.dylib 0x000000010bc9cf5a _sigtramp + 26",
"2 ??? 0x0 + 105827994913856",
"3 B4i Example -[b4i_imagedownloader _jobdone::] + 919",
"4 CoreFoundation __invoking___ + 140",
"5 CoreFoundation -[NSInvocation invoke] + 308",
"6 B4i Example +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1645",
"7 B4i Example -[B4ICommon CallSubDebug4::::] + 1052",
"8 B4i Example -[B4ICommon CallSubDebug2::::] + 341",
"9 B4i Example -[b4i_httpjob _complete::] + 702"
)
 

Attachments

  • test.zip
    14.8 KB · Views: 222
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is not ImageDownloader. You made many modifications.

Put a breakpoint in line 89. You will see that your code is wrong.

You should watch the collections video tutorial and see how to correctly use Maps.


Correct code:
B4X:
Private Sub ShowImgWhenComplete(ilo As imgldrobj,bmp As Bitmap)
   If tasks.ContainsKey(ilo.url) Then
       Dim ti As imgldrobj=tasks.Get(ilo.url)
       LogColor(ilo.url,Colors.Red)
       LogColor(ti.url,Colors.Blue)
       If ti.url=ilo.url Then
           If ti.cache Then
               saveBmpToFile(getkey(ilo.url),bmp)
               completeJobFromCache(ti)
           Else
               completeJobFromNet(ti,bmp)
           End If
       End If
   End If
End Sub
Tip 2: don't use ImageDownloader at all. It is not needed since the support for resumable subs. You can simplify your code: [B4X] OkHttpUtils2 with Wait For
Tip 3: remove the two modules and use iHttpUtils2 library instead.
 
Upvote 0

Ali Alsaedi

Member
Licensed User
Longtime User
This is not ImageDownloader. You made many modifications.

Put a breakpoint in line 89. You will see that your code is wrong.

You should watch the collections video tutorial and see how to correctly use Maps.


Correct code:
B4X:
Private Sub ShowImgWhenComplete(ilo As imgldrobj,bmp As Bitmap)
   If tasks.ContainsKey(ilo.url) Then
       Dim ti As imgldrobj=tasks.Get(ilo.url)
       LogColor(ilo.url,Colors.Red)
       LogColor(ti.url,Colors.Blue)
       If ti.url=ilo.url Then
           If ti.cache Then
               saveBmpToFile(getkey(ilo.url),bmp)
               completeJobFromCache(ti)
           Else
               completeJobFromNet(ti,bmp)
           End If
       End If
   End If
End Sub
Tip 2: don't use ImageDownloader at all. It is not needed since the support for resumable subs. You can simplify your code: [B4X] OkHttpUtils2 with Wait For
Tip 3: remove the two modules and use iHttpUtils2 library instead.
Thank You!
I use Tip2 and solved my problem.
Only in this way photos cached or not?
 
Upvote 0
Top