FileDocCategorySizeDatePackage
Utils.javaAPI DocAndroid 5.1 API2146Thu Mar 12 22:22:44 GMT 2015com.example.android.musicservicedemo

Utils

public class Utils extends Object

Fields Summary
private static final String
TAG
Constructors Summary
Methods Summary
public static final voidcheckNotNull(java.lang.Object object)
Utility method to check that parameters are not null

param
object


                    
          
        if (object == null) {
            throw new NullPointerException();
        }
    
public static android.graphics.BitmapgetBitmapFromURL(java.lang.String source)
Utility to download a bitmap

param
source
return

        try {
            URL url = new URL(source);
            HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
            httpConnection.setDoInput(true);
            httpConnection.connect();
            InputStream inputStream = httpConnection.getInputStream();
            return BitmapFactory.decodeStream(inputStream);
        } catch (IOException e) {
            Log.e(TAG, "getBitmapFromUrl: " + source, e);
        }
        return null;
    
public static intwrapIndex(int i, int size)
Utility method to wrap an index

param
i
param
size
return

        int m = i % size;
        if (m < 0) { // java modulus can be negative
            m += size;
        }
        return m;