Example usage for android.support.v4.app SupportActivity runOnUiThread

List of usage examples for android.support.v4.app SupportActivity runOnUiThread

Introduction

In this page you can find the example usage for android.support.v4.app SupportActivity runOnUiThread.

Prototype

void runOnUiThread(Runnable action);

Source Link

Usage

From source file:com.flipzu.flipzu.ListingsFragment.java

@Override
public void onListingReceived(List<BroadcastDataSet> bcastList, Integer listType) {

    debug.logV(TAG, "onListingReceived for list_type " + listType);

    if (bcastList == null && getSupportActivity() != null) {
        debug.logV(TAG, "onListingReceived got NULL bcastList");
        // actionBar.setProgressBarVisibility(View.INVISIBLE);
        getSupportActivity().setProgressBarIndeterminateVisibility(Boolean.FALSE);
        return;//w  w  w. j a va2 s .c om
    }

    if (bcastList.size() == 0) {
        mEndOfListing = true;
        /* show "empty" messages */
        if (this.isAdded()) {
            if (mListType == fi.FRIENDS) {
                this.setEmptyText(getText(R.string.empty_friends));
            } else if (mListType == fi.PROFILE) {
                this.setEmptyText(getText(R.string.empty_profile));
            } else if (mListType == fi.HOTTEST) {
                this.setEmptyText(getText(R.string.empty_hot));
            } else if (mListType == fi.SEARCH) {
                this.setEmptyText(getText(R.string.empty_search));
            }
        }
    } else {
        mEndOfListing = false;
    }

    debug.logV(TAG, "onListingReceived got bcastList size " + bcastList.size());

    for (BroadcastDataSet bcast : bcastList) {
        if (!bcast.isAuthorized()) {
            this.setEmptyText(getText(R.string.empty_auth_failed));
            debug.logV(TAG, "onListingReceived AUTH FAILED!");
        } else {
            if (mListType == fi.HOTTEST) {
                mBcasts.add(bcast);
                lastBcast = null;
            }
            /* filter repeated broadcasts from the getMore() web services */
            /*
             * this is because LIVE broadcasts go first, and sometimes OLD
             * live
             */
            /* bcasts started beyond LIST_LEN */
            else {
                /* start of listing */
                if (mFrom == null) {
                    lastBcast = null;
                }
                if (lastBcast == null) {
                    debug.logV(TAG, "onListingReceived, setting lastBcast ");
                    lastBcast = bcast;
                    mBcasts.add(bcast);
                } else {
                    if (!(!lastBcast.isLive() && bcast.isLive())) {
                        debug.logV(TAG, "onListingReceived, adding " + bcast.getUsername());
                        mBcasts.add(bcast);
                        lastBcast = bcast;
                    } // skip rest                   
                }
            }
            // debug.logV(TAG, "onListingReceived, new mBcasts size " +
            // mBcasts.size());
        }
    }

    SupportActivity a = getSupportActivity();
    if (a != null) {
        debug.logV(TAG, "running returnRes for list_type " + listType);
        a.runOnUiThread(returnRes);
    }
}