com.facebook.drawee.drawable.ProgressBarDrawable Java Examples

The following examples show how to use com.facebook.drawee.drawable.ProgressBarDrawable. 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: PicDialog.java    From PicKing with Apache License 2.0 6 votes vote down vote up
public void show(final PicInfo picInfo) {
    if (picInfo != null && !"".equals(picInfo.getPicUrl())) {
        this.picInfo = picInfo;
        photoDraweeView.getHierarchy().setProgressBarImage(new ProgressBarDrawable());
        photoDraweeView.setPhotoUri(Uri.parse(picInfo.getPicUrl()));
    }
    if (picInfo.getTitle() != null)
        picTitle.setText(picInfo.getTitle());
    if (picInfo.getTime() != null)
        picTime.setText(picInfo.getTime());
    if (picInfo.getTags() != null) {
        tags.removeAllViews();
        for (String s : picInfo.getTags()) {
            TextView t = new TextView(getOwnerActivity());
            t.setText(s);
            ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            layoutParams.setMarginEnd(15);
            t.setLayoutParams(layoutParams);
            t.setPadding(10, 10, 10, 10);
            t.setBackgroundColor(Color.GRAY);
            t.setTextColor(Color.WHITE);
            tags.addView(t);
        }
    }
    this.show();
}
 
Example #3
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 #4
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 #5
Source File: FrescoUtils.java    From materialup with Apache License 2.0 5 votes vote down vote up
public static final void setShotHierarchy(Context context, DraweeView view, ScalingUtils.ScaleType type, int bg) {
    final Resources res = context.getResources();
    final int color = ThemeUtil.getThemeColor(context, R.attr.colorAccent);
    final ProgressBarDrawable progress = new ProgressBarDrawable();
    progress.setBackgroundColor(Color.parseColor("#33000000"));
    progress.setColor(color);
    GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(res)
            .setPlaceholderImage(res.getDrawable(R.drawable.ic_holder))
            .setProgressBarImage(progress)
            .setBackground(new ColorDrawable(bg))
            .setActualImageScaleType(type)
            .build();
    view.setHierarchy(gdh);
}
 
Example #6
Source File: FrescoUtils.java    From droidddle with Apache License 2.0 5 votes vote down vote up
public static final void setShotHierarchy(Context context, DraweeView view, ScalingUtils.ScaleType type) {
    final Resources res = context.getResources();
    final int color = ThemeUtil.getThemeColor(context, R.attr.colorAccent);
    final ProgressBarDrawable progress = new ProgressBarDrawable();
    progress.setBackgroundColor(Color.parseColor("#33000000"));
    progress.setColor(color);
    GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(res)
            .setPlaceholderImage(res.getDrawable(R.drawable.placeholder))
            .setProgressBarImage(progress)
            .setActualImageScaleType(type)
            .build();
    view.setHierarchy(gdh);
}
 
Example #7
Source File: ImageActivity.java    From coderfun with GNU General Public License v3.0 5 votes vote down vote up
private void initSimpleDraweeView() {
    simpleDraweeView = (SimpleDraweeView) findViewById(R.id.draweeview);
    GenericDraweeHierarchy hierarchy = simpleDraweeView.getHierarchy();
    hierarchy.setProgressBarImage(new ProgressBarDrawable());
    Uri uri = Uri.parse(url);
    simpleDraweeView.setImageURI(uri);
}
 
Example #8
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 #9
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 #10
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 #11
Source File: FavoriteAdapter.java    From PicKing with Apache License 2.0 4 votes vote down vote up
public MyViewHolder(View itemView) {
    super(itemView);
    simpleDraweeView = (SimpleDraweeView) itemView.findViewById(R.id.fresco);
    simpleDraweeView.getHierarchy().setProgressBarImage(new ProgressBarDrawable());
    imageButton = (AppCompatImageButton) itemView.findViewById(R.id.love_button);
}
 
Example #12
Source File: DetailAdapter.java    From PicKing with Apache License 2.0 4 votes vote down vote up
public MyViewHolder(View itemView) {
    super(itemView);
    simpleDraweeView = (SimpleDraweeView) itemView.findViewById(R.id.fresco);
    simpleDraweeView.getHierarchy().setProgressBarImage(new ProgressBarDrawable());
    imageButton = (AppCompatImageButton) itemView.findViewById(R.id.love_button);
}
 
Example #13
Source File: FrescoImageLoader.java    From GalleryFinal with Apache License 2.0 4 votes vote down vote up
@Override
public void displayImage(Activity activity, String path, final GFImageView imageView, final Drawable defaultDrawable, int width, int height) {
    Resources resources = context.getResources();
    GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(resources)
            .setFadeDuration(300)
            .setPlaceholderImage(defaultDrawable)
            .setFailureImage(defaultDrawable)
            .setProgressBarImage(new ProgressBarDrawable())
            .build();

    final DraweeHolder<GenericDraweeHierarchy> draweeHolder = DraweeHolder.create(hierarchy, context);
    imageView.setOnImageViewListener(new GFImageView.OnImageViewListener() {
        @Override
        public void onDetach() {
            draweeHolder.onDetach();
        }

        @Override
        public void onAttach() {
            draweeHolder.onAttach();
        }

        @Override
        public boolean verifyDrawable(Drawable dr) {
            if (dr == draweeHolder.getHierarchy().getTopLevelDrawable()) {
                return true;
            }
            return false;
        }

        @Override
        public void onDraw(Canvas canvas) {
            Drawable drawable = draweeHolder.getHierarchy().getTopLevelDrawable();
            if (drawable == null) {
                imageView.setImageDrawable(defaultDrawable);
            } else {
                imageView.setImageDrawable(drawable);
            }
        }
    });
    Uri uri = new Uri.Builder()
            .scheme(UriUtil.LOCAL_FILE_SCHEME)
            .path(path)
            .build();
    ImageRequest imageRequest = ImageRequestBuilder
            .newBuilderWithSource(uri)
            .setResizeOptions(new ResizeOptions(width, height))//图片目标大小
            .build();
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(draweeHolder.getController())
            .setImageRequest(imageRequest)
            .build();
    draweeHolder.setController(controller);
}