com.facebook.drawee.generic.GenericDraweeHierarchyBuilder Java Examples

The following examples show how to use com.facebook.drawee.generic.GenericDraweeHierarchyBuilder. 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: ImagePageViewAdapter.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
    public Object instantiateItem(ViewGroup container,int position)
    {
        IBrowsingConversationImageView.PreImage data = datas.get(position);
        ZoomableDraweeView mImageView = new ZoomableDraweeView(context);
        final DraweeController ctrl = Fresco.newDraweeControllerBuilder()
                .setImageRequest(ImageRequest.fromUri(data.originUrl))
                .setLowResImageRequest(ImageRequest.fromUri(data.smallUrl))
                .setTapToRetryEnabled(false).setAutoPlayAnimations(true).build();

        GenericDraweeHierarchyBuilder hierarchyBuilder = new GenericDraweeHierarchyBuilder(
                context.getResources())
                .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
                .setProgressBarImage(new ProgressBarDrawable());

        mImageView.setHierarchy(hierarchyBuilder.build());
        mImageView.setController(ctrl);
        mImageView.setOnCreateContextMenuListener(listener);
//        mImageView.setOnClickListener(onClickListener);
        mImageView.setOnTouchListener(onTouchListener);
        viewSparseArray.append(position,mImageView);
        container.addView(mImageView);
        return mImageView;
    }
 
Example #2
Source File: ShapedDraweeView.java    From AndroidPlayground with MIT License 6 votes vote down vote up
private void setup(Context context, AttributeSet attrs, int defStyle) {
    if (getScaleType() == ScaleType.FIT_CENTER) {
        setScaleType(ScaleType.CENTER_CROP);
    }

    Drawable placeholder = null;
    if (attrs != null) {
        TypedArray typedArray =
                context.obtainStyledAttributes(attrs, R.styleable.ShapedDrawee, defStyle, 0);
        shape = typedArray.getDrawable(R.styleable.ShapedDrawee_maskShape);
        placeholder = typedArray.getDrawable(R.styleable.ShapedDrawee_placeholder);
        typedArray.recycle();
    }
    if (shape == null) {
        throw new IllegalArgumentException("maskShape must be specified in layout!");
    }

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(getResources()).setPlaceholderImage(placeholder)
                    .setPlaceholderImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
                    .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
                    .build();
    mDraweeHolder = DraweeHolder.create(hierarchy, getContext());
}
 
Example #3
Source File: FrescoConfig.java    From BlueBoard with Apache License 2.0 6 votes vote down vote up
public static GenericDraweeHierarchy getGenericDraweeHierarchy(Context context) {
        GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(context.getResources())
//            .reset()//重置
//            .setActualImageColorFilter(colorFilter)//颜色过滤
//            .setActualImageFocusPoint(focusPoint)//focusCrop, 需要指定一个居中点
//            .setActualImageMatrix(actualImageMatrix)
//            .setActualImageScaleType(actualImageScaleType)//fresco:actualImageScaleType="focusCrop"缩放类型
//            .setBackground(background)//fresco:backgroundImage="@color/blue"背景图片
//            .setBackgrounds(backgrounds)
//            .setFadeDuration(fadeDuration)//fresco:fadeDuration="300"加载图片动画时间
                .setFailureImage(FrescoConfig.sErrorDrawable)//fresco:failureImage="@drawable/error"失败图
//            .setFailureImage(failureDrawable, failureImageScaleType)//fresco:failureImageScaleType="centerInside"失败图缩放类型
//            .setOverlay(overlay)//fresco:overlayImage="@drawable/watermark"叠加图
//            .setOverlays(overlays)
                .setPlaceholderImage(FrescoConfig.sPlaceholderDrawable)//fresco:placeholderImage="@color/wait_color"占位图
//            .setPlaceholderImage(placeholderDrawable, placeholderImageScaleType)//fresco:placeholderImageScaleType="fitCenter"占位图缩放类型
//            .setPressedStateOverlay(drawable)//fresco:pressedStateOverlayImage="@color/red"按压状态下的叠加图
                .setProgressBarImage(new ProgressBarDrawable())//进度条fresco:progressBarImage="@drawable/progress_bar"进度条
//            .setProgressBarImage(progressBarImage, progressBarImageScaleType)//fresco:progressBarImageScaleType="centerInside"进度条类型
//            .setRetryImage(retryDrawable)//fresco:retryImage="@drawable/retrying"点击重新加载
//            .setRetryImage(retryDrawable, retryImageScaleType)//fresco:retryImageScaleType="centerCrop"点击重新加载缩放类型
                .setRoundingParams(RoundingParams.asCircle())//圆形/圆角fresco:roundAsCircle="true"圆形
                .build();
        return gdh;
    }
 
Example #4
Source File: DraweeMocksTest.java    From fresco with MIT License 6 votes vote down vote up
@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());
}
 
Example #5
Source File: DraweeMocks.java    From fresco with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: AvatarView.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
public void init(int size, float placeholderTextSize) {
    this.size = size;
    this.placeholderTextSize = placeholderTextSize;

    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(getResources());

    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(200)
            .setRoundingParams(new RoundingParams()
                    .setRoundAsCircle(true)
                    .setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY))
            //.setActualImageColorFilter(new PorterDuffColorFilter(0x19000000, PorterDuff.Mode.MULTIPLY))
            //.setOverlay(new AvatarBorderDrawable())
            .build();
    setHierarchy(hierarchy);
}
 
Example #7
Source File: CallBackgroundAvatarView.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #8
Source File: CoverAvatarView.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
private void init() {

        if (isInEditMode()) {
            return;
        }

        GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());

        builder.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
        builder.setOverlay(new CoverOverlayDrawable(getContext()));

        if (ActorSDK.sharedActor().style.getAvatarBackgroundResourse() != 0) {
            builder.setPlaceholderImage(getResources()
                    .getDrawable(ActorSDK.sharedActor().style.getAvatarBackgroundResourse()), ScalingUtils.ScaleType.CENTER_CROP);
        } else {
            builder.setPlaceholderImage(new ColorDrawable(
                    ActorSDK.sharedActor().style.getAvatarBackgroundColor()));
        }

        builder.setFadeDuration(0);

        setHierarchy(builder.build());
    }
 
Example #9
Source File: ItemDataAdapter.java    From ListItemFold with MIT License 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = layoutInflater.inflate(R.layout.item_data, null);
        ViewHolder viewHolder = new ViewHolder();
        viewHolder.myImageView = (SimpleDraweeView) convertView.findViewById(R.id.my_image_view);
        viewHolder.myTitle = (TextView) convertView.findViewById(R.id.my_title);
        viewHolder.myContent = (TextView) convertView.findViewById(R.id.my_content);
        GenericDraweeHierarchyBuilder builder =
                new GenericDraweeHierarchyBuilder(context.getResources());
        GenericDraweeHierarchy hierarchy = builder
                .setFadeDuration(200)
                .setPlaceholderImage(new ColorDrawable(0xf2f2f2))
                .setProgressBarImage(new CircularProgressDrawable())
                .build();
        viewHolder.myImageView.setHierarchy(hierarchy);
        convertView.setTag(viewHolder);
    }
    initializeViews(getItem(position), (ViewHolder) convertView.getTag());
    return convertView;
}
 
Example #10
Source File: ViewPagerActivity.java    From ZoomableDraweeView-sample with Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    ZoomableDraweeView view = new ZoomableDraweeView(container.getContext());
    view.setController(
            Fresco.newDraweeControllerBuilder()
                    .setUri(Uri.parse(items[position]))
                    .build());

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(container.getResources())
                    .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
                    .setProgressBarImage(new ProgressBarDrawable())
                    .build();

    view.setHierarchy(hierarchy);

    container.addView(view,
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    return view;
}
 
Example #11
Source File: CommentImageGrid.java    From CommentGallery with Apache License 2.0 6 votes vote down vote up
private ViewGroup generateImageLayout() {
    SquareDraweeView imageView = new SquareDraweeView(mContext);

    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(mContext.getResources());
    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(300).setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
            .build();
    if (mPlaceholderImageResId > 0) {
        hierarchy.setPlaceholderImage(mPlaceholderImageResId);
    }
    if (mFailureImageResId > 0) {
        hierarchy.setFailureImage(mFailureImageResId);
    }

    imageView.setHierarchy(hierarchy);
    RelativeLayout.LayoutParams imgLp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    imgLp.setMargins(mImageBorderThickness, mImageBorderThickness, mImageBorderThickness, mImageBorderThickness);
    RelativeLayout mainLayout = new RelativeLayout(mContext);
    mainLayout.setBackgroundColor(mImageBorderColor);
    mainLayout.addView(imageView, imgLp);
    return mainLayout;
}
 
Example #12
Source File: FrescoBasedReactTextInlineImageSpan.java    From react-native-GPay with MIT License 6 votes vote down vote up
public FrescoBasedReactTextInlineImageSpan(
    Resources resources,
    int height,
    int width,
    int tintColor,
    @Nullable Uri uri,
    ReadableMap headers,
    AbstractDraweeControllerBuilder draweeControllerBuilder,
    @Nullable Object callerContext) {
  mDraweeHolder = new DraweeHolder(
      GenericDraweeHierarchyBuilder.newInstance(resources)
          .build()
  );
  mDraweeControllerBuilder = draweeControllerBuilder;
  mCallerContext = callerContext;
  mTintColor = tintColor;
  mUri = (uri != null) ? uri : Uri.EMPTY;
  mHeaders = headers;
  mWidth = (int)(PixelUtil.toPixelFromDIP(width));
  mHeight = (int)(PixelUtil.toPixelFromDIP(height));

}
 
Example #13
Source File: ZoomableDraweeView.java    From fresco with MIT License 5 votes vote down vote up
protected void inflateHierarchy(Context context, @Nullable AttributeSet attrs) {
  Resources resources = context.getResources();
  GenericDraweeHierarchyBuilder builder =
      new GenericDraweeHierarchyBuilder(resources)
          .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
  GenericDraweeHierarchyInflater.updateBuilder(builder, context, attrs);
  setAspectRatio(builder.getDesiredAspectRatio());
  setHierarchy(builder.build());
}
 
Example #14
Source File: ZoomableActivity.java    From ZoomableDraweeView-sample with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Uri data = getIntent().getData();
    if (null == data) {
        throw new IllegalArgumentException("No data to display");
    }

    String title = getIntent().getStringExtra(KEY_TITLE);
    if (title != null) {
        setTitle(title);
    }

    Fresco.initialize(this);
    setContentView(R.layout.activity_zoomable);

    ZoomableDraweeView view = (ZoomableDraweeView) findViewById(R.id.zoomable);

    DraweeController ctrl = Fresco.newDraweeControllerBuilder().setUri(
            data).setTapToRetryEnabled(true).build();
    GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
            .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
            .setProgressBarImage(new ProgressBarDrawable())
            .build();

    view.setController(ctrl);
    view.setHierarchy(hierarchy);
}
 
Example #15
Source File: RecyclerDataAdapter.java    From ListItemFold with MIT License 5 votes vote down vote up
public ViewHolder(View convertView) {
    super(convertView);
    myImageView = (SimpleDraweeView) convertView.findViewById(R.id.my_image_view);
    myTitle = (TextView) convertView.findViewById(R.id.my_title);
    myContent = (TextView) convertView.findViewById(R.id.my_content);
    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(mContext.getResources());
    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(200)
            .setPlaceholderImage(new ColorDrawable(0xf2f2f2))
            .setProgressBarImage(new CircularProgressDrawable())
            .build();
    myImageView.setHierarchy(hierarchy);
    convertView.setOnClickListener(this);
}
 
Example #16
Source File: FrescoAdapter.java    From fresco with MIT License 5 votes vote down vote up
@Override
public FrescoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  GenericDraweeHierarchy gdh =
      new GenericDraweeHierarchyBuilder(getContext().getResources())
          .setPlaceholderImage(Drawables.sPlaceholderDrawable)
          .setFailureImage(Drawables.sErrorDrawable)
          .setProgressBarImage(new ProgressBarDrawable())
          .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
          .build();
  final InstrumentedDraweeView instrView = new InstrumentedDraweeView(getContext(), gdh);

  return new FrescoHolder(getContext(), parent, instrView, getPerfListener());
}
 
Example #17
Source File: NetImagePieceView.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
@Override
    protected void initView() {
        super.initView();
        GenericDraweeHierarchyBuilder builder =
                new GenericDraweeHierarchyBuilder(getResources());
        GenericDraweeHierarchy hierarchy = builder
//                .setProgressBarImage(getContext().getResources().getDrawable(R.drawable.default_loading))
//                .setFailureImage(getContext().getResources().getDrawable(R.drawable.job_error))
                .build();
        mDraweeHolder = DraweeHolder.create(hierarchy, getContext());
        setWillNotDraw(false);
    }
 
Example #18
Source File: BackgroundPreviewView.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
public void init(int width, int height, int corenerRadius) {
    this.width = width;
    this.height = height;

    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(getResources());

    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(200)
            .setRoundingParams(new RoundingParams()
                    .setCornersRadius(corenerRadius)
                    .setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY))
            .build();
    setHierarchy(hierarchy);
}
 
Example #19
Source File: StickerView.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
private void init() {
    builder = new GenericDraweeHierarchyBuilder(getResources());

    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(200)
            .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
            .build();
    setHierarchy(hierarchy);

    fastThumbLoader = new FastThumbLoader(this);

}
 
Example #20
Source File: ImageViewerAdapter.java    From photo-viewer with Apache License 2.0 5 votes vote down vote up
ImageViewerAdapter(Context context, ImageViewer.DataSet<?> dataSet,
				   ImageRequestBuilder imageRequestBuilder,
				   GenericDraweeHierarchyBuilder hierarchyBuilder,
				   boolean isZoomingAllowed) {
	this.context = context;
	this.dataSet = dataSet;
	this.holders = new HashSet<>();
	this.imageRequestBuilder = imageRequestBuilder;
	this.hierarchyBuilder = hierarchyBuilder;
	this.isZoomingAllowed = isZoomingAllowed;
}
 
Example #21
Source File: FrescoController.java    From base-module with Apache License 2.0 5 votes vote down vote up
/**
 * 加载图片到 View 上,可设置回调监听
 * @param draweeView
 * @param listener
 */
public void intoTarget(SimpleDraweeView draweeView, ControllerListener listener) {
    if ((mImageConfig != null && mImageConfig.useNewHierarchy) || !draweeView.hasHierarchy()) {
        GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder
                .newInstance(draweeView.getResources()).build();
        draweeView.setHierarchy(hierarchy);
    }
    parseImageConfig(draweeView.getHierarchy());
    if (mUri != null) {
        ImageDecodeOptions imageDecodeOptions = ImageDecodeOptions.newBuilder()
                .setDecodePreviewFrame(true)
                .build();
        ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(mUri)
                .setProgressiveRenderingEnabled(true)
                .setImageDecodeOptions(imageDecodeOptions);
        if (mWidth > 0 && mHeight > 0) {
            builder.setResizeOptions(new ResizeOptions(mWidth, mHeight));
        } else {
            int width = draweeView.getMeasuredWidth();
            int height = draweeView.getMeasuredHeight();
            if(width > 0 && height > 0){
                builder.setResizeOptions(new ResizeOptions(width, height));
            }
        }

        ImageRequest request = builder.build();
        AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(request)
                .setControllerListener(listener)
                .setOldController(draweeView.getController())
                .setAutoPlayAnimations(true)
                .build();
        draweeView.setController(controller);
    } else {
        draweeView.setImageURI("");
    }
}
 
Example #22
Source File: DraweeMocks.java    From fresco with MIT License 5 votes vote down vote up
/**
 * 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 #23
Source File: GenericDraweeView.java    From fresco with MIT License 5 votes vote down vote up
protected void inflateHierarchy(Context context, @Nullable AttributeSet attrs) {
  if (FrescoSystrace.isTracing()) {
    FrescoSystrace.beginSection("GenericDraweeView#inflateHierarchy");
  }
  GenericDraweeHierarchyBuilder builder =
      GenericDraweeHierarchyInflater.inflateBuilder(context, attrs);
  setAspectRatio(builder.getDesiredAspectRatio());
  setHierarchy(builder.build());
  if (FrescoSystrace.isTracing()) {
    FrescoSystrace.endSection();
  }
}
 
Example #24
Source File: LocationHolder.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
public LocationHolder(MessagesAdapter adapter, View itemView, Peer peer) {
    super(adapter, itemView, false);
    this.context = adapter.getMessagesFragment().getActivity();

    COLOR_PENDING = ActorSDK.sharedActor().style.getConvMediaStatePendingColor();
    COLOR_SENT = ActorSDK.sharedActor().style.getConvMediaStateSentColor();
    COLOR_RECEIVED = ActorSDK.sharedActor().style.getConvMediaStateDeliveredColor();
    COLOR_READ = ActorSDK.sharedActor().style.getConvMediaStateReadColor();
    COLOR_ERROR = ActorSDK.sharedActor().style.getConvMediaStateErrorColor();

    messageBubble = (FrameLayout) itemView.findViewById(R.id.bubbleContainer);

    // Content
    previewView = (SimpleDraweeView) itemView.findViewById(R.id.image);
    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(context.getResources());

    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(200)
            .setRoundingParams(new RoundingParams()
                    .setCornersRadius(Screen.dp(2))
                    .setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY))
            .build();
    previewView.setHierarchy(hierarchy);

    time = (TextView) itemView.findViewById(R.id.time);

    stateIcon = (TintImageView) itemView.findViewById(R.id.stateIcon);
    onConfigureViewHolder();
}
 
Example #25
Source File: DialogView.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void initStyles() {
        GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
                .setFadeDuration(0)
                .setRoundingParams(new RoundingParams()
                        .setRoundAsCircle(true))
                .build();
        draweeHolder = DraweeHolder.create(hierarchy, getContext());
        draweeHolder.getTopLevelDrawable().setCallback(this);

        setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(72)));
        setDividerPaddingLeft(Screen.dp(72));

//        setLayerType(LAYER_TYPE_HARDWARE, null);
    }
 
Example #26
Source File: ImageManager.java    From redgram-for-reddit with GNU General Public License v3.0 5 votes vote down vote up
private static GenericDraweeHierarchy buildGenericDraweesHierarchy(Context context) {
    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(context.getResources());
    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(300)
            .setActualImageFocusPoint(new PointF(0.5f, 0f))
            .setProgressBarImage(new ProgressBarDrawable())
            .build();
    return hierarchy;
}
 
Example #27
Source File: PostItemGalleryView.java    From redgram-for-reddit with GNU General Public License v3.0 5 votes vote down vote up
private GenericDraweeHierarchy getDraweeHierarchy(PostItem item) {
    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(getResources())
                    .setFadeDuration(300)
                    .setActualImageFocusPoint(new PointF(0.5f, 0f));
    return builder.build();
}
 
Example #28
Source File: PostItemAnimatedView.java    From redgram-for-reddit with GNU General Public License v3.0 5 votes vote down vote up
private GenericDraweeHierarchy getDraweeHierarchy(PostItem item) {
    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(getResources())
                    .setFadeDuration(300)
                    .setActualImageFocusPoint(new PointF(0.5f, 0f));
    return builder.build();
}
 
Example #29
Source File: ImageFragment.java    From TLint with Apache License 2.0 5 votes vote down vote up
@Override
public void initData() {
    showContent(true);
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
            .setProgressiveRenderingEnabled(true)
            .build();

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(getResources()).setProgressBarImage(
                    new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() {
                        @Override
                        public void onChange(int level) {
                            if (level > 100 && progress.getVisibility() == View.VISIBLE) {
                                progress.setVisibility(View.GONE);
                            }
                        }
                    }, ResourceUtil.getThemeColor(getActivity()))).build();
    hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);

    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setControllerListener(listener);
    controller.setImageRequest(request);
    controller.setOldController(image.getController());
    controller.setAutoPlayAnimations(true);
    image.setHierarchy(hierarchy);
    image.setController(controller.build());
}
 
Example #30
Source File: DraweeUtil.java    From fresco with MIT License 5 votes vote down vote up
/**
 * Creates the Hierarchy using the information into the Config
 *
 * @param context The Context
 * @param config The Config object
 * @return The Hierarchy to use
 */
public static GenericDraweeHierarchy createDraweeHierarchy(
    final Context context, final Config config) {
  FrescoSystrace.beginSection("DraweeUtil#createDraweeHierarchy");
  GenericDraweeHierarchyBuilder builder =
      new GenericDraweeHierarchyBuilder(context.getResources())
          .setFadeDuration(config.fadeDurationMs)
          .setPlaceholderImage(Const.PLACEHOLDER)
          .setFailureImage(Const.FAILURE)
          .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
  applyScaleType(builder, config);

  if (config.useRoundedCorners || config.drawBorder) {
    final Resources res = context.getResources();
    final RoundingParams roundingParams = new RoundingParams();

    if (config.useRoundedCorners) {
      roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
      roundingParams.setCornersRadius(res.getDimensionPixelSize(R.dimen.drawee_corner_radius));
      roundingParams.setRoundAsCircle(config.useRoundedAsCircle);
    }

    if (config.drawBorder) {
      //noinspection deprecation
      roundingParams.setBorderColor(res.getColor(R.color.colorPrimary));
      roundingParams.setBorderWidth(res.getDimensionPixelSize(R.dimen.drawee_border_width));
    }

    builder.setRoundingParams(roundingParams);
  }
  GenericDraweeHierarchy result = builder.build();
  FrescoSystrace.endSection();
  return result;
}