com.bumptech.glide.MemoryCategory Java Examples
The following examples show how to use
com.bumptech.glide.MemoryCategory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VideoSelectActivity.java From SimpleVideoEdit with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); binding = DataBindingUtil.setContentView(this, R.layout.video_select_layout); Bundle bd = getIntent().getExtras(); if(bd != null) clipIndex = bd.getInt("index"); Glide.get(this).setMemoryCategory(MemoryCategory.HIGH); getLoaderManager().initLoader(LOADER_ID_MEDIA_STORE_DATA, null, this); GridLayoutManager manager = new GridLayoutManager(this, 4); binding.videoSelectRecyclerview.addItemDecoration(new GridSpacingItemDecoration(5)); binding.videoSelectRecyclerview.setHasFixedSize(true); binding.videoSelectRecyclerview.setLayoutManager(manager); binding.nextStep.setOnClickListener(this); binding.nextStep.setTextAppearance(this, R.style.gray_text_18_style); binding.nextStep.setEnabled(false); }
Example #2
Source File: GlideModuleSetting.java From LeisureRead with Apache License 2.0 | 6 votes |
@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); }
Example #3
Source File: MainActivity.java From mr-mantou-android with GNU General Public License v3.0 | 4 votes |
@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)); }