use of us.koller.cameraroll.adapter.main.viewHolder.NestedRecyclerViewAlbumHolder in project Camera-Roll-Android-App by kollerlukas.
the class MainActivity method onActivityReenter.
@Override
public void onActivityReenter(final int resultCode, Intent intent) {
super.onActivityReenter(resultCode, intent);
int nestedRecyclerViewValue = getResources().getInteger(R.integer.STYLE_NESTED_RECYCLER_VIEW_VALUE);
if (intent.getAction() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && intent.getAction().equals(ItemActivity.SHARED_ELEMENT_RETURN_TRANSITION) && Settings.getInstance(this).getStyle(this, pick_photos) == nestedRecyclerViewValue) {
// handle shared-element transition, for nested nestedRecyclerView style
Bundle tmpReenterState = new Bundle(intent.getExtras());
if (tmpReenterState.containsKey(AlbumActivity.ALBUM_PATH) && tmpReenterState.containsKey(AlbumActivity.EXTRA_CURRENT_ALBUM_POSITION)) {
String albumPath = tmpReenterState.getString(AlbumActivity.ALBUM_PATH);
final int sharedElementReturnPosition = tmpReenterState.getInt(AlbumActivity.EXTRA_CURRENT_ALBUM_POSITION);
int index = -1;
ArrayList<Album> albums = MediaProvider.getAlbumsWithVirtualDirectories(this);
for (int i = 0; i < albums.size(); i++) {
if (albums.get(i).getPath().equals(albumPath)) {
index = i;
break;
}
}
if (index == -1) {
return;
}
// postponing transition until sharedElement is laid out
postponeEnterTransition();
setExitSharedElementCallback(mCallback);
final NestedRecyclerViewAlbumHolder.StartSharedElementTransitionCallback callback = new NestedRecyclerViewAlbumHolder.StartSharedElementTransitionCallback() {
@Override
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void startPostponedEnterTransition() {
// sharedElement is laid out --> start transition
MainActivity.this.startPostponedEnterTransition();
}
};
final int finalIndex = index;
recyclerView.scrollToPosition(index);
// wait until ViewHolder is laid out
recyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onLayoutChange(View v, int l, int t, int r, int b, int oL, int oT, int oR, int oB) {
RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(finalIndex);
if (viewHolder != null) {
recyclerView.removeOnLayoutChangeListener(this);
} else {
// viewHolder hasn't been laid out yet --> wait
recyclerView.scrollToPosition(finalIndex);
}
if (viewHolder instanceof NestedRecyclerViewAlbumHolder) {
// found ViewHolder
sharedElementViewHolder = (NestedRecyclerViewAlbumHolder) viewHolder;
((NestedRecyclerViewAlbumHolder) viewHolder).onSharedElement(sharedElementReturnPosition, callback);
}
}
});
}
}
}
use of us.koller.cameraroll.adapter.main.viewHolder.NestedRecyclerViewAlbumHolder in project Camera-Roll-Android-App by kollerlukas.
the class MainAdapter method onCreateViewHolder.
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
RecyclerView.ViewHolder viewHolder;
Resources res = parent.getContext().getResources();
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
if (viewType == res.getInteger(R.integer.STYLE_PARALLAX_VALUE)) {
View v = inflater.inflate(R.layout.album_cover_parallax, parent, false);
viewHolder = new SimpleAlbumHolder(v);
} else if (viewType == res.getInteger(R.integer.STYLE_CARDS_VALUE)) {
View v = inflater.inflate(R.layout.album_cover_card, parent, false);
viewHolder = new SimpleAlbumHolder(v);
} else if (viewType == res.getInteger(R.integer.STYLE_CARDS_2_VALUE)) {
View v = inflater.inflate(R.layout.album_cover_card_2, parent, false);
viewHolder = new SimpleAlbumHolder(v);
} else /*if (viewType == res.getInteger(R.integer.STYLE_NESTED_RECYCLER_VIEW_VALUE))*/
{
View v = inflater.inflate(R.layout.album_cover_nested_recyclerview, parent, false);
viewHolder = new NestedRecyclerViewAlbumHolder(v).setSelectorModeManager(getSelectorManager());
}
Context context = viewHolder.itemView.getContext();
Theme theme = Settings.getInstance(context).getThemeInstance(context);
ThemeableActivity.checkTags((ViewGroup) viewHolder.itemView, theme);
return viewHolder;
}
Aggregations