Skip to content

Commit

Permalink
One (random) color per intend in headline activity
Browse files Browse the repository at this point in the history
  • Loading branch information
jfreax committed Oct 3, 2013
1 parent af67bb0 commit 27e36c5
Showing 1 changed file with 49 additions and 40 deletions.
89 changes: 49 additions & 40 deletions src/de/jdsoft/law/LawHeadlineFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -624,49 +624,58 @@ public View getView(int position, View convertView, ViewGroup parent) {
LawHeadline item = getItem(position);
int currentDepth = Math.abs(item.depth);

if (item.color == -1) {
if (position == 0) {
currentDepth = 1;
colorForDepth[currentDepth] = COLOR[rand.nextInt(COLOR.length)];
// setPseudoDepthOnPosition(position, 0);
} else {
int lastDepth = getDepthOfPosition(position - 1);

if (getPseudoDepthOnPosition(position - 1) != -1) {

if (currentDepth == lastDepth) {
setPseudoDepthOnPosition(position, getPseudoDepthOnPosition(position - 1));
currentDepth = getPseudoDepthOnPosition(position - 1);
}
lastDepth = getPseudoDepthOnPosition(position - 1);
}

// One depth deeper, so we need a new color
if (currentDepth > lastDepth) {
if (currentDepth - lastDepth > 1) {
setPseudoDepthOnPosition(position, lastDepth + 1);
currentDepth = lastDepth + 1;
}

colorForDepth[currentDepth] = COLOR[rand.nextInt(COLOR.length)];

} else {
// We are now more then one depth higher, add some space
if (lastDepth - currentDepth > 1) {
item.padding = 24;
}

if (colorForDepth[currentDepth] == 0) {
colorForDepth[currentDepth] = COLOR[rand.nextInt(COLOR.length)];
}
}
}
item.color = colorForDepth[currentDepth];
item.intend = currentDepth; // save new depth
} else {
currentDepth = item.intend; // load saved intend depth
if (colorForDepth[currentDepth] == 0) {
colorForDepth[currentDepth] = COLOR[rand.nextInt(COLOR.length)];
}

item.color = colorForDepth[currentDepth];
item.intend = currentDepth; // save new depth


// if (item.color == -1) {
// if (position == 0) {
// currentDepth = 1;
// colorForDepth[currentDepth] = COLOR[rand.nextInt(COLOR.length)];
//// setPseudoDepthOnPosition(position, 0);
// } else {
// int lastDepth = getDepthOfPosition(position - 1);
//
// if (getPseudoDepthOnPosition(position - 1) != -1) {
//
// if (currentDepth == lastDepth) {
// setPseudoDepthOnPosition(position, getPseudoDepthOnPosition(position - 1));
// currentDepth = getPseudoDepthOnPosition(position - 1);
// }
// lastDepth = getPseudoDepthOnPosition(position - 1);
// }
//
// // One depth deeper, so we need a new color
// if (currentDepth > lastDepth) {
// if (currentDepth - lastDepth > 1) {
// setPseudoDepthOnPosition(position, lastDepth + 1);
// currentDepth = lastDepth + 1;
// }
//
// colorForDepth[currentDepth] = COLOR[rand.nextInt(COLOR.length)];
//
// } else {
// // We are now more then one depth higher, add some space
// if (lastDepth - currentDepth > 1) {
// item.padding = 24;
// }
//
// if (colorForDepth[currentDepth] == 0) {
// colorForDepth[currentDepth] = COLOR[rand.nextInt(COLOR.length)];
// }
// }
// }
// item.color = colorForDepth[currentDepth];
// item.intend = currentDepth; // save new depth
// } else {
// currentDepth = item.intend; // load saved intend depth
// }

holder.separator.setBackgroundColor(item.color);

// Intend
Expand Down

0 comments on commit 27e36c5

Please sign in to comment.