Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Ignore metadata from IDEA (Android Studio)
*.iml
.idea/
out/
bin/
gen/
*~
34 changes: 34 additions & 0 deletions src/com/BreakingBytes/SifterReader/ColorItemAdapter.java
Original file line number Diff line number Diff line change
@@ -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<? extends Map<String, ?>> 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;
}

}
2 changes: 1 addition & 1 deletion src/com/BreakingBytes/SifterReader/IssuesActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down