use of in.testpress.testpress.models.Post in project android by testpress.
the class PostsPager method next.
@Override
public boolean next() throws IOException {
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
boolean emptyPage = false;
try {
for (int i = 0; i < count && hasNext(); i++) {
Ln.d("PostsPager Getting Items");
List<Post> resourcePage = getItems(page, -1);
Ln.d("PostsPager Items Received");
emptyPage = resourcePage.isEmpty();
if (emptyPage)
break;
Ln.d("Looping through resources");
for (Post resource : resourcePage) {
resource = register(resource);
if (resource == null)
continue;
if (resource.category != null) {
resource.setCategory(resource.category);
}
Ln.d("Category ID " + resource.getCategoryId());
resource.setPublished(simpleDateFormat.parse(resource.getPublishedDate()).getTime());
resource.setModifiedDate(simpleDateFormat.parse(resource.getModified()).getTime());
resources.put(getId(resource), resource);
}
Ln.d("Looping resources over");
}
// Set page to count value if first call after call to reset()
if (count > 1) {
page = count;
count = 1;
}
page++;
} catch (ParseException e) {
Ln.d("ParseException " + e);
} catch (Exception e) {
hasMore = false;
throw e;
}
hasMore = hasNext() && !emptyPage;
return hasMore;
}
use of in.testpress.testpress.models.Post in project android by testpress.
the class PostDao method loadCurrentDeep.
protected Post loadCurrentDeep(Cursor cursor, boolean lock) {
Post entity = loadCurrent(cursor, 0, lock);
int offset = getAllColumns().length;
Category category = loadCurrentOther(daoSession.getCategoryDao(), cursor, offset);
entity.setCategory(category);
return entity;
}
use of in.testpress.testpress.models.Post in project android by testpress.
the class PostsListAdapter method getView.
@SuppressLint("SetTextI18n")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final Post post = getItem(position);
Ln.d("PostsListAdapter getView at position " + position);
Ln.d("PostsListAdapter getView post = " + post.getTitle());
if (convertView == null) {
convertView = activity.getLayoutInflater().inflate(layout, null);
}
TextView title = (TextView) convertView.findViewById(R.id.title);
title.setText(post.getTitle());
TextView date = (TextView) convertView.findViewById(R.id.date);
date.setText(FormatDate.getAbbreviatedTimeSpan(post.getPublished()));
TextView categoryView = (TextView) convertView.findViewById(R.id.category);
View categoryLayout = convertView.findViewById(R.id.category_layout);
if (post.getCategory() != null) {
categoryView.setText(post.getCategory().getName());
categoryLayout.setVisibility(View.VISIBLE);
} else {
categoryLayout.setVisibility(View.GONE);
}
convertView.findViewById(R.id.ripple_layout).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(activity, PostActivity.class);
intent.putExtra("shortWebUrl", post.getShort_web_url());
activity.startActivity(intent);
}
});
TextView commentsCount = (TextView) convertView.findViewById(R.id.comments_count);
View commentsLayout = convertView.findViewById(R.id.comments_layout);
if (post.getCommentsCount() == 0) {
commentsLayout.setVisibility(View.INVISIBLE);
} else {
commentsCount.setText(post.getCommentsCount().toString());
commentsLayout.setVisibility(View.VISIBLE);
}
title.setTypeface(TestpressSdk.getRubikMediumFont(activity));
ViewUtils.setTypeface(new TextView[] { commentsCount, date, categoryView }, TestpressSdk.getRubikRegularFont(activity));
return convertView;
}
Aggregations