return in;
}
- public static boolean checkIfNetAddressIsReachable(String url) {
-
- // The old method of fetching the URL to see if the net is "reachable" was not good;
- // it wasted bandwidth and time. For now just check if the url is empty.
- return (url.length() > 0);
- }
-
- public static void bookCoverImage(ImageView picture, String imageID,
- int size) {
-
- String urlS = (GlobalConfigs.httpAddress + "/opac/extras/ac/jacket/small/" + imageID);
- Log.d(TAG, "cover image: " + urlS);
-
- Bitmap bmp = null; // create a new Bitmap variable called bmp, and
- // initialize it to null
-
- try {
-
- URL url = new URL(urlS); // create a URL object from the urlS string
- // above
- URLConnection conn = url.openConnection(); // save conn as a
- // URLConnection
-
- conn.connect(); // connect to the URLConnection conn
- InputStream is = conn.getInputStream(); // get the image from the
- // URLConnection conn using
- // InputStream is
- BufferedInputStream bis = new BufferedInputStream(is, 8*1024); // create a
- // BufferedInputStream
- // called bis
- // from is
- bmp = BitmapFactory.decodeStream(bis); // use bis to convert the
- // stream to a bitmap image,
- // and save it to bmp
- int bmpHeight = bmp.getHeight(); // stores the original height of
- // the image
- if (bmpHeight != 1) {
- double scale = size / (double) bmpHeight; // sets the scaling
- // number to match the
- // desired size
- double bmpWidthh = (double) bmp.getWidth() * scale; // scales
- // and
- // stores
- // the
- // original
- // width
- // into the
- // desired
- // one
- int bmpWidth = (int) bmpWidthh; // gets the width of the picture
- // and saves it
- bmp = Bitmap.createScaledBitmap(bmp, bmpWidth, size, true); // creates
- // and
- // stores
- // a
- // new
- // bmp
- // with
- // desired
- // dimensions
- }
-
- } catch (MalformedURLException e) { // catch errors
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (IllegalStateException e) {
- e.printStackTrace();
- }
- picture.setImageBitmap(bmp); // send the Bitmap image bmp to pic, and
- // call the method to set the image.
-
- }
-
public static String getResponseTextcode(Object response) {
String textcode = null;
try {