Java 类com.bumptech.glide.MemoryCategory 实例源码

项目:LeisureRead    文件:GlideModuleSetting.java   
@Override
public void registerComponents(Context context, Glide glide) {

  //配置OkHttp
  OkHttpClient mOkHttpClient = new OkHttpClient()
      .newBuilder()
      .connectTimeout(15, TimeUnit.SECONDS)
      .readTimeout(15, TimeUnit.SECONDS)
      .build();

  //设置Glide请求为Okhttp
  glide.register(GlideUrl.class, InputStream.class,
      new OkHttpUrlLoader.Factory(mOkHttpClient));

  //设置Glide的内存缓存和BitmapPool使用最多他们初始值的最大大小的一半
  glide.setMemoryCategory(MemoryCategory.LOW);
}
项目:GitHub    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main_activity);
  GlideApp.get(this).setMemoryCategory(MemoryCategory.HIGH);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
      && ContextCompat.checkSelfPermission(this, permission.READ_EXTERNAL_STORAGE)
      != PackageManager.PERMISSION_GRANTED) {
    requestStoragePermission();
  } else {
    replaceFragment();
  }
}
项目:QxGradleConfig    文件:MainActivity.java   
private void config() {
    MemorySizeCalculator calculator = new MemorySizeCalculator(this); //默认由该类计算内存缓存size
    int defaultMemoryCacheSize = calculator.getMemoryCacheSize(); //自动计算出的默认缓存size
    int defaultBitmapPoolSize = calculator.getBitmapPoolSize();   //bitmap pool size

    Glide.get(this).setMemoryCategory(MemoryCategory.HIGH); //动态设置内存缓存size
}
项目:GitHub    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
    GlideApp.get(this).setMemoryCategory(MemoryCategory.HIGH);
}
项目:lrs_android    文件:MyGlideModuleConfig.java   
@Override
public void registerComponents(Context context, Glide glide) {
    //glide.clearDiskCache();
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
    glide.setMemoryCategory(MemoryCategory.NORMAL);
}
项目:Wallpapers-Android-Clean-Architecture    文件:GlideLoader.java   
public GlideLoader(Application context) {
    this.context = context;
    Glide.get(context).setMemoryCategory(MemoryCategory.LOW);
}
项目:Subs    文件:GlideLoader.java   
public GlideLoader(Application context) {
    this.context = context;
    Glide.get(context).setMemoryCategory(MemoryCategory.LOW);
}
项目:Android-Clean-Architecture    文件:ImageLoader.java   
public ImageLoader(Application context) {
    this.context = context;
    Glide.get(context).setMemoryCategory(MemoryCategory.LOW);
}
项目:mr-mantou-android    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    MiuiStatusBarCompat.enableLightStatusBar(getWindow());

    binding = DataBindingUtil.setContentView(this, R.layout.main_activity);

    setSupportActionBar(binding.toolbar);

    images = MrSharedState.getInstance().getImages();

    Glide.get(this).setMemoryCategory(MemoryCategory.HIGH);
    binding.content.setAdapter(new MainAdapter(this, images, Glide.with(this), this));

    setExitSharedElementCallback(new SharedElementCallback() {
        @Override
        public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
            if (reenterState != null) {
                int index = reenterState.getInt("index", 0);

                Image image = images.get(index);

                MainAdapter.ViewHolder holder = (MainAdapter.ViewHolder) binding.content
                        .findViewHolderForLayoutPosition(index);

                sharedElements.clear();

                if (holder != null && holder.binding != null) {
                    sharedElements.put(String.format("%s.image", image.getObjectId()), holder.binding.image);
                }

                reenterState = null;
            }
        }
    });

    Observable<List<Image>> load = Observable.just(images)
            .doOnSubscribe(() -> binding.refresher.setRefreshing(true))
            .doOnCompleted(() -> binding.refresher.setRefreshing(false))
            .map(whatever -> images.isEmpty() ? Image.all() : Image.since(images.get(0)))
            .observeOn(Schedulers.io())
            .flatMap(RxAVQuery::find)
            .observeOn(AndroidSchedulers.mainThread())
            .doOnNext(RxList.prependTo(images));

    RxSwipeRefreshLayout.refreshes(binding.refresher)
            .compose(bindToLifecycle())
            .flatMap(whatever -> load)
            .retry((count, tr) -> {
                Log.e(TAG, "An error occurred while fetching images", tr);
                ToastUtil.shorts(this, tr.getMessage());
                binding.refresher.setRefreshing(false);
                return true;
            })
            .filter(loaded -> !loaded.isEmpty())
            .subscribe(loaded -> binding.content.smoothScrollToPosition(0));

    load.compose(bindToLifecycle())
            .onErrorReturn(tr -> {
                Log.e(TAG, "An error occurred while fetching images", tr);
                ToastUtil.shorts(this, tr.getMessage());
                binding.refresher.setRefreshing(false);
                return null;
            })
            .subscribe();

    UpdateUtil.checkForUpdate(version -> UpdateUtil.promptUpdate(this, version));
}
项目:pretty-girl    文件:GirlAdapter.java   
public GirlAdapter(Context context, List<Image> images) {
    Glide.get(context).setMemoryCategory(MemoryCategory.HIGH);
    this.context = context;
    this.images = images;
}
项目:AmazeFileManager    文件:GlideApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    Glide.get(this).setMemoryCategory(MemoryCategory.HIGH);
}