Change first call of OnProgress for H264 download

This commit is contained in:
Erwan Croze 2016-06-30 16:47:25 +02:00
parent 171ada8a32
commit 9c5174e0bb

View file

@ -90,7 +90,7 @@ public class OpenH264DownloadHelper {
* @param object
* @return index of object in UserData list
*/
public int setUserDate(Object object) {
public int setUserData(Object object) {
this.userData.add(object);
return this.userData.indexOf(object);
}
@ -186,16 +186,15 @@ public class OpenH264DownloadHelper {
URL url = new URL(urlDownload);
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
urlConnection.connect();
openH264DownloadHelperListener.OnProgress(0,10);
InputStream inputStream = urlConnection.getInputStream();
FileOutputStream fileOutputStream = new FileOutputStream(fileDirection+"/"+nameFileDownload);
int totalSize = urlConnection.getContentLength();
openH264DownloadHelperListener.OnProgress(0,totalSize);
byte[] buffer = new byte[4096];
int bufferLength;
int total = 0;
openH264DownloadHelperListener.OnProgress(total, totalSize);
while((bufferLength = inputStream.read(buffer))>0 ){
total += bufferLength;
fileOutputStream.write(buffer, 0, bufferLength);