3 Replies Latest reply on Dec 6, 2013 9:40 AM by Armen Malxasyan

    Help Help Help!!! Download Progressbar not working in iOS only!

    Armen Malxasyan

      Already 3 days struggling on the code. We have made a download progressbar in our map app, so the user can download big file from server.

       

      When user clicks download button, an ajax call is sent to method controller which is down.

       

       

       

       

       

       

       

      def check_download_state

        Rho::System.startTimer(2000,url_for(:action => :wait_for_download_complete))

        puts "startTimer "

      end

       

       

      def wait_for_download_complete

        puts "CheckTimer "

        Rho::System.startTimer(2000,url_for(:action => :wait_for_download_complete))

        if !Rho::RhoFile.exists(Rho::RhoFile.join(Rho::Application.userFolder, "mbtiles111111.sqlite.zip"))

       

       

          @file_name =Rho::RhoFile.join(Rho::Application.userFolder, "mbtiles111111.sqlite.zip.rhodownload")      

          @size=File.size?(@file_name)     

          @size=@size.to_i   

          WebView.execute_js("downloaded_size('"+@size.to_s+"')")

          WebView.execute_js("console.log('"+@size.to_s+"')")  

          WebView.execute_js("update_progress2('"+@size.to_s+"')")

          puts "Downloaded" + @size.to_s

        else

       

        end

      end

       

       

       

      A timer should like loop till the download is finished, but the problem is that after 1rst loop the value of the file size is not changing. We have to pause the download (which stops the download and  removes the timer loop with stopTimer. ) and then restart again the download so that first loop again will show the  real size of file .  The problem is that this mechanism works in Rhosimulator,

      Anybody can give me a hint?

       

      Here is a github  if you could have a look would be great

       

      rhodesdownload/app/Settings at master · maridansoft/rhodesdownload · GitHub