From 8c4b878e215378290a6f01a07b24fa9425af8ccd Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 29 Dec 2012 09:35:44 -0800 Subject: [PATCH] preserve order of groups when removing one by removing it from list rather than allowing list to be regenerated. --- .../org/eehouse/android/xw4/GameListAdapter.java | 13 +++++++++++++ .../src/org/eehouse/android/xw4/GamesList.java | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java index e538a15c1..8e8902807 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -88,6 +88,19 @@ public class GameListAdapter implements ExpandableListAdapter { return success; } + public boolean removeGroup( long groupid ) + { + long[] newArray = new long[m_positions.length - 1]; + int destIndex = 0; + for ( long id : m_positions ) { + if ( id != groupid ) { + newArray[destIndex++] = id; + } + } + m_positions = newArray; + return true; + } + public void expandGroups( ExpandableListView view ) { HashMap info = gameInfo(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java index 60b08e681..41b35f383 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -554,7 +554,9 @@ public class GamesList extends XWExpandableListActivity case DELETE_GROUP_ACTION: GameUtils.deleteGroup( this, m_groupid ); - onContentChanged(); + if ( m_adapter.removeGroup( m_groupid ) ) { + onContentChanged(); + } break; default: Assert.fail();