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


Java ViewTarget类代码示例

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


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

示例1: into

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
/**
 * Sets the {@link ImageView} the resource will be loaded into, cancels any existing loads into
 * the view, and frees any resources Glide may have previously loaded into the view so they may be
 * reused.
 *
 * @see RequestManager#clear(Target)
 *
 * @param view The view to cancel previous loads for and load the new resource into.
 * @return The
 * {@link com.bumptech.glide.request.target.Target} used to wrap the given {@link ImageView}.
 */
public ViewTarget<ImageView, TranscodeType> into(ImageView view) {
  Util.assertMainThread();
  Preconditions.checkNotNull(view);

  RequestOptions requestOptions = this.requestOptions;
  if (!requestOptions.isTransformationSet()
      && requestOptions.isTransformationAllowed()
      && view.getScaleType() != null) {
    // Clone in this method so that if we use this RequestBuilder to load into a View and then
    // into a different target, we don't retain the transformation applied based on the previous
    // View's scale type.
    switch (view.getScaleType()) {
      case CENTER_CROP:
        requestOptions = requestOptions.clone().optionalCenterCrop();
        break;
      case CENTER_INSIDE:
        requestOptions = requestOptions.clone().optionalCenterInside();
        break;
      case FIT_CENTER:
      case FIT_START:
      case FIT_END:
        requestOptions = requestOptions.clone().optionalFitCenter();
        break;
      case FIT_XY:
        requestOptions = requestOptions.clone().optionalCenterInside();
        break;
      case CENTER:
      case MATRIX:
      default:
        // Do nothing.
    }
  }

  return into(
      glideContext.buildImageViewTarget(view, transcodeClass),
      /*targetListener=*/ null,
      requestOptions);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:50,代码来源:RequestBuilder.java

示例2: applyOptions

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
@Override
    public void applyOptions(Context context, GlideBuilder builder) {
        ViewTarget.setTagId(R.id.glide_tag_id);
        // Apply options to the builder here.
        // 默认内存和图片池大小
//        MemorySizeCalculator calculator = new MemorySizeCalculator(context);
//        int defaultMemoryCacheSize = calculator.getMemoryCacheSize(); // 默认内存大小
//        int defaultBitmapPoolSize = calculator.getBitmapPoolSize(); // 默认图片池大小
//        builder.setMemoryCache(new LruResourceCache(defaultMemoryCacheSize)); // 该两句无需设置,是默认的
//        builder.setBitmapPool(new LruBitmapPool(defaultBitmapPoolSize));
        //定义图片的本地磁盘缓存
//        File cacheDir = context.getExternalCacheDir();//指定的是数据的缓存地址
//        int diskCacheSize = 1024 * 1024 * 1024;//最多可以缓存多少字节的数据
        //设置磁盘缓存大小
//        builder.setDiskCache(new DiskLruCacheFactory(cacheDir.getPath(), "glide", diskCacheSize));
        // 定义缓存大小和位置
        if (BaseConfig.sSDCardExist) {
            builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, Constants.Dir.IMAGE_CACHE_DIR, extDiskSize)); //外部存储
        } else {
            builder.setDiskCache(new InternalCacheDiskCacheFactory(context, Constants.Dir.IMAGE_CACHE_DIR, intDiskSize));  //内部存储
        }
        // 自定义内存和图片池大小
//        builder.setMemoryCache(new LruResourceCache(memorySize));
//        builder.setBitmapPool(new LruBitmapPool(memorySize));
//        builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    }
 
开发者ID:liying2008,项目名称:Simpler,代码行数:27,代码来源:MyGlideModule.java

示例3: onCreate

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
@Override
    public void onCreate() {
        super.onCreate();
        ViewTarget.setTagId(R.id.glide_tag);
        isInstallWx = isWXAppInstalledAndSupported();

        //alibaba
        System.loadLibrary("gnustl_shared");
//        System.loadLibrary("ijkffmpeg");//目前使用微博的ijkffmpeg会出现1K再换wifi不重连的情况
        System.loadLibrary("qupai-media-thirdparty");
//        System.loadLibrary("alivc-media-jni");
        System.loadLibrary("qupai-media-jni");
        ApplicationGlue.initialize(this);

        //Bugly SDK初始化
        CrashReport.initCrashReport(getApplicationContext(), "3080098224", false);
    }
 
开发者ID:JunGeges,项目名称:AliZhiBoHao,代码行数:18,代码来源:MyApplication.java

示例4: applyOptions

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    //解决setTag问题
    ViewTarget.setTagId(R.id.glide_tag_id);
    //磁盘缓存
    builder.setDiskCache(new DiskLruCacheFactory(AppFileHelper.getAppCachePath(), 50 * 1024 * 1024));
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    //内存缓存
    MemorySizeCalculator calculator = new MemorySizeCalculator(context);
    int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
    int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
    //设置比默认大小大1.5倍的缓存和图片池大小
    int customMemoryCacheSize = (int) (1.5 * defaultMemoryCacheSize);
    int customBitmapPoolSize = defaultBitmapPoolSize;


    KLog.i("poolSize", "bitmapPoolSize >>>>>   "
            + android.text.format.Formatter.formatFileSize(context, customBitmapPoolSize)
            + "          memorySize>>>>>>>>   " +
            android.text.format.Formatter.formatFileSize(context, customMemoryCacheSize));

    builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
    builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));

}
 
开发者ID:razerdp,项目名称:FriendCircle,代码行数:26,代码来源:GlobalGlideConfiguration.java

示例5: display

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
public void display(Activity act, File file, ImageView tarView, final OnLoadImageListener
        listener) {
    if (listener == null) {
        return;
    }

    Glide.with(act).load(file).into(new ViewTarget<ImageView, GlideDrawable>(tarView) {

        @Override
        public void onStart() {
            super.onStart();
            listener.onStart();
        }

        @Override
        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
            listener.onLoadCompleted(resource, glideAnimation);
        }

        @Override
        public void onLoadFailed(Exception e, Drawable errorDrawable) {
            super.onLoadFailed(e, errorDrawable);
            listener.onLoadFailed(e, errorDrawable);
        }
    });
}
 
开发者ID:g977284333,项目名称:KwPresent,代码行数:27,代码来源:ImageLoader.java

示例6: loadCircularImage

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
/**
 * Loads an image into the OkulusImageView
 *
 * @param context         A reference to the context
 * @param imageView       The ImageView to load the bitmap into
 * @param imageResourceId The image resource to load
 * @param avatarSize      The size to scale the image to
 */
public static void loadCircularImage(Context context, OkulusImageView imageView, int imageResourceId, AvatarBitmapTransformation.AvatarSize avatarSize) {

    Glide.with(context)
            .load(imageResourceId)
            .asBitmap()
            .transform(AvatarBitmapTransformation.transformationFor(context, avatarSize))
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .into(new ViewTarget<OkulusImageView, Bitmap>(imageView) {
                @Override
                public void onResourceReady(Bitmap resource, GlideAnimation anim) {
                    OkulusImageView myView = this.view;
                    myView.setImageBitmap(resource);
                    // Set your resource on myView and/or start your animation here.
                }

            });
}
 
开发者ID:yeloapp,项目名称:yelo-android,代码行数:26,代码来源:Utils.java

示例7: onCreate

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_photogallery);

    //为glide设置全局tag id,避免ImageView Tag被glide占用
    ViewTarget.setTagId(R.id.glide_request);

    mUrls = getIntent().getStringArrayExtra(EXTRA_URLS);

    mViewPager = (HackyViewPager) findViewById(R.id.view_pager);
    mViewPager.setAdapter(new SamplePagerAdapter());
    mViewPager.setCurrentItem(getIntent().getIntExtra(EXTRA_POSITION, 0));

    findViewById(R.id.button_original).setOnClickListener(this);
    //findViewById(R.id.button_save).setOnClickListener(this);
}
 
开发者ID:jzyu,项目名称:PhotoGallery,代码行数:18,代码来源:PhotoGalleryActivity.java

示例8: getNullModelRequest

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
private RequestBuilder<Object> getNullModelRequest() {
  when(glideContext.buildImageViewTarget(isA(ImageView.class), isA(Class.class)))
      .thenReturn(mock(ViewTarget.class));
  when(glideContext.getDefaultRequestOptions()).thenReturn(new RequestOptions());
  when(requestManager.getDefaultRequestOptions())
      .thenReturn(new RequestOptions());
  when(requestManager.getDefaultTransitionOptions(any(Class.class)))
      .thenReturn(new GenericTransitionOptions<>());
  return new RequestBuilder<>(glide, requestManager, Object.class, context)
      .load((Object) null);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:RequestBuilderTest.java

示例9: onCreate

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    getAppComponent();
    ViewTarget.setTagId(R.id.glide_tag);
    LoggerUtil.init(BuildConfig.DEBUG);
    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    LeakCanary.install(this);
}
 
开发者ID:crazysunj,项目名称:CrazyDaily,代码行数:12,代码来源:App.java

示例10: getTargetDescription

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
private String getTargetDescription(Target<?> target) {
    String result;
    if (target instanceof WrappingTarget) {
        Target wrapped = ((WrappingTarget) target).getWrappedTarget();
        result = String.format(Locale.ROOT, "%s in %s", getTargetDescription(wrapped), target);
    } else if (target instanceof ViewTarget) {
        View v = ((ViewTarget) target).getView();
        LayoutParams p = v.getLayoutParams();
        result = String.format(Locale.ROOT,
                "%s(params=%dx%d->size=%dx%d)", target, p.width, p.height, v.getWidth(), v.getHeight());
    } else {
        result = String.valueOf(target);
    }
    return result;
}
 
开发者ID:RahulJanagouda,项目名称:StatusStories,代码行数:16,代码来源:LoggingListener.java

示例11: applyOptions

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
@Override
public void applyOptions(final Context context, GlideBuilder builder) {
    ViewTarget.setTagId(R.id.glide_tag_id);
    MemorySizeCalculator calculator = new MemorySizeCalculator(context);
    int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
    int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
    int customMemoryCacheSize = (int) (1.2 * defaultMemoryCacheSize);
    int customBitmapPoolSize = (int) (1.2 * defaultBitmapPoolSize);
    builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
     builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, cacheSize100MegaBytes));
}
 
开发者ID:yangchaojiang,项目名称:ZoomPreviewPicture,代码行数:13,代码来源:MyGlideModule.java

示例12: onCreate

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
@Override
    public void onCreate() {
        super.onCreate();
        sInstance = this;

//        LeakCanary.install(this);

        //为防止出现
        // "You must not call setTag() on a view Glide is targeting" on non-root ImageView
        //这个问题导致的软件崩溃
        ViewTarget.setTagId(R.id.glide_tag);


        initComponent();
    }
 
开发者ID:yinyiliang,项目名称:RabbitCloud,代码行数:16,代码来源:App.java

示例13: applyOptions

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // set max size of the disk cache for images
    builder.setDiskCache(new InternalCacheDiskCacheFactory(
            context, App.getAppComponent().getDownloadPreferencesManager()
            .getTotalImageCacheSize()));

    ViewTarget.setTagId(R.id.tag_glide);

    //从默认的RGB_565改为ARGB_8888显示
    builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_ARGB_8888));
}
 
开发者ID:ykrank,项目名称:S1-Next,代码行数:13,代码来源:S1NextGlideModule.java

示例14: applyOptions

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
@Override
public void applyOptions(final Context context, GlideBuilder builder) {
    ViewTarget.setTagId(R.id.glide_loader);
    builder.setDiskCache(new DiskLruCacheFactory(new DiskLruCacheFactory.CacheDirectoryGetter
            () {
        @Override
        public File getCacheDirectory() {
            return context.getExternalCacheDir();
        }
    }, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE));
}
 
开发者ID:waynell,项目名称:VideoListPlayer,代码行数:12,代码来源:VideoListGlideModule.java

示例15: loadImageViewTarget

import com.bumptech.glide.request.target.ViewTarget; //导入依赖的package包/类
private void loadImageViewTarget() {
    viewTarget = new ViewTarget<FutureStudioView, GlideDrawable>( customView ) {
        @Override
        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
            this.view.setImage( resource.getCurrent() );
        }
    };

    Glide
            .with( context.getApplicationContext() ) // safer!
            .load( eatFoodyImages[2] )
            .into( viewTarget );
}
 
开发者ID:fs-opensource,项目名称:android-tutorials-glide,代码行数:14,代码来源:UsageExampleTargetsAndRemoteViews.java


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