use of com.facebook.drawee.generic.GenericDraweeHierarchy 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.generic.GenericDraweeHierarchy in project actor-platform by actorapp.
the class CallBackgroundAvatarView method init.
public void init() {
if (blurActor == null) {
blurActor = system().actorOf(Props.create(new ActorCreator() {
@Override
public BlurActor create() {
return new BlurActor();
}
}), "actor/call_blur");
}
GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());
GenericDraweeHierarchy hierarchy = builder.setFadeDuration(200).build();
setHierarchy(hierarchy);
}
use of com.facebook.drawee.generic.GenericDraweeHierarchy in project fresco by facebook.
the class DraweeMocks method mockBuilderOf.
/**
* Creates a mock GenericDraweeHierarchyBuilder with stubbed build.
* @param drawableHierarchies drawable hierarchies to return on {@code build()}
* @return mock GenericDraweeHierarchyBuilder
*/
public static GenericDraweeHierarchyBuilder mockBuilderOf(GenericDraweeHierarchy... drawableHierarchies) {
GenericDraweeHierarchyBuilder builder = mock(GenericDraweeHierarchyBuilder.class, CALLS_REAL_METHODS);
final Supplier<GenericDraweeHierarchy> gdhProvider = supplierOf(drawableHierarchies);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return gdhProvider.get();
}
}).when(builder).build();
return builder;
}
use of com.facebook.drawee.generic.GenericDraweeHierarchy in project fresco by facebook.
the class DraweeMocks method mockDraweeHierarchyOf.
/**
* Creates a mock GenericDraweeHierarchy with some methods stubbed.
* @param topLevelDrawable drawable to return on {@code getTopLevelDrawable()}
* @return mock GenericDraweeHierarchy
*/
public static GenericDraweeHierarchy mockDraweeHierarchyOf(Drawable topLevelDrawable) {
GenericDraweeHierarchy gdh = mock(GenericDraweeHierarchy.class);
when(gdh.getTopLevelDrawable()).thenReturn(topLevelDrawable);
return gdh;
}
use of com.facebook.drawee.generic.GenericDraweeHierarchy in project fresco by facebook.
the class DraweeMocksTest method testMockBuilderOfDrawableHierarchies.
@Test
public void testMockBuilderOfDrawableHierarchies() {
GenericDraweeHierarchy gdh = DraweeMocks.mockDraweeHierarchy();
GenericDraweeHierarchyBuilder builder = DraweeMocks.mockBuilderOf(gdh);
assertEquals(gdh, builder.build());
assertEquals(gdh, builder.build());
assertEquals(gdh, builder.build());
assertEquals(gdh, builder.build());
assertEquals(gdh, builder.build());
GenericDraweeHierarchy gdh1 = DraweeMocks.mockDraweeHierarchy();
GenericDraweeHierarchy gdh2 = DraweeMocks.mockDraweeHierarchy();
GenericDraweeHierarchy gdh3 = DraweeMocks.mockDraweeHierarchy();
GenericDraweeHierarchyBuilder multiBuilder = DraweeMocks.mockBuilderOf(gdh1, gdh2, gdh3);
assertEquals(gdh1, multiBuilder.build());
assertEquals(gdh2, multiBuilder.build());
assertEquals(gdh3, multiBuilder.build());
assertEquals(gdh3, multiBuilder.build());
assertEquals(gdh3, multiBuilder.build());
}
Aggregations