Merge pull request #128 from lance0428/master

Fix duplicate feed problem and folder collapse/expand bug in main feed list view
This commit is contained in:
Samuel Clay 2013-04-01 16:01:06 -07:00
commit 6ee43b389c
2 changed files with 25 additions and 12 deletions

View file

@ -26,7 +26,6 @@ import com.newsblur.activity.AllStoriesItemsList;
import com.newsblur.domain.Folder;
import com.newsblur.util.AppConstants;
@SuppressWarnings("deprecation")
public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
private Handler mHandler;
@ -173,13 +172,12 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
}
}
@Override
public long getChildId(int groupPosition, int childPosition) {
if (groupPosition == 0) {
return blogCursorHelper.getId(childPosition);
} else {
groupPosition = groupPosition - 2;
return getChildrenCursorHelper(groupPosition, true).getId(childPosition);
MyCursorHelper childrenCursorHelper = getChildrenCursorHelper(groupPosition - 2, true);
return childrenCursorHelper.getId(childPosition);
}
}
@ -251,9 +249,22 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
@Override
public long getGroupId(int groupPosition) {
if (groupPosition >= 2) {
return folderCursorHelper.getId(groupPosition);
return folderCursorHelper.getId(groupPosition-2);
} else {
return groupPosition;
return Long.MAX_VALUE - groupPosition;
}
}
public String getGroupName(int groupPosition) {
if (groupPosition == 0) {
return "[ALL_SHARED_STORIES]";
} else if(groupPosition == 1) {
return "[ALL_STORIES]";
} else {
Cursor cursor = folderCursorHelper.getCursor();
cursor.moveToPosition(groupPosition-2);
// Is folder name really always unique?
return cursor.getString(cursor.getColumnIndex("folder_name"));
}
}

View file

@ -127,8 +127,8 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
sharedPreferences = getActivity().getSharedPreferences(PrefConstants.PREFERENCES, 0);
}
for (int i = 0; i < folderAdapter.getGroupCount(); i++) {
long groupId = folderAdapter.getGroupId(i);
if (sharedPreferences.getBoolean(AppConstants.FOLDER_PRE + groupId, true)) {
String groupName = folderAdapter.getGroupName(i);
if (sharedPreferences.getBoolean(AppConstants.FOLDER_PRE + "_" + groupName, true)) {
list.expandGroup(i);
} else {
list.collapseGroup(i);
@ -278,19 +278,21 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
folderAdapter.setBlogCursor(blogCursor);
folderAdapter.setGroupCursor(cursor);
folderAdapter.setCountCursor(countCursor);
folderAdapter.notifyDataSetChanged();
folderAdapter.notifyDataSetChanged();
checkOpenFolderPreferences();
}
@Override
public boolean onGroupClick(ExpandableListView list, View group, int groupPosition, long id) {
if (folderAdapter.isExpandable(groupPosition)) {
long groupId = folderAdapter.getGroupId(groupPosition);
String groupName = folderAdapter.getGroupName(groupPosition);
if (list.isGroupExpanded(groupPosition)) {
group.findViewById(R.id.row_foldersums).setVisibility(View.VISIBLE);
sharedPreferences.edit().putBoolean(AppConstants.FOLDER_PRE + groupId, false).commit();
sharedPreferences.edit().putBoolean(AppConstants.FOLDER_PRE + "_" + groupName, false).commit();
} else {
group.findViewById(R.id.row_foldersums).setVisibility(View.INVISIBLE);
sharedPreferences.edit().putBoolean(AppConstants.FOLDER_PRE + groupId, true).commit();
sharedPreferences.edit().putBoolean(AppConstants.FOLDER_PRE + "_" + groupName, true).commit();
}
return false;
} else {