Added all blurblog categories to an All Shared Stories folder.

This commit is contained in:
RyanBateman 2012-09-03 13:14:00 -04:00
parent d5b6f1ea8e
commit 233b51870a
9 changed files with 173 additions and 93 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 848 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/newsblur_blue"
android:paddingBottom="15dp"
android:paddingTop="15dp" >
<ImageView
android:id="@+id/row_everything_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="18dp"
android:layout_marginRight="12dp"
android:contentDescription="@string/description_row_folder_icon"
android:src="@drawable/person" />
<TextView
android:id="@+id/row_everythingtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="50dp"
android:text="@string/all_shared_stories"
android:textColor="@color/white"
android:textSize="16dp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/row_foldersums"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp" >
<TextView
android:id="@+id/row_foldersumneu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="@drawable/neutral_count_rect"
android:gravity="center"
android:padding="5dp"
android:textColor="@color/white"
android:textSize="12dp"
android:textStyle="bold" />
<TextView
android:id="@+id/row_foldersumpos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="@drawable/positive_count_rect"
android:gravity="center"
android:padding="5dp"
android:textColor="@color/white"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>

View file

@ -40,6 +40,7 @@
<string name="reading_sharedby">SHARED BY: </string>
<string name="everything">All stories</string>
<string name="all_shared_stories">All shared stories</string>
<string name="replied">Reply posted</string>
<string name="error_replying">There was an error replying</string>

View file

@ -23,14 +23,17 @@ import com.newsblur.domain.Folder;
@SuppressWarnings("deprecation")
public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
private Handler mHandler;
private boolean mAutoRequery;
private final int GROUP = 0;
private final int BLOG = 1;
private final int EVERYTHING = 2;
private final int FOLDER = 0;
private final int BLOG = 0;
private final int FEED = 1;
private final int ALL_STORIES = 1;
private final int ALL_SHARED_STORIES = 2;
private SparseArray<MyCursorHelper> mChildrenCursorHelpers;
private MyCursorHelper folderCursorHelper, blogCursorHelper;
private ContentResolver contentResolver;
@ -42,7 +45,7 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
private int[] childTo;
private int[] blogFrom;
private int[] blogTo;
private final int childLayout, expandedGroupLayout, collapsedGroupLayout, blogGroupLayout;
private final LayoutInflater inflater;
private ViewBinder groupViewBinder;
@ -60,7 +63,7 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
this.childLayout = childLayout;
this.blogGroupLayout = blogGroupLayout;
this.countCursor = countCursor;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
contentResolver = context.getContentResolver();
@ -71,15 +74,15 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
init(groupFrom, groupTo, childFrom, childTo, blogFrom, blogTo);
}
private void init(final String[] groupFromNames, final int[] groupTo, final String[] childFromNames, final int[] childTo, final String[] blogFromNames, final int[] blogTo) {
this.groupTo = groupTo;
this.childTo = childTo;
this.blogTo = blogTo;
initGroupFromColumns(groupFromNames);
initBlogFromColumns(blogFromNames);
if (getGroupCount() > 0) {
MyCursorHelper tmpCursorHelper = getChildrenCursorHelper(0, true);
if (tmpCursorHelper != null) {
@ -105,7 +108,7 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
groupFrom = new int[groupFromNames.length];
initFromColumns(folderCursorHelper.getCursor(), groupFromNames, groupFrom);
}
private void initBlogFromColumns(String[] blogFromNames) {
blogFrom = new int[blogFromNames.length];
initFromColumns(blogCursorHelper.getCursor(), blogFromNames, blogFrom);
@ -122,67 +125,98 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
uri = FeedProvider.FEED_FOLDER_MAP_URI.buildUpon().appendPath(parentFolder.getName()).build();
return contentResolver.query(uri, null, null, new String[] { currentState }, null);
}
@Override
public int getGroupType(int groupPosition) {
if (groupPosition < blogCursorHelper.getCount()) {
return BLOG;
} else if (groupPosition == blogCursorHelper.getCount()) {
return EVERYTHING;
if (groupPosition == 0) {
return ALL_SHARED_STORIES;
} else if (groupPosition == 1) {
return ALL_STORIES;
} else {
return GROUP;
return FOLDER;
}
}
public int getChildType(int groupPosition, int childPosition) {
if (groupPosition == 0) {
return BLOG;
} else {
return FEED;
}
};
@Override
public int getGroupTypeCount() {
return 3;
}
@Override
public int getChildTypeCount() {
return 2;
}
@Override
public Cursor getChild(int groupPosition, int childPosition) {
groupPosition = groupPosition - blogCursorHelper.getCount() - 1;
return getChildrenCursorHelper(groupPosition, true).moveTo(childPosition);
if (groupPosition == 0) {
blogCursorHelper.moveTo(childPosition);
return blogCursorHelper.getCursor();
} else {
groupPosition = groupPosition - 2;
return getChildrenCursorHelper(groupPosition, true).moveTo(childPosition);
}
}
@Override
public long getChildId(int groupPosition, int childPosition) {
groupPosition = groupPosition - blogCursorHelper.getCount() - 1;
return getChildrenCursorHelper(groupPosition, true).getId(childPosition);
if (groupPosition == 0) {
return blogCursorHelper.getId(childPosition);
} else {
groupPosition = groupPosition - 2;
return getChildrenCursorHelper(groupPosition, true).getId(childPosition);
}
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
groupPosition = groupPosition - blogCursorHelper.getCount() - 1;
MyCursorHelper cursorHelper = getChildrenCursorHelper(groupPosition, true);
Cursor cursor = cursorHelper.moveTo(childPosition);
if (cursor == null) {
throw new IllegalStateException("This should only be called when the cursor is valid");
}
View v;
if (convertView == null) {
v = newChildView(context, cursor, isLastChild, parent);
if (groupPosition == 0) {
blogCursorHelper.moveTo(childPosition);
if (convertView == null) {
v = newBlogView(context, blogCursorHelper.getCursor(), parent);
} else {
v = convertView;
}
bindBlogView(v, context, blogCursorHelper.getCursor());
} else {
v = convertView;
groupPosition = groupPosition - 2;
MyCursorHelper cursorHelper = getChildrenCursorHelper(groupPosition, true);
Cursor cursor = cursorHelper.moveTo(childPosition);
if (cursor == null) {
throw new IllegalStateException("This should only be called when the cursor is valid");
}
if (convertView == null) {
v = newChildView(context, cursor, isLastChild, parent);
} else {
v = convertView;
}
bindChildView(v, context, cursor, isLastChild);
}
bindChildView(v, context, cursor, isLastChild);
return v;
}
@Override
public int getChildrenCount(int groupPosition) {
if (groupPosition <= blogCursorHelper.getCount()) {
if (groupPosition == 0) {
return blogCursorHelper.getCount();
} else if (groupPosition == 1) {
return 0;
} else {
groupPosition = groupPosition - 2;
MyCursorHelper helper = getChildrenCursorHelper(groupPosition, true);
return (folderCursorHelper.isValid() && helper != null) ? helper.getCount() : 0;
}
groupPosition = groupPosition - blogCursorHelper.getCount() - 1;
MyCursorHelper helper = getChildrenCursorHelper(groupPosition, true);
return (folderCursorHelper.isValid() && helper != null) ? helper.getCount() : 0;
}
public View newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup parent) {
@ -191,24 +225,20 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
@Override
public Cursor getGroup(int groupPosition) {
if (groupPosition >= blogCursorHelper.getCount()) {
return folderCursorHelper.moveTo(groupPosition - blogCursorHelper.getCount() - 1);
if (groupPosition >= 2) {
return folderCursorHelper.moveTo(groupPosition - 2);
} else {
return blogCursorHelper.moveTo(groupPosition);
}
}
public boolean isGroup(int groupPosition) {
return (groupPosition > blogCursorHelper.getCount());
}
public boolean isBlog(int groupPosition) {
return (groupPosition < blogCursorHelper.getCount());
public boolean isExpandable(int groupPosition) {
return (groupPosition == 0 || groupPosition > 1);
}
@Override
public int getGroupCount() {
return (folderCursorHelper.getCount() + blogCursorHelper.getCount());
return (folderCursorHelper.getCount() + 2);
}
@Override
@ -223,33 +253,30 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
public void setBlogCursor(Cursor blogCursor) {
blogCursorHelper.changeCursor(blogCursor, false);
}
public void setCountCursor(Cursor countCursor) {
this.countCursor = countCursor;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
Cursor cursor = null;
View v;
if (groupPosition < blogCursorHelper.getCount()) {
cursor = blogCursorHelper.moveTo(groupPosition);
if (convertView == null) {
v = newBlogView(context, cursor, parent);
} else {
v = convertView;
}
bindBlogView(v, context, cursor);
} else if (groupPosition == blogCursorHelper.getCount()) {
if (groupPosition == 0) {
cursor = countCursor;
v = inflater.inflate(R.layout.row_everything, null, false);
v = inflater.inflate(R.layout.row_all_shared_stories, null, false);
countCursor.moveToFirst();
((TextView) v.findViewById(R.id.row_foldersumneu)).setText(countCursor.getString(countCursor.getColumnIndex(DatabaseConstants.SUM_NEUT)));
((TextView) v.findViewById(R.id.row_foldersumpos)).setText(countCursor.getString(countCursor.getColumnIndex(DatabaseConstants.SUM_POS)));
} else if (groupPosition == 1) {
cursor = countCursor;
v = inflater.inflate(R.layout.row_all_stories, null, false);
countCursor.moveToFirst();
((TextView) v.findViewById(R.id.row_foldersumneu)).setText(countCursor.getString(countCursor.getColumnIndex(DatabaseConstants.SUM_NEUT)));
((TextView) v.findViewById(R.id.row_foldersumpos)).setText(countCursor.getString(countCursor.getColumnIndex(DatabaseConstants.SUM_POS)));
} else {
cursor = folderCursorHelper.moveTo(groupPosition - blogCursorHelper.getCount() - 1);
cursor = folderCursorHelper.moveTo(groupPosition - 2);
if (convertView == null) {
v = newGroupView(context, cursor, isExpanded, parent);
} else {
@ -257,7 +284,7 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
}
bindGroupView(v, context, cursor, isExpanded);
}
if (cursor == null) {
throw new IllegalStateException("this should only be called when the cursor is valid");
}
@ -268,7 +295,7 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
private View newGroupView(Context context, Cursor cursor, boolean isExpanded, ViewGroup parent) {
return inflater.inflate((isExpanded) ? expandedGroupLayout : collapsedGroupLayout, parent, false);
}
private View newBlogView(Context context, Cursor cursor, ViewGroup parent) {
return inflater.inflate(blogGroupLayout, parent, false);
}
@ -294,11 +321,11 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
bindView(view, context, cursor, groupFrom, groupTo, groupViewBinder);
((ImageView) view.findViewById(R.id.row_folder_icon)).setImageResource(isExpanded ? R.drawable.folder_open : R.drawable.folder_closed);
}
protected void bindBlogView(View view, Context context, Cursor cursor) {
bindView(view, context, cursor, blogFrom, blogTo, blogViewBinder);
}
private void bindView(View view, Context context, Cursor cursor, int[] from, int[] to, ViewBinder viewbinder) {
final ViewBinder binder = viewbinder;
@ -359,7 +386,7 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
public void notifyDataSetChanged() {
notifyDataSetChanged(true);
}
public void notifyDataSetChanged(boolean releaseCursors) {
if (releaseCursors) {
releaseCursorHelpers();
@ -369,18 +396,18 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
}
super.notifyDataSetChanged();
}
public void requery() {
folderCursorHelper.getCursor().requery();
blogCursorHelper.getCursor().requery();
countCursor.requery();
}
@Override
public void notifyDataSetInvalidated() {
releaseCursorHelpers();
super.notifyDataSetInvalidated();
}
public void notifyDataSetInvalidated() {
releaseCursorHelpers();
super.notifyDataSetInvalidated();
}
class MyCursorHelper {
private Cursor mCursor;

View file

@ -102,10 +102,10 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
list.setOnGroupClickListener(this);
list.setOnChildClickListener(this);
int count = folderAdapter.getGroupCount();
for (int position = 1; position <= count; position++) {
list.expandGroup(position - 1);
}
// int count = folderAdapter.getGroupCount();
// for (int position = 1; position <= count; position++) {
// list.expandGroup(position - 1);
// }
return v;
}
@ -144,7 +144,7 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
case R.id.menu_mark_folder_as_read:
int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
if (folderAdapter.isGroup(groupPosition)) {
if (folderAdapter.isExpandable(groupPosition)) {
final Cursor folderCursor = ((MixedExpandableListAdapter) list.getExpandableListAdapter()).getGroup(groupPosition);
String folderId = folderCursor.getString(folderCursor.getColumnIndex(DatabaseConstants.FOLDER_NAME));
new MarkFolderAsReadTask(getActivity(), apiManager, resolver, folderAdapter).execute(folderId);
@ -193,27 +193,13 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
@Override
public boolean onGroupClick(ExpandableListView list, View group, int groupPosition, long id) {
if (folderAdapter.isGroup(groupPosition)) {
if (folderAdapter.isExpandable(groupPosition)) {
if (list.isGroupExpanded(groupPosition)) {
group.findViewById(R.id.row_foldersums).setVisibility(View.VISIBLE);
} else {
group.findViewById(R.id.row_foldersums).setVisibility(View.INVISIBLE);
}
return false;
} else if (folderAdapter.isBlog(groupPosition)) {
Cursor blurblogCursor = folderAdapter.getGroup(groupPosition);
String username = blurblogCursor.getString(blurblogCursor.getColumnIndex(DatabaseConstants.SOCIAL_FEED_USERNAME));
String userIcon = blurblogCursor.getString(blurblogCursor.getColumnIndex(DatabaseConstants.SOCIAL_FEED_ICON));
String userId = blurblogCursor.getString(blurblogCursor.getColumnIndex(DatabaseConstants.SOCIAL_FEED_ID));
final Intent intent = new Intent(getActivity(), SocialFeedItemsList.class);
intent.putExtra(ItemsList.EXTRA_BLURBLOG_USER_ICON, userIcon);
intent.putExtra(ItemsList.EXTRA_BLURBLOG_USERNAME, username);
intent.putExtra(ItemsList.EXTRA_BLURBLOG_USERID, userId);
intent.putExtra(ItemsList.EXTRA_STATE, currentState);
getActivity().startActivityForResult(intent, FEEDCHECK );
return true;
} else {
Intent i = new Intent(getActivity(), EverythingItemsList.class);
i.putExtra(EverythingItemsList.EXTRA_STATE, currentState);