Example usage for android.app ActionBar setSubtitle

List of usage examples for android.app ActionBar setSubtitle

Introduction

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

Prototype

public abstract void setSubtitle(@StringRes int resId);

Source Link

Document

Set the action bar's subtitle.

Usage

From source file:com.vituniversity.hostelautomation.bluetoothchat.BluetoothChatFragment.java

/**
 * Updates the status on the action bar.
 *
 * @param resId a string resource ID//from   w  w  w .j ava 2  s  . co m
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setStatus(int resId) {
    FragmentActivity activity = getActivity();
    if (null == activity) {
        return;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (null == actionBar) {
        return;
    }
    actionBar.setSubtitle(resId);
}

From source file:com.vituniversity.hostelautomation.bluetoothchat.BluetoothChatFragment.java

/**
 * Updates the status on the action bar.
 *
 * @param subTitle status/*  ww w.  j  a  v  a  2s . c o m*/
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setStatus(CharSequence subTitle) {
    FragmentActivity activity = getActivity();
    if (null == activity) {
        return;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (null == actionBar) {
        return;
    }
    actionBar.setSubtitle(subTitle);
    tvConnectionStatus.setText(subTitle);
}

From source file:org.apps8os.motivator.ui.MoodHistoryActivity.java

/** Called when the activity is first created. */
@Override//from  www .ja  v a2  s. c  o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mood_history);
    mDayDataHandler = new DayDataHandler(this);

    mCurrentSprint = getIntent().getExtras().getParcelable(Sprint.CURRENT_SPRINT);
    mRes = getResources();
    mSprintStartDateInMillis = mCurrentSprint.getStartTime();
    mSprintEndDateInMillis = mCurrentSprint.getEndTime();

    mDaysInSprint = mCurrentSprint.getDaysInSprint();
    ActionBar actionBar = getActionBar();

    Calendar mToday = Calendar.getInstance();
    UtilityMethods.setToDayStart(mToday);
    mToday.setFirstDayOfWeek(Calendar.MONDAY);

    mNumberOfTodayInSprint = mCurrentSprint.getCurrentDayOfTheSprint();

    // Check if the sprint is already over.
    if (mNumberOfTodayInSprint > mDaysInSprint) {
        mNumberOfTodayInSprint = mDaysInSprint;
    }
    actionBar.setSubtitle(mCurrentSprint.getSprintTitle());
    actionBar.setTitle(mNumberOfTodayInSprint + " " + getString(R.string.days));
    actionBar.setBackgroundDrawable(mRes.getDrawable(R.drawable.action_bar_orange));

    mStartDate = Calendar.getInstance();
    mStartDate.setFirstDayOfWeek(Calendar.MONDAY);
    mStartDate.setTimeInMillis(mSprintStartDateInMillis);

    // Calculate the number of weeks in the sprint
    mNumberOfWeeksInSprint = mToday.get(Calendar.WEEK_OF_YEAR) - mStartDate.get(Calendar.WEEK_OF_YEAR) + 1;
    if (mNumberOfWeeksInSprint < 0) {
        mNumberOfWeeksInSprint = 52 + 1 - mStartDate.get(Calendar.WEEK_OF_YEAR)
                + mToday.get(Calendar.WEEK_OF_YEAR);
    } else {

    }

    // Sets the default selections as today or this week.
    mSelectedDay = mNumberOfTodayInSprint - 1;
    mSelectedWeek = mNumberOfWeeksInSprint - 1;
    mViewPager = (ViewPager) findViewById(R.id.activity_mood_history_viewpager);

    titleIndicator = (TitlePageIndicator) findViewById(R.id.indicator);

    // Page change listener to keep the selected week and day in a member.
    titleIndicator.setOnPageChangeListener(new OnPageChangeListener() {
        @Override
        public void onPageScrollStateChanged(int arg0) {
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageSelected(int arg0) {
            if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
                mSelectedDay = arg0;
            } else if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
                mSelectedWeek = arg0;
                MoodHistoryWeekFragment fragment = mPagerAdapterWeek.getWeekFragment(arg0);
                if (fragment != null) {
                    fragment.updateSelectedAttribute(mSelectedAttribute, false);
                }
            }
        }
    });

    setPageTitles();

    // Load correct layout and functionality based on orientation
    if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        loadPortraitView();
    } else if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        loadLandscapeView();
    }

}

From source file:fm.krui.kruifm.StreamActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.stream_layout);

    // Instantiate class members
    prefManager = new PreferenceManager(this);
    favTrackManager = new FavoriteTrackManager(this);

    stationTag = getIntent().getIntExtra(KEY_STATION_TAG, -1);

    // Set ActionBar Title
    ActionBar actionBar = getActionBar();
    actionBar.setTitle(getString(R.string.listen_sidebar));
    actionBar.setSubtitle(getActivitySubtitle(getIntent()));

    // FIXME: Move these to PreferenceManager after expanding its scope for cleaner code
    trackPrefs = this.getSharedPreferences(StreamService.PREFS_NAME, 0);

    // Instantiate broadcast receiver
    broadcastReceiver = new BroadcastReceiver() {
        @Override/*from ww w . j  ava  2  s  .  co  m*/
        public void onReceive(Context context, Intent intent) {
            processBroadcastCommand(intent);
        }
    };

    // Retrieve player state to determine how to build this activity
    boolean playerState = prefManager.getPlayerState();

    // If audio is playing in StreamService, we don't want to rebuffer, and we want to restore the UI state from the cache.
    if (playerState) {
        restoreUIState();
    }

    // If audio is NOT playing, buffer and treat this launch like a clean startup.
    else {
        // Determine the URL we need to use to stream based on the station tag and quality preferences
        streamUrl = getStreamUrl(stationTag);
        Log.v(TAG, "streamUrl is now set to: " + streamUrl);

        // Perform initial configuration of audio server
        changeUrl(stationTag);

        // Begin buffering the audio
        startAudio((ImageView) this.findViewById(R.id.play_audio_imageview));
    }

    // Build play button listener
    final ImageView playButton = (ImageView) this.findViewById(R.id.play_audio_imageview);
    playButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            handleAudio(playButton);
        }
    });

    // Build volume seek bar listener
    // ** DISABLED FOR NOW -- This might be completely thrown out. **
    /*final SeekBar volumeSeekBar = (SeekBar)this.findViewById(R.id.volume_seekbar);
    volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            
    // When seek bar progress is changed, change the audio of the media player appropriately.
    @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        // Send new volume via intent? Will this be slow?
    }
            
    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
    }
            
    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
    }
    }); */

    // Build settings button listener and apply it to settings icon and submit button
    View.OnClickListener flipListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Card flip animation which toggles between stream controls and settings views
            flipCard();
        }
    };

    final ImageView settingsButton = (ImageView) this.findViewById(R.id.stream_settings_imageview);
    final Button saveSettingsButton = (Button) this.findViewById(R.id.set_stream_settings_button);
    settingsButton.setOnClickListener(flipListener);
    saveSettingsButton.setOnClickListener(flipListener);

    // Build favorite button listener
    final ImageView favoriteButton = (ImageView) this.findViewById(R.id.stream_favorite_imageview);
    favoriteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (trackIsFavorite) {
                favoriteButton.setImageResource(R.drawable.star_unfilled_white);
                trackIsFavorite = false;
                removeTrackFromFavorites();
            } else {
                favoriteButton.setImageResource(R.drawable.star_filled_white);
                trackIsFavorite = true;
                addTrackToFavorites();
            }
        }
    });

    // Build settings switches
    final Switch streamQualitySwitch = (Switch) this.findViewById(R.id.stream_quality_switch);
    final Switch albumArtSwitch = (Switch) this.findViewById(R.id.stream_album_art_switch);

    // Set initial state of switches
    albumArtSwitch.setChecked(prefManager.getAlbumArtDownloadPreference());
    if (prefManager.getStreamQuality() == prefManager.HIGH_QUALITY) {
        streamQualitySwitch.setChecked(true);
    } else {
        streamQualitySwitch.setChecked(false);
    }

    // Assign listeners to switches
    streamQualitySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                prefManager.setStreamQuality(prefManager.HIGH_QUALITY);
                Log.v(TAG, "Stream quality setting is now: " + prefManager.getStreamQuality());
            } else {
                prefManager.setStreamQuality(prefManager.LOW_QUALITY);
                Log.v(TAG, "Stream quality setting is now: " + prefManager.getStreamQuality());
            }
            changeUrl(stationSpinnerPosition);
        }
    });

    albumArtSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                prefManager.setAlbumArtDownloadPreference(true);
                Log.v(TAG, "Album Art Download setting is now " + prefManager.getAlbumArtDownloadPreference());
            } else {
                prefManager.setAlbumArtDownloadPreference(false);
                Log.v(TAG, "Album Art Download setting is now " + prefManager.getAlbumArtDownloadPreference());
            }
        }
    });

    // ***** Old onCreate function starts here!
    // Initialize screen lock/wake receiver
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    BroadcastReceiver screenReceiver = new ScreenReceiver();

    // Attach it to this activity
    this.getApplicationContext().registerReceiver(screenReceiver, filter);

}

From source file:com.android.talkback.TalkBackPreferencesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Shows TalkBack's abbreviated version number in the action bar,
    ActionBar actionBar = getActionBar();
    PackageInfo packageInfo = TalkBackPreferenceFragment.getPackageInfo(this);
    if (actionBar != null && packageInfo != null) {
        actionBar.setSubtitle(getString(R.string.talkback_preferences_subtitle, packageInfo.versionName));
    }//w w  w .  j a  va 2  s  .  c  om

    getFragmentManager().beginTransaction().replace(android.R.id.content, new TalkBackPreferenceFragment())
            .commit();
}

From source file:fm.krui.kruifm.StreamContainer.java

/**
 * Styles the ActionBar appropriately based on the fragment to be loaded
 * @param fragmentId Integer identifier of fragment
 *///from   w  w  w .  ja v a 2  s .c om
private void applyActionBarParameters(int fragmentId) {
    // Default params
    ActionBar actionBar = getActionBar();
    String title = "";
    String subTitle = "";
    int navigationMode = ActionBar.NAVIGATION_MODE_STANDARD;

    // Set params based on opening tab
    switch (fragmentId) {
    case STREAM_TAB:
        //navigationMode = ActionBar.NAVIGATION_MODE_LIST;
        break;
    case PLAYLIST_TAB:
        title = getString(R.string.extended_playlist_title);
        subTitle = getString(R.string.extended_playlist_subtitle);
        break;
    case DJ_TAB:
        title = getString(R.string.dj_info_tab);
        break;
    case FAVORITE_TRACKS_TAB:
        title = getString(R.string.favorite_tracks_title);
        subTitle = getString(R.string.favorite_tracks_subtitle);
        break;
    case MUSIC_ARTICLES_TAB:
        title = getString(R.string.music_content_sidebar);
        break;
    case NEWS_ARTICLES_TAB:
        title = getString(R.string.news_content_sidebar);
        break;
    case SPORTS_ARTICLES_TAB:
        title = getString(R.string.sports_content_sidebar);
        break;
    }

    // Apply parameters
    actionBar.setNavigationMode(navigationMode);
    actionBar.setTitle(title);
    actionBar.setSubtitle(subTitle);
}

From source file:uk.org.downiesoft.slideshow.GridViewFragment.java

/**
 * Set the title/subtitle in the ActionBar to reflect the current path/sub-path
 * @param aFile The current file location.
 *///from   www . ja  v a 2 s.  c  om
private void setStatus(final ZFile aFile) {
    final ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null) {
        String subPath = aFile.getSubPath();
        String images = getString(R.string.text_images_placeholder);
        if (subPath.endsWith(images)) {
            subPath = subPath.substring(subPath.lastIndexOf(images));
            if (subPath.endsWith(File.separator)) {
                subPath = subPath.substring(0, subPath.length() - 1);
            }
        }
        if (aFile.isZipFile()) {
            File zip = new File(aFile.getRootPath());
            actionBar.setTitle(zip.getName());
            if (subPath.length() == 0) {
                actionBar.setSubtitle(null);
            } else {
                if (subPath.length() > 30) {
                    subPath = "\u2026" + subPath.substring(subPath.length() - 30);
                }
                actionBar.setSubtitle(subPath);
            }
        } else {
            actionBar.setTitle(aFile.getName());
            actionBar.setSubtitle(null);
        }
    }
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

private void updateTitle(ContactList list) {
    String title = null;/*  w w w. j  a v  a  2s  . c om*/
    String subTitle = null;
    int cnt = list.size();
    switch (cnt) {
    case 0: {
        String recipient = null;
        if (mRecipientsEditor != null) {
            recipient = mRecipientsEditor.getText().toString();
        }
        title = TextUtils.isEmpty(recipient) ? getString(R.string.new_message) : recipient;
        break;
    }
    case 1: {
        title = list.get(0).getName(); // get name returns the number if there's no
                                       // name available.
        String number = list.get(0).getNumber();
        if (!title.equals(number)) {
            subTitle = PhoneNumberUtils.formatNumber(number, number,
                    MmsApp.getApplication().getCurrentCountryIso());
        }
        break;
    }
    default: {
        // Handle multiple recipients
        title = list.formatNames(", ");
        subTitle = getResources().getQuantityString(R.plurals.recipient_count, cnt, cnt);
        break;
    }
    }
    mDebugRecipients = list.serialize();

    ActionBar actionBar = getActionBar();
    actionBar.setTitle(title);
    actionBar.setSubtitle(subTitle);
}

From source file:com.polychrom.cordova.ActionBarPlugin.java

@Override
public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext)
        throws JSONException {
    if (!plugin_actions.contains(action)) {
        return false;
    }//  w w w  . j  a  va 2 s  .c  o m

    final Activity ctx = (Activity) cordova;

    if ("isAvailable".equals(action)) {
        JSONObject result = new JSONObject();
        result.put("value", ctx.getWindow().hasFeature(Window.FEATURE_ACTION_BAR));
        callbackContext.success(result);
        return true;
    }

    final ActionBar bar = ctx.getActionBar();
    if (bar == null) {
        Window window = ctx.getWindow();
        if (!window.hasFeature(Window.FEATURE_ACTION_BAR)) {
            callbackContext
                    .error("ActionBar feature not available, Window.FEATURE_ACTION_BAR must be enabled!");
        } else {
            callbackContext.error("Failed to get ActionBar");
        }

        return true;
    }

    if (menu == null) {
        callbackContext.error("Options menu not initialised");
        return true;
    }

    final StringBuffer error = new StringBuffer();
    JSONObject result = new JSONObject();

    if ("isShowing".equals(action)) {
        result.put("value", bar.isShowing());
    } else if ("getHeight".equals(action)) {
        result.put("value", bar.getHeight());
    } else if ("getDisplayOptions".equals(action)) {
        result.put("value", bar.getDisplayOptions());
    } else if ("getNavigationMode".equals(action)) {
        result.put("value", bar.getNavigationMode());
    } else if ("getSelectedNavigationItem".equals(action)) {
        result.put("value", bar.getSelectedNavigationIndex());
    } else if ("getSubtitle".equals(action)) {
        result.put("value", bar.getSubtitle());
    } else if ("getTitle".equals(action)) {
        result.put("value", bar.getTitle());
    } else {
        try {
            JSONException exception = new Runnable() {
                public JSONException exception = null;

                public void run() {
                    try {
                        // This is a bit of a hack (should be specific to the request, not global)
                        bases = new String[] { removeFilename(webView.getOriginalUrl()),
                                removeFilename(webView.getUrl()) };

                        if ("show".equals(action)) {
                            bar.show();
                        } else if ("hide".equals(action)) {
                            bar.hide();
                        } else if ("setMenu".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("menu can not be null");
                                return;
                            }

                            menu_definition = args.getJSONArray(0);

                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                                ctx.invalidateOptionsMenu();
                            }
                        } else if ("setTabs".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("menu can not be null");
                                return;
                            }

                            bar.removeAllTabs();
                            tab_callbacks.clear();

                            if (!buildTabs(bar, args.getJSONArray(0))) {
                                error.append("Invalid tab bar definition");
                            }
                        } else if ("setDisplayHomeAsUpEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("showHomeAsUp can not be null");
                                return;
                            }

                            bar.setDisplayHomeAsUpEnabled(args.getBoolean(0));
                        } else if ("setDisplayOptions".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("options can not be null");
                                return;
                            }

                            final int options = args.getInt(0);
                            bar.setDisplayOptions(options);
                        } else if ("setDisplayShowHomeEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("showHome can not be null");
                                return;
                            }

                            bar.setDisplayShowHomeEnabled(args.getBoolean(0));
                        } else if ("setDisplayShowTitleEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("showTitle can not be null");
                                return;
                            }

                            bar.setDisplayShowTitleEnabled(args.getBoolean(0));
                        } else if ("setDisplayUseLogoEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("useLogo can not be null");
                                return;
                            }

                            bar.setDisplayUseLogoEnabled(args.getBoolean(0));
                        } else if ("setHomeButtonEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("enabled can not be null");
                                return;
                            }

                            bar.setHomeButtonEnabled(args.getBoolean(0));
                        } else if ("setIcon".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("icon can not be null");
                                return;
                            }

                            Drawable drawable = getDrawableForURI(args.getString(0));
                            bar.setIcon(drawable);
                        } else if ("setListNavigation".equals(action)) {
                            JSONArray items = null;
                            if (args.isNull(0) == false) {
                                items = args.getJSONArray(0);
                            }

                            navigation_adapter.setItems(items);
                            bar.setListNavigationCallbacks(navigation_adapter, navigation_listener);
                        } else if ("setLogo".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("logo can not be null");
                                return;
                            }

                            Drawable drawable = getDrawableForURI(args.getString(0));
                            bar.setLogo(drawable);
                        } else if ("setNavigationMode".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("mode can not be null");
                                return;
                            }

                            final int mode = args.getInt(0);
                            bar.setNavigationMode(mode);
                        } else if ("setSelectedNavigationItem".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("position can not be null");
                                return;
                            }

                            bar.setSelectedNavigationItem(args.getInt(0));
                        } else if ("setSubtitle".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("subtitle can not be null");
                                return;
                            }

                            bar.setSubtitle(args.getString(0));
                        } else if ("setTitle".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("title can not be null");
                                return;
                            }

                            bar.setTitle(args.getString(0));
                        }
                    } catch (JSONException e) {
                        exception = e;
                    } finally {
                        synchronized (this) {
                            this.notify();
                        }
                    }
                }

                // Run task synchronously
                {
                    synchronized (this) {
                        ctx.runOnUiThread(this);
                        this.wait();
                    }
                }
            }.exception;

            if (exception != null) {
                throw exception;
            }
        } catch (InterruptedException e) {
            error.append("Function interrupted on UI thread");
        }
    }

    if (error.length() == 0) {
        if (result.length() > 0) {
            callbackContext.success(result);
        } else {
            callbackContext.success();
        }
    } else {
        callbackContext.error(error.toString());
    }

    return true;
}

From source file:com.native5.plugins.ActionBarPlugin.java

@Override
public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext)
        throws JSONException {
    if (!plugin_actions.contains(action)) {
        return false;
    }//w w  w .  j ava2s. c  o m

    final Activity ctx = (Activity) cordova;

    if ("isAvailable".equals(action)) {
        JSONObject result = new JSONObject();
        result.put("value", ctx.getWindow().hasFeature(Window.FEATURE_ACTION_BAR));
        callbackContext.success(result);
        return true;
    }

    final ActionBar bar = ctx.getActionBar();
    if (bar == null) {
        Window window = ctx.getWindow();
        if (!window.hasFeature(Window.FEATURE_ACTION_BAR)) {
            callbackContext
                    .error("ActionBar feature not available, Window.FEATURE_ACTION_BAR must be enabled!");
        } else {
            callbackContext.error("Failed to get ActionBar");
        }

        return true;
    }

    if (menu == null) {
        callbackContext.error("Options menu not initialised");
        return true;
    }

    final StringBuffer error = new StringBuffer();
    JSONObject result = new JSONObject();

    if ("isShowing".equals(action)) {
        result.put("value", bar.isShowing());
    } else if ("getHeight".equals(action)) {
        result.put("value", bar.getHeight());
    } else if ("getDisplayOptions".equals(action)) {
        result.put("value", bar.getDisplayOptions());
    } else if ("getNavigationMode".equals(action)) {
        result.put("value", bar.getNavigationMode());
    } else if ("getSelectedNavigationItem".equals(action)) {
        result.put("value", bar.getSelectedNavigationIndex());
    } else if ("getSubtitle".equals(action)) {
        result.put("value", bar.getSubtitle());
    } else if ("getTitle".equals(action)) {
        result.put("value", bar.getTitle());
    } else {
        try {
            JSONException exception = new Runnable() {
                public JSONException exception = null;

                public void run() {
                    try {
                        // This is a bit of a hack (should be specific to the request, not global)
                        bases = new String[] { removeFilename(webView.getOriginalUrl()),
                                removeFilename(webView.getUrl()) };

                        if ("show".equals(action)) {
                            LOG.d("native5-action-bar", "Showing Action Bar");
                            bar.show();
                        } else if ("hide".equals(action)) {
                            bar.hide();
                        } else if ("setMenu".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("menu can not be null");
                                return;
                            }

                            menu_definition = args.getJSONArray(0);

                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                                ctx.invalidateOptionsMenu();
                            }
                        } else if ("setTabs".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("menu can not be null");
                                return;
                            }

                            bar.removeAllTabs();
                            tab_callbacks.clear();

                            if (!buildTabs(bar, args.getJSONArray(0))) {
                                error.append("Invalid tab bar definition");
                            }
                        } else if ("setDisplayHomeAsUpEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("showHomeAsUp can not be null");
                                return;
                            }

                            bar.setDisplayHomeAsUpEnabled(args.getBoolean(0));
                        } else if ("setDisplayOptions".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("options can not be null");
                                return;
                            }

                            final int options = args.getInt(0);
                            bar.setDisplayOptions(options);
                        } else if ("setDisplayShowHomeEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("showHome can not be null");
                                return;
                            }

                            bar.setDisplayShowHomeEnabled(args.getBoolean(0));
                        } else if ("setDisplayShowTitleEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("showTitle can not be null");
                                return;
                            }

                            bar.setDisplayShowTitleEnabled(args.getBoolean(0));
                        } else if ("setDisplayUseLogoEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("useLogo can not be null");
                                return;
                            }

                            bar.setDisplayUseLogoEnabled(args.getBoolean(0));
                        } else if ("setHomeButtonEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("enabled can not be null");
                                return;
                            }

                            bar.setHomeButtonEnabled(args.getBoolean(0));
                        } else if ("setIcon".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("icon can not be null");
                                return;
                            }

                            Drawable drawable = getDrawableForURI(args.getString(0));
                            bar.setIcon(drawable);
                        } else if ("setListNavigation".equals(action)) {
                            JSONArray items = null;
                            if (args.isNull(0) == false) {
                                items = args.getJSONArray(0);
                            }

                            navigation_adapter.setItems(items);
                            bar.setListNavigationCallbacks(navigation_adapter, navigation_listener);
                        } else if ("setLogo".equals(action)) {
                            String uri = args.getString(0);
                            if (args.isNull(0)) {
                                error.append("logo can not be null");
                                return;
                            }

                            //                        try {
                            //                           InputStream ims = ctx.getAssets().open(uri);
                            Drawable drawable = getDrawableForURI(uri);
                            //                                 Drawable.createFromStream(ims, null);
                            bar.setLogo(drawable);
                            bar.setBackgroundDrawable(getDrawableForURI("images/logo-bg.png"));
                            //                        } catch (IOException e) {
                            //                           e.printStackTrace();
                            //                        }
                        } else if ("setNavigationMode".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("mode can not be null");
                                return;
                            }

                            final int mode = args.getInt(0);
                            bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
                        } else if ("setSelectedNavigationItem".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("position can not be null");
                                return;
                            }
                            bar.setSelectedNavigationItem(args.getInt(0));
                        } else if ("setSelectedTab".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("position can not be null");
                                return;
                            }
                            LOG.d("setSelectedTab", bar.getTabCount() + "");
                            bar.selectTab(bar.getTabAt(args.getInt(0)));
                        } else if ("setSubtitle".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("subtitle can not be null");
                                return;
                            }

                            bar.setSubtitle(args.getString(0));
                        } else if ("setTitle".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("title can not be null");
                                return;
                            }

                            bar.setTitle(args.getString(0));
                        }
                    } catch (JSONException e) {
                        exception = e;
                    } finally {
                        synchronized (this) {
                            this.notify();
                        }
                    }
                }

                // Run task synchronously
                {
                    synchronized (this) {
                        ctx.runOnUiThread(this);
                        this.wait();
                    }
                }
            }.exception;

            if (exception != null) {
                throw exception;
            }
        } catch (InterruptedException e) {
            error.append("Function interrupted on UI thread");
        }
    }

    if (error.length() == 0) {
        if (result.length() > 0) {
            callbackContext.success(result);
        } else {
            callbackContext.success();
        }
    } else {
        callbackContext.error(error.toString());
    }

    return true;
}