Example usage for android.app ActionBar NAVIGATION_MODE_LIST

List of usage examples for android.app ActionBar NAVIGATION_MODE_LIST

Introduction

In this page you can find the example usage for android.app ActionBar NAVIGATION_MODE_LIST.

Prototype

int NAVIGATION_MODE_LIST

To view the source code for android.app ActionBar NAVIGATION_MODE_LIST.

Click Source Link

Document

List navigation mode.

Usage

From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java

private void displayPathShortcut() {
    // /QUICK PATH
    if (parentFolder != null && getActivity().getActionBar() != null) {
        //// w w w. j  a  v a2 s  . com
        getActivity().getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
        String pathValue = parentFolder.getName();
        if (parentFolder.getProperty(PropertyIds.PATH) != null) {
            pathValue = parentFolder.getProperty(PropertyIds.PATH).getValue();
        }

        boolean fromSite = false;
        if (getActivity() instanceof MainActivity) {
            fromSite = currentSiteParameter != null;
        }

        List<String> listFolder = getPath(pathValue, fromSite);

        SpinnerAdapter adapter = new PathAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item,
                listFolder);

        OnNavigationListener mOnNavigationListener = new OnNavigationListener() {

            @Override
            public boolean onNavigationItemSelected(int itemPosition, long itemId) {
                if (itemPosition == 0) {
                    return true;
                }

                if (isShortcut()) {
                    boolean fromSite = false;
                    if (getActivity() instanceof MainActivity) {
                        fromSite = currentSiteParameter != null;
                    }

                    // Determine the path
                    String pathValue = parentFolder.getProperty(PropertyIds.PATH).getValue();
                    List<String> listFolder = getPath(pathValue, fromSite);

                    List<String> subPath = listFolder.subList(itemPosition, listFolder.size());
                    Collections.reverse(subPath);
                    String path = subPath.remove(0);
                    for (String string : subPath) {
                        path += string + "/";
                    }

                    ((BaseActivity) getActivity()).addBrowserFragment(path);
                } else {
                    for (int i = 0; i < itemPosition; i++) {
                        getFragmentManager().popBackStack();
                    }
                }

                return true;
            }

        };

        getActivity().getActionBar().setListNavigationCallbacks(adapter, mOnNavigationListener);

        shortcutAlreadyVisible = true;
    }
}

From source file:com.nuvolect.securesuite.main.ContactListActivity.java

/**
 * Start the GUI, method assumes that a master account is already set
 *//*from w  w w .ja  va 2  s  . c  om*/
private void startGui() {

    SqlCipher.getInstance(m_ctx);
    /**
     * Detect app upgrade and provide a placeholder for managing upgrades, database changes, etc.
     */
    boolean appUpgraded = LicenseUtil.appUpgraded(m_act);

    if (appUpgraded) {

        Toast.makeText(getApplicationContext(), "Application upgraded", Toast.LENGTH_LONG).show();

        // Execute upgrade methods
    }

    // Set default settings
    PreferenceManager.setDefaultValues(this, R.xml.settings, false);

    // Set the progress bar to off, otherwise some devices will default to on
    setProgressBarIndeterminateVisibility(false);

    // Load group data into memory, used for group titles and people counts
    MyGroups.loadGroupMemory();

    boolean isFirstTime = Persist.isStartingUp(m_ctx);
    if (isFirstTime) {

        String account = LicensePersist.getLicenseAccount(m_ctx);
        Cryp.setCurrentAccount(account);
        MyGroups.addBaseGroupsToNewAccount(m_ctx, account);
        Cryp.setCurrentGroup(MyGroups.getDefaultGroup(account));

        try {
            // Import a default contact when starting first time
            InputStream vcf = getResources().getAssets().open(CConst.APP_VCF);
            ImportVcard.importVcf(m_ctx, vcf, Cryp.getCurrentGroup());

        } catch (IOException e) {
            LogUtil.logException(ContactListActivity.class, e);
        }

        // First time, request phone management access
        PermissionUtil.requestFirstTimePermissions(m_act);
    }

    // Support for action bar pull down menu
    adapter = ArrayAdapter.createFromResource(this, R.array.action_bar_spinner_menu,
            android.R.layout.simple_spinner_dropdown_item);

    // Action bar spinner menu callback
    navigationListener = new OnNavigationListener() {

        // List items from resource
        String[] navItems = getResources().getStringArray(R.array.action_bar_spinner_menu);

        @Override
        public boolean onNavigationItemSelected(int position, long id) {

            if (DEBUG)
                LogUtil.log("ContactListActivity NavigationItemSelected: " + navItems[position]);

            // Do stuff when navigation item is selected
            switch (CConst.NavMenu.values()[position]) {

            case contacts: {

                // Persist the navigation selection for fragments to pick up
                Persist.setNavChoice(m_act, position, navItems[position]);

                break;
            }

            case groups: {

                // Persist the navigation selection for fragments to pick up
                Persist.setNavChoice(m_act, position, navItems[position]);

                // Dispatch to the main group list activity
                Intent intent = new Intent(m_act, GroupListActivity.class);
                startActivity(intent);

                // Remove this activity from the stack
                // Group list is the only activity on the stack
                m_act.finish();

                break;
            }
            case passwords: {

                actionBar.setSelectedNavigationItem(Persist.getNavChoice(m_act));
                PasswordFragment f = PasswordFragment.newInstance(m_act);
                f.start();
                break;
            }
            case calendar: {

                Intent intent = new Intent(m_act, CalendarActivity.class);
                startActivity(intent);
                break;
            }
            case finder: {

                Intent intent = new Intent(m_act, FinderActivity.class);
                startActivity(intent);
                break;
            }
            case server: {

                /**
                 * Restore the spinner such that the Password is never persisted
                 * and never shows.
                 */
                actionBar.setSelectedNavigationItem(Persist.getNavChoice(m_act));
                ServerFragment f = ServerFragment.newInstance(m_act);
                f.start();
                break;
            }
            default:
            }
            return true;
        }
    };

    actionBar = getActionBar();
    ActionBarUtil.setNavigationMode(actionBar, ActionBar.NAVIGATION_MODE_LIST);
    ActionBarUtil.setDisplayShowTitleEnabled(actionBar, false);
    ActionBarUtil.setListNavigationCallbacks(actionBar, adapter, navigationListener);
    AppTheme.applyActionBarTheme(m_act, actionBar);

    // Start with the previous contact or reset to a valid contact
    m_contact_id = Persist.getCurrentContactId(m_act);
    if (m_contact_id <= 0 || !SqlCipher.validContactId(m_contact_id)) {
        m_contact_id = SqlCipher.getFirstContactID();
        Persist.setCurrentContactId(m_act, m_contact_id);
    }

    // savedInstanceState is non-null when there is fragment state
    // saved from previous configurations of this activity
    // (e.g. when rotating the screen from portrait to landscape).
    // In this case, the fragment will automatically be re-added
    // to its container so we don't need to manually add it.
    // For more information, see the Fragments API guide at:
    //
    // http://developer.android.com/guide/components/fragments.html
    //
    if (isFirstTime || m_savedInstanceState == null) {

        if (findViewById(R.id.contact_detail_container) != null) {
            // Setup for single or dual fragments depending on display size
            // The detail container view will be present only in the large-screen layouts
            // (res/values-large and res/values-sw600dp). If this view is present, then the
            // activity should be in two-pane mode.
            mTwoPane = true;

            m_clf_fragment = startContactListFragment();

            // In two-pane mode, list items should be given the 'activated' state when touched.
            m_clf_fragment.setActivateOnItemClick(true);

            // In two-pane mode, show the detail view in this activity by
            // adding or replacing the detail fragment using a fragment transaction.
            startContactDetailFragment();

        } else {
            mTwoPane = false;
            m_clf_fragment = startContactListFragment();
        }
    }
}

From source file:com.tweetlanes.android.view.HomeActivity.java

private boolean configureListNavigation() {

    if (mSpinnerAdapter == null) {
        return false;
    }//from  w  w w . j av  a 2  s. c  o m

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

    int accountIndex = 0;
    AccountDescriptor currentAccount = getApp().getCurrentAccount();
    if (currentAccount != null) {
        String testScreenName = "@" + currentAccount.getScreenName().toLowerCase();
        for (int i = 0; i < mAdapterStrings.length; i++) {
            if (testScreenName.equals(mAdapterStrings[i].toLowerCase())) {
                accountIndex = i;
                break;
            }
        }
    }
    actionBar.setSelectedNavigationItem(accountIndex);
    actionBar.setDisplayHomeAsUpEnabled(false);
    return true;
}

From source file:com.alirezaafkar.toolbar.ToolbarWidgetWrapper.java

@Override
public void setNavigationMode(int mode) {
    final int oldMode = mNavigationMode;
    if (mode != oldMode) {
        switch (oldMode) {
        case ActionBar.NAVIGATION_MODE_LIST:
            if (mSpinner != null && mSpinner.getParent() == mToolbar) {
                mToolbar.removeView(mSpinner);
            }/*from www. j av a 2  s. c  om*/
            break;
        case ActionBar.NAVIGATION_MODE_TABS:
            if (mTabView != null && mTabView.getParent() == mToolbar) {
                mToolbar.removeView(mTabView);
            }
            break;
        }

        mNavigationMode = mode;

        switch (mode) {
        case ActionBar.NAVIGATION_MODE_STANDARD:
            break;
        case ActionBar.NAVIGATION_MODE_LIST:
            ensureSpinner();
            mToolbar.addView(mSpinner, 0);
            break;
        case ActionBar.NAVIGATION_MODE_TABS:
            if (mTabView != null) {
                mToolbar.addView(mTabView, 0);
                RtlToolbar.LayoutParams lp = (RtlToolbar.LayoutParams) mTabView.getLayoutParams();
                lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
                lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
                lp.gravity = Gravity.START | Gravity.BOTTOM;
            }
            break;
        default:
            throw new IllegalArgumentException("Invalid navigation mode " + mode);
        }
    }
}

From source file:com.shafiq.mytwittle.view.HomeActivity.java

private boolean configureListNavigation() {

    if (mSpinnerAdapter == null) {
        return false;
    }//from w  w  w  . j  a v a 2  s.  com

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

    int accountIndex = 0;
    AccountDescriptor currentAccount = getApp().getCurrentAccount();
    if (currentAccount != null) {
        String testScreenName = "@" + currentAccount.getScreenName()
                + (currentAccount.getSocialNetType() == SocialNetConstant.Type.Appdotnet ? " (App.net)"
                        : " (Twitter)");
        for (int i = 0; i < mAdapterStrings.length; i++) {
            if (testScreenName.toLowerCase().equals(mAdapterStrings[i].toLowerCase())) {
                accountIndex = i;
                break;
            }
        }
    }
    actionBar.setSelectedNavigationItem(accountIndex);
    actionBar.setDisplayHomeAsUpEnabled(false);
    return true;
}

From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java

@Override
public void setNavigationMode(int mode) {
    final int oldMode = mNavigationMode;
    if (mode != oldMode) {
        switch (oldMode) {
        case ActionBar.NAVIGATION_MODE_LIST:
            if (mSpinner != null && mSpinner.getParent() == mToolbar) {
                mToolbar.removeView(mSpinner);
            }//w ww.  ja  v  a  2  s.  c  o m
            break;
        case ActionBar.NAVIGATION_MODE_TABS:
            if (mTabView != null && mTabView.getParent() == mToolbar) {
                mToolbar.removeView(mTabView);
            }
            break;
        }

        mNavigationMode = mode;

        switch (mode) {
        case ActionBar.NAVIGATION_MODE_STANDARD:
            break;
        case ActionBar.NAVIGATION_MODE_LIST:
            ensureSpinner();
            mToolbar.addView(mSpinner, 0);
            break;
        case ActionBar.NAVIGATION_MODE_TABS:
            if (mTabView != null) {
                mToolbar.addView(mTabView, 0);
                Toolbar.LayoutParams lp = (Toolbar.LayoutParams) mTabView.getLayoutParams();
                lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
                lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
                lp.gravity = Gravity.START | Gravity.BOTTOM;
            }
            break;
        default:
            throw new IllegalArgumentException("Invalid navigation mode " + mode);
        }
    }
}

From source file:com.aknowledge.v1.automation.RemoteActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_remote);
    myApp = (PyHomeController) getApplication();

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(
            // Specify a SpinnerAdapter to populate the dropdown list.
            new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_list_item_1,
                    android.R.id.text1, new String[] { "All" }),
            this);

}

From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java

public void updateActionBar() {
    final ActionBar actionBar = getActionBar();

    actionBar.setDisplayShowHomeEnabled(true);

    final boolean showIndicator = !mShowAsDialog && (mState.action != ACTION_MANAGE);
    actionBar.setDisplayHomeAsUpEnabled(showIndicator);
    if (mDrawerToggle != null) {
        mDrawerToggle.setDrawerIndicatorEnabled(showIndicator);
    }/*from w  w w.j a  va 2 s . co  m*/

    if (isRootsDrawerOpen()) {
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
        actionBar.setIcon(new ColorDrawable());

        if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) {
            actionBar.setTitle(R.string.title_open);
        } else if (mState.action == ACTION_CREATE) {
            actionBar.setTitle(R.string.title_save);
        }
    } else {
        final RootInfo root = getCurrentRoot();
        actionBar.setIcon(root != null ? root.loadIcon(this) : null);

        if (mState.stack.size() <= 1) {
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
            actionBar.setTitle(root.title);
        } else {
            mIgnoreNextNavigation = true;
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
            actionBar.setTitle(null);
            actionBar.setListNavigationCallbacks(mStackAdapter, mStackListener);
            actionBar.setSelectedNavigationItem(mStackAdapter.getCount() - 1);
        }
    }
}

From source file:com.google.samples.apps.iosched.ui.SessionLivestreamActivity.java

/**
 * Load the list of currently live sessions or upcoming live sessions. This
 * populates the Action Bar (either the title or as list navigation.
 *///  w ww.  j av a2  s . c o m
private void loadSessionsList(Cursor data) {
    mLivestreamAdapter.swapCursor(data);
    if (data != null && data.getCount() > 0) {
        mSessionsFound = true;
        final ActionBar actionBar = getActionBar();
        if (data.getCount() == 1) {
            // Just one session on, display title in Action Bar
            if (data.moveToFirst()) {
                actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
                actionBar.setDisplayShowTitleEnabled(true);
                actionBar.setTitle(data.getString(SessionsQuery.TITLE));
            }
        } else if (data.getCount() > 1) {
            // 2+ sessions found, set Action Bar to list navigation (spinner)
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
            actionBar.setListNavigationCallbacks(mLivestreamAdapter, this);
            actionBar.setDisplayShowTitleEnabled(false);
            getActionBar().setSelectedNavigationItem(locateSelectedItem(data));
        }
    } else if (mSessionsFound) {
        // Sessions were previously found but no sessions are currently live,
        // adjust query to see if there are any future sessions at all
        mSessionsFound = false;
        final Bundle bundle = new Bundle();
        bundle.putBoolean(LOADER_SESSIONS_ARG, true);
        getLoaderManager().restartLoader(SessionsQuery._TOKEN, bundle, this);
    } else {
        // No sessions live right now and no sessions coming up, get out
        finish();
    }
}

From source file:com.tweetlanes.android.core.view.HomeActivity.java

private boolean configureListNavigation() {

    if (mSpinnerAdapter == null) {
        return false;
    }/*from   w w  w  .j  av  a 2s  .co m*/

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

    int accountIndex = 0;
    AccountDescriptor currentAccount = getApp().getCurrentAccount();
    if (currentAccount != null) {
        for (int i = 0; i < getApp().getAccounts().size(); i++) {
            if (currentAccount.getAccountKey().equals(getApp().getAccounts().get(i).getAccountKey())) {
                accountIndex = i;
                break;
            }
        }
    }
    actionBar.setSelectedNavigationItem(accountIndex);
    actionBar.setDisplayHomeAsUpEnabled(false);
    return true;
}