use of com.google.android.libraries.cast.companionlibrary.utils.FetchBitmapTask in project Shuttle by timusus.
the class VideoCastControllerFragment method showImage.
/*
* Gets the image at the given url and populates the image view with that. It tries to cache the
* image to avoid unnecessary network calls.
*/
private void showImage(final Uri uri) {
if (uri == null) {
mCastController.setImage(BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.album_art_placeholder_large));
return;
}
if (mUrlAndBitmap != null && mUrlAndBitmap.isMatch(uri)) {
// we can reuse mBitmap
mCastController.setImage(mUrlAndBitmap.mBitmap);
return;
}
mUrlAndBitmap = null;
if (mImageAsyncTask != null) {
mImageAsyncTask.cancel(true);
}
Point screenSize = Utils.getDisplaySize(getActivity());
mImageAsyncTask = new FetchBitmapTask(screenSize.x, screenSize.y, false) {
@Override
protected void onPostExecute(Bitmap bitmap) {
if (bitmap != null) {
mUrlAndBitmap = new UrlAndBitmap();
mUrlAndBitmap.mBitmap = bitmap;
mUrlAndBitmap.mUrl = uri;
if (!isCancelled()) {
mCastController.setImage(bitmap);
}
}
if (this == mImageAsyncTask) {
mImageAsyncTask = null;
}
}
};
mImageAsyncTask.execute(uri);
}
use of com.google.android.libraries.cast.companionlibrary.utils.FetchBitmapTask in project zype-android by zype.
the class VideoMediaRouteControllerDialog method setIcon.
public void setIcon(Uri uri) {
if (mIconUri != null && mIconUri.equals(uri)) {
return;
}
mIconUri = uri;
if (uri == null) {
Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.album_art_placeholder);
mIcon.setImageBitmap(bm);
return;
}
if (mFetchBitmap != null) {
mFetchBitmap.cancel(true);
}
mFetchBitmap = new FetchBitmapTask() {
@Override
protected void onPostExecute(Bitmap bitmap) {
mIcon.setImageBitmap(bitmap);
if (this == mFetchBitmap) {
mFetchBitmap = null;
}
}
};
mFetchBitmap.execute(mIconUri);
}
use of com.google.android.libraries.cast.companionlibrary.utils.FetchBitmapTask in project zype-android by zype.
the class MiniController method setIcon.
@Override
public void setIcon(Uri uri) {
if (mIconUri != null && mIconUri.equals(uri)) {
return;
}
mIconUri = uri;
if (mFetchBitmapTask != null) {
mFetchBitmapTask.cancel(true);
}
mFetchBitmapTask = new FetchBitmapTask() {
@Override
protected void onPostExecute(Bitmap bitmap) {
if (bitmap == null) {
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.album_art_placeholder);
}
setIcon(bitmap);
if (this == mFetchBitmapTask) {
mFetchBitmapTask = null;
}
}
};
mFetchBitmapTask.execute(uri);
}
use of com.google.android.libraries.cast.companionlibrary.utils.FetchBitmapTask in project zype-android by zype.
the class VideoCastControllerFragment method showImage.
/*
* Gets the image at the given url and populates the image view with that. It tries to cache the
* image to avoid unnecessary network calls.
*/
private void showImage(final Uri uri) {
if (mImageAsyncTask != null) {
mImageAsyncTask.cancel(true);
}
if (uri == null) {
mCastController.setImage(BitmapFactory.decodeResource(getActivity().getResources(), com.google.android.libraries.cast.companionlibrary.R.drawable.album_art_placeholder_large));
return;
}
if (mUrlAndBitmap != null && mUrlAndBitmap.isMatch(uri)) {
// we can reuse mBitmap
mCastController.setImage(mUrlAndBitmap.mBitmap);
return;
}
mUrlAndBitmap = null;
mImageAsyncTask = new FetchBitmapTask() {
@Override
protected void onPostExecute(Bitmap bitmap) {
if (bitmap != null) {
mUrlAndBitmap = new UrlAndBitmap();
mUrlAndBitmap.mBitmap = bitmap;
mUrlAndBitmap.mUrl = uri;
mCastController.setImage(bitmap);
}
if (this == mImageAsyncTask) {
mImageAsyncTask = null;
}
}
};
mImageAsyncTask.execute(uri);
}
Aggregations