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

@ -27,9 +27,12 @@ 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;
@ -125,37 +128,67 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
@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;
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;
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;
View v;
if (groupPosition == 0) {
blogCursorHelper.moveTo(childPosition);
if (convertView == null) {
v = newBlogView(context, blogCursorHelper.getCursor(), parent);
} else {
v = convertView;
}
bindBlogView(v, context, blogCursorHelper.getCursor());
} else {
groupPosition = groupPosition - 2;
MyCursorHelper cursorHelper = getChildrenCursorHelper(groupPosition, true);
@ -163,27 +196,28 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
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);
} else {
v = convertView;
}
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;
}
groupPosition = groupPosition - blogCursorHelper.getCount() - 1;
} else {
groupPosition = groupPosition - 2;
MyCursorHelper helper = getChildrenCursorHelper(groupPosition, true);
return (folderCursorHelper.isValid() && helper != null) ? helper.getCount() : 0;
}
}
public View newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup parent) {
return inflater.inflate(childLayout, parent, false);
@ -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
@ -229,27 +259,24 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
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 {

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);