summaryrefslogtreecommitdiffstats
path: root/src/com/android/calendar/AgendaAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/calendar/AgendaAdapter.java')
-rw-r--r--src/com/android/calendar/AgendaAdapter.java37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/com/android/calendar/AgendaAdapter.java b/src/com/android/calendar/AgendaAdapter.java
index 1bce5acc..1b93b7e2 100644
--- a/src/com/android/calendar/AgendaAdapter.java
+++ b/src/com/android/calendar/AgendaAdapter.java
@@ -23,26 +23,29 @@ import android.provider.Calendar.Attendees;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.view.View;
-import android.widget.FrameLayout;
import android.widget.ResourceCursorAdapter;
import android.widget.TextView;
public class AgendaAdapter extends ResourceCursorAdapter {
static private String mNoTitleLabel; // todo update on locale change.
private Resources mResources;
+ private int mDeclinedColor;
+
+ static class ViewHolder {
+ int overLayColor; // Used by AgendaItemView to gray out the entire item if so desired
- private static class ViewHolder {
/* Event */
- View stripe;
TextView title;
TextView when;
TextView where;
+ int calendarColor; // Used by AgendaItemView to color the vertical stripe
}
public AgendaAdapter(Context context, int resource) {
super(context, resource, null);
mResources = context.getResources();
mNoTitleLabel = mResources.getString(R.string.no_title_label);
+ mDeclinedColor = mResources.getColor(R.drawable.agenda_item_declined);
}
@Override
@@ -52,7 +55,6 @@ public class AgendaAdapter extends ResourceCursorAdapter {
if (holder == null) {
holder = new ViewHolder();
view.setTag(holder);
- holder.stripe = view.findViewById(R.id.vertical_stripe);
holder.title = (TextView) view.findViewById(R.id.title);
holder.when = (TextView) view.findViewById(R.id.when);
holder.where = (TextView) view.findViewById(R.id.where);
@@ -60,19 +62,20 @@ public class AgendaAdapter extends ResourceCursorAdapter {
// Fade text if event was declined.
int selfAttendeeStatus = cursor.getInt(AgendaActivity.INDEX_SELF_ATTENDEE_STATUS);
- boolean declined = (selfAttendeeStatus == Attendees.ATTENDEE_STATUS_DECLINED);
+ if (selfAttendeeStatus == Attendees.ATTENDEE_STATUS_DECLINED) {
+ holder.overLayColor = mDeclinedColor;
+ } else {
+ holder.overLayColor = 0;
+ }
- View stripe = holder.stripe;
TextView title = holder.title;
TextView when = holder.when;
TextView where = holder.where;
+ /* Calendar Color */
int color = cursor.getInt(AgendaActivity.INDEX_COLOR);
- ((FrameLayout) view).setForeground(declined ?
- mResources.getDrawable(R.drawable.agenda_item_declined) : null);
+ holder.calendarColor = color;
- stripe.setBackgroundColor(color);
-
// What
String titleString = cursor.getString(AgendaActivity.INDEX_TITLE);
if (titleString == null || titleString.length() == 0) {
@@ -80,7 +83,7 @@ public class AgendaAdapter extends ResourceCursorAdapter {
}
title.setText(titleString);
title.setTextColor(color);
-
+
// When
long begin = cursor.getLong(AgendaActivity.INDEX_BEGIN);
long end = cursor.getLong(AgendaActivity.INDEX_END);
@@ -97,16 +100,16 @@ public class AgendaAdapter extends ResourceCursorAdapter {
}
whenString = DateUtils.formatDateRange(context, begin, end, flags);
when.setText(whenString);
-
+
String rrule = cursor.getString(AgendaActivity.INDEX_RRULE);
if (rrule != null) {
- when.setCompoundDrawablesWithIntrinsicBounds(null, null,
+ when.setCompoundDrawablesWithIntrinsicBounds(null, null,
context.getResources().getDrawable(R.drawable.ic_repeat_dark), null);
when.setCompoundDrawablePadding(5);
} else {
when.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
}
-
+
/*
// Repeating info
View repeatContainer = view.findViewById(R.id.repeat_icon);
@@ -117,7 +120,7 @@ public class AgendaAdapter extends ResourceCursorAdapter {
repeatContainer.setVisibility(View.GONE);
}
*/
-
+
/*
// Reminder
boolean hasAlarm = cursor.getInt(AgendaActivity.INDEX_HAS_ALARM) != 0;
@@ -125,7 +128,7 @@ public class AgendaAdapter extends ResourceCursorAdapter {
updateReminder(view, context, begin, cursor.getLong(AgendaActivity.INDEX_EVENT_ID));
}
*/
-
+
// Where
String whereString = cursor.getString(AgendaActivity.INDEX_EVENT_LOCATION);
if (whereString != null && whereString.length() > 0) {
@@ -141,7 +144,7 @@ public class AgendaAdapter extends ResourceCursorAdapter {
ContentResolver cr = context.getContentResolver();
Uri uri = Reminders.CONTENT_URI;
String where = String.format(REMINDERS_WHERE, eventId);
-
+
Cursor remindersCursor = cr.query(uri, REMINDERS_PROJECTION, where, null, null);
if (remindersCursor != null) {
LayoutInflater inflater =