40 lines
939 B
Java
40 lines
939 B
Java
package net.crystalyx.setaswallpaper;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.BitmapFactory;
|
|
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.net.URL;
|
|
import java.net.URLConnection;
|
|
|
|
public class HttpThreadHandler implements Runnable {
|
|
private final URL url;
|
|
private Bitmap bitmap;
|
|
private String errorMessage;
|
|
|
|
public HttpThreadHandler(URL url) {
|
|
this.url = url;
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
try {
|
|
URLConnection connection = url.openConnection();
|
|
connection.connect();
|
|
InputStream inputStream = connection.getInputStream();
|
|
bitmap = BitmapFactory.decodeStream(inputStream);
|
|
} catch (IOException e) {
|
|
errorMessage = e.getMessage();
|
|
}
|
|
}
|
|
|
|
public Bitmap gitBitmap() {
|
|
return bitmap;
|
|
}
|
|
|
|
public String getErrorMessage() {
|
|
return errorMessage;
|
|
}
|
|
}
|