public void leftSilde() {

    if (style == MONTH_STYLE) {
      if (mShowDate.month == 1) {
        mShowDate.month = 12;
        mShowDate.year -= 1;
      } else {
        mShowDate.month -= 1;
      }

    } else if (style == WEEK_STYLE) {
      int lastMonthDays = JGDateUtil.getMonthDays(mShowDate.year, mShowDate.month);
      if (mShowDate.day - WEEK < 1) {
        if (mShowDate.month == 1) {
          mShowDate.month = 12;
          mShowDate.year -= 1;
        } else {
          mShowDate.month -= 1;
        }
        mShowDate.day = lastMonthDays - WEEK + mShowDate.day;

      } else {
        mShowDate.day -= WEEK;
      }
      Log.i(TAG, "leftSilde" + mShowDate.toString());
    }
    update();
  }
 private void fillMonthDate() {
   int monthDay = JGDateUtil.getCurrentMonthDay();
   int lastMonthDays = JGDateUtil.getMonthDays(mShowDate.year, mShowDate.month - 1);
   int currentMonthDays = JGDateUtil.getMonthDays(mShowDate.year, mShowDate.month);
   int firstDayWeek = JGDateUtil.getWeekDayFromDate(mShowDate.year, mShowDate.month);
   boolean isCurrentMonth = false;
   if (JGDateUtil.isCurrentMonth(mShowDate)) {
     isCurrentMonth = true;
   }
   int day = 0;
   for (int j = 0; j < TOTAL_ROW; j++) {
     rows[j] = new Row(j);
     for (int i = 0; i < TOTAL_COL; i++) {
       int postion = i + j * TOTAL_COL;
       if (postion >= firstDayWeek && postion < firstDayWeek + currentMonthDays) {
         day++;
         if (isCurrentMonth && day == monthDay) {
           JGCustomDate date = JGCustomDate.modifiDayForObject(mShowDate, day);
           // mClickCell = new Cell(date,State.TODAY, i,j);
           date.week = i;
           // mCallBack.clickDate(date);
           // rows[j].cells[i] = new Cell(date,State.CLICK_DAY, i,j);
           rows[j].cells[i] = new Cell(date, State.CURRENT_MONTH_DAY, i, j);
           continue;
         }
         rows[j].cells[i] =
             new Cell(
                 JGCustomDate.modifiDayForObject(mShowDate, day), State.CURRENT_MONTH_DAY, i, j);
       } else if (postion < firstDayWeek) {
         rows[j].cells[i] =
             new Cell(
                 new JGCustomDate(
                     mShowDate.year,
                     mShowDate.month - 1,
                     lastMonthDays - (firstDayWeek - postion - 1)),
                 State.PAST_MONTH_DAY,
                 i,
                 j);
       } else if (postion >= firstDayWeek + currentMonthDays) {
         rows[j].cells[i] =
             new Cell(
                 (new JGCustomDate(
                     mShowDate.year,
                     mShowDate.month + 1,
                     postion - firstDayWeek - currentMonthDays + 1)),
                 State.NEXT_MONTH_DAY,
                 i,
                 j);
       }
     }
   }
 }
  public void rightSilde() {
    if (style == MONTH_STYLE) {

      if (mShowDate.month == 12) {
        mShowDate.month = 1;
        mShowDate.year += 1;
      } else {
        mShowDate.month += 1;
      }

    } else if (style == WEEK_STYLE) {
      int currentMonthDays = JGDateUtil.getMonthDays(mShowDate.year, mShowDate.month);
      if (mShowDate.day + WEEK > currentMonthDays) {
        if (mShowDate.month == 12) {
          mShowDate.month = 1;
          mShowDate.year += 1;
        } else {
          mShowDate.month += 1;
        }
        mShowDate.day = WEEK - currentMonthDays + mShowDate.day;
      } else {
        mShowDate.day += WEEK;
      }
    }
    update();
  }
 private void measureClickCell(int col, int row) {
   if (col >= TOTAL_COL || row >= TOTAL_ROW) return;
   if (mClickCell != null) {
     rows[mClickCell.j].cells[mClickCell.i] = mClickCell;
   }
   if (rows[row] != null) {
     mClickCell =
         new Cell(
             rows[row].cells[col].date,
             rows[row].cells[col].state,
             rows[row].cells[col].i,
             rows[row].cells[col].j);
     rows[row].cells[col].state = State.CLICK_DAY;
     JGCustomDate date = rows[row].cells[col].date;
     date.week = col;
     mCallBack.clickDate(date);
     invalidate();
   }
 }
 private void fillWeekDate() {
   int lastMonthDays = JGDateUtil.getMonthDays(mShowDate.year, mShowDate.month - 1);
   rows[0] = new Row(0);
   int day = mShowDate.day;
   for (int i = TOTAL_COL - 1; i >= 0; i--) {
     day -= 1;
     if (day < 1) {
       day = lastMonthDays;
     }
     JGCustomDate date = JGCustomDate.modifiDayForObject(mShowDate, day);
     if (JGDateUtil.isToday(date)) {
       mClickCell = new Cell(date, State.TODAY, i, 0);
       date.week = i;
       mCallBack.clickDate(date);
       rows[0].cells[i] = new Cell(date, State.CLICK_DAY, i, 0);
       continue;
     }
     rows[0].cells[i] = new Cell(date, State.CURRENT_MONTH_DAY, i, 0);
   }
 }
  public void switchStyle(int style) {
    JGCalendarView.style = style;
    if (style == MONTH_STYLE) {
      update();
    } else if (style == WEEK_STYLE) {
      int firstDayWeek = JGDateUtil.getWeekDayFromDate(mShowDate.year, mShowDate.month);
      int day = 1 + WEEK - firstDayWeek;
      mShowDate.day = day;

      update();
    }
  }
    public void drawSelf(Canvas canvas) {
      Calendar now = Calendar.getInstance();
      Calendar calendar = date.toCalendar();
      double count = 0;
      boolean flag1 = false, flag2 = false;
      for (int i = 0; i < list.size(); i++) {
        JGDataSet item = list.get(i);
        if (item.hasSameDate(calendar)) {
          if (item.getType() == 0) {
            count += 1;
            outDays++;
          } else if (item.getType() == 1) {
            count += 0.5;
            flag1 = true;
          } else if (item.getType() == 2) {
            count += 0.5;
            flag2 = true;
          }
        }
      }
      if (flag1 & flag2) inDays++;
      switch (state) {
        case CURRENT_MONTH_DAY:
          if (calendar.compareTo(now) < 0) {
            passedDays++;
            if (count >= 1) {
              signedDays++;
              mRecordPaint.setColor(Color.parseColor("#AB79FF56")); // green
            } else mRecordPaint.setColor(Color.parseColor("#B6FF5E3A")); // red
            canvas.drawCircle(
                (float) (mCellSpace * (i + 0.5)),
                (float) ((j + 0.5) * mCellSpace),
                mCellSpace / 4,
                mRecordPaint);
          } else {
            mRecordPaint.setColor(Color.parseColor("#ffcfcfcf")); // grey
            canvas.drawCircle(
                (float) (mCellSpace * (i + 0.5)),
                (float) ((j + 0.5) * mCellSpace),
                mCellSpace / 4,
                mRecordPaint);
          }
          mTextPaint.setColor(Color.parseColor("#80000000"));
          break;
        case NEXT_MONTH_DAY:
        case PAST_MONTH_DAY:
          mTextPaint.setColor(Color.parseColor("#40000000"));
          break;
        case TODAY:
          mTextPaint.setColor(Color.parseColor("#F24949"));
          break;
        case CLICK_DAY:
          if (calendar.compareTo(now) < 0) {
            passedDays++;
            if (count >= 1) {
              signedDays++;
            }
          }
          mTextPaint.setColor(Color.parseColor("#fffffe"));
          canvas.drawCircle(
              (float) (mCellSpace * (i + 0.5)),
              (float) ((j + 0.5) * mCellSpace),
              mCellSpace / 2,
              mCirclePaint);
          break;
      }

      String content = date.day + "";
      canvas.drawText(
          content,
          (float) ((i + 0.5) * mCellSpace - mTextPaint.measureText(content) / 2),
          (float) ((j + 0.7) * mCellSpace - mTextPaint.measureText(content, 0, 1) / 2),
          mTextPaint);
    }