100 likes | 183 Views
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.
E N D
Purdue Pride4.7.10Joe GutierrezTung HoJanam Jhaveri Purdue Pride
Timeline • 7 weeks • March 10th: Widget, RSS tutorials • March 24th: RSS Feed • April 7th: SQL LiteDatabase (currently working on) • April 21st: Widget • April 28th: Work off any loose ends Purdue Pride
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) Purdue Pride
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 } Purdue Pride
Database Code public static booleaninsertItem(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 booleandeleteItem(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); intnumRows = 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 } } Purdue Pride
Database Code catch (SQLException e) { Log.e("PurduePride",e.toString()); } return feeds; } public static RSSItemgetItem() { 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; } } Purdue Pride
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(); } */ } Purdue Pride
Pride RSS handler.setContext(this); Purdue Pride
Widget XML <?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 widgetandroid:minWidth="240dp"android:minHeight="300dp" //Update rate of the Widget (set to once every 24 hrs)android:updatePeriodMillis="86400000" //Layout of widget to be initializedandroid:initialLayout="@layout/purduepridewidget" //Configuration activity to automatically launch widgetandroid: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
Next Task • April 7th: Have RSS feed interacting with database (in Progress) • April 21st: Display RSS feed onto Widget Purdue Pride