Android Tutorial ImageDownloader - The simple way to download images

Discussion in 'Tutorials & Examples' started by Erel, Jul 9, 2013.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    Not sure that I understand. Where does the local image come from?
     
  2. lock255

    lock255 Well-Known Member Licensed User

    In practice, when would that be in error would show ImageView1 an image contained locally.
    The type to show an image prepared by me saying "Page not available", so as to make more cute dialogue with the user.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    See how JobDone works. You need to change it so it will load a local image if job.Success = false.
     
  4. lock255

    lock255 Well-Known Member Licensed User

    Yes I understand, but have not uploaded an image locally, would you suggest me a simple tutorial to do that?
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    I'm sorry but I'm not sure that I understand.
     
  6. sule

    sule Member Licensed User

    how can we save this pics to file.File.DirInternal
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    If you just want to download the images (and not show them) then it will be simpler to use HttpUtils2.
     
  8. stanks

    stanks Active Member Licensed User

    how to apply this example on widget service?
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    ImageDownloader works with standard ImageViews. It will not work widget image views. However if you go over the code and understand it then you should be able to modify it to work with widgets.
     
  10. stanks

    stanks Active Member Licensed User

    i moved part of code from activity resume to service_create, but what to do with activity_pause? do i need code in activity_pause?
     
    Last edited: Apr 9, 2014
  11. stanks

    stanks Active Member Licensed User

    i think i solved it

    thanks
     
  12. Douglas Farias

    Douglas Farias Expert Licensed User

    Erel how can i know when the imageview have the photo or no ?

    i make this

    Code:
    If kv.GetSimple("imgcrop") = "3" Then
        links.Put(imvImage, 
    "http://localhost/clickfight/UsersImages/"&userid&"/MeuPerfil/NaoEnviadas/FinalPictures/"&"3.jpg")
        CallSubDelayed2(ImageDownloader, 
    "Download", links)
        
    ProgressDialogHide
    my progressdialog close but the image dont show in the same time show me 2 3 seconds later
    how can i know if the image downloaded is on imageview ProgressDialogHide
     
  13. Douglas Farias

    Douglas Farias Expert Licensed User

    done *-* when the image is realy visible close my progressdialog

    this is the code from downloaderimage

    Code:
    Sub JobDone(Job As HttpJob)
        ongoingTasks.Remove(Job.JobName)
        
    If Job.Success Then
            
    Dim bmp As Bitmap = Job.GetBitmap
            
    cache.Put(Job.JobName, bmp)
            
    If tasks.IsInitialized Then
                
    For i = 0 To tasks.Size - 1
                    
    Dim link As String = tasks.GetValueAt(i)
                    
    If link = Job.JobName Then
                        
    Dim iv As ImageView = tasks.GetKeyAt(i)
                        iv.SetBackgroundImage(bmp)
                        
    ProgressDialogHide
                    
    End If
                
    Next
            
    End If
        
    Else
        
    ProgressDialogHide
            
    Log("Error downloading image: " & Job.JobName & CRLF & Job.ErrorMessage)
        
    End If
        Job.Release
    End Sub
     
  14. eSolution

    eSolution Member Licensed User

    With Image Downloader 2 - I have a problem when I try to start the app in rapid debug mode on my device, I get this error: "
    pkg: /data/local/tmp/1_RAPID_DEBUG.apk
    Failure [INSTALL_FAILED_VERSION_DOWNGRADE]

    Restarting ADB Server may solve this problem.
    "
    I have restarted ADB several times, other projects compile ok and run ok ... I have tried all android platforms above 14 (14 to L) and the error is present on all... I use Java 1.8.05 , My Android SDK is up to date (last update made 30 min ago) and my B4A is the last update 3.82

    Any fix for this kind of behavior?

    Image Downloader 1 works fine


    EDIT: I have found the problem: the example use the 1.0 CustomListView, after an update to 1.1 it works like a charm :D
     
    Last edited: Jul 5, 2014
  15. bluedude

    bluedude Well-Known Member Licensed User

    I use this solution but my images in an imageview never get the correct gravity. Does setbackground actually use a Gravity.fill setting? My images always get cut off at the sides a little.

    Tried to use a resizeimage solution but that reduces the quality too much.

    Should I use loadbitmap instead?
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    ImageDownloader uses LoadBitmap internally to load the bitmap. Try to set the gravity in JobDone after the image is set.
     
  17. bluedude

    bluedude Well-Known Member Licensed User

    Hi,

    I already do that but it does not work as expected. Is there another solution to make images (company logos) always scale perfectly?

    On iPhone we use a small PDF viewer, this works extremely well.
     
  18. bluedude

    bluedude Well-Known Member Licensed User

    Found the issue, I set a panel background with a holo bg panel, this one cuts off the image on the sides.
     
  19. tpakis

    tpakis Active Member Licensed User

    I'm trying to optimize the memory allocation, cause i am having problems when i show a large list of images. In the service there is a cache map where the links and the bitmaps are stored, and in the main activity there is the clv with the loaded images. What is causing the problem, the cache or the clv? Should i try to have less images loaded, or to erase the cache?
     
  20. Douglas Farias

    Douglas Farias Expert Licensed User

Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice