use of com.bumptech.glide.samples.flickr.api.Photo in project glide by bumptech.
the class FullscreenActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fullscreen_activity);
ImageView fullscreenView = (ImageView) findViewById(R.id.fullscreen_view);
Photo photo = getIntent().getParcelableExtra(ARG_PHOTO);
Glide.with(this).load(photo).apply(fitCenterTransform(this)).into(fullscreenView);
}
use of com.bumptech.glide.samples.flickr.api.Photo in project glide by bumptech.
the class FlickrPhotoList method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View result = inflater.inflate(R.layout.flickr_photo_list, container, false);
list = (RecyclerView) result.findViewById(R.id.flickr_photo_list);
layoutManager = new LinearLayoutManager(getActivity());
list.setLayoutManager(layoutManager);
adapter = new FlickrPhotoListAdapter();
list.setAdapter(adapter);
preloadSizeProvider = new ViewPreloadSizeProvider<>();
RecyclerViewPreloader<Photo> preloader = new RecyclerViewPreloader<>(Glide.with(this), adapter, preloadSizeProvider, PRELOAD_AHEAD_ITEMS);
list.addOnScrollListener(preloader);
list.setItemViewCacheSize(0);
if (currentPhotos != null) {
adapter.setPhotos(currentPhotos);
}
final RequestManager requestManager = Glide.with(this);
fullRequest = requestManager.asDrawable().apply(centerCropTransform(getActivity()).placeholder(new ColorDrawable(Color.GRAY)));
thumbRequest = requestManager.asDrawable().apply(diskCacheStrategyOf(DiskCacheStrategy.DATA).override(Api.SQUARE_THUMB_SIZE)).transition(withCrossFade());
list.setRecyclerListener(new RecyclerView.RecyclerListener() {
@Override
public void onViewRecycled(RecyclerView.ViewHolder holder) {
PhotoTitleViewHolder vh = (PhotoTitleViewHolder) holder;
requestManager.clear(vh.imageView);
}
});
if (savedInstanceState != null) {
int index = savedInstanceState.getInt(STATE_POSITION_INDEX);
int offset = savedInstanceState.getInt(STATE_POSITION_OFFSET);
layoutManager.scrollToPositionWithOffset(index, offset);
}
return result;
}
use of com.bumptech.glide.samples.flickr.api.Photo in project glide by bumptech.
the class FlickrPhotoGrid method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle args = getArguments();
photoSize = args.getInt(IMAGE_SIZE_KEY);
thumbnail = args.getBoolean(THUMBNAIL_KEY);
fullRequest = Glide.with(this).asDrawable().transition(withNoTransition()).apply(centerCropTransform(getActivity()));
thumbnailRequest = Glide.with(this).asDrawable().transition(withNoTransition()).apply(diskCacheStrategyOf(DiskCacheStrategy.DATA).centerCrop(getActivity()).override(Api.SQUARE_THUMB_SIZE));
preloadRequest = thumbnail ? thumbnailRequest.clone().apply(priorityOf(Priority.HIGH)) : fullRequest;
final View result = inflater.inflate(R.layout.flickr_photo_grid, container, false);
final int gridMargin = getResources().getDimensionPixelOffset(R.dimen.grid_margin);
int spanCount = getResources().getDisplayMetrics().widthPixels / (photoSize + (2 * gridMargin));
grid = (RecyclerView) result.findViewById(R.id.flickr_photo_grid);
layoutManager = new GridLayoutManager(getActivity(), spanCount);
grid.setLayoutManager(layoutManager);
grid.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(gridMargin, gridMargin, gridMargin, gridMargin);
}
});
grid.setRecyclerListener(new RecyclerView.RecyclerListener() {
@Override
public void onViewRecycled(RecyclerView.ViewHolder holder) {
PhotoViewHolder photoViewHolder = (PhotoViewHolder) holder;
Glide.with(FlickrPhotoGrid.this).clear(photoViewHolder.imageView);
}
});
int heightCount = getResources().getDisplayMetrics().heightPixels / photoSize;
grid.getRecycledViewPool().setMaxRecycledViews(0, spanCount * heightCount * 2);
grid.setItemViewCacheSize(0);
adapter = new PhotoAdapter();
grid.setAdapter(adapter);
FixedPreloadSizeProvider<Photo> preloadSizeProvider = new FixedPreloadSizeProvider<>(photoSize, photoSize);
RecyclerViewPreloader<Photo> preloader = new RecyclerViewPreloader<>(Glide.with(this), adapter, preloadSizeProvider, args.getInt(PRELOAD_KEY));
grid.addOnScrollListener(preloader);
if (currentPhotos != null) {
adapter.setPhotos(currentPhotos);
}
if (savedInstanceState != null) {
int index = savedInstanceState.getInt(STATE_POSITION_INDEX);
grid.scrollToPosition(index);
}
return result;
}
Aggregations