mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
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:
commit
6ee43b389c
2 changed files with 25 additions and 12 deletions
|
@ -26,7 +26,6 @@ import com.newsblur.activity.AllStoriesItemsList;
|
||||||
import com.newsblur.domain.Folder;
|
import com.newsblur.domain.Folder;
|
||||||
import com.newsblur.util.AppConstants;
|
import com.newsblur.util.AppConstants;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
|
@ -173,13 +172,12 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getChildId(int groupPosition, int childPosition) {
|
public long getChildId(int groupPosition, int childPosition) {
|
||||||
if (groupPosition == 0) {
|
if (groupPosition == 0) {
|
||||||
return blogCursorHelper.getId(childPosition);
|
return blogCursorHelper.getId(childPosition);
|
||||||
} else {
|
} else {
|
||||||
groupPosition = groupPosition - 2;
|
MyCursorHelper childrenCursorHelper = getChildrenCursorHelper(groupPosition - 2, true);
|
||||||
return getChildrenCursorHelper(groupPosition, true).getId(childPosition);
|
return childrenCursorHelper.getId(childPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,9 +249,22 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
||||||
@Override
|
@Override
|
||||||
public long getGroupId(int groupPosition) {
|
public long getGroupId(int groupPosition) {
|
||||||
if (groupPosition >= 2) {
|
if (groupPosition >= 2) {
|
||||||
return folderCursorHelper.getId(groupPosition);
|
return folderCursorHelper.getId(groupPosition-2);
|
||||||
} else {
|
} 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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,8 +127,8 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
|
||||||
sharedPreferences = getActivity().getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
sharedPreferences = getActivity().getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < folderAdapter.getGroupCount(); i++) {
|
for (int i = 0; i < folderAdapter.getGroupCount(); i++) {
|
||||||
long groupId = folderAdapter.getGroupId(i);
|
String groupName = folderAdapter.getGroupName(i);
|
||||||
if (sharedPreferences.getBoolean(AppConstants.FOLDER_PRE + groupId, true)) {
|
if (sharedPreferences.getBoolean(AppConstants.FOLDER_PRE + "_" + groupName, true)) {
|
||||||
list.expandGroup(i);
|
list.expandGroup(i);
|
||||||
} else {
|
} else {
|
||||||
list.collapseGroup(i);
|
list.collapseGroup(i);
|
||||||
|
@ -278,19 +278,21 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
|
||||||
folderAdapter.setBlogCursor(blogCursor);
|
folderAdapter.setBlogCursor(blogCursor);
|
||||||
folderAdapter.setGroupCursor(cursor);
|
folderAdapter.setGroupCursor(cursor);
|
||||||
folderAdapter.setCountCursor(countCursor);
|
folderAdapter.setCountCursor(countCursor);
|
||||||
folderAdapter.notifyDataSetChanged();
|
folderAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
checkOpenFolderPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onGroupClick(ExpandableListView list, View group, int groupPosition, long id) {
|
public boolean onGroupClick(ExpandableListView list, View group, int groupPosition, long id) {
|
||||||
if (folderAdapter.isExpandable(groupPosition)) {
|
if (folderAdapter.isExpandable(groupPosition)) {
|
||||||
long groupId = folderAdapter.getGroupId(groupPosition);
|
String groupName = folderAdapter.getGroupName(groupPosition);
|
||||||
if (list.isGroupExpanded(groupPosition)) {
|
if (list.isGroupExpanded(groupPosition)) {
|
||||||
group.findViewById(R.id.row_foldersums).setVisibility(View.VISIBLE);
|
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 {
|
} else {
|
||||||
group.findViewById(R.id.row_foldersums).setVisibility(View.INVISIBLE);
|
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;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue