Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cells are filled throughout each sections on each month #466

Closed
BilalMH opened this issue Oct 10, 2018 · 1 comment
Closed

Cells are filled throughout each sections on each month #466

BilalMH opened this issue Oct 10, 2018 · 1 comment

Comments

@BilalMH
Copy link

BilalMH commented Oct 10, 2018

I've done the code before where it says to decorate the cellview by checking the date. However, I'm gettin the same cells coloured on each month... I don't know why. Please see my code below

    private class BookedDayDecorator implements CalendarCellDecorator {

        private ArrayList<CalendarModel> mData;

        public BookedDayDecorator(ArrayList<CalendarModel> calendarModel) {
            this.mData = calendarModel;
        }

        @Override
        public void decorate(CalendarCellView cellView, Date date) {
            for (int i = 0; i < mData.size(); i++) {
                if (cellView.isCurrentMonth()) {
                    if (MyFunctions.getDateFromString(mData.get(i).getStarts_at()).compareTo(date) * date.compareTo(MyFunctions.getDateFromString(mData.get(i).getEnds_at())) >= 0) {
                        if (mData.get(i).getType().equals("booking")) {
                            int purpleColor = Color.parseColor("#7a00ff");
                            cellView.setBackgroundColor(purpleColor);
                            cellView.getDayOfMonthTextView().setTextColor(Color.WHITE);
                            cellView.getDayOfMonthTextView().setTypeface(cellView.getDayOfMonthTextView().getTypeface(), Typeface.BOLD);
                        } else if (mData.get(i).getType().equals("block")) {
                            cellView.setBackground(getResources().getDrawable(R.drawable.bgnd_blocked_day));
                            cellView.getDayOfMonthTextView().setTextColor(Color.WHITE);
                            cellView.getDayOfMonthTextView().setTypeface(cellView.getDayOfMonthTextView().getTypeface(), Typeface.BOLD);
                        } else {

                            Date today = new Date();

                            if (date.before(today)) {
                                cellView.getDayOfMonthTextView().setTypeface(cellView.getDayOfMonthTextView().getTypeface(), Typeface.BOLD);
                                cellView.setAlpha(0.3f);
                            } else {

                                cellView.setBackgroundColor(Color.WHITE);
                                cellView.getDayOfMonthTextView().setTextColor(getResources().getColor(R.color.dark_gray));
                            }
                        }
                    }
                }

            }
        }
    }

See attached screenshot as well. Any help would be appreciated

screenshot_1539177075 copy

@edenman
Copy link
Collaborator

edenman commented Oct 10, 2018

This is not a support forum. Please stop.

@edenman edenman closed this as completed Oct 10, 2018
@square square locked as off-topic and limited conversation to collaborators Oct 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants