Search in sources :

Example 1 with ReaderPostList

use of org.wordpress.android.models.ReaderPostList in project WordPress-Android by wordpress-mobile.

the class ReaderPostAdapter method removePostsInBlog.

public void removePostsInBlog(long blogId) {
    int numRemoved = 0;
    ReaderPostList postsInBlog = mPosts.getPostsInBlog(blogId);
    for (ReaderPost post : postsInBlog) {
        int index = mPosts.indexOfPost(post);
        if (index > -1) {
            numRemoved++;
            mPosts.remove(index);
        }
    }
    if (numRemoved > 0) {
        notifyDataSetChanged();
    }
}
Also used : ReaderPostList(org.wordpress.android.models.ReaderPostList) ReaderPost(org.wordpress.android.models.ReaderPost)

Example 2 with ReaderPostList

use of org.wordpress.android.models.ReaderPostList in project WordPress-Android by wordpress-mobile.

the class ReaderPostTable method getPostsWithTag.

public static ReaderPostList getPostsWithTag(ReaderTag tag, int maxPosts, boolean excludeTextColumn) {
    if (tag == null) {
        return new ReaderPostList();
    }
    String columns = (excludeTextColumn ? COLUMN_NAMES_NO_TEXT : "*");
    String sql = "SELECT " + columns + " FROM tbl_posts WHERE tag_name=? AND tag_type=?";
    if (tag.tagType == ReaderTagType.DEFAULT) {
        // longer followed if this is "Followed Sites"
        if (tag.isPostsILike()) {
            sql += " AND is_liked != 0";
        } else if (tag.isFollowedSites()) {
            sql += " AND is_followed != 0";
        }
    }
    sql += " ORDER BY " + getSortColumnForTag(tag) + " DESC";
    if (maxPosts > 0) {
        sql += " LIMIT " + Integer.toString(maxPosts);
    }
    String[] args = { tag.getTagSlug(), Integer.toString(tag.tagType.toInt()) };
    Cursor cursor = ReaderDatabase.getReadableDb().rawQuery(sql, args);
    try {
        return getPostListFromCursor(cursor);
    } finally {
        SqlUtils.closeCursor(cursor);
    }
}
Also used : ReaderPostList(org.wordpress.android.models.ReaderPostList) Cursor(android.database.Cursor)

Example 3 with ReaderPostList

use of org.wordpress.android.models.ReaderPostList in project WordPress-Android by wordpress-mobile.

the class ReaderPostTable method addOrUpdatePost.

public static void addOrUpdatePost(ReaderPost post) {
    if (post == null) {
        return;
    }
    ReaderPostList posts = new ReaderPostList();
    posts.add(post);
    addOrUpdatePosts(null, posts);
}
Also used : ReaderPostList(org.wordpress.android.models.ReaderPostList)

Aggregations

ReaderPostList (org.wordpress.android.models.ReaderPostList)3 Cursor (android.database.Cursor)1 ReaderPost (org.wordpress.android.models.ReaderPost)1