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


Java ScalingUtils類代碼示例

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


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

示例1: onCreate

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

  ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayHomeAsUpEnabled(true);
  }

  SimpleDraweeView simpleDraweeView = (SimpleDraweeView) findViewById(R.id.image);
  simpleDraweeView.setImageURI(getIntent().getData());

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getWindow().setSharedElementEnterTransition(DraweeTransition.createTransitionSet(
        ScalingUtils.ScaleType.CENTER_CROP, ScalingUtils.ScaleType.FIT_CENTER));
    getWindow().setSharedElementReturnTransition(DraweeTransition.createTransitionSet(
        ScalingUtils.ScaleType.FIT_CENTER, ScalingUtils.ScaleType.CENTER_CROP));
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:ImageDetailsActivity.java

示例2: displayImage

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的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

示例3: convertToFrescoScaleType

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的package包/類
private static ScalingUtils.ScaleType convertToFrescoScaleType(ImageView.ScaleType scaleType, ScalingUtils.ScaleType defaultScaleType) {
    switch (scaleType) {
        case CENTER:
            return ScalingUtils.ScaleType.CENTER;
        case CENTER_CROP:
            return ScalingUtils.ScaleType.CENTER_CROP;
        case CENTER_INSIDE:
            return ScalingUtils.ScaleType.CENTER_INSIDE;
        case FIT_CENTER:
            return ScalingUtils.ScaleType.FIT_CENTER;
        case FIT_START:
            return ScalingUtils.ScaleType.FIT_START;
        case FIT_END:
            return ScalingUtils.ScaleType.FIT_END;
        case FIT_XY:
            return ScalingUtils.ScaleType.FIT_XY;
        case MATRIX:
            //NOTE this case
            //you should set FocusPoint to make sentence
            return ScalingUtils.ScaleType.FOCUS_CROP;
        default:
            return defaultScaleType;
    }
}
 
開發者ID:lizhangqu,項目名稱:FrescoLoader,代碼行數:25,代碼來源:FrescoLoader.java

示例4: generateImageLayout

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的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.drawable.ScalingUtils; //導入依賴的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: createSimpleDraweeView

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的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

示例7: toScaleType

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的package包/類
/**
 * Converts JS resize modes into {@code ScalingUtils.ScaleType}.
 * See {@code ImageResizeMode.js}.
 */
public static ScalingUtils.ScaleType toScaleType(@Nullable String resizeModeValue) {
  if ("contain".equals(resizeModeValue)) {
    return ScalingUtils.ScaleType.FIT_CENTER;
  }
  if ("cover".equals(resizeModeValue)) {
    return ScalingUtils.ScaleType.CENTER_CROP;
  }
  if ("stretch".equals(resizeModeValue)) {
    return ScalingUtils.ScaleType.FIT_XY;
  }
  if ("center".equals(resizeModeValue)) {
    return ScalingUtils.ScaleType.CENTER_INSIDE;
  }
  if (resizeModeValue == null) {
    // Use the default. Never use null.
    return defaultValue();
  }
  throw new JSApplicationIllegalArgumentException(
      "Invalid resize mode: '" + resizeModeValue + "'");
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:25,代碼來源:ImageResizeMode.java

示例8: testImageResizeMode

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的package包/類
@Test
public void testImageResizeMode() {
  assertThat(ImageResizeMode.toScaleType(null))
      .isEqualTo(ScalingUtils.ScaleType.CENTER_CROP);

  assertThat(ImageResizeMode.toScaleType("contain"))
      .isEqualTo(ScalingUtils.ScaleType.FIT_CENTER);

  assertThat(ImageResizeMode.toScaleType("cover"))
      .isEqualTo(ScalingUtils.ScaleType.CENTER_CROP);

  assertThat(ImageResizeMode.toScaleType("stretch"))
      .isEqualTo(ScalingUtils.ScaleType.FIT_XY);

  assertThat(ImageResizeMode.toScaleType("center"))
      .isEqualTo(ScalingUtils.ScaleType.CENTER_INSIDE);

  // No resizeMode set
  assertThat(ImageResizeMode.defaultValue())
      .isEqualTo(ScalingUtils.ScaleType.CENTER_CROP);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:22,代碼來源:ImageResizeModeTest.java

示例9: toScaleType

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的package包/類
/**
 * Converts JS resize modes into {@code ScalingUtils.ScaleType}.
 * See {@code ImageResizeMode.js}.
 */
public static ScalingUtils.ScaleType toScaleType(@Nullable String resizeModeValue) {
  if ("contain".equals(resizeModeValue)) {
    return ScalingUtils.ScaleType.CENTER_INSIDE;
  }
  if ("cover".equals(resizeModeValue)) {
    return ScalingUtils.ScaleType.CENTER_CROP;
  }
  if ("stretch".equals(resizeModeValue)) {
    return ScalingUtils.ScaleType.FIT_XY;
  }
  if (resizeModeValue == null) {
    // Use the default. Never use null.
    return defaultValue();
  }
  throw new JSApplicationIllegalArgumentException(
      "Invalid resize mode: '" + resizeModeValue + "'");
}
 
開發者ID:john1jan,項目名稱:ReactNativeSignatureExample,代碼行數:22,代碼來源:ImageResizeMode.java

示例10: testImageResizeMode

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的package包/類
@Test
public void testImageResizeMode() {
  assertThat(ImageResizeMode.toScaleType(null))
      .isEqualTo(ScalingUtils.ScaleType.CENTER_CROP);

  assertThat(ImageResizeMode.toScaleType("contain"))
      .isEqualTo(ScalingUtils.ScaleType.CENTER_INSIDE);

  assertThat(ImageResizeMode.toScaleType("cover"))
      .isEqualTo(ScalingUtils.ScaleType.CENTER_CROP);

  assertThat(ImageResizeMode.toScaleType("stretch"))
      .isEqualTo(ScalingUtils.ScaleType.FIT_XY);

  // No resizeMode set
  assertThat(ImageResizeMode.defaultValue())
      .isEqualTo(ScalingUtils.ScaleType.CENTER_CROP);
}
 
開發者ID:john1jan,項目名稱:ReactNativeSignatureExample,代碼行數:19,代碼來源:ImageResizeModeTest.java

示例11: loadImage

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的package包/類
public void loadImage(String url,String lowurl, int placeHolderResId, int errorResId,ScalingUtils.ScaleType scaleType){
    final boolean isHttp = url.startsWith("http");
    Uri uri = isHttp ? Uri.parse(url) :  Uri.fromFile(new File(url));
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder()
         .setImageRequest(ImageRequest.fromUri(uri));
    if(lowurl!=null &&  lowurl.startsWith("http")) {
        controller .setLowResImageRequest(ImageRequest.fromUri(lowurl));
    }
    getHierarchy().setActualImageScaleType(scaleType);
                    // controller.setUri(URI);
    getHierarchy().setPlaceholderImage(getResources().getDrawable( placeHolderResId ),scaleType);
    getHierarchy().setFailureImage(getResources().getDrawable(errorResId),scaleType);
    controller.setOldController(this.getController())
         .setControllerListener(new BaseControllerListener<ImageInfo>() {
             @Override
             public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                 if (imageInfo == null) {
                     return;
                 }
                 PhotoDraweeView.this.update(imageInfo.getWidth(), imageInfo.getHeight());
             }
         });
    this.setController(controller.build());
}
 
開發者ID:LightSun,項目名稱:android-photo-picker,代碼行數:25,代碼來源:PhotoDraweeView.java

示例12: getRadii

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的package包/類
void getRadii(Bitmap source, float[] computedCornerRadii, float[] mappedRadii) {
    ScalingUtils.getTransform(
        sMatrix,
        new Rect(0, 0, source.getWidth(), source.getHeight()),
        source.getWidth(),
        source.getHeight(),
        0.0f,
        0.0f,
        mScaleType);
    sMatrix.invert(sInverse);

    mappedRadii[0] = sInverse.mapRadius(computedCornerRadii[0]);
    mappedRadii[1] = mappedRadii[0];

    mappedRadii[2] = sInverse.mapRadius(computedCornerRadii[1]);
    mappedRadii[3] = mappedRadii[2];

    mappedRadii[4] = sInverse.mapRadius(computedCornerRadii[2]);
    mappedRadii[5] = mappedRadii[4];

    mappedRadii[6] = sInverse.mapRadius(computedCornerRadii[3]);
    mappedRadii[7] = mappedRadii[6];
}
 
開發者ID:ManrajGrover,項目名稱:react-native-box-loaders,代碼行數:24,代碼來源:ReactImageView.java

示例13: showThumbnail

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的package包/類
@Override
public View showThumbnail(BigImageView parent, Uri thumbnail, int scaleType) {
    SimpleDraweeView thumbnailView = (SimpleDraweeView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.ui_fresco_thumbnail, parent, false);
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(thumbnail)
            .build();
    switch (scaleType) {
        case BigImageView.INIT_SCALE_TYPE_CENTER_CROP:
            thumbnailView.getHierarchy()
                    .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
            break;
        case BigImageView.INIT_SCALE_TYPE_CENTER_INSIDE:
            thumbnailView.getHierarchy()
                    .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_INSIDE);
            break;
        case BigImageView.INIT_SCALE_TYPE_START:
            thumbnailView.getHierarchy()
                    .setActualImageScaleType(ScalingUtils.ScaleType.FIT_START);
            break;
        default:
            break;
    }
    thumbnailView.setController(controller);
    return thumbnailView;
}
 
開發者ID:Piasy,項目名稱:BigImageViewer,代碼行數:27,代碼來源:FrescoImageLoader.java

示例14: onCreate

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的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

示例15: instantiateItem

import com.facebook.drawee.drawable.ScalingUtils; //導入依賴的package包/類
@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;
}
 
開發者ID:kunny,項目名稱:ZoomableDraweeView-sample,代碼行數:22,代碼來源:ViewPagerActivity.java


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