Giter Club home page Giter Club logo

android-calendar-card's Introduction

Android Arsenal

API

android-calendar-card (Google Play Demo)

Android calendar view (like card) Simple and easy to modify

Author: Michał Szwarc

CalendarCard screenshot 2

#CalendarCardPager

CalendarCardPager screenshot2

License

Copyright 2013-2015 Michał Szwarc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-calendar-card's People

Contributors

kenumir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-calendar-card's Issues

Last Months dates

Last months dates go to 32. Looking at your screenshots it didn't do it at one point but does it now. Know of a fix? I don't mind fixing for you but since it seems to be rather recent maybe it's something you could just roll back.
2014-01-28-23-08-03 1

Is it possible to show from Sunday to Monday?

Thank @kenumir so much for this best Calendar library.

I custom your calendar and show correctly from Monday to Sunday with respective day.

Now I want show from Sunday to Monday.

  • I'm able to show the Title from Sunday to Monday.
  • But the Day not show respectively with.

I try to set locale or setFirstDayOfWeek but looks not work as I thought.

in CalendarCard.java

 private void updateCells(boolean isRefresh, ArrayList<CardGridItem> o) {
               Calendar cal;
               Integer counter = 0;

        if (mCalendarDateDisplay != null)	cal = (Calendar) mCalendarDateDisplay.clone();
        else	cal = Calendar.getInstance();

        /*
         * Set specified specifiedMonth to refresh if have
         */
        if (isRefresh)  cal.set(Calendar.MONTH, getSpecifiedMonth());
        cal.set(Calendar.DAY_OF_MONTH, 1);

        int daySpacing = getDaySpacing(cal.get(Calendar.DAY_OF_WEEK));

        /*
         DAY IN PREVIOUS MONTH
          */
        if (daySpacing > 0) {
            Calendar mCalPrevMonth = (Calendar)cal.clone();

            mCalPrevMonth.add(Calendar.MONTH, -1);
            mCalPrevMonth.set(Calendar.DAY_OF_MONTH, mCalPrevMonth.getActualMaximum(Calendar.DAY_OF_MONTH) - daySpacing + 1);

            for(int i=0; i<daySpacing; i++) {
                CheckableLayout cell = cells.get(counter);
                cell.setTag(
                        new CardGridItem(mCalPrevMonth.get(Calendar.DAY_OF_MONTH), mCalPrevMonth.get(Calendar.MONTH), mCalPrevMonth.get(Calendar.YEAR))
                                .setEnabled(isValidMonth(mCalPrevMonth))
                                .setDiffMonth(true)
                                .setSaturday(isSaturday(mCalPrevMonth))
                                .setSunday(isSunday(mCalPrevMonth))
                                .setTransferToSpecifiedMonth(true));

                /*
                Need check previous month is out of range or not
                - If Yes, should disable cell
                 - If no, allow select previous and transfer to previous month
                 */
                cell.setEnabled(isValidMonth(mCalPrevMonth));

                (mOnItemRender == null ? mOnItemRenderDefault : mOnItemRender).onRender(cell, (CardGridItem)cell.getTag());
                counter++;
                mCalPrevMonth.add(Calendar.DAY_OF_MONTH, 1);
            }
        }

        /*
        DAY IN CURRENT MONTH
         */
        // Reset first day & last day in Card array for checking & update new items from API
        int firstDay = cal.get(Calendar.DAY_OF_MONTH);

        cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));

        int lastDay = cal.get(Calendar.DAY_OF_MONTH) + 1;

        Calendar mCalCurrentMonth = Calendar.getInstance();
        int currentDay = mCalCurrentMonth.get(Calendar.MONTH) == cal.get(Calendar.MONTH) ?
                mCalCurrentMonth.get(Calendar.DAY_OF_MONTH) :
                cal.get(Calendar.DAY_OF_MONTH);

        for (int i = firstDay; i < lastDay; i++) {

            cal.set(Calendar.DAY_OF_MONTH, i - 1);

            Calendar date = (Calendar) cal.clone();
            date.add(Calendar.DAY_OF_MONTH, 1);

            CheckableLayout cell = cells.get(counter);

            /*
            Change to logic disable from first day to current day to show respective color
            */
            CardGridItem item = new CardGridItem(i, date.get(Calendar.MONTH), date.get(Calendar.YEAR))
                    .setEnabled(isValidDay(date))
                    .setDate(date)
                    .setSaturday(isSaturday(date))
                    .setSunday(isSunday(date));

            cell.setTag(item);

            /*
            Change to logic disable from first day to current day
            - Return true if current month not equal to specified Month
            - Return true if current month equal to specified Month && i > current day of current Month
            - Otherwise return false
             */
            boolean isDiffMonth = mCalCurrentMonth.get(Calendar.MONTH) != getSpecifiedMonth();
            boolean isSameMonth = mCalCurrentMonth.get(Calendar.MONTH) == getSpecifiedMonth();
            boolean isSameYear = mCalCurrentMonth.get(Calendar.YEAR) == getSpecifiedYear();
            cell.setEnabled(isSameYear
                    && (isDiffMonth || (isSameMonth && i > currentDay)));
            cell.setVisibility(View.VISIBLE);

            (mOnItemRender == null ? mOnItemRenderDefault : mOnItemRender).onRender(cell, (CardGridItem) cell.getTag());
            counter++;
        }

        /*
        DAY IN NEXT MONTH
         */
        if (mCalendarDateDisplay != null)	cal = (Calendar) mCalendarDateDisplay.clone();
        else	cal = Calendar.getInstance();

        Calendar mCalNextMonth = (Calendar)cal.clone();

        cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));

        daySpacing = getDaySpacingEnd(cal.get(Calendar.DAY_OF_WEEK));

        if (daySpacing > 0) {

            mCalNextMonth.add(Calendar.MONTH, 1);
            mCalNextMonth.set(Calendar.DAY_OF_MONTH, 1);

            for(int i=0; i<daySpacing; i++) {
                CheckableLayout cell = cells.get(counter);

                cell.setTag(new CardGridItem(i + 1, mCalNextMonth.get(Calendar.MONTH), mCalNextMonth.get(Calendar.YEAR))
                        .setEnabled(true)
                        .setDiffMonth(true)
                        .setSaturday(isSaturday(mCalNextMonth))
                        .setSunday(isSunday(mCalNextMonth))
                        .setTransferToSpecifiedMonth(true));
                cell.setEnabled(true);
                cell.setVisibility(View.VISIBLE);

                (mOnItemRender == null ? mOnItemRenderDefault : mOnItemRender).onRender(cell, (CardGridItem)cell.getTag());

                counter++;
                mCalNextMonth.add(Calendar.DAY_OF_MONTH, 1);
            }
        }

        if (counter < cells.size()) {
            for(int i=counter; i<cells.size(); i++) {
                cells.get(i).setVisibility(View.GONE);
            }
        }
    }`

Therefore I post this enhancement,
Please help me detail how to do this?

Thank you,

Problem with pager version

On load the cells are rectangle in the first two pages, go to page 3 and they are square, go back to page 1 and the these cells are now square, is there a way of keeping the cells square at all times

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.