@@ -0,0 +1,2021 @@
+package com.dev.bins.calendar.view;%0A%0Aimport android.support.annotation.IntDef;%0Aimport android.support.v7.widget.RecyclerView;%0Aimport android.view.ViewGroup;%0A%0Aimport java.lang.annotation.Retention;%0Aimport java.lang.annotation.RetentionPolicy;%0A%0Aimport static com.dev.bins.calendar.view.CalendarAdapter.STATE_OPEN;%0A%0A/**%0A * Created by bin on 25/10/2017.%0A */%0A%0Apublic class LayoutManager extends RecyclerView.LayoutManager %7B%0A%0A    private RecyclerView mRecyclerView;%0A    private CalendarAdapter mAdapter;%0A%0A    @Override%0A    public RecyclerView.LayoutParams generateDefaultLayoutParams() %7B%0A        return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);%0A    %7D%0A%0A%0A    @Override%0A    public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) %7B%0A        if (getItemCount() == 0) %7B%0A            removeAndRecycleAllViews(recycler);%0A            return;%0A        %7D%0A%0A        final int childCount = getChildCount();%0A        if (childCount == 0 && state.isPreLayout()) %7B%0A            return;%0A        %7D%0A        int width = getWidth();%0A        int cellHeight = width/7;%0A        if (mAdapter.getCurrentState() == STATE_OPEN)%7B%0A%0A        %7Delse %7B%0A%0A        %7D%0A%0A%0A    %7D%0A%0A%0A    @Override%0A    public boolean canScrollHorizontally() %7B%0A        return true;%0A    %7D%0A%0A    @Override%0A    public boolean canScrollVertically() %7B%0A        return false;%0A    %7D%0A%0A%0A    @Override%0A    public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) %7B%0A        return super.scrollHorizontallyBy(dx, recycler, state);%0A    %7D%0A%0A    @Override%0A    public void onAttachedToWindow(RecyclerView view) %7B%0A        super.onAttachedToWindow(view);%0A        mRecyclerView = view;%0A        mAdapter = (CalendarAdapter) mRecyclerView.getAdapter();%0A    %7D%0A%0A%0A    @Override%0A    public void onDetachedFromWindow(RecyclerView view, RecyclerView.Recycler recycler) %7B%0A        super.onDetachedFromWindow(view, recycler);%0A        mRecyclerView = null;%0A        mAdapter = null;%0A    %7D%0A%0A%0A%0A%0A%7D%0A

add LayoutManager