@Test public void addReadPostTest() throws Exception { ReadingHistoryController.getInstance().initialize(RuntimeEnvironment.application); Post posta = new Post(); posta.setUuid("abc"); Post postb = new Post(); postb.setUuid("123"); ReadingHistoryController.getInstance().addReadPost(posta); assertTrue(ReadingHistoryController.getInstance().postIsRead(posta)); assertFalse(ReadingHistoryController.getInstance().postIsRead(postb)); }
public void addReadPost(Post post) { if (postIsRead(post)) { return; } SQLiteDatabase db = dbHelper.getWritableDatabase(); ContentValues val = new ContentValues(); val.put(ReadingHistoryContract.HistoryEntry.COLUMN_POST_UUID, post.getUuid()); db.insert(ReadingHistoryContract.HistoryEntry.TABLE_NAME, null, val); db.close(); }
ReadingHistoryController { public void addReadPost(Post post) { if (postIsRead(post)) { return; } SQLiteDatabase db = dbHelper.getWritableDatabase(); ContentValues val = new ContentValues(); val.put(ReadingHistoryContract.HistoryEntry.COLUMN_POST_UUID, post.getUuid()); db.insert(ReadingHistoryContract.HistoryEntry.TABLE_NAME, null, val); db.close(); } }
ReadingHistoryController { public void addReadPost(Post post) { if (postIsRead(post)) { return; } SQLiteDatabase db = dbHelper.getWritableDatabase(); ContentValues val = new ContentValues(); val.put(ReadingHistoryContract.HistoryEntry.COLUMN_POST_UUID, post.getUuid()); db.insert(ReadingHistoryContract.HistoryEntry.TABLE_NAME, null, val); db.close(); } private  ReadingHistoryController(); }
ReadingHistoryController { public void addReadPost(Post post) { if (postIsRead(post)) { return; } SQLiteDatabase db = dbHelper.getWritableDatabase(); ContentValues val = new ContentValues(); val.put(ReadingHistoryContract.HistoryEntry.COLUMN_POST_UUID, post.getUuid()); db.insert(ReadingHistoryContract.HistoryEntry.TABLE_NAME, null, val); db.close(); } private  ReadingHistoryController(); static ReadingHistoryController getInstance(); void initialize(Context context); boolean postIsRead(Post post); void addReadPost(Post post); }
ReadingHistoryController { public void addReadPost(Post post) { if (postIsRead(post)) { return; } SQLiteDatabase db = dbHelper.getWritableDatabase(); ContentValues val = new ContentValues(); val.put(ReadingHistoryContract.HistoryEntry.COLUMN_POST_UUID, post.getUuid()); db.insert(ReadingHistoryContract.HistoryEntry.TABLE_NAME, null, val); db.close(); } private  ReadingHistoryController(); static ReadingHistoryController getInstance(); void initialize(Context context); boolean postIsRead(Post post); void addReadPost(Post post);  }