private void processFromWeb ( URL source , ListeFilme listeFilme ) { Request . Builder builder = new Request . Builder ( ) . url ( source ) ; builder . addHeader ( "User-Agent" , Config . getUserAgent ( ) ) ; //our progress monitor callback InputStreamProgressMonitor monitor = new InputStreamProgressMonitor ( ) { private int oldProgress = 0 ; @ Override public void progress ( long bytesRead , long size ) { final int iProgress = ( int ) ( bytesRead * 100 / size ) ; if ( iProgress != oldProgress ) { oldProgress = iProgress ; notifyProgress ( source . toString ( ) , iProgress ) ; } } } ; try ( Response response = MVHttpClient . getInstance ( ) . getHttpClient ( ) . newCall ( builder . build ( ) ) . execute ( ) ; ResponseBody body = response . body ( ) ) { if ( response . isSuccessful ( ) ) { try ( InputStream input = new ProgressMonitorInputStream ( body . byteStream ( ) , body . contentLength ( ) , monitor ) ) { try ( InputStream is = selectDecompressor ( source . toString ( ) , input ) ; JsonParser jp = new JsonFactory ( ) . createParser ( is ) ) { readData ( jp , listeFilme ) ; } } } } catch ( Exception ex ) { Log . errorLog ( 945123641 , ex , "FilmListe: " + source ) ; listeFilme . clear ( ) ; } }
Download a process a filmliste from the web .