use of org.wordpress.android.ui.stats.models.StatsPostModel in project WordPress-Android by wordpress-mobile.
the class PostsAndPagesAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
// reuse views
if (rowView == null) {
rowView = inflater.inflate(R.layout.stats_list_cell, parent, false);
// configure view holder
StatsViewHolder viewHolder = new StatsViewHolder(rowView);
rowView.setTag(viewHolder);
}
final StatsPostModel currentRowData = list.get(position);
StatsViewHolder holder = (StatsViewHolder) rowView.getTag();
// Entry
holder.setEntryTextOpenDetailsPage(currentRowData);
// Setup the more button
holder.setMoreButtonOpenInReader(currentRowData);
// totals
holder.totalsTextView.setText(FormatUtils.formatDecimal(currentRowData.getTotals()));
// no icon
holder.networkImageView.setVisibility(View.GONE);
return rowView;
}
use of org.wordpress.android.ui.stats.models.StatsPostModel in project WordPress-Android by wordpress-mobile.
the class RemoteTests method testTopPost.
public void testTopPost() throws Exception {
StatsRestRequestAbstractListener listener = new StatsRestRequestAbstractListener() {
@Override
void parseResponse(JSONObject response) throws JSONException {
TopPostsAndPagesModel model = new TopPostsAndPagesModel(123456, response);
assertNotNull(model.getTopPostsAndPages());
assertEquals(model.getTopPostsAndPages().size(), 10);
StatsPostModel postModel = model.getTopPostsAndPages().get(0);
assertEquals(postModel.getItemID(), "39806");
assertEquals(postModel.getTotals(), 2420);
assertEquals(postModel.getTitle(), "Home");
assertEquals(postModel.getUrl(), "http://automattic.com/home/");
assertEquals(postModel.getDate(), StatsUtils.toMs("2011-08-30 21:47:38"));
assertEquals(postModel.getPostType(), "page");
postModel = model.getTopPostsAndPages().get(9);
assertEquals(postModel.getItemID(), "39254");
assertEquals(postModel.getTotals(), 56);
assertEquals(postModel.getTitle(), "Growth Explorer");
assertEquals(postModel.getUrl(), "http://automattic.com/work-with-us/growth-explorer/");
assertEquals(postModel.getDate(), StatsUtils.toMs("2011-08-25 19:37:27"));
assertEquals(postModel.getPostType(), "page");
}
};
mRestClient.makeRequest(Request.Method.POST, "https://public-api.wordpress.com/rest/v1.1/sites/123456/stats/top-posts", null, listener, errListener);
}
use of org.wordpress.android.ui.stats.models.StatsPostModel in project WordPress-Android by wordpress-mobile.
the class ActivityLauncher method viewStatsSinglePostDetails.
public static void viewStatsSinglePostDetails(Context context, SiteModel site, PostModel post, boolean isPage) {
if (post == null)
return;
StatsPostModel statsPostModel = new StatsPostModel(site.getSiteId(), String.valueOf(post.getRemotePostId()), post.getTitle(), post.getLink(), isPage ? StatsConstants.ITEM_TYPE_PAGE : StatsConstants.ITEM_TYPE_POST);
viewStatsSinglePostDetails(context, statsPostModel);
}
use of org.wordpress.android.ui.stats.models.StatsPostModel in project WordPress-Android by wordpress-mobile.
the class RemoteTests method testTopPostEmptyURL.
public void testTopPostEmptyURL() throws Exception {
StatsRestRequestAbstractListener listener = new StatsRestRequestAbstractListener() {
@Override
void parseResponse(JSONObject response) throws JSONException {
TopPostsAndPagesModel model = new TopPostsAndPagesModel(1234567890, response);
assertNotNull(model.getTopPostsAndPages());
assertEquals(model.getTopPostsAndPages().size(), 10);
StatsPostModel postModel = model.getTopPostsAndPages().get(0);
assertEquals(postModel.getItemID(), "750");
assertEquals(postModel.getTotals(), 7);
assertEquals(postModel.getTitle(), "Asynchronous unit testing Core Data with Xcode 6");
// This post has no URL?!? Unpublished post that was prev published?
assertEquals(postModel.getUrl(), "");
assertEquals(postModel.getDate(), StatsUtils.toMs("2014-08-06 14:52:11"));
assertEquals(postModel.getPostType(), "post");
}
};
mRestClient.makeRequest(Request.Method.POST, "https://public-api.wordpress.com/rest/v1.1/sites/1234567890/stats/top-posts", null, listener, errListener);
}
use of org.wordpress.android.ui.stats.models.StatsPostModel in project WordPress-Android by wordpress-mobile.
the class StatsTopPostsAndPagesFragment method updateUI.
@Override
protected void updateUI() {
if (!isAdded()) {
return;
}
if (hasTopPostsAndPages()) {
List<StatsPostModel> postViews = mTopPostsAndPagesModel.getTopPostsAndPages();
ArrayAdapter adapter = new PostsAndPagesAdapter(getActivity(), postViews);
StatsUIHelper.reloadLinearLayout(getActivity(), adapter, mList, getMaxNumberOfItemsToShowInList());
showHideNoResultsUI(false);
} else {
showHideNoResultsUI(true);
}
}
Aggregations