From 27e36c5b5e0ae9b5ea86088588baebaefdfbc383 Mon Sep 17 00:00:00 2001 From: Jens Dieskau Date: Thu, 3 Oct 2013 16:34:38 +0200 Subject: [PATCH] One (random) color per intend in headline activity --- src/de/jdsoft/law/LawHeadlineFragment.java | 89 ++++++++++++---------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/src/de/jdsoft/law/LawHeadlineFragment.java b/src/de/jdsoft/law/LawHeadlineFragment.java index 4507379..e23be07 100644 --- a/src/de/jdsoft/law/LawHeadlineFragment.java +++ b/src/de/jdsoft/law/LawHeadlineFragment.java @@ -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