use of android.widget.ArrayAdapter in project WordPress-Android by wordpress-mobile.
the class StatsVideoplaysFragment method updateUI.
@Override
protected void updateUI() {
if (!isAdded()) {
return;
}
if (hasVideoplays()) {
ArrayAdapter adapter = new TopPostsAndPagesAdapter(getActivity(), getVideoplays());
StatsUIHelper.reloadLinearLayout(getActivity(), adapter, mList, getMaxNumberOfItemsToShowInList());
showHideNoResultsUI(false);
} else {
showHideNoResultsUI(true);
}
}
use of android.widget.ArrayAdapter in project WordPress-Android by wordpress-mobile.
the class StatsGeoviewsFragment method updateUI.
@Override
protected void updateUI() {
if (!isAdded()) {
return;
}
if (hasCountries()) {
List<GeoviewModel> countries = getCountries();
ArrayAdapter adapter = new GeoviewsAdapter(getActivity(), countries);
StatsUIHelper.reloadLinearLayout(getActivity(), adapter, mList, getMaxNumberOfItemsToShowInList());
showHideNoResultsUI(false);
showMap(countries);
} else {
showHideNoResultsUI(true);
hideMap();
}
}
use of android.widget.ArrayAdapter in project WordPress-Android by wordpress-mobile.
the class StatsCommentsFragment method updateUI.
@Override
protected void updateUI() {
if (!isAdded()) {
return;
}
if (mCommentsModel == null && mCommentFollowersModel == null) {
showHideNoResultsUI(true);
mTotalsLabel.setVisibility(View.GONE);
mTopPagerContainer.setVisibility(View.GONE);
return;
}
mTopPagerContainer.setVisibility(View.VISIBLE);
if (mCommentFollowersModel != null) {
// check if comment-followers is already here
mTotalsLabel.setVisibility(View.VISIBLE);
int totalNumberOfFollowers = mCommentFollowersModel.getTotal();
String totalCommentsFollowers = getString(R.string.stats_comments_total_comments_followers);
mTotalsLabel.setText(String.format(totalCommentsFollowers, FormatUtils.formatDecimal(totalNumberOfFollowers)));
}
ArrayAdapter adapter = null;
if (mTopPagerSelectedButtonIndex == 0 && hasAuthors()) {
adapter = new AuthorsAdapter(getActivity(), getAuthors());
} else if (mTopPagerSelectedButtonIndex == 1 && hasPosts()) {
adapter = new PostsAndPagesAdapter(getActivity(), getPosts());
}
if (adapter != null) {
StatsUIHelper.reloadLinearLayout(getActivity(), adapter, mList, getMaxNumberOfItemsToShowInList());
showHideNoResultsUI(false);
} else {
showHideNoResultsUI(true);
}
}
use of android.widget.ArrayAdapter in project WordPress-Android by wordpress-mobile.
the class StatsFollowersFragment method updateUI.
@Override
protected void updateUI() {
if (!isAdded()) {
return;
}
if (!hasDataAvailable()) {
showHideNoResultsUI(true);
mTotalsLabel.setText(getTotalFollowersLabel(0));
return;
}
mTotalsLabel.setVisibility(View.VISIBLE);
final FollowersModel followersModel = getCurrentDataModel();
if (followersModel != null && followersModel.getFollowers() != null && followersModel.getFollowers().size() > 0) {
ArrayAdapter adapter = new DotComFollowerAdapter(getActivity(), followersModel.getFollowers());
StatsUIHelper.reloadLinearLayout(getActivity(), adapter, mList, getMaxNumberOfItemsToShowInList());
showHideNoResultsUI(false);
if (mTopPagerSelectedButtonIndex == 0) {
mTotalsLabel.setText(getTotalFollowersLabel(followersModel.getTotalWPCom()));
} else {
mTotalsLabel.setText(getTotalFollowersLabel(followersModel.getTotalEmail()));
}
if (isSingleView()) {
if (followersModel.getPages() > 1) {
mBottomPaginationContainer.setVisibility(View.VISIBLE);
mTopPaginationContainer.setVisibility(View.VISIBLE);
String paginationLabel = String.format(getString(R.string.stats_pagination_label), FormatUtils.formatDecimal(followersModel.getPage()), FormatUtils.formatDecimal(followersModel.getPages()));
mBottomPaginationText.setText(paginationLabel);
mTopPaginationText.setText(paginationLabel);
setNavigationButtonsEnabled(true);
// Setting up back buttons
if (followersModel.getPage() == 1) {
// first page. No go back buttons
setNavigationBackButtonsVisibility(false);
} else {
setNavigationBackButtonsVisibility(true);
View.OnClickListener clickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
setNavigationButtonsEnabled(false);
refreshStats(followersModel.getPage() - 1, new StatsService.StatsEndpointsEnum[] { sectionsToUpdate()[mTopPagerSelectedButtonIndex] });
}
};
mBottomPaginationGoBackButton.setOnClickListener(clickListener);
mTopPaginationGoBackButton.setOnClickListener(clickListener);
}
// Setting up forward buttons
if (followersModel.getPage() == followersModel.getPages()) {
// last page. No go forward buttons
setNavigationForwardButtonsVisibility(false);
} else {
setNavigationForwardButtonsVisibility(true);
View.OnClickListener clickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
setNavigationButtonsEnabled(false);
refreshStats(followersModel.getPage() + 1, new StatsService.StatsEndpointsEnum[] { sectionsToUpdate()[mTopPagerSelectedButtonIndex] });
}
};
mBottomPaginationGoForwardButton.setOnClickListener(clickListener);
mTopPaginationGoForwardButton.setOnClickListener(clickListener);
}
// Change the total number of followers label by adding the current paging info
int startIndex = followersModel.getPage() * StatsService.MAX_RESULTS_REQUESTED_PER_PAGE - StatsService.MAX_RESULTS_REQUESTED_PER_PAGE + 1;
int endIndex = startIndex + followersModel.getFollowers().size() - 1;
String pagedLabel = getString(mTopPagerSelectedButtonIndex == 0 ? R.string.stats_followers_total_wpcom_paged : R.string.stats_followers_total_email_paged, startIndex, endIndex, FormatUtils.formatDecimal(mTopPagerSelectedButtonIndex == 0 ? followersModel.getTotalWPCom() : followersModel.getTotalEmail()));
mTotalsLabel.setText(pagedLabel);
} else {
// No paging required. Hide the controls.
mBottomPaginationContainer.setVisibility(View.GONE);
mTopPaginationContainer.setVisibility(View.GONE);
}
}
} else {
showHideNoResultsUI(true);
mBottomPaginationContainer.setVisibility(View.GONE);
mTotalsLabel.setText(getTotalFollowersLabel(0));
}
// Always visible. Even if the current tab is empty, otherwise the user can't switch tab
mTopPagerContainer.setVisibility(View.VISIBLE);
}
use of android.widget.ArrayAdapter in project IceNet by anton46.
the class JsonArrayActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ListView listView = (ListView) findViewById(R.id.list);
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("Loading...");
dialog.show();
IceNet.connect().createRequest().get().pathUrl("/notes").fromJsonArray().mappingInto(Notes.class).execute("request_string", new RequestCallback<Notes>() {
@Override
public void onRequestSuccess(Notes notes) {
dialog.dismiss();
String[] values = new String[notes.size()];
for (int i = 0; i < notes.size(); i++) values[i] = notes.get(i).getTitle();
adapter = new ArrayAdapter<String>(JsonArrayActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
listView.setAdapter(adapter);
}
@Override
public void onRequestError(RequestError error) {
dialog.dismiss();
}
});
}
Aggregations