mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Merge pull request #205 from ojiikun/master
Android: Ensure All Stories / Root Folder Always Appears
This commit is contained in:
commit
88aa70adff
17 changed files with 132 additions and 88 deletions
|
@ -31,7 +31,7 @@ public class AllSharedStoriesReading extends Reading {
|
|||
|
||||
setupCountCursor();
|
||||
|
||||
stories = contentResolver.query(FeedProvider.ALL_SHARED_STORIES_URI, null, FeedProvider.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " desc");
|
||||
stories = contentResolver.query(FeedProvider.ALL_SHARED_STORIES_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " desc");
|
||||
setTitle(getResources().getString(R.string.all_shared_stories));
|
||||
storiesToMarkAsRead = new ValueMultimap();
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), getContentResolver(), stories);
|
||||
|
@ -43,7 +43,7 @@ public class AllSharedStoriesReading extends Reading {
|
|||
}
|
||||
|
||||
private void setupCountCursor() {
|
||||
Cursor cursor = getContentResolver().query(FeedProvider.FEEDS_URI, null, FeedProvider.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " desc");
|
||||
Cursor cursor = getContentResolver().query(FeedProvider.FEEDS_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " desc");
|
||||
startManagingCursor(cursor);
|
||||
feedIds = new ArrayList<String>();
|
||||
while (cursor.moveToNext()) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class AllStoriesItemsList extends ItemsList {
|
|||
apiManager = new APIManager(this);
|
||||
resolver = getContentResolver();
|
||||
|
||||
Cursor cursor = resolver.query(FeedProvider.FEEDS_URI, null, FeedProvider.getStorySelectionFromState(currentState), null, null);
|
||||
Cursor cursor = resolver.query(FeedProvider.FEEDS_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, null);
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
feedIds.add(cursor.getString(cursor.getColumnIndex(DatabaseConstants.FEED_ID)));
|
||||
|
|
|
@ -32,7 +32,7 @@ public class AllStoriesReading extends Reading {
|
|||
|
||||
setupCountCursor();
|
||||
|
||||
stories = contentResolver.query(FeedProvider.ALL_STORIES_URI, null, FeedProvider.getStorySelectionFromState(currentState), null, null);
|
||||
stories = contentResolver.query(FeedProvider.ALL_STORIES_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, null);
|
||||
setTitle(getResources().getString(R.string.all_stories));
|
||||
storiesToMarkAsRead = new ValueMultimap();
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), getContentResolver(), stories);
|
||||
|
@ -44,7 +44,7 @@ public class AllStoriesReading extends Reading {
|
|||
}
|
||||
|
||||
private void setupCountCursor() {
|
||||
Cursor cursor = getContentResolver().query(FeedProvider.FEEDS_URI, null, FeedProvider.getStorySelectionFromState(currentState), null, null);
|
||||
Cursor cursor = getContentResolver().query(FeedProvider.FEEDS_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, null);
|
||||
feedIds = new ArrayList<String>();
|
||||
while (cursor.moveToNext()) {
|
||||
feedIds.add(cursor.getString(cursor.getColumnIndex(DatabaseConstants.FEED_ID)));
|
||||
|
|
|
@ -43,7 +43,7 @@ public class FeedItemsList extends ItemsList {
|
|||
folderName = getIntent().getStringExtra(EXTRA_FOLDER_NAME);
|
||||
|
||||
final Uri feedUri = FeedProvider.FEEDS_URI.buildUpon().appendPath(feedId).build();
|
||||
Cursor cursor = getContentResolver().query(feedUri, null, FeedProvider.getStorySelectionFromState(currentState), null, null);
|
||||
Cursor cursor = getContentResolver().query(feedUri, null, DatabaseConstants.getStorySelectionFromState(currentState), null, null);
|
||||
cursor.moveToFirst();
|
||||
Feed feed = Feed.fromCursor(cursor);
|
||||
setTitle(feed.title);
|
||||
|
@ -143,4 +143,4 @@ public class FeedItemsList extends ItemsList {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class FeedReading extends Reading {
|
|||
|
||||
Uri storiesURI = FeedProvider.FEED_STORIES_URI.buildUpon().appendPath(feedId).build();
|
||||
storiesToMarkAsRead = new HashSet<String>();
|
||||
stories = contentResolver.query(storiesURI, null, FeedProvider.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
stories = contentResolver.query(storiesURI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
|
||||
final Uri feedUri = FeedProvider.FEEDS_URI.buildUpon().appendPath(feedId).build();
|
||||
Cursor feedCursor = contentResolver.query(feedUri, null, null, null, null);
|
||||
|
|
|
@ -41,7 +41,7 @@ public class FolderItemsList extends ItemsList {
|
|||
apiManager = new APIManager(this);
|
||||
|
||||
final Uri feedsUri = FeedProvider.FEED_FOLDER_MAP_URI.buildUpon().appendPath(folderName).build();
|
||||
Cursor cursor = getContentResolver().query(feedsUri, new String[] { DatabaseConstants.FEED_ID } , FeedProvider.getStorySelectionFromState(currentState), null, null);
|
||||
Cursor cursor = getContentResolver().query(feedsUri, new String[] { DatabaseConstants.FEED_ID } , DatabaseConstants.getStorySelectionFromState(currentState), null, null);
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
feedIds.add(cursor.getString(cursor.getColumnIndex(DatabaseConstants.FEED_ID)));
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.newsblur.database.DatabaseConstants;
|
||||
import com.newsblur.database.FeedProvider;
|
||||
import com.newsblur.database.MixedFeedsReadingAdapter;
|
||||
import com.newsblur.domain.ValueMultimap;
|
||||
|
@ -31,7 +32,7 @@ public class FolderReading extends Reading {
|
|||
|
||||
Uri storiesURI = FeedProvider.MULTIFEED_STORIES_URI;
|
||||
storiesToMarkAsRead = new ValueMultimap();
|
||||
stories = contentResolver.query(storiesURI, null, FeedProvider.getStorySelectionFromState(currentState), feedIds, null);
|
||||
stories = contentResolver.query(storiesURI, null, DatabaseConstants.getStorySelectionFromState(currentState), feedIds, null);
|
||||
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), getContentResolver(), stories);
|
||||
setupPager();
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.content.Intent;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.newsblur.database.DatabaseConstants;
|
||||
import com.newsblur.database.FeedProvider;
|
||||
import com.newsblur.database.MixedFeedsReadingAdapter;
|
||||
import com.newsblur.domain.SocialFeed;
|
||||
|
@ -39,7 +40,7 @@ public class SocialFeedReading extends Reading {
|
|||
socialFeed = SocialFeed.fromCursor(contentResolver.query(socialFeedUri, null, null, null, null));
|
||||
|
||||
Uri storiesURI = FeedProvider.SOCIALFEED_STORIES_URI.buildUpon().appendPath(userId).build();
|
||||
stories = contentResolver.query(storiesURI, null, FeedProvider.getStorySelectionFromState(currentState), null, null);
|
||||
stories = contentResolver.query(storiesURI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, null);
|
||||
setTitle(getIntent().getStringExtra(EXTRA_USERNAME));
|
||||
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), getContentResolver(), stories);
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.newsblur.database;
|
|||
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
import com.newsblur.util.AppConstants;
|
||||
|
||||
public class DatabaseConstants {
|
||||
|
||||
public static final String FOLDER_TABLE = "folders";
|
||||
|
@ -134,14 +136,17 @@ public class DatabaseConstants {
|
|||
FOLDER_TABLE + "." + FOLDER_ID, FOLDER_TABLE + "." + FOLDER_NAME, " SUM(" + FEED_POSITIVE_COUNT + ") AS " + SUM_POS, " SUM(" + FEED_NEUTRAL_COUNT + ") AS " + SUM_NEUT, " SUM(" + FEED_NEGATIVE_COUNT + ") AS " + SUM_NEG
|
||||
};
|
||||
|
||||
public static final String FOLDER_INTELLIGENCE_ALL = " HAVING SUM(" + DatabaseConstants.FEED_NEGATIVE_COUNT + " + " + DatabaseConstants.FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.FEED_POSITIVE_COUNT + ") >= 0 ";
|
||||
public static final String FOLDER_INTELLIGENCE_SOME = " HAVING SUM(" + DatabaseConstants.FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
public static final String FOLDER_INTELLIGENCE_BEST = " HAVING SUM(" + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
// this union clause lets folder queries also select the "root" folder that should appear whether or not it has unread stories
|
||||
private static final String FOLDER_UNION_ROOT = " OR " + DatabaseConstants.FOLDER_TABLE + "." + DatabaseConstants.FOLDER_NAME + "='" + AppConstants.ROOT_FOLDER + "'";
|
||||
|
||||
public static final String SOCIAL_INTELLIGENCE_ALL = "";
|
||||
public static final String SOCIAL_INTELLIGENCE_SOME = " (" + DatabaseConstants.SOCIAL_FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.SOCIAL_FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
public static final String SOCIAL_INTELLIGENCE_BEST = " (" + DatabaseConstants.SOCIAL_FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
private static final String SUM_STORY_TOTAL = "storyTotal";
|
||||
private static final String FOLDER_INTELLIGENCE_ALL = " HAVING SUM(" + DatabaseConstants.FEED_NEGATIVE_COUNT + " + " + DatabaseConstants.FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.FEED_POSITIVE_COUNT + ") >= 0";
|
||||
private static final String FOLDER_INTELLIGENCE_SOME = " HAVING SUM(" + DatabaseConstants.FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0";
|
||||
private static final String FOLDER_INTELLIGENCE_BEST = " HAVING SUM(" + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0";
|
||||
|
||||
private static final String SOCIAL_INTELLIGENCE_ALL = "";
|
||||
private static final String SOCIAL_INTELLIGENCE_SOME = " (" + DatabaseConstants.SOCIAL_FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.SOCIAL_FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
private static final String SOCIAL_INTELLIGENCE_BEST = " (" + DatabaseConstants.SOCIAL_FEED_POSITIVE_COUNT + ") > 0 ";
|
||||
private static final String SUM_STORY_TOTAL = "storyTotal";
|
||||
|
||||
|
||||
private static String STORY_SUM_TOTAL = " CASE " +
|
||||
|
@ -161,6 +166,80 @@ public class DatabaseConstants {
|
|||
STORY_PERMALINK, STORY_READ, STORY_SHARE_COUNT, STORY_TAGS, STORY_TITLE, STORY_SOCIAL_USER_ID, STORY_SOURCE_USER_ID, STORY_SHARED_USER_IDS, STORY_FRIEND_USER_IDS, STORY_PUBLIC_USER_IDS, STORY_SUM_TOTAL
|
||||
};
|
||||
|
||||
/**
|
||||
* Selection args to filter stories.
|
||||
*/
|
||||
public static String getStorySelectionFromState(int state) {
|
||||
String selection = null;
|
||||
switch (state) {
|
||||
case (AppConstants.STATE_ALL):
|
||||
selection = STORY_INTELLIGENCE_ALL;
|
||||
break;
|
||||
case (AppConstants.STATE_SOME):
|
||||
selection = STORY_INTELLIGENCE_SOME;
|
||||
break;
|
||||
case (AppConstants.STATE_BEST):
|
||||
selection = STORY_INTELLIGENCE_BEST;
|
||||
break;
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selection args to filter folders. This always additionally includes the root folder and assumes folders are joined with feed counts.
|
||||
*/
|
||||
public static String getFolderSelectionFromState(int state) {
|
||||
String selection = null;
|
||||
switch (state) {
|
||||
case (AppConstants.STATE_ALL):
|
||||
selection = FOLDER_INTELLIGENCE_ALL + FOLDER_UNION_ROOT;
|
||||
break;
|
||||
case (AppConstants.STATE_SOME):
|
||||
selection = FOLDER_INTELLIGENCE_SOME + FOLDER_UNION_ROOT;
|
||||
break;
|
||||
case (AppConstants.STATE_BEST):
|
||||
selection = FOLDER_INTELLIGENCE_BEST + FOLDER_UNION_ROOT;
|
||||
break;
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selection args to filter feeds. Watch out: cheats and uses the same args as from folder selection.
|
||||
*/
|
||||
public static String getFeedSelectionFromState(int state) {
|
||||
String selection = null;
|
||||
switch (state) {
|
||||
case (AppConstants.STATE_ALL):
|
||||
selection = FOLDER_INTELLIGENCE_ALL;
|
||||
break;
|
||||
case (AppConstants.STATE_SOME):
|
||||
selection = FOLDER_INTELLIGENCE_SOME;
|
||||
break;
|
||||
case (AppConstants.STATE_BEST):
|
||||
selection = FOLDER_INTELLIGENCE_BEST;
|
||||
break;
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selection args to filter social feeds.
|
||||
*/
|
||||
public static String getBlogSelectionFromState(int state) {
|
||||
String selection = null;
|
||||
switch (state) {
|
||||
case (AppConstants.STATE_ALL):
|
||||
selection = SOCIAL_INTELLIGENCE_ALL;
|
||||
break;
|
||||
case (AppConstants.STATE_SOME):
|
||||
selection = SOCIAL_INTELLIGENCE_SOME;
|
||||
break;
|
||||
case (AppConstants.STATE_BEST):
|
||||
selection = SOCIAL_INTELLIGENCE_BEST;
|
||||
break;
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -273,6 +273,12 @@ public class FeedProvider extends ContentProvider {
|
|||
|
||||
@Override
|
||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||
|
||||
// TODO: the fact that most of the app uses this subclass of ContentProvider cast as such may
|
||||
// deepy confuse future maintainers as to why the .query() method magically does far, far more
|
||||
// than suggested by the normal contract and provided args. This method should be renamed
|
||||
// to make it painfully obvious that it expands upon the normal ContentProvider.query contract.
|
||||
|
||||
final SQLiteDatabase db = databaseHelper.getReadableDatabase();
|
||||
switch (uriMatcher.match(uri)) {
|
||||
|
||||
|
@ -421,6 +427,8 @@ public class FeedProvider extends ContentProvider {
|
|||
StringBuilder folderBuilder = new StringBuilder();
|
||||
folderBuilder.append(folderQuery);
|
||||
if (selectionArgs != null && selectionArgs.length > 0) {
|
||||
// TODO: by not iterating over the selectionArgs array, this method wildly breaks the contract of the query() method and
|
||||
// will almost certainly confuse callers eventually
|
||||
folderBuilder.append(selectionArgs[0]);
|
||||
}
|
||||
folderBuilder.append(" ORDER BY ");
|
||||
|
@ -506,39 +514,5 @@ public class FeedProvider extends ContentProvider {
|
|||
throw new UnsupportedOperationException("Unknown URI: " + uri);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getStorySelectionFromState(int state) {
|
||||
String selection = null;
|
||||
switch (state) {
|
||||
case (AppConstants.STATE_ALL):
|
||||
selection = DatabaseConstants.STORY_INTELLIGENCE_ALL;
|
||||
break;
|
||||
case (AppConstants.STATE_SOME):
|
||||
selection = DatabaseConstants.STORY_INTELLIGENCE_SOME;
|
||||
break;
|
||||
case (AppConstants.STATE_BEST):
|
||||
selection = DatabaseConstants.STORY_INTELLIGENCE_BEST;
|
||||
break;
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
public static String getFolderSelectionFromState(int state) {
|
||||
String selection = null;
|
||||
switch (state) {
|
||||
case (AppConstants.STATE_ALL):
|
||||
selection = DatabaseConstants.FOLDER_INTELLIGENCE_ALL;
|
||||
break;
|
||||
case (AppConstants.STATE_SOME):
|
||||
selection = DatabaseConstants.FOLDER_INTELLIGENCE_SOME;
|
||||
break;
|
||||
case (AppConstants.STATE_BEST):
|
||||
selection = DatabaseConstants.FOLDER_INTELLIGENCE_BEST;
|
||||
break;
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
|||
private Cursor getChildrenCursor(Cursor folderCursor) {
|
||||
final Folder parentFolder = Folder.fromCursor(folderCursor);
|
||||
Uri uri = FeedProvider.FEED_FOLDER_MAP_URI.buildUpon().appendPath(parentFolder.getName()).build();
|
||||
return contentResolver.query(uri, null, null, new String[] { FeedProvider.getFolderSelectionFromState(currentState) }, null);
|
||||
return contentResolver.query(uri, null, null, new String[] { DatabaseConstants.getFeedSelectionFromState(currentState) }, null);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -102,7 +102,7 @@ public class AllSharedStoriesItemListFragment extends ItemListFragment implement
|
|||
@Override
|
||||
public void changeState(int state) {
|
||||
currentState = state;
|
||||
Cursor cursor = contentResolver.query(FeedProvider.ALL_SHARED_STORIES_URI, null, FeedProvider.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " desc");
|
||||
Cursor cursor = contentResolver.query(FeedProvider.ALL_SHARED_STORIES_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " desc");
|
||||
adapter.swapCursor(cursor);
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class AllSharedStoriesItemListFragment extends ItemListFragment implement
|
|||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), FeedProvider.ALL_SHARED_STORIES_URI, null, FeedProvider.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " desc");
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), FeedProvider.ALL_SHARED_STORIES_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " desc");
|
||||
return cursorLoader;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class AllStoriesItemListFragment extends ItemListFragment implements Load
|
|||
itemList.setEmptyView(v.findViewById(R.id.empty_view));
|
||||
|
||||
contentResolver = getActivity().getContentResolver();
|
||||
Cursor cursor = contentResolver.query(FeedProvider.ALL_STORIES_URI, null, FeedProvider.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
Cursor cursor = contentResolver.query(FeedProvider.ALL_STORIES_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
|
||||
String[] groupFrom = new String[] { DatabaseConstants.STORY_TITLE, DatabaseConstants.STORY_AUTHORS, DatabaseConstants.STORY_TITLE, DatabaseConstants.STORY_SHORTDATE, DatabaseConstants.STORY_INTELLIGENCE_AUTHORS, DatabaseConstants.FEED_TITLE };
|
||||
int[] groupTo = new int[] { R.id.row_item_title, R.id.row_item_author, R.id.row_item_title, R.id.row_item_date, R.id.row_item_sidebar, R.id.row_item_feedtitle };
|
||||
|
@ -95,7 +95,7 @@ public class AllStoriesItemListFragment extends ItemListFragment implements Load
|
|||
@Override
|
||||
public void changeState(int state) {
|
||||
currentState = state;
|
||||
final String selection = FeedProvider.getStorySelectionFromState(state);
|
||||
final String selection = DatabaseConstants.getStorySelectionFromState(state);
|
||||
Cursor cursor = contentResolver.query(FeedProvider.ALL_STORIES_URI, null, selection, null, DatabaseConstants.STORY_SHARED_DATE + " DESC");
|
||||
adapter.swapCursor(cursor);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class AllStoriesItemListFragment extends ItemListFragment implements Load
|
|||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), FeedProvider.ALL_STORIES_URI, null, FeedProvider.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_SHARED_DATE + " DESC");
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), FeedProvider.ALL_STORIES_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_SHARED_DATE + " DESC");
|
||||
return cursorLoader;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public class FeedItemListFragment extends ItemListFragment implements LoaderMana
|
|||
|
||||
contentResolver = getActivity().getContentResolver();
|
||||
storiesUri = FeedProvider.FEED_STORIES_URI.buildUpon().appendPath(feedId).build();
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, FeedProvider.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
|
||||
setupFeed();
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class FeedItemListFragment extends ItemListFragment implements LoaderMana
|
|||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {
|
||||
Uri uri = FeedProvider.FEED_STORIES_URI.buildUpon().appendPath(feedId).build();
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), uri, null, FeedProvider.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), uri, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
return cursorLoader;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ public class FeedItemListFragment extends ItemListFragment implements LoaderMana
|
|||
}
|
||||
|
||||
private void refreshStories() {
|
||||
final String selection = FeedProvider.getStorySelectionFromState(currentState);
|
||||
final String selection = DatabaseConstants.getStorySelectionFromState(currentState);
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, selection, null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
adapter.swapCursor(cursor);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public class FolderItemListFragment extends ItemListFragment implements LoaderMa
|
|||
contentResolver = getActivity().getContentResolver();
|
||||
storiesUri = FeedProvider.MULTIFEED_STORIES_URI;
|
||||
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, FeedProvider.getStorySelectionFromState(currentState), feedIds, null);
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, DatabaseConstants.getStorySelectionFromState(currentState), feedIds, null);
|
||||
getActivity().startManagingCursor(cursor);
|
||||
|
||||
String[] groupFrom = new String[] { DatabaseConstants.STORY_TITLE, DatabaseConstants.FEED_TITLE, DatabaseConstants.STORY_READ, DatabaseConstants.STORY_SHORTDATE, DatabaseConstants.STORY_INTELLIGENCE_AUTHORS, DatabaseConstants.STORY_AUTHORS };
|
||||
|
@ -109,7 +109,7 @@ public class FolderItemListFragment extends ItemListFragment implements LoaderMa
|
|||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {
|
||||
Uri uri = FeedProvider.MULTIFEED_STORIES_URI;
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), uri, null, FeedProvider.getStorySelectionFromState(currentState), feedIds, DatabaseConstants.STORY_DATE + " DESC");
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), uri, null, DatabaseConstants.getStorySelectionFromState(currentState), feedIds, DatabaseConstants.STORY_DATE + " DESC");
|
||||
return cursorLoader;
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ public class FolderItemListFragment extends ItemListFragment implements LoaderMa
|
|||
|
||||
public void changeState(int state) {
|
||||
currentState = state;
|
||||
final String selection = FeedProvider.getStorySelectionFromState(state);
|
||||
final String selection = DatabaseConstants.getStorySelectionFromState(state);
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, selection, feedIds, DatabaseConstants.STORY_DATE + " DESC");
|
||||
getActivity().startManagingCursor(cursor);
|
||||
adapter.swapCursor(cursor);
|
||||
|
|
|
@ -63,10 +63,11 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
|
|||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Cursor folderCursor = resolver.query(FeedProvider.FOLDERS_URI, null, null, new String[] { DatabaseConstants.FOLDER_INTELLIGENCE_SOME }, null);
|
||||
Cursor socialFeedCursor = resolver.query(FeedProvider.SOCIAL_FEEDS_URI, null, DatabaseConstants.SOCIAL_INTELLIGENCE_SOME, null, null);
|
||||
Cursor countCursor = resolver.query(FeedProvider.FEED_COUNT_URI, null, DatabaseConstants.SOCIAL_INTELLIGENCE_SOME, null, null);
|
||||
Cursor sharedCountCursor = resolver.query(FeedProvider.SOCIALCOUNT_URI, null, DatabaseConstants.SOCIAL_INTELLIGENCE_SOME, null, null);
|
||||
// all cursors are initially queried in the "some" unread state to match the default view mode
|
||||
Cursor folderCursor = resolver.query(FeedProvider.FOLDERS_URI, null, null, new String[] { DatabaseConstants.getFolderSelectionFromState(AppConstants.STATE_SOME) }, null);
|
||||
Cursor socialFeedCursor = resolver.query(FeedProvider.SOCIAL_FEEDS_URI, null, DatabaseConstants.getBlogSelectionFromState(AppConstants.STATE_SOME), null, null);
|
||||
Cursor countCursor = resolver.query(FeedProvider.FEED_COUNT_URI, null, DatabaseConstants.getBlogSelectionFromState(AppConstants.STATE_SOME), null, null);
|
||||
Cursor sharedCountCursor = resolver.query(FeedProvider.SOCIALCOUNT_URI, null, DatabaseConstants.getBlogSelectionFromState(AppConstants.STATE_SOME), null, null);
|
||||
|
||||
ImageLoader imageLoader = ((NewsBlurApplication) getActivity().getApplicationContext()).getImageLoader();
|
||||
groupViewBinder = new FolderTreeViewBinder(imageLoader);
|
||||
|
@ -219,7 +220,7 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
|
|||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... arg) {
|
||||
Cursor cursor = resolver.query(FeedProvider.FEEDS_URI, null, FeedProvider.getStorySelectionFromState(currentState), null, null);
|
||||
Cursor cursor = resolver.query(FeedProvider.FEEDS_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, null);
|
||||
while (cursor.moveToNext()) {
|
||||
feedIds.add(cursor.getString(cursor.getColumnIndex(DatabaseConstants.FEED_ID)));
|
||||
}
|
||||
|
@ -250,30 +251,18 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
|
|||
}
|
||||
|
||||
public void changeState(int state) {
|
||||
String groupSelection = null, blogSelection = null;
|
||||
groupViewBinder.setState(state);
|
||||
blogViewBinder.setState(state);
|
||||
currentState = state;
|
||||
|
||||
switch (state) {
|
||||
case (AppConstants.STATE_ALL):
|
||||
groupSelection = DatabaseConstants.FOLDER_INTELLIGENCE_ALL;
|
||||
blogSelection = DatabaseConstants.SOCIAL_INTELLIGENCE_ALL;
|
||||
break;
|
||||
case (AppConstants.STATE_SOME):
|
||||
groupSelection = DatabaseConstants.FOLDER_INTELLIGENCE_SOME;
|
||||
blogSelection = DatabaseConstants.SOCIAL_INTELLIGENCE_SOME;
|
||||
break;
|
||||
case (AppConstants.STATE_BEST):
|
||||
groupSelection = DatabaseConstants.FOLDER_INTELLIGENCE_BEST;
|
||||
blogSelection = DatabaseConstants.SOCIAL_INTELLIGENCE_BEST;
|
||||
break;
|
||||
}
|
||||
String groupSelection = DatabaseConstants.getFolderSelectionFromState(state);
|
||||
String blogSelection = DatabaseConstants.getBlogSelectionFromState(state);
|
||||
// the countCursor always counts neutral/"some" unreads, no matter what mode we are in
|
||||
String countSelection = DatabaseConstants.getBlogSelectionFromState(AppConstants.STATE_SOME);
|
||||
|
||||
folderAdapter.currentState = state;
|
||||
Cursor cursor = resolver.query(FeedProvider.FOLDERS_URI, null, null, new String[] { groupSelection }, null);
|
||||
Cursor blogCursor = resolver.query(FeedProvider.SOCIAL_FEEDS_URI, null, blogSelection, null, null);
|
||||
Cursor countCursor = resolver.query(FeedProvider.FEED_COUNT_URI, null, DatabaseConstants.SOCIAL_INTELLIGENCE_SOME, null, null);
|
||||
Cursor countCursor = resolver.query(FeedProvider.FEED_COUNT_URI, null, countSelection, null, null);
|
||||
|
||||
folderAdapter.setBlogCursor(blogCursor);
|
||||
folderAdapter.setGroupCursor(cursor);
|
||||
|
|
|
@ -95,7 +95,7 @@ public class SocialFeedItemListFragment extends ItemListFragment implements Load
|
|||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {
|
||||
Uri uri = FeedProvider.SOCIALFEED_STORIES_URI.buildUpon().appendPath(userId).build();
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), uri, null, FeedProvider.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_SHARED_DATE + " desc");
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), uri, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_SHARED_DATE + " desc");
|
||||
return cursorLoader;
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ public class SocialFeedItemListFragment extends ItemListFragment implements Load
|
|||
|
||||
public void changeState(int state) {
|
||||
currentState = state;
|
||||
final String selection = FeedProvider.getStorySelectionFromState(state);
|
||||
final String selection = DatabaseConstants.getStorySelectionFromState(state);
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, selection, null, DatabaseConstants.STORY_SHARED_DATE + " desc");
|
||||
adapter.swapCursor(cursor);
|
||||
getActivity().startManagingCursor(cursor);
|
||||
|
|
Loading…
Add table
Reference in a new issue