From dea9fe57c2434af24e19d83cc9a60117c503f055 Mon Sep 17 00:00:00 2001 From: Robert Kolner Date: Mon, 5 Dec 2011 19:22:46 +0100 Subject: [PATCH] Added price to event list. --- res/layout/event_list_row.xml | 8 +++++- src/com/studentersamfundet/app/Event.java | 5 +++- .../app/ui/ProgramListActivity.java | 26 +++++++++++-------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/res/layout/event_list_row.xml b/res/layout/event_list_row.xml index cde0186..c553194 100644 --- a/res/layout/event_list_row.xml +++ b/res/layout/event_list_row.xml @@ -8,7 +8,7 @@ + + diff --git a/src/com/studentersamfundet/app/Event.java b/src/com/studentersamfundet/app/Event.java index 8211fa5..7c34c1e 100644 --- a/src/com/studentersamfundet/app/Event.java +++ b/src/com/studentersamfundet/app/Event.java @@ -91,7 +91,10 @@ public class Event implements Serializable { } public String getPriceString() { - return "" +this.regularPrice +'/' +this.memberPrice; + if (this.regularPrice > 0 || this.memberPrice > 0) + return "" +this.regularPrice +'/' +this.memberPrice +"kr"; + + return ""; } public Uri getTicketUri() { diff --git a/src/com/studentersamfundet/app/ui/ProgramListActivity.java b/src/com/studentersamfundet/app/ui/ProgramListActivity.java index 0d22236..adaaf3f 100644 --- a/src/com/studentersamfundet/app/ui/ProgramListActivity.java +++ b/src/com/studentersamfundet/app/ui/ProgramListActivity.java @@ -107,6 +107,7 @@ public class ProgramListActivity extends BaseDnsActivity { final Event e = getItem(position); + /* Set text: */ TextView titleView = (TextView) row.findViewById(R.id.event_list_row_text); titleView.setText(Html.fromHtml(e.title)); @@ -114,6 +115,20 @@ public class ProgramListActivity extends BaseDnsActivity { TextView dateView = (TextView) row.findViewById(R.id.event_list_row_date); dateView.setText(dateFormat.format(e.getDate())); + TextView priceView = (TextView) row.findViewById(R.id.event_list_row_price); + priceView.setText(e.getPriceString()); + + /* Apply styles: */ + if (position % 2 == 0) { + row.setBackgroundResource(R.color.ListItemBackgroundEven); + } else { + row.setBackgroundResource(R.color.ListItemBackgroundOdd); + } + titleView.setTextAppearance(ProgramListActivity.this, R.style.ListItemTextTitle); + dateView.setTextAppearance(ProgramListActivity.this, R.style.ListItemTextDate); + priceView.setTextAppearance(ProgramListActivity.this, R.style.ListItemTextDate); + + /* Add onClickListeners: */ row.setOnClickListener(new OnClickListener() { public void onClick(View v) { @@ -150,17 +165,6 @@ public class ProgramListActivity extends BaseDnsActivity { } }); - /* Apply styles: */ - if (position % 2 == 0) { - row.setBackgroundResource(R.color.ListItemBackgroundEven); - titleView.setTextAppearance(ProgramListActivity.this, R.style.ListItemTextTitle); - dateView.setTextAppearance(ProgramListActivity.this, R.style.ListItemTextDate); - } else { - row.setBackgroundResource(R.color.ListItemBackgroundOdd); - titleView.setTextAppearance(ProgramListActivity.this, R.style.ListItemTextTitle); - dateView.setTextAppearance(ProgramListActivity.this, R.style.ListItemTextDate); - } - return row; } };