1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.calendar; 18 19 import android.content.Context; 20 import android.graphics.Canvas; 21 import android.graphics.Paint; 22 import android.util.AttributeSet; 23 import android.widget.RelativeLayout; 24 25 import com.android.calendar.AgendaAdapter.ViewHolder; 26 27 /** 28 * A custom layout for each item in the Agenda list view. 29 */ 30 public class AgendaItemView extends RelativeLayout { 31 Paint mPaint = new Paint(); 32 AgendaItemView(Context context)33 public AgendaItemView(Context context) { 34 super(context); 35 } 36 AgendaItemView(Context context, AttributeSet attrs)37 public AgendaItemView(Context context, AttributeSet attrs) { 38 super(context, attrs); 39 } 40 41 @Override dispatchDraw(Canvas canvas)42 protected void dispatchDraw(Canvas canvas) { 43 super.dispatchDraw(canvas); 44 ViewHolder holder = (ViewHolder) getTag(); 45 if (holder != null) { 46 /* Draw vertical color stripe */ 47 mPaint.setColor(holder.calendarColor); 48 canvas.drawRect(0, 0, 5, getHeight(), mPaint); 49 50 /* Gray out item if the event was declined */ 51 if (holder.overLayColor != 0) { 52 mPaint.setColor(holder.overLayColor); 53 canvas.drawRect(0, 0, getWidth(), getHeight(), mPaint); 54 } 55 } 56 } 57 } 58