Search in sources :

Example 1 with Category

use of in.testpress.testpress.models.Category in project android by testpress.

the class PostsListFragment method writeToDB.

protected void writeToDB(List<Post> posts) {
    // Insert the categories and posts to the database
    List<Category> categories = new ArrayList<Category>();
    for (Post post : posts) {
        if (post.category != null) {
            Ln.e("Post category for " + post.getTitle() + " is " + post.category.getName());
            categories.add(post.category);
        } else {
            Ln.e("Post category for " + post.getTitle() + " is null");
        }
    }
    categoryDao.insertOrReplaceInTx(categories);
    postDao.insertOrReplaceInTx(posts);
    LogAllPosts();
}
Also used : Category(in.testpress.testpress.models.Category) Post(in.testpress.testpress.models.Post) ArrayList(java.util.ArrayList)

Aggregations

Category (in.testpress.testpress.models.Category)1 Post (in.testpress.testpress.models.Post)1 ArrayList (java.util.ArrayList)1