use of com.cleveroad.fanlayoutmanager.callbacks.FanChildDrawingOrderCallback in project FanLayoutManager by Cleveroad.
the class MainFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rvCards);
FanLayoutManagerSettings fanLayoutManagerSettings = FanLayoutManagerSettings.newBuilder(getContext()).withFanRadius(true).withAngleItemBounce(5).withViewHeightDp(160).withViewWidthDp(120).build();
fanLayoutManager = new FanLayoutManager(getContext(), fanLayoutManagerSettings);
recyclerView.setLayoutManager(fanLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
adapter = new SportCardsAdapter(getContext());
adapter.addAll(SportCardsUtils.generateSportCards());
adapter.setOnItemClickListener(new SportCardsAdapter.OnItemClickListener() {
@Override
public void onItemClicked(int itemPosition, final View view) {
if (fanLayoutManager.getSelectedItemPosition() != itemPosition) {
fanLayoutManager.switchItem(recyclerView, itemPosition);
} else {
fanLayoutManager.straightenSelectedItem(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
onClick(view, fanLayoutManager.getSelectedItemPosition());
} else {
onClick(fanLayoutManager.getSelectedItemPosition());
}
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
}
}
});
recyclerView.setAdapter(adapter);
recyclerView.setChildDrawingOrderCallback(new FanChildDrawingOrderCallback(fanLayoutManager));
(view.findViewById(R.id.logo)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fanLayoutManager.collapseViews();
}
});
}
Aggregations