use of com.alexvasilkov.gestures.transition.tracker.FromTracker in project GestureViews by alexvasilkov.
the class ListAnyToAllActivity method createAnimator.
@Override
protected ViewsTransitionAnimator<?> createAnimator(final RecyclerView list, final ViewPager pager) {
// Initializing images animator. It requires us to provide FromTracker and IntoTracker items
// that are used to find images views for particular item IDs in the list and in the pager
// to keep them in sync.
// In this example we will show all images from across all list items in a pager.
// We will use combination {list item position, image position} to precisely identify each
// image and its position in the list. We will also need to map images positions inside
// the pager to there list positions and vice versa, see data preparations above.
final FromTracker<Position> listTracker = new FromTracker<Position>() {
@Override
public View getViewById(@NonNull Position pos) {
// We should return image view of particular image inside corresponding list item
RecyclerView.ViewHolder holder = list.findViewHolderForLayoutPosition(pos.itemPos);
return holder == null ? null : ListAdapter.getImageView(holder, pos.imagePos);
}
@Override
public int getPositionById(@NonNull Position pos) {
// We should return position of corresponding list item
return pos.itemPos;
}
};
final IntoTracker<Position> pagerTracker = new IntoTracker<Position>() {
@Override
public Position getIdByPosition(int position) {
// We should return list position for corresponding pager position
return positions.get(position);
}
@Override
public int getPositionById(@NonNull Position pos) {
// We should return pager position for corresponding list position
return positions.indexOf(pos);
}
@Override
public View getViewById(@NonNull Position pos) {
// We should return image view for a given pager position
int pagerPos = getPositionById(pos);
PagerAdapter adapter = (PagerAdapter) Objects.requireNonNull(pager.getAdapter());
RecyclePagerAdapter.ViewHolder holder = adapter.getViewHolder(pagerPos);
return holder == null ? null : PagerAdapter.getImageView(holder);
}
};
return animator = GestureTransitions.from(list, listTracker).into(pager, pagerTracker);
}
use of com.alexvasilkov.gestures.transition.tracker.FromTracker in project GestureViews by alexvasilkov.
the class ListAnyToAnyActivity method createAnimator.
@Override
protected ViewsTransitionAnimator<?> createAnimator(final RecyclerView list, final ViewPager pager) {
// Initializing images animator. It requires us to provide FromTracker and IntoTracker items
// that are used to find images views for particular item IDs in the list and in the pager
// to keep them in sync.
// In this example we will show several images from single list item in a pager.
// When image is clicked we will store selected list item position locally and then request
// particular image within this item (by image position inside the item).
final FromTracker<Integer> listTracker = new FromTracker<Integer>() {
@Override
public View getViewById(@NonNull Integer imagePos) {
// We should return image view of particular image inside current list item
RecyclerView.ViewHolder holder = list.findViewHolderForLayoutPosition(currItemPos);
return holder == null ? null : ListAdapter.getImageView(holder, imagePos);
}
@Override
public int getPositionById(@NonNull Integer imagePos) {
// images belonging to a single list item we can just return this item's position
return currItemPos;
}
};
final IntoTracker<Integer> pagerTracker = new SimpleTracker() {
@Override
protected View getViewAt(int imagePos) {
// We should return image view for a given pager position
PagerAdapter adapter = (PagerAdapter) Objects.requireNonNull(pager.getAdapter());
RecyclePagerAdapter.ViewHolder holder = adapter.getViewHolder(imagePos);
return holder == null ? null : PagerAdapter.getImageView(holder);
}
};
return animator = GestureTransitions.from(list, listTracker).into(pager, pagerTracker);
}
use of com.alexvasilkov.gestures.transition.tracker.FromTracker in project GestureViews by alexvasilkov.
the class ComplexListV1Activity method createAnimator.
@Override
protected ViewsTransitionAnimator createAnimator(final RecyclerView list, final ViewPager pager) {
// Initializing images animator. It requires us to provide FromTracker and IntoTracker items
// that are used to find images views for particular item IDs in the list and in the pager
// to keep them in sync.
// In this example we will show all images from across all list items in a pager.
// We will use combination {list item position, image position} to precisely identify each
// image and its position in the list. We will also need to map images positions inside
// the pager to there list positions and vice versa, see data preparations above.
final FromTracker<Position> listTracker = new FromTracker<Position>() {
@Override
public View getViewById(@NonNull Position pos) {
// We should return image view of particular image inside corresponding list item
RecyclerView.ViewHolder holder = list.findViewHolderForLayoutPosition(pos.itemPos);
return holder == null ? null : ListAdapter.getImageView(holder, pos.imagePos);
}
@Override
public int getPositionById(@NonNull Position pos) {
// We should return position of corresponding list item
return pos.itemPos;
}
};
final IntoTracker<Position> pagerTracker = new IntoTracker<Position>() {
@Override
public Position getIdByPosition(int position) {
// We should return list position for corresponding pager position
return positions.get(position);
}
@Override
public int getPositionById(@NonNull Position pos) {
// We should return pager position for corresponding list position
return positions.indexOf(pos);
}
@Override
public View getViewById(@NonNull Position pos) {
// We should return image view for a given pager position
int pagerPos = getPositionById(pos);
PagerAdapter adapter = (PagerAdapter) pager.getAdapter();
RecyclePagerAdapter.ViewHolder holder = adapter.getViewHolder(pagerPos);
return holder == null ? null : PagerAdapter.getImageView(holder);
}
};
return animator = GestureTransitions.from(list, listTracker).into(pager, pagerTracker);
}
use of com.alexvasilkov.gestures.transition.tracker.FromTracker in project GestureViews by alexvasilkov.
the class ComplexListV2Activity method createAnimator.
@Override
protected ViewsTransitionAnimator createAnimator(final RecyclerView list, final ViewPager pager) {
// Initializing images animator. It requires us to provide FromTracker and IntoTracker items
// that are used to find images views for particular item IDs in the list and in the pager
// to keep them in sync.
// In this example we will show several images from single list item in a pager.
// When image is clicked we will store selected list item position locally and then request
// particular image within this item (by image position inside the item).
final FromTracker<Integer> listTracker = new FromTracker<Integer>() {
@Override
public View getViewById(@NonNull Integer imagePos) {
// We should return image view of particular image inside current list item
RecyclerView.ViewHolder holder = list.findViewHolderForLayoutPosition(currItemPos);
return holder == null ? null : ListAdapter.getImageView(holder, imagePos);
}
@Override
public int getPositionById(@NonNull Integer imagePos) {
// images belonging to a single list item we can just return this item's position
return currItemPos;
}
};
final IntoTracker<Integer> pagerTracker = new SimpleTracker() {
@Override
protected View getViewAt(int imagePos) {
// We should return image view for a given pager position
PagerAdapter adapter = (PagerAdapter) pager.getAdapter();
RecyclePagerAdapter.ViewHolder holder = adapter.getViewHolder(imagePos);
return holder == null ? null : PagerAdapter.getImageView(holder);
}
};
return animator = GestureTransitions.from(list, listTracker).into(pager, pagerTracker);
}
Aggregations