Search in sources :

Example 1 with Media

use of com.cpjd.models.Media in project Roblu by wdavies973.

the class TBATeamInfoTask method run.

public void run() {
    listener.teamRetrieved(new TBA().getTeam(teamNumber));
    try {
        Media[] medias = new TBA().getMedia(teamNumber, Integer.parseInt(year));
        for (Media media : medias) {
            String url = (String) media.details.get("thumbnail_url");
            if (url == null || url.equals(""))
                continue;
            Log.d("RBS", "Attempting to download image at URL: " + url);
            Bitmap b = Picasso.with(context).load(url).get();
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            b.compress(Bitmap.CompressFormat.PNG, 100, stream);
            byte[] byteArray = stream.toByteArray();
            listener.imageRetrieved(byteArray);
            break;
        }
    } catch (Exception e) {
        Log.d("RBS", "Failed to download team picture: " + e.getMessage());
    }
    try {
        thread.join();
    } catch (Exception e) {
        Log.d("RBS", "Failed to stop TBATeamInfoTask thread.");
    }
}
Also used : TBA(com.cpjd.main.TBA) Bitmap(android.graphics.Bitmap) Media(com.cpjd.models.Media) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

Bitmap (android.graphics.Bitmap)1 TBA (com.cpjd.main.TBA)1 Media (com.cpjd.models.Media)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1