Added itemlist for feeds. Moved re-syncing functionality to item-list.

This commit is contained in:
RyanBateman 2012-07-23 11:23:52 -04:00
parent 5f459487b0
commit c4714abf57
16 changed files with 433 additions and 99 deletions

View file

@ -35,6 +35,9 @@
android:name=".activity.Profile"
android:label="@string/profile"/>
<activity
android:name=".activity.ItemsList" />
<activity
android:name=".activity.Reading"/>

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="@color/darkgray"/>
</shape>

View file

@ -1,4 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="@color/lightgray"/>
</shape>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/darkgray" />
<size android:height="1dp" />
</shape>
</item>
<item android:top="1dp">
<shape android:shape="rectangle">
<solid android:color="@color/lightgray" />
<size android:height="1dp" />
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/activity_background"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/activity_itemlist_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true" />
<View
android:layout_width="fill_parent"
android:layout_height="8dip"
android:layout_alignParentTop="true"
android:background="@drawable/orangeline_shadow" />
</RelativeLayout>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/itemlistfragment_list"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@drawable/list_background"
android:divider="@drawable/divider_light"
android:dividerHeight="2dp" />
</LinearLayout>

View file

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="@+id/row_item_sidebar"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp" />
<TextView
android:id="@+id/row_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/row_item_sidebar"
android:textColor="@color/darkgray"
android:textSize="18dp" />
<TextView
android:id="@+id/row_item_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/row_item_title"
android:layout_marginTop="10dp"
android:textColor="@color/darkgray"
android:textSize="12dp" />
<TextView
android:id="@+id/row_item_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/row_item_title"
android:layout_marginTop="10dp"
android:layout_toRightOf="@id/row_item_sidebar"
android:layout_toLeftOf="@id/row_item_date"
android:textColor="@color/lightgray"
android:textSize="12dp" />
</RelativeLayout>

View file

@ -1,14 +1,129 @@
package com.newsblur.activity;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import com.newsblur.R;
import com.newsblur.database.FeedProvider;
import com.newsblur.domain.Feed;
import com.newsblur.domain.Story;
import com.newsblur.fragment.ItemListFragment;
import com.newsblur.service.DetachableResultReceiver;
import com.newsblur.service.DetachableResultReceiver.Receiver;
import com.newsblur.service.SyncService;
public class ItemsList extends SherlockFragmentActivity {
public static final String EXTRA_FEED = "feedId";
private ItemListFragment itemListFragment;
private FragmentManager fragmentManager;
private final String FRAGMENT_TAG = "itemListFragment";
private SyncReadingUpdaterFragment syncFragment;
private String feedId;
private String TAG = "ItemsList";
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_itemslist);
fragmentManager = getSupportFragmentManager();
feedId = getIntent().getStringExtra(EXTRA_FEED);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final Uri feedUri = FeedProvider.FEEDS_URI.buildUpon().appendPath(feedId).build();
Feed feed = Feed.fromCursor(getContentResolver().query(feedUri, null, null, null, null));
setTitle(feed.title);
itemListFragment = (ItemListFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (itemListFragment == null && feedId != null) {
itemListFragment = ItemListFragment.newInstance(feedId);
itemListFragment.setRetainInstance(true);
FragmentTransaction listTransaction = fragmentManager.beginTransaction();
listTransaction.add(R.id.activity_itemlist_container, itemListFragment, FRAGMENT_TAG);
listTransaction.commit();
}
syncFragment = (SyncReadingUpdaterFragment) fragmentManager.findFragmentByTag(SyncReadingUpdaterFragment.TAG);
if (syncFragment == null) {
syncFragment = new SyncReadingUpdaterFragment();
fragmentManager.beginTransaction().add(syncFragment, SyncReadingUpdaterFragment.TAG).commit();
triggerRefresh();
}
}
}
public void redrawUI() {
Log.d(TAG , "Redrawing UI");
itemListFragment.updated();
}
public void triggerRefresh() {
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_FEED_UPDATE);
intent.putExtra(SyncService.EXTRA_TASK_FEED_ID, feedId);
startService(intent);
}
public static class SyncReadingUpdaterFragment extends Fragment implements Receiver {
public static final String TAG = "SyncReadingFragment";
private DetachableResultReceiver receiver;
public SyncReadingUpdaterFragment() {
receiver = new DetachableResultReceiver(new Handler());
receiver.setReceiver(this);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
Log.d(TAG, "Creating syncfragment");
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
Log.d(TAG, "Attached");
}
@Override
public void onReceiverResult(int resultCode, Bundle resultData) {
switch (resultCode) {
case SyncService.STATUS_FINISHED:
Log.d(TAG, "Synchronisation finished.");
if (getActivity() != null) {
((ItemsList) getActivity()).redrawUI();
}
break;
case SyncService.STATUS_RUNNING:
Log.d(TAG, "Synchronisation running.");
break;
default:
Log.e(TAG, "Unrecognised response attempting to get reading data");
break;
}
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
}
return false;
}
}

View file

@ -3,6 +3,7 @@ package com.newsblur.activity;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
@ -34,14 +35,15 @@ public class Reading extends SherlockFragmentActivity {
public static final String EXTRA_FEED = "feed_selected";
public static final String TAG = "ReadingActivity";
public static final String EXTRA_POSITION = "feed_position";
private ViewPager pager;
private SyncReadingUpdaterFragment syncFragment;
private FragmentManager fragmentManager;
private ReadingAdapter readingAdapter;
private String feedId;
private final int READING_LOADER = 0x01;
private ContentResolver contentResolver;
private Feed feed;
private int passedPosition;
@Override
protected void onCreate(Bundle savedInstanceBundle) {
@ -53,16 +55,19 @@ public class Reading extends SherlockFragmentActivity {
fragmentManager = getSupportFragmentManager();
feedId = getIntent().getStringExtra(EXTRA_FEED);
passedPosition = getIntent().getIntExtra(EXTRA_POSITION, 0);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
readingAdapter = new ReadingAdapter(fragmentManager, this, feedId);
contentResolver = getContentResolver();
final Uri feedUri = FeedProvider.FEEDS_URI.buildUpon().appendPath(feedId).build();
Uri storiesURI = FeedProvider.STORIES_URI.buildUpon().appendPath(feedId).build();
Cursor stories = contentResolver.query(storiesURI, null, null, null, null);
readingAdapter = new ReadingAdapter(fragmentManager, this, feedId, stories);
final Uri feedUri = FeedProvider.FEEDS_URI.buildUpon().appendPath(feedId).build();
feed = Feed.fromCursor(contentResolver.query(feedUri, null, null, null, null));
setTitle(feed.title);
View view = findViewById(R.id.reading_floatbar);
GradientDrawable gradient;
int borderColor = Color.BLACK;
@ -73,29 +78,21 @@ public class Reading extends SherlockFragmentActivity {
gradient = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[] { Color.DKGRAY, Color.LTGRAY });
}
view.setBackgroundDrawable(gradient);
findViewById(R.id.reading_divider).setBackgroundColor(borderColor);
findViewById(R.id.reading_divider_bottom).setBackgroundColor(borderColor);
getSupportLoaderManager().initLoader(READING_LOADER , null, readingAdapter);
syncFragment = (SyncReadingUpdaterFragment) fragmentManager.findFragmentByTag(SyncReadingUpdaterFragment.TAG);
if (syncFragment == null) {
syncFragment = new SyncReadingUpdaterFragment();
fragmentManager.beginTransaction().add(syncFragment, SyncReadingUpdaterFragment.TAG).commit();
triggerRefresh();
}
getSupportLoaderManager().initLoader(READING_LOADER , null, readingAdapter);
pager = (ViewPager) findViewById(R.id.reading_pager);
pager.setPageMargin(UIUtils.convertDPsToPixels(getApplicationContext(), 1));
pager.setPageMarginDrawable(R.drawable.divider_light);
pager.setAdapter(readingAdapter);
setProgressBarVisibility(true);
pager.setCurrentItem(passedPosition);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
@ -104,20 +101,6 @@ public class Reading extends SherlockFragmentActivity {
return true;
}
public void triggerRefresh() {
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_FEED_UPDATE);
intent.putExtra(SyncService.EXTRA_TASK_FEED_ID, feedId);
startService(intent);
}
public void redrawUI() {
Log.d(TAG, "Redrawing reading pager...");
getSupportLoaderManager().restartLoader(READING_LOADER, null, readingAdapter);
setProgressBarVisibility(false);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int currentItem = pager.getCurrentItem();
@ -148,46 +131,4 @@ public class Reading extends SherlockFragmentActivity {
}
}
public static class SyncReadingUpdaterFragment extends Fragment implements Receiver {
public static final String TAG = "SyncReadingFragment";
private DetachableResultReceiver receiver;
public SyncReadingUpdaterFragment() {
receiver = new DetachableResultReceiver(new Handler());
receiver.setReceiver(this);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
Log.d(TAG, "Creating syncfragment");
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
Log.d(TAG, "Attached");
}
@Override
public void onReceiverResult(int resultCode, Bundle resultData) {
switch (resultCode) {
case SyncService.STATUS_FINISHED:
Log.d(TAG, "Synchronisation finished.");
if (getActivity() != null) {
((Reading) getActivity()).redrawUI();
}
break;
case SyncService.STATUS_RUNNING:
Log.d(TAG, "Synchronisation running.");
break;
default:
Log.e(TAG, "Unrecognised response attempting to get reading data");
break;
}
}
}
}

View file

@ -64,5 +64,10 @@ public class DatabaseConstants {
public static final String[] FOLDER_COLUMNS = {
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[] STORY_COLUMNS = {
STORY_AUTHORS, STORY_COMMENT_COUNT, STORY_CONTENT, STORY_DATE, STORY_FEED_ID, STORY_ID, STORY_INTELLIGENCE_AUTHORS, STORY_INTELLIGENCE_FEED, STORY_INTELLIGENCE_TAGS, STORY_INTELLIGENCE_TITLE,
STORY_PERMALINK, STORY_READ, STORY_SHARE_COUNT, STORY_TAGS, STORY_TITLE
};
}

View file

@ -138,7 +138,7 @@ public class FeedProvider extends ContentProvider {
case FEED_STORIES:
selection = DatabaseConstants.STORY_FEED_ID + " = ?";
selectionArgs = new String[] { uri.getLastPathSegment() };
cursor = db.query(DatabaseConstants.STORY_TABLE, null, selection, selectionArgs, null, null, null);
cursor = db.query(DatabaseConstants.STORY_TABLE, DatabaseConstants.STORY_COLUMNS, selection, selectionArgs, null, null, null);
break;
// Query for feeds with no folder mapping

View file

@ -23,13 +23,16 @@ public class ReadingAdapter extends FragmentStatePagerAdapter implements LoaderM
private Uri feedUri;
private String TAG = "ReadingAdapter";
private LoadingFragment loadingFragment;
public ReadingAdapter(final FragmentManager fragmentManager, final Context context, final String feedId) {
public ReadingAdapter(final FragmentManager fragmentManager, final Context context, final String feedId, final Cursor cursor) {
super(fragmentManager);
this.context = context;
this.cursor = cursor;
feedUri = FeedProvider.STORIES_URI.buildUpon().appendPath(feedId).build();
}
@Override
public Fragment getItem(int position) {
if (cursor == null || cursor.getCount() == 0) {

View file

@ -27,7 +27,7 @@ public class Story implements Serializable {
public String commentCount;
@SerializedName("read_status")
public int read;
public String read;
@SerializedName("story_tags")
public String[] tags;
@ -50,12 +50,9 @@ public class Story implements Serializable {
@SerializedName("story_feed_id")
public String feedId;
@SerializedName("intelligence_feed")
public String intelligenceFeed;
@SerializedName("intelligence")
public Intelligence intelligence = new Intelligence();
@SerializedName("intelligence_authors")
public String intelligenceAuthors;
@SerializedName("intelligence_title")
public String intelligenceTitle;
@ -69,10 +66,11 @@ public class Story implements Serializable {
values.put(DatabaseConstants.STORY_COMMENT_COUNT, commentCount);
values.put(DatabaseConstants.STORY_SHARE_COUNT, shareCount);
values.put(DatabaseConstants.STORY_AUTHORS, authors);
values.put(DatabaseConstants.STORY_INTELLIGENCE_AUTHORS, intelligenceAuthors);
values.put(DatabaseConstants.STORY_INTELLIGENCE_FEED, intelligenceFeed);
values.put(DatabaseConstants.STORY_INTELLIGENCE_AUTHORS, intelligence.intelligenceAuthors);
values.put(DatabaseConstants.STORY_INTELLIGENCE_FEED, intelligence.intelligenceFeed);
values.put(DatabaseConstants.STORY_INTELLIGENCE_TAGS, intelligence.intelligenceTags);
values.put(DatabaseConstants.STORY_INTELLIGENCE_TITLE, intelligence.intelligenceTitle);
values.put(DatabaseConstants.STORY_TAGS, TextUtils.join(",", tags));
values.put(DatabaseConstants.STORY_INTELLIGENCE_TITLE, intelligenceTitle);
values.put(DatabaseConstants.STORY_READ, read);
values.put(DatabaseConstants.STORY_FEED_ID, feedId);
return values;
@ -87,13 +85,29 @@ public class Story implements Serializable {
story.shareCount = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_SHARE_COUNT));
story.commentCount = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_COMMENT_COUNT));
story.permalink = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_PERMALINK));
story.intelligenceAuthors = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_INTELLIGENCE_AUTHORS));
story.intelligenceFeed = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_INTELLIGENCE_FEED));
story.read = cursor.getInt(cursor.getColumnIndex(DatabaseConstants.STORY_READ));
story.intelligence.intelligenceAuthors = cursor.getInt(cursor.getColumnIndex(DatabaseConstants.STORY_INTELLIGENCE_AUTHORS));
story.intelligence.intelligenceFeed = cursor.getInt(cursor.getColumnIndex(DatabaseConstants.STORY_INTELLIGENCE_FEED));
story.intelligence.intelligenceTags = cursor.getInt(cursor.getColumnIndex(DatabaseConstants.STORY_INTELLIGENCE_TAGS));
story.intelligence.intelligenceTitle = cursor.getInt(cursor.getColumnIndex(DatabaseConstants.STORY_INTELLIGENCE_TITLE));
story.read = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_READ));
story.tags = TextUtils.split(cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_TAGS)), ",");
story.feedId = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_FEED_ID));
story.id = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_ID));
return story;
}
private class Intelligence {
@SerializedName("feed")
public int intelligenceFeed = 0;
@SerializedName("author")
public int intelligenceAuthors = 0;
@SerializedName("tags")
public int intelligenceTags = 0;
@SerializedName("title")
public int intelligenceTitle = 0;
}
}

View file

@ -14,6 +14,7 @@ import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ExpandableListView.OnGroupClickListener;
import com.newsblur.R;
import com.newsblur.activity.ItemsList;
import com.newsblur.activity.Reading;
import com.newsblur.database.DatabaseConstants;
import com.newsblur.database.FeedProvider;
@ -101,10 +102,10 @@ public class FolderFeedListFragment extends Fragment implements OnGroupClickList
@Override
public boolean onChildClick(ExpandableListView list, View childView, int groupPosition, int childPosition, long id) {
final Intent intent = new Intent(getActivity(), Reading.class);
final Intent intent = new Intent(getActivity(), ItemsList.class);
Cursor childCursor = folderAdapter.getChild(groupPosition, childPosition);
String feedId = childCursor.getString(childCursor.getColumnIndex(DatabaseConstants.FEED_ID));
intent.putExtra(Reading.EXTRA_FEED, feedId);
intent.putExtra(ItemsList.EXTRA_FEED, feedId);
getActivity().startActivity(intent);
return true;
}

View file

@ -0,0 +1,109 @@
package com.newsblur.fragment;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v4.widget.CursorAdapter;
import android.support.v4.widget.SimpleCursorAdapter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import com.newsblur.R;
import com.newsblur.activity.Reading;
import com.newsblur.database.DatabaseConstants;
import com.newsblur.database.FeedProvider;
import com.newsblur.view.ItemViewBinder;
public class ItemListFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor>, OnItemClickListener {
private static final String TAG = "itemListFragment";
private ContentResolver contentResolver;
private String feedId;
public static int ITEMLIST_LOADER = 0x01;
private SimpleCursorAdapter adapter;
public ItemListFragment(final String feedId) {
this.feedId = feedId;
}
public ItemListFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public static ItemListFragment newInstance(final String feedId) {
return new ItemListFragment(feedId);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_itemlist, null);
ListView itemList = (ListView) v.findViewById(R.id.itemlistfragment_list);
contentResolver = getActivity().getContentResolver();
Uri uri = FeedProvider.STORIES_URI.buildUpon().appendPath(feedId).build();
Cursor cursor = contentResolver.query(uri, null, null, null, null);
String[] groupFrom = new String[] { DatabaseConstants.STORY_TITLE, DatabaseConstants.STORY_AUTHORS, DatabaseConstants.STORY_READ, DatabaseConstants.STORY_DATE, DatabaseConstants.STORY_INTELLIGENCE_AUTHORS };
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 };
getLoaderManager().initLoader(ITEMLIST_LOADER , null, this);
adapter = new SimpleCursorAdapter(getActivity(), R.layout.row_item, cursor, groupFrom, groupTo, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
adapter.setViewBinder(new ItemViewBinder());
itemList.setAdapter(adapter);
itemList.setOnItemClickListener(this);
return v;
}
@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {
Uri uri = FeedProvider.STORIES_URI.buildUpon().appendPath(feedId).build();
CursorLoader cursorLoader = new CursorLoader(getActivity(), uri, null, null, null, null);
return cursorLoader;
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
Log.d(TAG, "Load finished: " + cursor.getCount());
adapter.swapCursor(cursor);
}
public void updated() {
getLoaderManager().restartLoader(ITEMLIST_LOADER , null, this);
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
Log.d(TAG, "Loader reset");
adapter.notifyDataSetInvalidated();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getActivity(), Reading.class);
i.putExtra(Reading.EXTRA_FEED, feedId);
i.putExtra(Reading.EXTRA_POSITION, position);
startActivity(i);
}
}

View file

@ -8,7 +8,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.newsblur.R;

View file

@ -0,0 +1,53 @@
package com.newsblur.view;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Typeface;
import android.support.v4.widget.SimpleCursorAdapter.ViewBinder;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.newsblur.R;
import com.newsblur.database.DatabaseConstants;
public class ItemViewBinder implements ViewBinder {
@Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
final String columnName = cursor.getColumnName(columnIndex);
if (TextUtils.equals(columnName, DatabaseConstants.STORY_READ)) {
String read = cursor.getString(columnIndex);
if (Boolean.parseBoolean(read) == false) {
((TextView) view).setTypeface(null, Typeface.BOLD);
} else {
((TextView) view).setTypeface(null, Typeface.NORMAL);
}
return true;
} else if (TextUtils.equals(columnName, DatabaseConstants.STORY_AUTHORS)) {
if (TextUtils.isEmpty(cursor.getString(columnIndex))) {
view.setVisibility(View.GONE);
} else {
view.setVisibility(View.VISIBLE);
}
} else if (TextUtils.equals(columnName, DatabaseConstants.STORY_INTELLIGENCE_AUTHORS)) {
int authors = cursor.getInt(columnIndex);
int tags = cursor.getInt(cursor.getColumnIndex(DatabaseConstants.STORY_INTELLIGENCE_TAGS));
int feed = cursor.getInt(cursor.getColumnIndex(DatabaseConstants.STORY_INTELLIGENCE_FEED));
int title = cursor.getInt(cursor.getColumnIndex(DatabaseConstants.STORY_INTELLIGENCE_TITLE));
if (authors + tags + feed + title > 0) {
view.setBackgroundResource(R.drawable.positive_count_rect);
} else if (authors + tags + feed + title == 0){
view.setBackgroundResource(R.drawable.neutral_count_rect);
} else {
view.setBackgroundResource(R.drawable.negative_count_rect);
}
((TextView) view).setText("");
return true;
}
return false;
}
}