Android Open Source - TasksReminder Calendar Cell View






From Project

Back to project page TasksReminder.

License

The source code is released under:

MIT License

If you think the Android project TasksReminder listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

// Copyright 2013 Square, Inc.
//  w w w  . j ava2  s . c  om
package com.squareup.timessquare;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
import com.squareup.timessquare.MonthCellDescriptor.RangeState;

public class CalendarCellView extends TextView {
  private static final int[] STATE_SELECTABLE = {
      R.attr.state_selectable
  };
  private static final int[] STATE_CURRENT_MONTH = {
      R.attr.state_current_month
  };
  private static final int[] STATE_TODAY = {
      R.attr.state_today
  };
  private static final int[] STATE_HIGHLIGHTED = {
      R.attr.state_highlighted
  };
  private static final int[] STATE_RANGE_FIRST = {
      R.attr.state_range_first
  };
  private static final int[] STATE_RANGE_MIDDLE = {
      R.attr.state_range_middle
  };
  private static final int[] STATE_RANGE_LAST = {
      R.attr.state_range_last
  };

  private boolean isSelectable = false;
  private boolean isCurrentMonth = false;
  private boolean isToday = false;
  private boolean isHighlighted = false;
  private RangeState rangeState = RangeState.NONE;

  @SuppressWarnings("UnusedDeclaration")
  public CalendarCellView(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  public void setSelectable(boolean isSelectable) {
    this.isSelectable = isSelectable;
    refreshDrawableState();
  }

  public void setCurrentMonth(boolean isCurrentMonth) {
    this.isCurrentMonth = isCurrentMonth;
    refreshDrawableState();
  }

  public void setToday(boolean isToday) {
    this.isToday = isToday;
    refreshDrawableState();
  }

  public void setRangeState(MonthCellDescriptor.RangeState rangeState) {
    this.rangeState = rangeState;
    refreshDrawableState();
  }

  public void setHighlighted(boolean highlighted) {
    isHighlighted = highlighted;
    refreshDrawableState();
  }

  @Override protected int[] onCreateDrawableState(int extraSpace) {
    final int[] drawableState = super.onCreateDrawableState(extraSpace + 5);

    if (isSelectable) {
      mergeDrawableStates(drawableState, STATE_SELECTABLE);
    }

    if (isCurrentMonth) {
      mergeDrawableStates(drawableState, STATE_CURRENT_MONTH);
    }

    if (isToday) {
      mergeDrawableStates(drawableState, STATE_TODAY);
    }

    if (isHighlighted) {
      mergeDrawableStates(drawableState, STATE_HIGHLIGHTED);
    }

    if (rangeState == MonthCellDescriptor.RangeState.FIRST) {
      mergeDrawableStates(drawableState, STATE_RANGE_FIRST);
    } else if (rangeState == MonthCellDescriptor.RangeState.MIDDLE) {
      mergeDrawableStates(drawableState, STATE_RANGE_MIDDLE);
    } else if (rangeState == RangeState.LAST) {
      mergeDrawableStates(drawableState, STATE_RANGE_LAST);
    }

    return drawableState;
  }
}




Java Source Code List

com.sampa.tasksreminder.AlarmManagerHelper.java
com.sampa.tasksreminder.AlarmReceiver.java
com.sampa.tasksreminder.AlarmService.java
com.sampa.tasksreminder.DatePickerActivity.java
com.sampa.tasksreminder.DatePickerActivity_.java
com.sampa.tasksreminder.MainActivity.java
com.sampa.tasksreminder.MainActivity_.java
com.sampa.tasksreminder.NewTaskActivity.java
com.sampa.tasksreminder.NewTaskActivity_.java
com.sampa.tasksreminder.ShowTaskActivity.java
com.sampa.tasksreminder.ShowTaskActivity_.java
com.sampa.tasksreminder.TaskCursorAdapter.java
com.sampa.tasksreminder.TaskSQLiteHelper.java
com.sampa.tasksreminder.Task.java
com.sampa.tasksreminder.TimePickerFragment.java
com.sampa.tasksreminder.TimePickerFragment_.java
com.squareup.timessquare.CalendarCellView.java
com.squareup.timessquare.CalendarGridView.java
com.squareup.timessquare.CalendarPickerView.java
com.squareup.timessquare.CalendarRowView.java
com.squareup.timessquare.Logr.java
com.squareup.timessquare.MonthCellDescriptor.java
com.squareup.timessquare.MonthDescriptor.java
com.squareup.timessquare.MonthView.java