40 lines
959 B
Java
40 lines
959 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 = this.url.openConnection();
|
||
|
connection.connect();
|
||
|
InputStream inputStream = connection.getInputStream();
|
||
|
this.bitmap = BitmapFactory.decodeStream(inputStream);
|
||
|
} catch (IOException e) {
|
||
|
errorMessage = e.getMessage();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Bitmap gitBitmap() {
|
||
|
return this.bitmap;
|
||
|
}
|
||
|
|
||
|
public String getErrorMessage() {
|
||
|
return this.errorMessage;
|
||
|
}
|
||
|
}
|