Search in sources :

Example 1 with LinearSnapHelper

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();
}
Also used : LinearSnapHelper(android.support.v7.widget.LinearSnapHelper) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with LinearSnapHelper

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()));
}
Also used : GravitySnapHelper(com.github.rubensousa.gravitysnaphelper.GravitySnapHelper) LinearSnapHelper(android.support.v7.widget.LinearSnapHelper) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) GravityPagerSnapHelper(com.github.rubensousa.gravitysnaphelper.GravityPagerSnapHelper)

Aggregations

LinearSnapHelper (android.support.v7.widget.LinearSnapHelper)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 GravityPagerSnapHelper (com.github.rubensousa.gravitysnaphelper.GravityPagerSnapHelper)1 GravitySnapHelper (com.github.rubensousa.gravitysnaphelper.GravitySnapHelper)1 SimpleDateFormat (java.text.SimpleDateFormat)1