use of com.facebook.imagepipeline.request.ImageRequest in project remusic by aa112901.
the class SimpleWidgetProvider method pushUpdate.
// 更新所有的 widget
private synchronized void pushUpdate(final Context context, AppWidgetManager appWidgetManager, boolean updateProgress) {
pushAction(context, MediaService.SEND_PROGRESS);
RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.simple_control_widget_layout);
//将按钮与点击事件绑定
remoteView.setOnClickPendingIntent(R.id.widget_play, getPendingIntent(context, R.id.widget_play));
remoteView.setOnClickPendingIntent(R.id.widget_pre, getPendingIntent(context, R.id.widget_pre));
remoteView.setOnClickPendingIntent(R.id.widget_next, getPendingIntent(context, R.id.widget_next));
remoteView.setOnClickPendingIntent(R.id.widget_love, getPendingIntent(context, R.id.widget_love));
remoteView.setTextViewText(R.id.widget_content, trackname == null && art == null ? "" : trackname + "-" + art);
remoteView.setProgressBar(R.id.widget_progress, (int) duration, (int) position, false);
isFav = false;
long[] favlists = PlaylistsManager.getInstance(context).getPlaylistIds(IConstants.FAV_PLAYLIST);
for (long i : favlists) {
if (currentId == i) {
isFav = true;
break;
}
}
if (isFav) {
remoteView.setImageViewResource(R.id.widget_love, R.drawable.widget_unstar_selector);
} else {
remoteView.setImageViewResource(R.id.widget_love, R.drawable.widget_star_selector);
}
if (isPlaying) {
remoteView.setImageViewResource(R.id.widget_play, R.drawable.widget_pause_selector);
} else {
remoteView.setImageViewResource(R.id.widget_play, R.drawable.widget_play_selector);
}
if (updateProgress) {
if (albumuri == null) {
remoteView.setImageViewResource(R.id.widget_image, R.drawable.placeholder_disk_210);
} else {
if (isTrackLocal) {
Bitmap bitmap = ImageUtils.getArtworkQuick(context, Uri.parse(albumuri), 160, 160);
if (bitmap != null) {
remoteView.setImageViewBitmap(R.id.widget_image, bitmap);
} else {
remoteView.setImageViewResource(R.id.widget_image, R.drawable.placeholder_disk_210);
}
} else {
Bitmap bitmap = albumMap.get(albumuri);
if (bitmap != null)
remoteView.setImageViewBitmap(R.id.widget_image, bitmap);
}
}
} else {
if (albumuri == null) {
remoteView.setImageViewResource(R.id.widget_image, R.drawable.placeholder_disk_210);
} else {
if (isTrackLocal) {
final Bitmap bitmap = ImageUtils.getArtworkQuick(context, Uri.parse(albumuri), 160, 160);
if (bitmap != null) {
remoteView.setImageViewBitmap(R.id.widget_image, bitmap);
} else {
remoteView.setImageViewResource(R.id.widget_image, R.drawable.placeholder_disk_210);
}
albumMap.clear();
} else {
if (albumMap.get(albumuri) != null) {
remoteView.setImageViewBitmap(R.id.widget_image, albumMap.get(albumuri));
//noBit = null;
} else {
Uri uri = Uri.parse(albumuri);
if (uri == null) {
noBit = BitmapFactory.decodeResource(context.getResources(), R.drawable.placeholder_disk_210);
albumMap.put(albumuri, noBit);
pushUpdate(context, AppWidgetManager.getInstance(context), false);
} else {
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri).setProgressiveRenderingEnabled(true).build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
dataSource.subscribe(new BaseBitmapDataSubscriber() {
@Override
public void onNewResultImpl(@Nullable Bitmap bitmap) {
// No need to do any cleanup.
if (bitmap != null) {
noBit = bitmap.copy(bitmap.getConfig(), true);
albumMap.put(albumuri, noBit);
}
pushUpdate(context, AppWidgetManager.getInstance(context), false);
}
@Override
public void onFailureImpl(DataSource dataSource) {
// No cleanup required here.
noBit = BitmapFactory.decodeResource(context.getResources(), R.drawable.placeholder_disk_210);
albumMap.put(albumuri, noBit);
pushUpdate(context, AppWidgetManager.getInstance(context), false);
}
}, CallerThreadExecutor.getInstance());
}
}
}
}
}
// 相当于获得所有本程序创建的appwidget
ComponentName componentName = new ComponentName(context, SimpleWidgetProvider.class);
appWidgetManager.updateAppWidget(componentName, remoteView);
}
use of com.facebook.imagepipeline.request.ImageRequest in project remusic by aa112901.
the class LoodView method initUI.
/**
* 初始化UI
*
* @param context
*/
private void initUI(Context context) {
LayoutInflater.from(context).inflate(R.layout.load_view, this, true);
for (String imagesID : imageNet) {
final SimpleDraweeView mAlbumArt = new SimpleDraweeView(context);
ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable anim) {
if (imageInfo == null) {
return;
}
QualityInfo qualityInfo = imageInfo.getQualityInfo();
FLog.d("Final image received! " + "Size %d x %d", "Quality level %d, good enough: %s, full quality: %s", imageInfo.getWidth(), imageInfo.getHeight(), qualityInfo.getQuality(), qualityInfo.isOfGoodEnoughQuality(), qualityInfo.isOfFullQuality());
}
@Override
public void onIntermediateImageSet(String id, @Nullable ImageInfo imageInfo) {
//FLog.d("Intermediate image received");
}
@Override
public void onFailure(String id, Throwable throwable) {
mAlbumArt.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_210));
}
};
Uri uri = null;
try {
uri = Uri.parse(imagesID);
} catch (Exception e) {
e.printStackTrace();
}
if (uri != null) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(mAlbumArt.getController()).setImageRequest(request).setControllerListener(controllerListener).build();
mAlbumArt.setController(controller);
} else {
mAlbumArt.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_210));
}
//view.setImageURI(Uri.parse(imagesID));
// view.setImageResource(imagesID);
// view.setImageResource(imagesID);
mAlbumArt.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageViewList.add(mAlbumArt);
}
dotViewList.add(findViewById(R.id.v_dot1));
dotViewList.add(findViewById(R.id.v_dot2));
dotViewList.add(findViewById(R.id.v_dot3));
dotViewList.add(findViewById(R.id.v_dot4));
dotViewList.add(findViewById(R.id.v_dot5));
dotViewList.add(findViewById(R.id.v_dot6));
dotViewList.add(findViewById(R.id.v_dot7));
viewPager = (ViewPager) findViewById(R.id.viewPager);
viewPager.setFocusable(true);
fPagerAdapter = new FPagerAdapter();
viewPager.setAdapter(fPagerAdapter);
viewPager.addOnPageChangeListener(new MyPageChangeListener());
}
use of com.facebook.imagepipeline.request.ImageRequest in project remusic by aa112901.
the class RoundView method setAlbum.
public void setAlbum(String albumPath) {
if (albumPath == null) {
albumView.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_play_song));
} else {
try {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(albumPath)).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(albumView.getController()).setImageRequest(request).setControllerListener(controllerListener).build();
albumView.setController(controller);
} catch (Exception e) {
e.printStackTrace();
}
}
Log.e("roundview", "setalbum = " + albumPath);
}
use of com.facebook.imagepipeline.request.ImageRequest in project actor-platform by actorapp.
the class PhotoHolder method bindImage.
public void bindImage(Uri uri) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(previewView.getLayoutParams().width, previewView.getLayoutParams().height)).build();
PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(previewView.getController()).setImageRequest(request).setControllerListener(animationController).build();
previewView.setController(controller);
}
use of com.facebook.imagepipeline.request.ImageRequest in project actor-platform by actorapp.
the class StickerView method bind.
public void bind(FileReference fileReference, int size) {
if (this.fileReference != null && this.fileReference.equals(fileReference)) {
return;
}
if (bindedFile != null) {
bindedFile.detach();
bindedFile = null;
}
setImageURI(null);
this.fileReference = fileReference;
bindedFile = messenger().bindFile(fileReference, true, new FileVMCallback() {
private boolean isFastThumbLoaded = false;
private void checkFastThumb() {
if (!isFastThumbLoaded) {
isFastThumbLoaded = true;
// if (sticker.getThumb() != null) {
// fastThumbLoader.request(sticker.getThumb());
// }
}
}
@Override
public void onNotDownloaded() {
checkFastThumb();
}
@Override
public void onDownloading(float progress) {
checkFastThumb();
}
@Override
public void onDownloaded(FileSystemReference reference) {
imageFile = new File(reference.getDescriptor());
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(imageFile)).setAutoRotateEnabled(true).build();
PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(getController()).setImageRequest(request).build();
setController(controller);
loaded = true;
}
});
}
Aggregations