当前位置: 首页>>代码示例>>Java>>正文


Java Target类代码示例

本文整理汇总了Java中com.bumptech.glide.request.target.Target的典型用法代码示例。如果您正苦于以下问题:Java Target类的具体用法?Java Target怎么用?Java Target使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Target类属于com.bumptech.glide.request.target包,在下文中一共展示了Target类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLoadFailed

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
@Override
public boolean onLoadFailed(GlideException e, Object model, Target<PictureDrawable> target,
    boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
  return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:SvgSoftwareLayerSetter.java

示例2: setImageUrls

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
public void setImageUrls(Collection<String> imageUrls) {
    // clean up outdated stuff
    for (Target target : mTargets) {
        Glide.clear(target); // clears mBitmaps[i] as well
    }
    if (imageUrls == null) imageUrls = Collections.emptyList();
    int newSize = imageUrls.size();
    mImageUrls = imageUrls.toArray(new String[newSize]);
    mBitmaps = new Bitmap[newSize];
    mDrawRects = new RectF[newSize];
    mTargets = new Target[newSize];
    if (!haveRule) {
        mColumns = imageUrls.size() <= 4 ? 2 : 3;
    }
    for (int i = 0; i < imageUrls.size(); i++) {
        mTargets[i] = new PositionTarget(i);
    }
    requestLayout();
}
 
开发者ID:HotBitmapGG,项目名称:Acg,代码行数:20,代码来源:MomentPicView.java

示例3: saveToFile

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
private void saveToFile() {
    if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        Toast.makeText(this, R.string.gallery_save_file_not_have_external_storage, Toast.LENGTH_SHORT).show();
        return;
    }

    final Future<File> future = getImageLoader()
            .load(mPath)
            .downloadOnly(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL);

    AppOperator.runOnThread(new Runnable() {
        @Override
        public void run() {
            try {
                File sourceFile = future.get();
                if (sourceFile == null || !sourceFile.exists())
                    return;
                String extension = BitmapUtil.getExtension(sourceFile.getAbsolutePath());
                String extDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
                        .getAbsolutePath() + File.separator + "开源中国";
                File extDirFile = new File(extDir);
                if (!extDirFile.exists()) {
                    if (!extDirFile.mkdirs()) {
                        // If mk dir error
                        callSaveStatus(false, null);
                        return;
                    }
                }
                final File saveFile = new File(extDirFile, String.format("IMG_%s.%s", System.currentTimeMillis(), extension));
                final boolean isSuccess = StreamUtil.copyFile(sourceFile, saveFile);
                callSaveStatus(isSuccess, saveFile);
            } catch (Exception e) {
                e.printStackTrace();
                callSaveStatus(false, null);
            }
        }
    });
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:39,代码来源:LargeImageActivity.java

示例4: transform

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
@Override
public final Resource<Bitmap> transform(
    Context context, Resource<Bitmap> resource, int outWidth, int outHeight) {
  if (!Util.isValidDimensions(outWidth, outHeight)) {
    throw new IllegalArgumentException(
        "Cannot apply transformation on width: " + outWidth + " or height: " + outHeight
            + " less than or equal to zero and not Target.SIZE_ORIGINAL");
  }
  BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
  Bitmap toTransform = resource.get();
  int targetWidth = outWidth == Target.SIZE_ORIGINAL ? toTransform.getWidth() : outWidth;
  int targetHeight = outHeight == Target.SIZE_ORIGINAL ? toTransform.getHeight() : outHeight;
  Bitmap transformed = transform(bitmapPool, toTransform, targetWidth, targetHeight);

  final Resource<Bitmap> result;
  if (toTransform.equals(transformed)) {
    result = resource;
  } else {
    result = BitmapResource.obtain(transformed, bitmapPool);
  }
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:BitmapTransformation.java

示例5: into

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
/**
 * Set the target the resource will be loaded into.
 *
 * @param target The target to load the resource into.
 * @return The given target.
 * @see RequestManager#clear(Target)
 */
public <Y extends Target<TranscodeType>> Y into(@NonNull Y target) {
  Util.assertMainThread();
  Preconditions.checkNotNull(target);
  if (!isModelSet) {
    throw new IllegalArgumentException("You must call #load() before calling #into()");
  }

  Request previous = target.getRequest();

  if (previous != null) {
    requestManager.clear(target);
  }

  requestOptions.lock();
  Request request = buildRequest(target);
  target.setRequest(request);
  requestManager.track(target, request);

  return target;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:RequestBuilder.java

示例6: obtainRequest

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
private Request obtainRequest(Target<TranscodeType> target,
    RequestOptions requestOptions, RequestCoordinator requestCoordinator,
    TransitionOptions<?, ? super TranscodeType> transitionOptions, Priority priority,
    int overrideWidth, int overrideHeight) {
  requestOptions.lock();

  return SingleRequest.obtain(
      context,
      model,
      transcodeClass,
      requestOptions,
      overrideWidth,
      overrideHeight,
      priority,
      target,
      requestListener,
      requestCoordinator,
      context.getEngine(),
      transitionOptions.getTransitionFactory());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:RequestBuilder.java

示例7: setUp

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  Glide.tearDown();

  RobolectricPackageManager pm = RuntimeEnvironment.getRobolectricPackageManager();
  ApplicationInfo info =
      pm.getApplicationInfo(RuntimeEnvironment.application.getPackageName(), 0);
  info.metaData = new Bundle();
  info.metaData.putString(SetupModule.class.getName(), "GlideModule");

  // Ensure that target's size ready callback will be called synchronously.
  target = mock(Target.class);
  imageView = new ImageView(RuntimeEnvironment.application);
  imageView.setLayoutParams(new ViewGroup.LayoutParams(100, 100));
  imageView.layout(0, 0, 100, 100);
  doAnswer(new CallSizeReady()).when(target).getSize(isA(SizeReadyCallback.class));

  Handler bgHandler = mock(Handler.class);
  when(bgHandler.post(isA(Runnable.class))).thenAnswer(new Answer<Boolean>() {
    @Override
    public Boolean answer(InvocationOnMock invocation) throws Throwable {
      Runnable runnable = (Runnable) invocation.getArguments()[0];
      runnable.run();
      return true;
    }
  });

  Lifecycle lifecycle = mock(Lifecycle.class);
  RequestManagerTreeNode treeNode = mock(RequestManagerTreeNode.class);
  requestManager = new RequestManager(Glide.get(getContext()), lifecycle, treeNode);
  requestManager.resumeRequests();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:GlideTest.java

示例8: testClone

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
@Test
public void testClone() throws IOException {
  Target<Drawable> firstTarget = mock(Target.class);
  doAnswer(new CallSizeReady(100, 100)).when(firstTarget).getSize(isA(SizeReadyCallback.class));
  Target<Drawable> secondTarget = mock(Target.class);
  doAnswer(new CallSizeReady(100, 100)).when(secondTarget).getSize(isA(SizeReadyCallback.class));
  RequestBuilder<Drawable> firstRequest = requestManager
      .load(mockUri("content://first"));

  firstRequest.into(firstTarget);

  firstRequest.clone()
      .apply(placeholderOf(new ColorDrawable(Color.RED)))
      .into(secondTarget);

  verify(firstTarget).onResourceReady(isA(Drawable.class), isA(Transition.class));
  verify(secondTarget).onResourceReady(notNull(Drawable.class), isA(Transition.class));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:GlideTest.java

示例9: onResourceReady

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
@Override
public boolean onResourceReady(PictureDrawable resource, Object model,
    Target<PictureDrawable> target, DataSource dataSource, boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
  return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:SvgSoftwareLayerSetter.java

示例10: showContact

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
@TargetApi(VERSION_CODES.ICE_CREAM_SANDWICH)
private void showContact(long id) {
  GlideRequests glideRequests = GlideApp.with(this);
  RequestOptions originalSize = new RequestOptions().override(Target.SIZE_ORIGINAL);

  Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);
  glideRequests.load(contactUri).apply(originalSize).into(imageViewContact);

  Uri lookupUri = Contacts.getLookupUri(getContentResolver(), contactUri);
  glideRequests.load(lookupUri).apply(originalSize).into(imageViewLookup);

  Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
  glideRequests.load(photoUri).apply(originalSize).into(imageViewPhoto);

  if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
    Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
    glideRequests.load(displayPhotoUri).apply(originalSize).into(imageViewDisplayPhoto);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:MainActivity.java

示例11: saveImageToLocal

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
/**
 * 保存图片到本地
 *
 * @param fileName 文件名
 */
private void saveImageToLocal(final String fileName) {
    Observable.create(new ObservableOnSubscribe<File>() {
        @Override
        public void subscribe(ObservableEmitter<File> e) throws Exception {
            e.onNext(Glide.with(ImageBrowseActivity.this)
                    .load(mImageUrl)
                    .downloadOnly(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
                    .get());
            e.onComplete();
        }
    }).compose(RxHelper.<File>rxSchedulerHelper()).subscribe(new Consumer<File>() {
        @Override
        public void accept(File file) throws Exception {
            saveImage(fileName, file);
        }
    });
}
 
开发者ID:Horrarndoo,项目名称:YiZhi,代码行数:23,代码来源:ImageBrowseActivity.java

示例12: clear

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
/**
 * Cancel any pending loads Glide may have for the target and free any resources (such as
 * {@link Bitmap}s) that may have been loaded for the target so they may be reused.
 *
 * @param target The Target to cancel loads for.
 */
public void clear(@Nullable final Target<?> target) {
  if (target == null) {
    return;
  }

  if (Util.isOnMainThread()) {
    untrackOrDelegate(target);
  } else {
    mainHandler.post(new Runnable() {
      @Override
      public void run() {
        clear(target);
      }
    });
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:RequestManager.java

示例13: untrackOrDelegate

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
private void untrackOrDelegate(Target<?> target) {
  boolean isOwnedByUs = untrack(target);
  // We'll end up here if the Target was cleared after the RequestManager that started the request
  // is destroyed. That can happen for at least two reasons:
  // 1. We call clear() on a background thread using something other than Application Context
  // RequestManager.
  // 2. The caller retains a reference to the RequestManager after the corresponding Activity or
  // Fragment is destroyed, starts a load with it, and then clears that load with a different
  // RequestManager. Callers seem especially likely to do this in retained Fragments (#2262).
  //
  // #1 is always an error. At best the caller is leaking memory briefly in something like an
  // AsyncTask. At worst the caller is leaking an Activity or Fragment for a sustained period of
  // time if they do something like reference the Activity RequestManager in a long lived
  // background thread or task.
  //
  // #2 is always an error. Callers shouldn't be starting new loads using RequestManagers after
  // the corresponding Activity or Fragment is destroyed because retaining any reference to the
  // RequestManager leaks memory. It's possible that there's some brief period of time during or
  // immediately after onDestroy where this is reasonable, but I can't think of why.
  if (!isOwnedByUs && !glide.removeFromManagers(target) && target.getRequest() != null) {
    Request request = target.getRequest();
    target.setRequest(null);
    request.clear();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:RequestManager.java

示例14: onResourceReady

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
@Override
public boolean onResourceReady(
        GlideDrawable resource,
        GlideUrl uri,
        Target<GlideDrawable> target,
        boolean isFromMemoryCache,
        boolean isFirstResource
) {
    if (!(target instanceof ImageViewTarget)) {
        return false;
    }
    ImageViewWithUrl view = (ImageViewWithUrl) ((ImageViewTarget) target).getView();
    ThemedReactContext context = (ThemedReactContext) view.getContext();
    RCTEventEmitter eventEmitter = context.getJSModule(RCTEventEmitter.class);
    int viewId = view.getId();
    eventEmitter.receiveEvent(viewId, REACT_ON_LOAD_EVENT, new WritableNativeMap());
    eventEmitter.receiveEvent(viewId, REACT_ON_LOAD_END_EVENT, new WritableNativeMap());
    return false;
}
 
开发者ID:DylanVann,项目名称:react-native-fast-image,代码行数:20,代码来源:FastImageViewManager.java

示例15: obtainRequest

import com.bumptech.glide.request.target.Target; //导入依赖的package包/类
private Request obtainRequest(
    Target<TranscodeType> target,
    RequestListener<TranscodeType> targetListener,
    RequestOptions requestOptions,
    RequestCoordinator requestCoordinator,
    TransitionOptions<?, ? super TranscodeType> transitionOptions,
    Priority priority,
    int overrideWidth,
    int overrideHeight) {
  return SingleRequest.obtain(
      context,
      glideContext,
      model,
      transcodeClass,
      requestOptions,
      overrideWidth,
      overrideHeight,
      priority,
      target,
      targetListener,
      requestListener,
      requestCoordinator,
      glideContext.getEngine(),
      transitionOptions.getTransitionFactory());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:RequestBuilder.java


注:本文中的com.bumptech.glide.request.target.Target类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。