Search in sources :

Example 1 with GenericDraweeHierarchy

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;
}
Also used : ViewGroup(android.view.ViewGroup) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) DraweeController(com.facebook.drawee.interfaces.DraweeController) BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) ControllerListener(com.facebook.drawee.controller.ControllerListener) QualityInfo(com.facebook.imagepipeline.image.QualityInfo) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Animatable(android.graphics.drawable.Animatable) ImageInfo(com.facebook.imagepipeline.image.ImageInfo) RoundingParams(com.facebook.drawee.generic.RoundingParams) Nullable(android.support.annotation.Nullable)

Example 2 with GenericDraweeHierarchy

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);
}
Also used : GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) ActorCreator(im.actor.runtime.actors.ActorCreator)

Example 3 with GenericDraweeHierarchy

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;
}
Also used : Answer(org.mockito.stubbing.Answer) GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Example 4 with GenericDraweeHierarchy

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;
}
Also used : GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy)

Example 5 with GenericDraweeHierarchy

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());
}
Also used : GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) Test(org.junit.Test)

Aggregations

GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)20 GenericDraweeHierarchyBuilder (com.facebook.drawee.generic.GenericDraweeHierarchyBuilder)11 RoundingParams (com.facebook.drawee.generic.RoundingParams)5 ProgressBarDrawable (com.facebook.drawee.drawable.ProgressBarDrawable)4 DraweeController (com.facebook.drawee.interfaces.DraweeController)4 Uri (android.net.Uri)3 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)3 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)3 Canvas (android.graphics.Canvas)2 PointF (android.graphics.PointF)2 Drawable (android.graphics.drawable.Drawable)2 InstrumentedDraweeView (com.facebook.samples.comparison.instrumentation.InstrumentedDraweeView)2 InstrumentedDraweeView (com.facebook.samples.scrollperf.instrumentation.InstrumentedDraweeView)2 Context (android.content.Context)1 Resources (android.content.res.Resources)1 Animatable (android.graphics.drawable.Animatable)1 Nullable (android.support.annotation.Nullable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1