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.");
}
}
Aggregations