當前位置: 首頁>>代碼示例>>Java>>正文


Java GenericDraweeHierarchy類代碼示例

本文整理匯總了Java中com.facebook.drawee.generic.GenericDraweeHierarchy的典型用法代碼示例。如果您正苦於以下問題:Java GenericDraweeHierarchy類的具體用法?Java GenericDraweeHierarchy怎麽用?Java GenericDraweeHierarchy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GenericDraweeHierarchy類屬於com.facebook.drawee.generic包,在下文中一共展示了GenericDraweeHierarchy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testMockBuilderOfDrawableHierarchies

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
@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());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:DraweeMocksTest.java

示例2: changeDraweeViewScaleType

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
private void changeDraweeViewScaleType(
    SimpleDraweeView draweeView,
    ScaleType scaleType,
    @Nullable PointF focusPoint) {
  final GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
  hierarchy.setActualImageScaleType(scaleType);
  hierarchy.setActualImageFocusPoint(focusPoint != null ? focusPoint : new PointF(0.5f, 0.5f));

  final RoundingParams roundingParams = Preconditions.checkNotNull(hierarchy.getRoundingParams());
  if (BITMAP_ONLY_SCALETYPES.contains(scaleType)) {
    roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
  } else {
    roundingParams.setOverlayColor(mWindowBackgroundColor);
  }
  hierarchy.setRoundingParams(roundingParams);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:DraweeRoundedCornersFragment.java

示例3: displayImage

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
private void displayImage(SimpleDraweeView draweeView, String url) {
    GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
    //設置占位圖
    if (hierarchy == null) {
        hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources())
                .setPlaceholderImage(getResources().getDrawable(R.mipmap.ic_launcher)
                        , ScalingUtils.ScaleType.CENTER).build();
        draweeView.setHierarchy(hierarchy);
    } else {
        hierarchy.setPlaceholderImage(getResources().getDrawable(R.mipmap.ic_launcher)
                , ScalingUtils.ScaleType.CENTER);
    }

    //構建ImageRequestBuilder,傳入請求Uri
    ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url));
    //構建Controller
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(draweeView.getController())
            .setImageRequest(requestBuilder.build())
            .build();
    //設置圖片,Fresco設置顯示圖片都是通過Controller來實現
    draweeView.setController(controller);
}
 
開發者ID:idisfkj,項目名稱:Zoomable,代碼行數:24,代碼來源:MainActivity.java

示例4: generateImageLayout

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
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;
}
 
開發者ID:ibosong,項目名稱:CommentGallery,代碼行數:24,代碼來源:CommentImageGrid.java

示例5: Attacher

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
public Attacher(DraweeView<GenericDraweeHierarchy> draweeView) {
    mDraweeView = new WeakReference<>(draweeView);
    draweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    draweeView.setOnTouchListener(this);
    mScaleDragDetector = new ScaleDragDetector(draweeView.getContext(), this);
    mGestureDetector = new GestureDetectorCompat(draweeView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {
                @Override public void onLongPress(MotionEvent e) {
                    super.onLongPress(e);
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getDraweeView());
                    }
                }
            });
    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
}
 
開發者ID:lanyuanxiaoyao,項目名稱:PicKing,代碼行數:17,代碼來源:Attacher.java

示例6: run

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
@Override public void run() {

            DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();
            if (draweeView == null) {
                return;
            }

            float t = interpolate();
            float scale = mZoomStart + t * (mZoomEnd - mZoomStart);
            float deltaScale = scale / getScale();

            onScale(deltaScale, mFocalX, mFocalY);

            if (t < 1f) {
                postOnAnimation(draweeView, this);
            }
        }
 
開發者ID:lanyuanxiaoyao,項目名稱:PicKing,代碼行數:18,代碼來源:Attacher.java

示例7: createSimpleDraweeView

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
private SimpleDraweeView createSimpleDraweeView() {
    SimpleDraweeView view = new SimpleDraweeView(itemView.getContext());
    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(itemView.getContext().getResources());
    GenericDraweeHierarchy hierarchy = builder
            .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
            .setPlaceholderImage(R.color.loading_color)
            .setPlaceholderImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
            .setFailureImage(R.mipmap.ic_failed)
            .setFailureImageScaleType(ScalingUtils.ScaleType.CENTER)
            .build();
    view.setHierarchy(hierarchy);
    view.setTag(atomicInteger.getAndIncrement());
    view.setOnClickListener(this);
    return view;
}
 
開發者ID:mingdroid,項目名稱:tumbviewer,代碼行數:17,代碼來源:PhotoPostVH.java

示例8: loadHeadView

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
public static void loadHeadView(Context context, SimpleDraweeView simpleDraweeView, Uri httpUri) {
    //初始化圓角圓形參數對象
    RoundingParams rp = new RoundingParams();
    //設置圖像是否為圓形
    rp.setRoundAsCircle(true);

    final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(context.getResources())
            .setRoundingParams(rp)
            .build();

    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(httpUri)
            .setTapToRetryEnabled(true)
            .setOldController(simpleDraweeView.getController())
            .build();
    simpleDraweeView.setHierarchy(hierarchy);
    simpleDraweeView.setController(controller);
}
 
開發者ID:lennyup,項目名稱:react-native-udesk,代碼行數:19,代碼來源:UdeskUtil.java

示例9: onDrag

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
@Override public void onDrag(float dx, float dy) {

        DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();

        if (draweeView != null && !mScaleDragDetector.isScaling()) {
            mMatrix.postTranslate(dx, dy);
            checkMatrixAndInvalidate();

            ViewParent parent = draweeView.getParent();
            if (parent == null) {
                return;
            }

            if (mAllowParentInterceptOnEdge
                    && !mScaleDragDetector.isScaling()
                    && !mBlockParentIntercept) {
                if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f) || (
                        mScrollEdge == EDGE_RIGHT
                                && dx <= -1f)) {
                    parent.requestDisallowInterceptTouchEvent(false);
                }
            } else {
                parent.requestDisallowInterceptTouchEvent(true);
            }
        }
    }
 
開發者ID:LightSun,項目名稱:android-photo-picker,代碼行數:27,代碼來源:Attacher.java

示例10: run

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
@Override public void run() {
    if (mScroller.isFinished()) {
        return;
    }

    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();

    if (draweeView != null && mScroller.computeScrollOffset()) {
        final int newX = mScroller.getCurrX();
        final int newY = mScroller.getCurrY();
        mMatrix.postTranslate(mCurrentX - newX, mCurrentY - newY);
        draweeView.invalidate();
        mCurrentX = newX;
        mCurrentY = newY;
        postOnAnimation(draweeView, this);
    }
}
 
開發者ID:iKnown,項目名稱:AndroidImageSelect,代碼行數:18,代碼來源:Attacher.java

示例11: init

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
protected void init() {
    if (null == mAttacher || null == mAttacher.getImageView()) {
        mAttacher = new PhotoViewAttacher(this);
    }

    if (null != mPendingScaleType) {
        setScaleType(mPendingScaleType);
        mPendingScaleType = null;
    }

    if (mDraweeHolder == null) {
        GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
                .setFadeDuration(500)
                .setProgressBarImage(new CustomProgressbarDrawable(this))
                .build();
        mDraweeHolder = DraweeHolder.create(hierarchy, getContext());
    }
}
 
開發者ID:lizubing1992,項目名稱:Li-MVPArms,代碼行數:19,代碼來源:PhotoView.java

示例12: getGenericDraweeHierarchy

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
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(ConfigConstants.sErrorDrawable)//fresco:failureImage="@drawable/error"失敗圖
//            .setFailureImage(failureDrawable, failureImageScaleType)//fresco:failureImageScaleType="centerInside"失敗圖縮放類型
//            .setOverlay(overlay)//fresco:overlayImage="@drawable/watermark"疊加圖
//            .setOverlays(overlays)
              .setPlaceholderImage(ConfigConstants.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;
  }
 
開發者ID:lizubing1992,項目名稱:Li-MVPArms,代碼行數:26,代碼來源:ConfigConstants.java

示例13: onCreate

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_image);

    final SimpleDraweeView mImageView = (SimpleDraweeView) findViewById(R.id.view_image_image);
    final int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
    final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
        .setFadeDuration(shortAnimTime)
        .setProgressBarImage(new ImageLoadingDrawable(getResources()))
        .setFailureImage(getResources().getDrawable(R.drawable.ic_upload_failed), ScalingUtils.ScaleType.CENTER_INSIDE)
        .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
        .build();
    mImageView.setHierarchy(hierarchy);

    mImageView.setImageURI(getIntent().getParcelableExtra(EXTRA_IMAGE_URI));
}
 
開發者ID:badoo,項目名稱:Chateau,代碼行數:18,代碼來源:FullScreenImageActivity.java

示例14: mockBuilderOf

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:DraweeMocks.java

示例15: onCreateViewHolder

import com.facebook.drawee.generic.GenericDraweeHierarchy; //導入依賴的package包/類
@Override
public VolleyDraweeHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(getContext().getResources())
      .setPlaceholderImage(Drawables.sPlaceholderDrawable)
      .setFailureImage(Drawables.sErrorDrawable)
      .build();
  InstrumentedDraweeView view = new InstrumentedDraweeView(getContext());
  view.setHierarchy(gdh);
  return new VolleyDraweeHolder(getContext(), parent, view, getPerfListener());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:VolleyDraweeAdapter.java


注:本文中的com.facebook.drawee.generic.GenericDraweeHierarchy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。