Added short parsed date.

This commit is contained in:
RyanBateman 2012-07-25 21:52:38 -04:00
parent f2ab6bc3f3
commit 03851ce035
6 changed files with 16 additions and 14 deletions

View file

@ -53,6 +53,7 @@ public class BlurDatabase extends SQLiteOpenHelper {
DatabaseConstants.STORY_AUTHORS + TEXT + ", " +
DatabaseConstants.STORY_CONTENT + TEXT + ", " +
DatabaseConstants.STORY_DATE + TEXT + ", " +
DatabaseConstants.STORY_SHORTDATE + TEXT + ", " +
DatabaseConstants.STORY_FEED_ID + INTEGER + ", " +
DatabaseConstants.STORY_ID + TEXT + " PRIMARY KEY, " +
DatabaseConstants.STORY_INTELLIGENCE_AUTHORS + INTEGER + ", " +

View file

@ -43,21 +43,22 @@ public class DatabaseConstants {
public static final String STORY_TABLE = "stories";
public static final String STORY_ID = BaseColumns._ID;
public static final String STORY_AUTHORS = "authors";
public static final String STORY_TITLE = "title";
public static final String STORY_DATE = "date";
public static final String STORY_CONTENT = "content";
public static final String STORY_COMMENT_COUNT = "comment_count";
public static final String STORY_SHARE_COUNT = "share_count";
public static final String STORY_PERMALINK = "permalink";
public static final String STORY_AUTHORS = "authors";
public static final String STORY_FEED_ID = "feed_id";
public static final String STORY_INTELLIGENCE_AUTHORS = "intelligence_authors";
public static final String STORY_INTELLIGENCE_TAGS = "intelligence_tags";
public static final String STORY_INTELLIGENCE_FEED = "intelligence_feed";
public static final String STORY_INTELLIGENCE_TITLE = "intelligence_title";
public static final String STORY_PERMALINK = "permalink";
public static final String STORY_READ = "read";
public static final String STORY_TAGS = "tags";
public static final String STORY_FEED_ID = "feed_id";
public static final String STORY_SHARE_COUNT = "share_count";
public static final String STORY_SHARED_USER_IDS = "shared_user_ids";
public static final String STORY_SHORTDATE = "shortDate";
public static final String STORY_TAGS = "tags";
public static final String COMMENT_ID = BaseColumns._ID;
public static final String COMMENT_STORYID = "comment_storyid";
@ -80,9 +81,10 @@ public class DatabaseConstants {
};
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_AUTHORS, STORY_COMMENT_COUNT, STORY_CONTENT, STORY_DATE, STORY_SHORTDATE, 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, STORY_SHARED_USER_IDS
};
}

View file

@ -57,12 +57,16 @@ public class Story implements Serializable {
@SerializedName("intelligence")
public Intelligence intelligence = new Intelligence();
@SerializedName("short_parsed_date")
public String shortDate;
public ContentValues getValues() {
final ContentValues values = new ContentValues();
values.put(DatabaseConstants.STORY_ID, id);
values.put(DatabaseConstants.STORY_TITLE, title);
values.put(DatabaseConstants.STORY_DATE, date.getTime());
values.put(DatabaseConstants.STORY_SHORTDATE, shortDate);
values.put(DatabaseConstants.STORY_CONTENT, content);
values.put(DatabaseConstants.STORY_PERMALINK, permalink);
values.put(DatabaseConstants.STORY_COMMENT_COUNT, commentCount);
@ -85,6 +89,7 @@ public class Story implements Serializable {
story.content = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_CONTENT));
story.title = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_TITLE));
story.date = new Date(cursor.getLong(cursor.getColumnIndex(DatabaseConstants.STORY_DATE)));
story.shortDate = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_SHORTDATE));
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));

View file

@ -59,7 +59,7 @@ public class ItemListFragment extends Fragment implements LoaderManager.LoaderCa
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 };
String[] groupFrom = new String[] { DatabaseConstants.STORY_TITLE, DatabaseConstants.STORY_AUTHORS, DatabaseConstants.STORY_READ, DatabaseConstants.STORY_SHORTDATE, 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);

View file

@ -150,7 +150,7 @@ public class ReadingItemFragment extends Fragment {
}
}
itemDate.setText(story.date.toGMTString());
itemDate.setText(story.shortDate);
itemTitle.setText(story.title);
itemAuthors.setText(story.authors);
}

View file

@ -1,7 +1,5 @@
package com.newsblur.view;
import java.util.Date;
import android.database.Cursor;
import android.graphics.Typeface;
import android.support.v4.widget.SimpleCursorAdapter.ViewBinder;
@ -46,10 +44,6 @@ public class ItemViewBinder implements ViewBinder {
((TextView) view).setText("");
return true;
} else if (TextUtils.equals(columnName, DatabaseConstants.STORY_DATE)) {
Date date = new Date(cursor.getLong(columnIndex));
((TextView) view).setText(date.toLocaleString());
return true;
}
return false;