mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00
Reading activity for Saved Stories.
This commit is contained in:
parent
c485b7e11e
commit
22413d19fd
7 changed files with 108 additions and 13 deletions
|
@ -99,6 +99,9 @@
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.AllStoriesReading"/>
|
android:name=".activity.AllStoriesReading"/>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".activity.SavedStoriesReading"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.AllSharedStoriesReading"/>
|
android:name=".activity.AllSharedStoriesReading"/>
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:background="@drawable/saved_count_rect"
|
android:background="@drawable/saved_count_rect"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="5dp"
|
android:padding="3dp"
|
||||||
android:shadowColor="@color/saved_drop_shadow"
|
android:shadowColor="@color/saved_drop_shadow"
|
||||||
android:shadowDy="1"
|
android:shadowDy="1"
|
||||||
android:shadowRadius="1"
|
android:shadowRadius="1"
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.newsblur.activity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.newsblur.R;
|
||||||
|
import com.newsblur.database.DatabaseConstants;
|
||||||
|
import com.newsblur.database.FeedProvider;
|
||||||
|
import com.newsblur.database.MixedFeedsReadingAdapter;
|
||||||
|
import com.newsblur.service.SyncService;
|
||||||
|
|
||||||
|
public class SavedStoriesReading extends Reading {
|
||||||
|
|
||||||
|
private Cursor stories;
|
||||||
|
private int currentPage;
|
||||||
|
private boolean stopLoading = false;
|
||||||
|
private boolean requestedPage = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceBundle) {
|
||||||
|
super.onCreate(savedInstanceBundle);
|
||||||
|
|
||||||
|
setResult(RESULT_OK);
|
||||||
|
|
||||||
|
stories = contentResolver.query(FeedProvider.STARRED_STORIES_URI, null, null, null, null);
|
||||||
|
setTitle(getResources().getString(R.string.saved_stories_title));
|
||||||
|
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), getContentResolver(), stories);
|
||||||
|
|
||||||
|
setupPager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
super.onPageSelected(position);
|
||||||
|
checkStoryCount(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void triggerRefresh() {
|
||||||
|
triggerRefresh(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkStoryCount(int position) {
|
||||||
|
if (position == stories.getCount() - 1 && !stopLoading && !requestedPage) {
|
||||||
|
requestedPage = true;
|
||||||
|
currentPage += 1;
|
||||||
|
triggerRefresh(currentPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void triggerRefresh(int page) {
|
||||||
|
if (!stopLoading) {
|
||||||
|
setSupportProgressBarIndeterminateVisibility(true);
|
||||||
|
final Intent intent = new Intent(Intent.ACTION_SYNC, null, this, SyncService.class);
|
||||||
|
intent.putExtra(SyncService.EXTRA_STATUS_RECEIVER, syncFragment.receiver);
|
||||||
|
intent.putExtra(SyncService.SYNCSERVICE_TASK, SyncService.EXTRA_TASK_STARRED_STORIES_UPDATE);
|
||||||
|
if (page > 1) {
|
||||||
|
intent.putExtra(SyncService.EXTRA_TASK_PAGE_NUMBER, Integer.toString(page));
|
||||||
|
}
|
||||||
|
startService(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAfterSync() {
|
||||||
|
setSupportProgressBarIndeterminateVisibility(false);
|
||||||
|
stories.requery();
|
||||||
|
requestedPage = false;
|
||||||
|
readingAdapter.notifyDataSetChanged();
|
||||||
|
checkStoryCount(pager.getCurrentItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setNothingMoreToUpdate() {
|
||||||
|
stopLoading = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeAfterUpdate() { }
|
||||||
|
|
||||||
|
}
|
|
@ -305,7 +305,7 @@ public class FeedProvider extends ContentProvider {
|
||||||
mdb = db;
|
mdb = db;
|
||||||
}
|
}
|
||||||
public Cursor rawQuery(String sql, String[] selectionArgs) {
|
public Cursor rawQuery(String sql, String[] selectionArgs) {
|
||||||
Log.d(LoggingDatabase.class.getName(), "rawQuery: " + sql);
|
//Log.d(LoggingDatabase.class.getName(), "rawQuery: " + sql);
|
||||||
return mdb.rawQuery(sql, selectionArgs);
|
return mdb.rawQuery(sql, selectionArgs);
|
||||||
}
|
}
|
||||||
public Cursor query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy) {
|
public Cursor query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy) {
|
||||||
|
|
|
@ -21,8 +21,9 @@ public class MultipleFeedItemsAdapter extends SimpleCursorAdapter {
|
||||||
private Cursor cursor;
|
private Cursor cursor;
|
||||||
private ImageLoader imageLoader;
|
private ImageLoader imageLoader;
|
||||||
private int storyTitleUnread, storyAuthorUnread, storyTitleRead, storyAuthorRead, storyDateUnread, storyDateRead, storyFeedUnread, storyFeedRead;
|
private int storyTitleUnread, storyAuthorUnread, storyTitleRead, storyAuthorRead, storyDateUnread, storyDateRead, storyFeedUnread, storyFeedRead;
|
||||||
|
private boolean ignoreReadStatus;
|
||||||
|
|
||||||
public MultipleFeedItemsAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
|
public MultipleFeedItemsAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags, boolean ignoreReadStatus) {
|
||||||
super(context, layout, c, from, to, flags);
|
super(context, layout, c, from, to, flags);
|
||||||
imageLoader = ((NewsBlurApplication) context.getApplicationContext()).getImageLoader();
|
imageLoader = ((NewsBlurApplication) context.getApplicationContext()).getImageLoader();
|
||||||
this.cursor = c;
|
this.cursor = c;
|
||||||
|
@ -35,8 +36,14 @@ public class MultipleFeedItemsAdapter extends SimpleCursorAdapter {
|
||||||
storyDateRead = context.getResources().getColor(R.color.story_date_read);
|
storyDateRead = context.getResources().getColor(R.color.story_date_read);
|
||||||
storyFeedUnread = context.getResources().getColor(R.color.story_feed_unread);
|
storyFeedUnread = context.getResources().getColor(R.color.story_feed_unread);
|
||||||
storyFeedRead = context.getResources().getColor(R.color.story_feed_read);
|
storyFeedRead = context.getResources().getColor(R.color.story_feed_read);
|
||||||
|
|
||||||
|
this.ignoreReadStatus = ignoreReadStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MultipleFeedItemsAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
|
||||||
|
this(context, layout, c, from, to, flags, false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return cursor.getCount();
|
return cursor.getCount();
|
||||||
|
@ -69,7 +76,7 @@ public class MultipleFeedItemsAdapter extends SimpleCursorAdapter {
|
||||||
borderTwo.setBackgroundColor(Color.LTGRAY);
|
borderTwo.setBackgroundColor(Color.LTGRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! Story.fromCursor(cursor).read) {
|
if (this.ignoreReadStatus || (! Story.fromCursor(cursor).read)) {
|
||||||
((TextView) v.findViewById(R.id.row_item_author)).setTextColor(storyAuthorUnread);
|
((TextView) v.findViewById(R.id.row_item_author)).setTextColor(storyAuthorUnread);
|
||||||
((TextView) v.findViewById(R.id.row_item_date)).setTextColor(storyDateUnread);
|
((TextView) v.findViewById(R.id.row_item_date)).setTextColor(storyDateUnread);
|
||||||
((TextView) v.findViewById(R.id.row_item_feedtitle)).setTextColor(storyFeedUnread);
|
((TextView) v.findViewById(R.id.row_item_feedtitle)).setTextColor(storyFeedUnread);
|
||||||
|
|
|
@ -138,14 +138,15 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
|
||||||
ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
|
ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
|
||||||
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
|
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
|
||||||
|
|
||||||
// Only create a context menu for child items
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
// Group (folder) item
|
case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
|
||||||
case 0:
|
int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
|
||||||
inflater.inflate(R.menu.context_folder, menu);
|
if (! folderAdapter.isRowSavedStories(groupPosition) ) {
|
||||||
|
inflater.inflate(R.menu.context_folder, menu);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
// Child (feed) item
|
|
||||||
case 1:
|
case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
|
||||||
inflater.inflate(R.menu.context_feed, menu);
|
inflater.inflate(R.menu.context_feed, menu);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import com.newsblur.R;
|
import com.newsblur.R;
|
||||||
import com.newsblur.activity.AllStoriesReading;
|
import com.newsblur.activity.SavedStoriesReading;
|
||||||
import com.newsblur.activity.FeedReading;
|
import com.newsblur.activity.FeedReading;
|
||||||
import com.newsblur.activity.ItemsList;
|
import com.newsblur.activity.ItemsList;
|
||||||
import com.newsblur.database.DatabaseConstants;
|
import com.newsblur.database.DatabaseConstants;
|
||||||
|
@ -63,7 +63,7 @@ public class SavedStoriesItemListFragment extends ItemListFragment implements Lo
|
||||||
|
|
||||||
getLoaderManager().initLoader(ITEMLIST_LOADER , null, this);
|
getLoaderManager().initLoader(ITEMLIST_LOADER , null, this);
|
||||||
|
|
||||||
adapter = new MultipleFeedItemsAdapter(getActivity(), R.layout.row_socialitem, cursor, groupFrom, groupTo, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
|
adapter = new MultipleFeedItemsAdapter(getActivity(), R.layout.row_socialitem, cursor, groupFrom, groupTo, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER, true);
|
||||||
|
|
||||||
itemList.setOnScrollListener(this);
|
itemList.setOnScrollListener(this);
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ public class SavedStoriesItemListFragment extends ItemListFragment implements Lo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
Intent i = new Intent(getActivity(), AllStoriesReading.class);
|
Intent i = new Intent(getActivity(), SavedStoriesReading.class);
|
||||||
i.putExtra(FeedReading.EXTRA_POSITION, position);
|
i.putExtra(FeedReading.EXTRA_POSITION, position);
|
||||||
startActivityForResult(i, READING_RETURNED );
|
startActivityForResult(i, READING_RETURNED );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue