use of android.support.v7.widget.LinearSnapHelper in project Horizontal-Calendar by Mulham-Raee.
the class HorizontalCalendar method loadHorizontalCalendar.
/* Init Calendar View */
private void loadHorizontalCalendar() {
dateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
mListDays = new ArrayList<>();
calendarView = (HorizontalCalendarView) rootView.findViewById(calendarId);
calendarView.setHasFixedSize(true);
calendarView.setHorizontalScrollBarEnabled(false);
calendarView.setHorizontalCalendar(this);
LinearSnapHelper snapHelper = new LinearSnapHelper();
snapHelper.attachToRecyclerView(calendarView);
hide();
new InitializeDatesList().execute();
}
use of android.support.v7.widget.LinearSnapHelper in project RecyclerViewSnap by rubensousa.
the class SnapAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Snap snap = mSnaps.get(position);
holder.snapTextView.setText(snap.getText());
if (snap.getGravity() == Gravity.START || snap.getGravity() == Gravity.END) {
holder.recyclerView.setLayoutManager(new LinearLayoutManager(holder.recyclerView.getContext(), LinearLayoutManager.HORIZONTAL, false));
new GravitySnapHelper(snap.getGravity(), false, this).attachToRecyclerView(holder.recyclerView);
} else if (snap.getGravity() == Gravity.CENTER_HORIZONTAL || snap.getGravity() == Gravity.CENTER_VERTICAL) {
holder.recyclerView.setLayoutManager(new LinearLayoutManager(holder.recyclerView.getContext(), snap.getGravity() == Gravity.CENTER_HORIZONTAL ? LinearLayoutManager.HORIZONTAL : LinearLayoutManager.VERTICAL, false));
new LinearSnapHelper().attachToRecyclerView(holder.recyclerView);
} else if (snap.getGravity() == Gravity.CENTER) {
// Pager snap
holder.recyclerView.setLayoutManager(new LinearLayoutManager(holder.recyclerView.getContext(), LinearLayoutManager.HORIZONTAL, false));
new GravityPagerSnapHelper(Gravity.START).attachToRecyclerView(holder.recyclerView);
} else {
// Top / Bottom
holder.recyclerView.setLayoutManager(new LinearLayoutManager(holder.recyclerView.getContext()));
new GravitySnapHelper(snap.getGravity()).attachToRecyclerView(holder.recyclerView);
}
holder.recyclerView.setAdapter(new Adapter(snap.getGravity() == Gravity.START || snap.getGravity() == Gravity.END || snap.getGravity() == Gravity.CENTER_HORIZONTAL, snap.getGravity() == Gravity.CENTER, snap.getApps()));
}
Aggregations