Upload
tawana
View
19
Download
3
Embed Size (px)
DESCRIPTION
Purdue Pride 4.7.10 Joe Gutierrez Tung Ho Janam Jhaveri. Timeline. 7 weeks March 10 th : Widget, RSS tutorials March 24 th : RSS Feed April 7 th : SQL Lite Database (currently working on) April 21 st : Widget April 28 th : Work off any loose ends. Milestones. - PowerPoint PPT Presentation
Citation preview
Purdue Pride 1
Purdue Pride4.7.10
Joe GutierrezTung Ho
Janam Jhaveri
4/7/2010
Purdue Pride 2
Timeline
•7 weeks
•March 10th: Widget, RSS tutorials
•March 24th: RSS Feed
•April 7th: SQL Lite Database (currently working on)
•April 21st: Widget
•April 28th: Work off any loose ends
4/7/2010
Purdue Pride 3
Milestones
•Website with RSS feed is set up (3.3.10)
•Basic widget displays hard-coded text (3.10.10)
•Successfully store and recall data from SQL Lite with an application (3.24.10)
•Successfully retrieve and display RSS feed onto view (4.1.10)
4/7/2010
Purdue Pride 4
Database Code
public class PrideDB {
private static final String FEEDS_TABLE = "feeds"; private static final String DATABASE_NAME = "pride";
private static SQLiteDatabase db; public PrideDB(Context ctx) {
db = ctx.openOrCreateDatabase(DATABASE_NAME, 0, null); //API change
}
4/7/2010
Purdue Pride 5
Database Code
public static boolean insertItem(String title, String description) { ContentValues values = new ContentValues(); values.put("title", title); values.put("description", description); return(db.insert(FEEDS_TABLE, null, values) > 0);
} public boolean deleteItem(Long feedID) {
return(db.delete(FEEDS_TABLE, "feed_id=" + feedID.toString(), null) > 0); } public static List<RSSItem> getItems() {
ArrayList<RSSItem> feeds = new ArrayList<RSSItem>(); try {
Cursor c = db.query(FEEDS_TABLE, new String[] {"feed_id", "title", "description"} , null, null, null, null, null); int numRows = c.getCount(); //API change for( int i =0; i < numRows; ++i) { RSSItem item = new RSSItem(); item.feedId = c.getLong(0); item.title = c.getString(1); item.description = c.getString(2); feeds.add(item); c.moveToNext(); //API change } }
4/7/2010
Purdue Pride 6
Database Code
catch (SQLException e) { Log.e("PurduePride",e.toString()); }
return feeds; } public static RSSItem getItem() {
RSSItem item = new RSSItem(); try {
Cursor c = db.query(FEEDS_TABLE, new String[] {"feed_id", "title", "description"} , null, null, null, null, null); item.feedId = c.getLong(0); //item.title = c.getString(1); //item.description = c.getString(2);
} catch (SQLException e) { Log.e("PurduePride",e.toString()); }
return item; } }
4/7/2010
Purdue Pride 7
RSS Handler
if (item.title != null) { PrideDB.insertItem(item.title, item.description); item.title = null; item.description = null; /*itemsAdded++; if (itemsAdded >= ARTICLES_LIMIT) { throw new SAXException(); } */ }
4/7/2010
Purdue Pride 8
Pride RSS
4/7/2010
handler.setContext(this);
Purdue Pride 9
Widget XML
4/7/2010
<?xml version="1.0"?> //XML file with some metadata about the widget. "Called" in main Widget Java file
<appwidget-provider xmlns:android="http://cobweb.ecn.purdue.edu/~vipfor/index.html" //Dimensions of the widget android:minWidth="240dp" android:minHeight="300dp" //Update rate of the Widget (set to once every 24 hrs) android:updatePeriodMillis="86400000" //Layout of widget to be initialized android:initialLayout="@layout/purduepridewidget" //Configuration activity to automatically launch widget android:configure="com.vip.pruduepride.purdueprideConfigure" ></appwidget-provider>
<receiver android:name="PurduePrideWidget" > <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/WidgetXML" /> </receiver>
Purdue Pride 10
Next Task
4/7/2010
April 7th: Have RSS feed interacting with database (in Progress)
April 21st: Display RSS feed onto Widget