Abort http job or any other fix for my issue

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Hello
I am sorry if this has been answered but I could not find any related post.

What my application does is listing some images from internet after selecting an item from a list and every item has its own images.
The application works as expected until I go back to select another item to show its images I get outofbounds error . I think the problem is because of some http job from the last item like if it was delayed till I got back and chose another item.

Now can I abort current jobs so they do not get finished at wrong time?
And if there is any other better way to fix this issue please help me
And thanks in advance
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Thanks a lot .
No I was trying to accomplish a similar result by clearing an array of bitmaps
And I checked with IsPaused() before calling the function that sets images to imageviews.
I will check ImageDownloader as soon as possible .
Thanks again
 
Upvote 0

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Hello again.
I used ImageDownloader and it was really great but now I noticed it has this issue although it shouldn't but anyway the problem happens when I enter one category and quickly get back to the first Activity and the choose another category.
When I do this the old images get downloaded instead of the new ones .
How can I fix this?
 
Upvote 0

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I am sorry I am developing it for someone else but I will try to make it clearer

I have main activity with some categories when I click one of them I start the second activity and pass links to ImageDownloader to show them on the second activity

If I for example chose category "A" then I pressed back button which will call "ActivityIsPaused" and chose category "B" I would get "A" images.
I hope it is clear now
 
Upvote 0

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I think so .

I am putting imageviews and links to map in a for loop

B4X:
imgviewsmap.Put(imv,url.Get(i))

and then I pass the map to download Sub

B4X:
CallSubDelayed2(Imagedownloader, "Download",imgviewsmap )
 
Upvote 0

somed3v3loper

Well-Known Member
Licensed User
Longtime User
After using some log statements here and there now I believe that this call is delayed
B4X:
CallSubDelayed2(Imagedownloader, "Download",imgviewsmap )
When I get back to main activity and then to the second download sub of Imagedownloader gets executed twice
But if replace CallSubDelayed2 with CallSub2 , images never gets downloaded
 
Upvote 0

somed3v3loper

Well-Known Member
Licensed User
Longtime User
edit :That did not help

By the way would DoEvents be our problem? because I added it at loops in imagedownloader service
 
Last edited:
Upvote 0

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I think my problem happens because the ImageDownloader finds the same imageviews

B4X:
Dim imv as ImageView
Seems to have always the same android.widget.ImageView{42b9f158... reference
When image gets downloaded and the user is back to the second activity, ImageDownloader find the same key of imagviews,links and sets their bitmaps

I hope my post is clear
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…