package me.soundlocker.soundlocker;

import android.os.AsyncTask;

import org.apache.commons.lang3.ArrayUtils;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class DownloadSongByteData extends AsyncTask<URL, Integer, Byte[]> {

    @Override
    protected Byte[] doInBackground(URL... params) {
        URL url = params[0];
        HttpURLConnection urlConnection = null;
        try {
            urlConnection = (HttpURLConnection) url.openConnection();
            InputStream fileInputStream = new BufferedInputStream(urlConnection.getInputStream());
            byte[] result = inputStreamToByteArray(fileInputStream);
            return ArrayUtils.toObject(result);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            urlConnection.disconnect();
        }
        return null;
    }

    private byte[] inputStreamToByteArray(InputStream inStream) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buffer = new byte[8192];
        int bytesRead;
        while ((bytesRead = inStream.read(buffer)) > 0) {
            baos.write(buffer, 0, bytesRead);
        }
        return baos.toByteArray();
    }
}

@@ -104,16 +104,17 @@
 yUtils;%0A
+%0A
 import j
@@ -293,26 +293,13 @@
 net.
-HttpURLConnection;
+URL;%0A
 %0Aimp
@@ -306,24 +306,44 @@
 ort java
+x
 .net.
-URL
+ssl.HttpsURLConnection
 ;%0A%0Apubli
@@ -518,24 +518,25 @@
         Http
+s
 URLConnectio
@@ -606,16 +606,17 @@
  = (Http
+s
 URLConne

Use HttpsURLConnection for Spotify previews