Search in sources :

Example 31 with ArrayAdapter

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);
    }
}
Also used : ArrayAdapter(android.widget.ArrayAdapter)

Example 32 with ArrayAdapter

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();
    }
}
Also used : GeoviewModel(org.wordpress.android.ui.stats.models.GeoviewModel) ArrayAdapter(android.widget.ArrayAdapter)

Example 33 with ArrayAdapter

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);
    }
}
Also used : ArrayAdapter(android.widget.ArrayAdapter) PostsAndPagesAdapter(org.wordpress.android.ui.stats.adapters.PostsAndPagesAdapter)

Example 34 with ArrayAdapter

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);
}
Also used : FollowersModel(org.wordpress.android.ui.stats.models.FollowersModel) StatsService(org.wordpress.android.ui.stats.service.StatsService) WPNetworkImageView(org.wordpress.android.widgets.WPNetworkImageView) View(android.view.View) ArrayAdapter(android.widget.ArrayAdapter)

Example 35 with ArrayAdapter

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();
        }
    });
}
Also used : ListView(android.widget.ListView) RequestError(labs.anton.icenet.RequestError) ProgressDialog(android.app.ProgressDialog) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

ArrayAdapter (android.widget.ArrayAdapter)309 View (android.view.View)154 TextView (android.widget.TextView)102 ListView (android.widget.ListView)92 AdapterView (android.widget.AdapterView)89 ArrayList (java.util.ArrayList)55 Spinner (android.widget.Spinner)51 ViewGroup (android.view.ViewGroup)40 Intent (android.content.Intent)33 AutoCompleteTextView (android.widget.AutoCompleteTextView)29 Button (android.widget.Button)26 ImageView (android.widget.ImageView)26 DialogInterface (android.content.DialogInterface)23 ListAdapter (android.widget.ListAdapter)21 RecyclerView (android.support.v7.widget.RecyclerView)18 LayoutInflater (android.view.LayoutInflater)18 LinearLayout (android.widget.LinearLayout)18 Bundle (android.os.Bundle)17 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)17 EditText (android.widget.EditText)15