use of com.example.android.unsplash.ui.grid.PhotoViewHolder in project atlas by alibaba.
the class MainActivity method populateGrid.
private void populateGrid() {
grid.setAdapter(new PhotoAdapter(this, relevantPhotos));
grid.addOnItemTouchListener(new OnItemSelectedListener(MainActivity.this) {
public void onItemSelected(RecyclerView.ViewHolder holder, int position) {
if (!(holder instanceof PhotoViewHolder)) {
return;
}
MainActivity activity = MainActivity.this;
PhotoViewHolder pvh = (PhotoViewHolder) holder;
final Intent intent = getDetailActivityStartIntent(activity, position, pvh);
final ActivityOptions activityOptions = getActivityOptions(pvh);
activity.startActivityForResult(intent, IntentUtil.INSTANCE.getREQUEST_CODE(), activityOptions.toBundle());
}
});
empty.setVisibility(View.GONE);
}
use of com.example.android.unsplash.ui.grid.PhotoViewHolder in project atlas by alibaba.
the class MainActivity method onActivityReenter.
@Override
public void onActivityReenter(int resultCode, Intent data) {
postponeEnterTransition();
// Start the postponed transition when the recycler view is ready to be drawn.
grid.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
grid.getViewTreeObserver().removeOnPreDrawListener(this);
startPostponedEnterTransition();
return true;
}
});
if (data == null) {
return;
}
final int selectedItem = data.getIntExtra(IntentUtil.INSTANCE.getSELECTED_ITEM_POSITION(), 0);
grid.scrollToPosition(selectedItem);
PhotoViewHolder holder = (PhotoViewHolder) grid.findViewHolderForAdapterPosition(selectedItem);
if (holder == null) {
Log.w(TAG, "onActivityReenter: Holder is null, remapping cancelled.");
return;
}
DetailSharedElementEnterCallback callback = new DetailSharedElementEnterCallback(getIntent());
callback.setView(holder.itemView);
setExitSharedElementCallback(callback);
}
Aggregations