From b78648da71185feec2725cf7dfa55d690753745e Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 30 Oct 2014 19:12:13 +0200 Subject: [PATCH] Simplified code --- .../activities/actions/AppModeDialog.java | 54 ++++--------------- 1 file changed, 11 insertions(+), 43 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java index 000323a0ff..3f01f6803a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java @@ -157,51 +157,19 @@ public class AppModeDialog { } } visible.clear(); - if (selected.size() > 0) { - List positions = new ArrayList(); - for (ApplicationMode mode : selected){ - for (int i =0; i< values.size(); i++){ - if (mode.equals(values.get(i))){ - positions.add(i); - } - } + visible.add(ApplicationMode.DEFAULT); + for (ApplicationMode mode : selected){ + if (mode != ApplicationMode.DEFAULT) { + visible.add(mode); + break; } - - if (positions.size() == 1) { - int pos = positions.get(0); - if (pos < values.size() - 1 && pos > 0){ - visible.add(values.get(pos - 1)); - visible.add(values.get(pos)); - visible.add(values.get(pos + 1)); - } else if (pos == 0) { - visible.add(values.get(pos)); - visible.add(values.get(1)); - visible.add(values.get(2)); - } else if (pos == values.size() -1) { - visible.add(values.get(pos - 1)); - visible.add(values.get(pos - 2)); - visible.add(values.get(pos)); + } + for(ApplicationMode mode : values) { + if (!visible.contains(mode)) { + visible.add(mode); + if (visible.size() == 3){ + break; } - } else if (positions.size() == 2) { - int pos1 = positions.get(0); - int pos2 = positions.get(1); - if (pos1 + 1 != pos2){ - visible.add(values.get(pos1)); - visible.add(values.get(pos1 + 1)); - visible.add(values.get(pos2)); - } else if (pos1 > 0 && pos1 + 1 == pos2) { - visible.add(values.get(pos1 - 1)); - visible.add(values.get(pos1)); - visible.add(values.get(pos2)); - } else if (pos1 == 0 && pos1 + 1 == pos2) { - visible.add(values.get(pos1)); - visible.add(values.get(pos2)); - visible.add(values.get(pos2 + 1)); - } - } - } else { - for (int i =0; i<3; i++){ - visible.add(values.get(i)); } } }