use of com.facebook.drawee.interfaces.DraweeController in project remusic by aa112901.
the class RoundFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_roundimage, container, false);
((ViewGroup) rootView).setAnimationCacheEnabled(false);
if (getArguments() != null) {
albumPath = getArguments().getString("album");
}
// CircleImageView circleImageView = (CircleImageView) rootView.findViewById(R.id.circle);
sdv = (SimpleDraweeView) rootView.findViewById(R.id.sdv);
// 初始化圆角圆形参数对象
RoundingParams rp = new RoundingParams();
// 设置图像是否为圆形
rp.setRoundAsCircle(true);
// 设置圆角半径
// rp.setCornersRadius(20);
// 分别设置左上角、右上角、左下角、右下角的圆角半径
// rp.setCornersRadii(20,25,30,35);
// 分别设置(前2个)左上角、(3、4)右上角、(5、6)左下角、(7、8)右下角的圆角半径
// rp.setCornersRadii(new float[]{20,25,30,35,40,45,50,55});
// 设置边框颜色及其宽度
rp.setBorder(Color.BLACK, 6);
// 获取GenericDraweeHierarchy对象
GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources()).setRoundingParams(rp).setFadeDuration(300).build();
// 设置Hierarchy
sdv.setHierarchy(hierarchy);
// Log.e("music id",musicId + "");
// String uri = MusicUtils.getAlbumdata(getContext().getApplicationContext(), musicId);
//
// if (musicId != -1 && uri != null) {
// //circleImageView.setImageBitmap(bitmap);
// //circleImageView.setImageURI(Uri.parse(uri));
// Uri ur = MusicUtils.getAlbumUri(getContext().getApplicationContext(), musicId);
// sdv.setImageURI(ur);
// } else {
//
// // circleImageView.setImageResource(R.drawable.placeholder_disk_play_song);
// Uri urr = Uri.parse("res:/" + R.drawable.placeholder_disk_play_song);
// sdv.setImageURI(urr);
// }
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) {
sdv.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_play_song));
}
};
if (albumPath == null) {
sdv.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(sdv.getController()).setImageRequest(request).setControllerListener(controllerListener).build();
sdv.setController(controller);
// sdv.setImageBitmap(BitmapFactory.decodeStream(HttpUtil.getFromCache(getActivity(),getAlbumPath())));
} catch (Exception e) {
e.printStackTrace();
}
}
return rootView;
}
use of com.facebook.drawee.interfaces.DraweeController in project fresco by facebook.
the class SimpleDraweeView method setImageURI.
/**
* Displays an image given by the uri.
*
* @param uri uri of the image
* @param callerContext caller context
*/
public void setImageURI(Uri uri, @Nullable Object callerContext) {
DraweeController controller = mControllerBuilder.setCallerContext(callerContext).setUri(uri).setOldController(getController()).build();
setController(controller);
}
use of com.facebook.drawee.interfaces.DraweeController in project fresco by facebook.
the class DraweeHolderTest method testNewControllerKeepsHierarchy.
@Test
public void testNewControllerKeepsHierarchy() {
mDraweeHolder.setController(mController);
assertSame(mDraweeHierarchy, mDraweeHolder.getHierarchy());
DraweeController another = DraweeMocks.mockController();
mDraweeHolder.setController(another);
assertSame(mDraweeHierarchy, mDraweeHolder.getHierarchy());
assertSame(another, mDraweeHolder.getController());
assertNull(mController.getHierarchy());
assertSame(mDraweeHierarchy, another.getHierarchy());
}
use of com.facebook.drawee.interfaces.DraweeController in project fresco by facebook.
the class DraweeViewTest method testNewControllerKeepsHierarchy.
@Test
public void testNewControllerKeepsHierarchy() {
mDraweeView.setHierarchy(mDraweeHierarchy);
mDraweeView.setController(mController);
DraweeController controller2 = DraweeMocks.mockController();
mDraweeView.setController(controller2);
assertSame(controller2, mDraweeView.getController());
assertSame(mTopLevelDrawable, mDraweeView.getDrawable());
verify(mController).setHierarchy(null);
verify(controller2).setHierarchy(mDraweeHierarchy);
}
use of com.facebook.drawee.interfaces.DraweeController in project fresco by facebook.
the class DraweeSpanSimpleTextFragment method updateText.
private void updateText() {
// The # will be replaced with the image.
String text = getString(R.string.drawee_span_simple_text);
int imagePosition = text.indexOf('#');
DraweeSpanStringBuilder draweeSpanStringBuilder = new DraweeSpanStringBuilder(text);
DraweeHierarchy draweeHierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources()).setPlaceholderImage(new ColorDrawable(Color.RED)).setActualImageScaleType(mScaleType).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setUri(mInlineImageUri).build();
draweeSpanStringBuilder.setImageSpan(getContext(), /* Context */
draweeHierarchy, /* hierarchy to be used */
controller, /* controller to be used to update the hierarchy */
imagePosition, /* image index within the text */
200, /* image width */
200, /* image height */
false, /* auto resize */
DraweeSpan.ALIGN_CENTER);
/* alignment */
int imagePosition2 = text.indexOf('@');
DraweeHierarchy draweeAnimatedHierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources()).setPlaceholderImage(new ColorDrawable(Color.RED)).setActualImageScaleType(mScaleType).build();
DraweeController animatedController = Fresco.newDraweeControllerBuilder().setUri(mInlineAnimatedImageUri).setAutoPlayAnimations(true).build();
draweeSpanStringBuilder.setImageSpan(getContext(), /* Context */
draweeAnimatedHierarchy, /* hierarchy to be used */
animatedController, /* controller to be used to update the hierarchy */
imagePosition2, /* image index within the text */
200, /* image width */
200, /* image height */
false, /* auto resize */
DraweeSpan.ALIGN_CENTER);
/* alignment */
mDraweeSpanTextView.setDraweeSpanStringBuilder(draweeSpanStringBuilder);
}
Aggregations