use of in.testpress.testpress.models.Post in project android by testpress.
the class PostActivity method updateCommentsCount.
@SuppressLint("DefaultLocale")
void updateCommentsCount(int count) {
List<Post> posts = postDao.queryBuilder().where(PostDao.Properties.Id.eq(post.getId())).list();
if (!posts.isEmpty()) {
Post post = posts.get(0);
post.setCommentsCount(count);
post.update();
}
post.setCommentsCount(count);
}
use of in.testpress.testpress.models.Post in project android by testpress.
the class PostActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post_details_layout);
Injector.inject(this);
ButterKnife.inject(this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
postDetails.setVisibility(View.GONE);
progressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.primary), PorterDuff.Mode.SRC_IN);
postDao = ((TestpressApplication) getApplicationContext()).getDaoSession().getPostDao();
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
shortWebUrl = getIntent().getStringExtra(SHORT_WEB_URL);
progressDialog = new ProgressDialog(this);
progressDialog.setMessage(getResources().getString(R.string.please_wait));
progressDialog.setCancelable(false);
in.testpress.util.UIUtils.setIndeterminateDrawable(this, progressDialog, 4);
ViewUtils.setTypeface(new TextView[] { loadPreviousCommentsText, commentsLabel, loadNewCommentsText, title }, TestpressSdk.getRubikMediumFont(this));
ViewUtils.setTypeface(new TextView[] { date, summary, commentsEmptyView, commentsEditText }, TestpressSdk.getRubikRegularFont(this));
if (shortWebUrl != null) {
List<Post> posts = postDao.queryBuilder().where(PostDao.Properties.Short_web_url.eq(shortWebUrl)).list();
if (!posts.isEmpty()) {
post = posts.get(0);
if (post.getContentHtml() != null) {
displayPost(post);
return;
}
}
// If there is no post in this url in db or
// If it content_html is null then fetch the post
fetchPost();
} else {
setEmptyText(R.string.invalid_post, R.string.try_after_sometime, R.drawable.ic_error_outline_black_18dp);
}
}
use of in.testpress.testpress.models.Post in project android by testpress.
the class PostsListFragment method initOldPostLoadingPager.
void initOldPostLoadingPager() {
pager = new PostsPager(getTestpressService(), null);
pager.setQueryParams("order", "-published_date");
Post lastPost = postDao.queryBuilder().orderDesc(PostDao.Properties.Published).list().get((int) postDao.count() - 1);
pager.setQueryParams("until", lastPost.getPublishedDate());
pager.setLatestModifiedDate(null);
}
use of in.testpress.testpress.models.Post in project android by testpress.
the class PostsListFragment method initRefreshPager.
void initRefreshPager() {
if (refreshPager == null) {
refreshPager = new PostsPager(getTestpressService(), postDao);
refreshPager.setQueryParams("order", "-published_date");
if (postDao.count() > 0) {
Post latest = postDao.queryBuilder().orderDesc(PostDao.Properties.ModifiedDate).list().get(0);
refreshPager.setLatestModifiedDate(latest.getModified());
LogLatestPostModifiedDate(latest);
LogAllPosts();
}
}
}
use of in.testpress.testpress.models.Post 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();
}
Aggregations