From 864ad84952ca9003887b8cf8dfab450edc2c848c Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Thu, 1 Aug 2013 14:32:26 -0700 Subject: [PATCH 1/3] Update to ignore Android Studio metadata --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 6bc71e0..e9fa834 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Ignore metadata from IDEA (Android Studio) +*.iml +.idea/ bin/ gen/ *~ From 6988fba46e67b771d557764022f90965d48751f5 Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Fri, 2 Aug 2013 08:33:02 -0700 Subject: [PATCH 2/3] Added a custom adapter to display the issues list with alternating colored rows. --- .../SifterReader/ColorItemAdapter.java | 34 +++++++++++++++++++ .../SifterReader/IssuesActivity.java | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/com/BreakingBytes/SifterReader/ColorItemAdapter.java diff --git a/src/com/BreakingBytes/SifterReader/ColorItemAdapter.java b/src/com/BreakingBytes/SifterReader/ColorItemAdapter.java new file mode 100644 index 0000000..486551f --- /dev/null +++ b/src/com/BreakingBytes/SifterReader/ColorItemAdapter.java @@ -0,0 +1,34 @@ +package com.BreakingBytes.SifterReader; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.SimpleAdapter; + +import java.util.List; +import java.util.Map; + +/** + * Extension of SimpleAdapter that will color the background of a list item based on the item's + * position within the list. This is based on code by Ying Kit Yuen at: + * http://eureka.ykyuen.info/2010/03/15/android-%E2%80%93-applying-alternate-row-color-in-listview-with-simpleadapter/ + * + * Created by sbeitzel on 8/1/13. + */ +public class ColorItemAdapter extends SimpleAdapter { + private static final int[] COLORS = new int[] {0x30FF0000, 0x300000FF}; // dark red, blue + + public ColorItemAdapter(Context context, List> data, int resource, String[] from, int[] to) { + super(context, data, resource, from, to); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + View view = super.getView(position, convertView, parent); + int colorPos = position % COLORS.length; + assert view != null; + view.setBackgroundColor(COLORS[colorPos]); + return view; + } + +} diff --git a/src/com/BreakingBytes/SifterReader/IssuesActivity.java b/src/com/BreakingBytes/SifterReader/IssuesActivity.java index f963160..cbc88f9 100644 --- a/src/com/BreakingBytes/SifterReader/IssuesActivity.java +++ b/src/com/BreakingBytes/SifterReader/IssuesActivity.java @@ -318,7 +318,7 @@ private void fillData() { mSifterHelper.onException(e.toString()); return; } - ListAdapter adapter = new SimpleAdapter(this, issuesList, + ListAdapter adapter = new ColorItemAdapter(this, issuesList, R.layout.issue_row, new String[] {NUMBER, STATUS, PRIORITY, SUBJECT}, new int[] {R.id.issue_number, R.id.issue_status, R.id.issue_priority, R.id.issue_subject}); From 5011e3cfa0b23ec82d2a1fb858382069f03fbe8d Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Fri, 2 Aug 2013 08:35:09 -0700 Subject: [PATCH 3/3] Adding Android Studio's compiler output directory to the ignore list. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e9fa834..d1c0ec9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Ignore metadata from IDEA (Android Studio) *.iml .idea/ +out/ bin/ gen/ *~