com.facebook.drawee.interfaces.DraweeHierarchy Java Examples
The following examples show how to use
com.facebook.drawee.interfaces.DraweeHierarchy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DraweeSpanStringBuilder.java From fresco with MIT License | 6 votes |
public void setImageSpan( Context context, DraweeHierarchy draweeHierarchy, DraweeController draweeController, int startIndex, int endIndex, final int drawableWidthPx, final int drawableHeightPx, boolean enableResizing, @BetterImageSpan.BetterImageSpanAlignment int verticalAlignment) { DraweeHolder draweeHolder = DraweeHolder.create(draweeHierarchy, context); draweeHolder.setController(draweeController); setImageSpan( draweeHolder, startIndex, endIndex, drawableWidthPx, drawableHeightPx, enableResizing, verticalAlignment); }
Example #2
Source File: DraweeSpanStringBuilder.java From fresco with MIT License | 6 votes |
public void setImageSpan( Context context, DraweeHierarchy draweeHierarchy, DraweeController draweeController, int index, final int drawableWidthPx, final int drawableHeightPx, boolean enableResizing, @BetterImageSpan.BetterImageSpanAlignment int verticalAlignment) { setImageSpan( context, draweeHierarchy, draweeController, index, index, drawableWidthPx, drawableHeightPx, enableResizing, verticalAlignment); }
Example #3
Source File: AbstractDraweeController.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
/** * Sets the hierarchy. * * <p>The controller should be detached when this method is called. * @param hierarchy This must be an instance of {@link SettableDraweeHierarchy} */ @Override public void setHierarchy(@Nullable DraweeHierarchy hierarchy) { if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v( TAG, "controller %x %s: setHierarchy: %s", System.identityHashCode(this), mId, hierarchy); } mEventTracker.recordEvent( (hierarchy != null) ? Event.ON_SET_HIERARCHY : Event.ON_CLEAR_HIERARCHY); // force release in case request was submitted if (mIsRequestSubmitted) { mDeferredReleaser.cancelDeferredRelease(this); release(); } // clear the existing hierarchy if (mSettableDraweeHierarchy != null) { mSettableDraweeHierarchy.setControllerOverlay(null); mSettableDraweeHierarchy = null; } // set the new hierarchy if (hierarchy != null) { Preconditions.checkArgument(hierarchy instanceof SettableDraweeHierarchy); mSettableDraweeHierarchy = (SettableDraweeHierarchy) hierarchy; mSettableDraweeHierarchy.setControllerOverlay(mControllerOverlay); } }
Example #4
Source File: ImagePerfMonitor.java From fresco with MIT License | 5 votes |
public void addViewportData() { DraweeHierarchy hierarchy = mPipelineDraweeController.getHierarchy(); if (hierarchy != null && hierarchy.getTopLevelDrawable() != null) { Rect bounds = hierarchy.getTopLevelDrawable().getBounds(); mImagePerfState.setOnScreenWidth(bounds.width()); mImagePerfState.setOnScreenHeight(bounds.height()); } }
Example #5
Source File: PipelineDraweeController.java From fresco with MIT License | 5 votes |
/** * updateDebugOverlay updates the debug overlay. Subclasses of {@link PipelineDraweeController} * can override this method (and call <code>super</code>) to provide additional debug information. */ protected void updateDebugOverlay( @Nullable CloseableImage image, DebugControllerOverlayDrawable debugOverlay) { debugOverlay.setControllerId(getId()); final DraweeHierarchy draweeHierarchy = getHierarchy(); ScaleType scaleType = null; if (draweeHierarchy != null) { final ScaleTypeDrawable scaleTypeDrawable = ScalingUtils.getActiveScaleTypeDrawable(draweeHierarchy.getTopLevelDrawable()); scaleType = scaleTypeDrawable != null ? scaleTypeDrawable.getScaleType() : null; } debugOverlay.setScaleType(scaleType); // fill in image origin text and color hint final int origin = mDebugOverlayImageOriginListener.getImageOrigin(); final String originText = ImageOriginUtils.toString(origin); final int originColor = DebugOverlayImageOriginColor.getImageOriginColor(origin); debugOverlay.setOrigin(originText, originColor); if (image != null) { debugOverlay.setDimensions(image.getWidth(), image.getHeight()); debugOverlay.setImageSize(image.getSizeInBytes()); } else { debugOverlay.reset(); } }
Example #6
Source File: DraweeHolder.java From fresco with MIT License | 5 votes |
/** * Creates a new instance of DraweeHolder that detaches / attaches controller whenever context * notifies it about activity's onStop and onStart callbacks. */ public static <DH extends DraweeHierarchy> DraweeHolder<DH> create( @Nullable DH hierarchy, Context context) { DraweeHolder<DH> holder = new DraweeHolder<DH>(hierarchy); holder.registerWithContext(context); return holder; }
Example #7
Source File: DraweeMocks.java From fresco with MIT License | 5 votes |
/** * Creates a mock GenericDraweeHierarchyBuilder that builds a new DH instance each time. * * @return mock GenericDraweeHierarchyBuilder */ public static GenericDraweeHierarchyBuilder mockGenericDraweeHierarchyBuilder() { GenericDraweeHierarchyBuilder builder = mock(GenericDraweeHierarchyBuilder.class, CALLS_REAL_METHODS); doAnswer( new Answer<Object>() { @Override public DraweeHierarchy answer(InvocationOnMock invocation) throws Throwable { return mockDraweeHierarchy(); } }) .when(builder) .build(); return builder; }
Example #8
Source File: AbstractDraweeController.java From fresco with MIT License | 5 votes |
/** * Sets the hierarchy. * * <p>The controller should be detached when this method is called. * * @param hierarchy This must be an instance of {@link SettableDraweeHierarchy} */ @Override public void setHierarchy(@Nullable DraweeHierarchy hierarchy) { if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v( TAG, "controller %x %s: setHierarchy: %s", System.identityHashCode(this), mId, hierarchy); } mEventTracker.recordEvent( (hierarchy != null) ? Event.ON_SET_HIERARCHY : Event.ON_CLEAR_HIERARCHY); // force release in case request was submitted if (mIsRequestSubmitted) { mDeferredReleaser.cancelDeferredRelease(this); release(); } // clear the existing hierarchy if (mSettableDraweeHierarchy != null) { mSettableDraweeHierarchy.setControllerOverlay(null); mSettableDraweeHierarchy = null; } // set the new hierarchy if (hierarchy != null) { Preconditions.checkArgument(hierarchy instanceof SettableDraweeHierarchy); mSettableDraweeHierarchy = (SettableDraweeHierarchy) hierarchy; mSettableDraweeHierarchy.setControllerOverlay(mControllerOverlay); } if (mLoggingListener != null) { setUpLoggingListener(); } }
Example #9
Source File: DraweeViewTest.java From fresco with MIT License | 5 votes |
@Before public void setUp() { Activity activity = Robolectric.buildActivity(Activity.class).create().get(); mDrawable = DrawableTestUtils.mockDrawable(); mTopLevelDrawable = DrawableTestUtils.mockDrawable(); mDraweeHierarchy = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable); mController = DraweeMocks.mockController(); mDraweeView = new DraweeView<DraweeHierarchy>(activity); }
Example #10
Source File: DraweeViewTest.java From fresco with MIT License | 5 votes |
@Test public void testSetHierarchy() { mDraweeView.setHierarchy(mDraweeHierarchy); assertSame(mDraweeHierarchy, mDraweeView.getHierarchy()); assertSame(mTopLevelDrawable, mDraweeView.getDrawable()); DraweeHierarchy hierarchy2 = DraweeMocks.mockDraweeHierarchy(); mDraweeView.setHierarchy(hierarchy2); assertSame(hierarchy2, mDraweeView.getHierarchy()); assertSame(hierarchy2.getTopLevelDrawable(), mDraweeView.getDrawable()); }
Example #11
Source File: DraweeHolderTest.java From fresco with MIT License | 5 votes |
@Test public void testOverrideControllerHierarchy() { DraweeHierarchy otherHierarchy = mock(DraweeHierarchy.class); mController.setHierarchy(otherHierarchy); assertSame(otherHierarchy, mController.getHierarchy()); mDraweeHolder.setController(mController); assertSame(mController, mDraweeHolder.getController()); assertSame(mDraweeHierarchy, mDraweeHolder.getHierarchy()); assertSame(mDraweeHierarchy, mController.getHierarchy()); }
Example #12
Source File: DraweeHolderTest.java From fresco with MIT License | 5 votes |
@Test public void testSetNewControllerWithInvalidController() { final DraweeHierarchy draweeHierarchy2 = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable); final DraweeHolder draweeHolder2 = new DraweeHolder(draweeHierarchy2); mDraweeHolder.onAttach(); mDraweeHolder.setController(mController); draweeHolder2.setController(mController); mDraweeHolder.setController(null); verify(mController, never()).onDetach(); assertEquals(draweeHierarchy2, mController.getHierarchy()); }
Example #13
Source File: DraweeHolderTest.java From fresco with MIT License | 5 votes |
@Test public void testSetNewHierarchyWithInvalidController() { final DraweeHierarchy draweeHierarchy2 = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable); final DraweeHolder draweeHolder2 = new DraweeHolder(draweeHierarchy2); mDraweeHolder.setController(mController); draweeHolder2.setController(mController); final DraweeHierarchy draweeHierarchy3 = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable); mDraweeHolder.setHierarchy(draweeHierarchy3); assertEquals(draweeHierarchy2, mController.getHierarchy()); }
Example #14
Source File: DraweeHolderTest.java From fresco with MIT License | 5 votes |
@Test public void testOnDetachWithInvalidController() { final DraweeHierarchy draweeHierarchy2 = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable); final DraweeHolder draweeHolder2 = new DraweeHolder(draweeHierarchy2); mDraweeHolder.onAttach(); mDraweeHolder.setController(mController); draweeHolder2.setController(mController); mDraweeHolder.onDetach(); verify(mController, never()).onDetach(); }
Example #15
Source File: DraweeHolderTest.java From fresco with MIT License | 5 votes |
@Test public void testTouchEventWithInvalidController() { final DraweeHierarchy draweeHierarchy2 = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable); final DraweeHolder draweeHolder2 = new DraweeHolder(draweeHierarchy2); mDraweeHolder.setController(mController); draweeHolder2.setController(mController); mDraweeHolder.onTouchEvent(mock(MotionEvent.class)); verify(mController, never()).onTouchEvent(any(MotionEvent.class)); }
Example #16
Source File: DraweeSpanSimpleTextFragment.java From fresco with MIT License | 4 votes |
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); }
Example #17
Source File: AbstractDraweeController.java From fresco with MIT License | 4 votes |
/** Gets the hierarchy */ @Override public @Nullable DraweeHierarchy getHierarchy() { return mSettableDraweeHierarchy; }
Example #18
Source File: PipelineDraweeController.java From fresco with MIT License | 4 votes |
@Override public void setHierarchy(@Nullable DraweeHierarchy hierarchy) { super.setHierarchy(hierarchy); maybeUpdateDebugOverlay(null); }
Example #19
Source File: AbstractDraweeController.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 4 votes |
/** Gets the hierarchy */ @Override public @Nullable DraweeHierarchy getHierarchy() { return mSettableDraweeHierarchy; }
Example #20
Source File: DraweeHolder.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 3 votes |
/** * Creates a new instance of DraweeHolder that detaches / attaches controller whenever context * notifies it about activity's onStop and onStart callbacks. * * <p>It is strongly recommended to pass a {@link ListenableActivity} as context. The holder will * then also be able to respond to onStop and onStart events from that activity, making sure the * image does not waste memory when the activity is stopped. */ public static <DH extends DraweeHierarchy> DraweeHolder<DH> create( @Nullable DH hierarchy, Context context) { DraweeHolder<DH> holder = new DraweeHolder<DH>(hierarchy); holder.registerWithContext(context); return holder; }