Example usage for android.app ActionBar setDisplayUseLogoEnabled

List of usage examples for android.app ActionBar setDisplayUseLogoEnabled

Introduction

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

Prototype

public abstract void setDisplayUseLogoEnabled(boolean useLogo);

Source Link

Document

Set whether to display the activity logo rather than the activity icon.

Usage

From source file:org.jorge.lolin1.ui.activities.ChatRoomActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBar actionBar = getActionBar();
    friendName = null;/*w  w  w .  java  2 s  .  c  o m*/
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(Boolean.TRUE);
        actionBar.setTitle(friendName = getIntent().getStringExtra(ChatOverviewActivity.KEY_FRIEND_NAME));
        try {
            actionBar
                    .setLogo(
                            Drawable.createFromPath(
                                    ProfileCacheableBitmapLoader
                                            .getPathByID(getApplicationContext(),
                                                    FriendManager.getInstance().findFriendByName(friendName)
                                                            .getStatus().getProfileIconId())
                                            .getAbsolutePath()));
        } catch (NullPointerException ex) {
            startActivity(new Intent(getApplicationContext(), ChatOverviewActivity.class));//Clicking notification with app closed
            finish();
            return;
        }
        actionBar.setDisplayUseLogoEnabled(Boolean.TRUE);
    }
    ChatNotificationManager.dismissNotifications(getApplicationContext(), friendName);
    setContentView(R.layout.activity_chat_room);

    final EditText messageContentsTextField = (EditText) findViewById(android.R.id.inputArea);

    messageContentsTextField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId != EditorInfo.IME_ACTION_DONE)
                return Boolean.FALSE;
            String contents = messageContentsTextField.getText().toString();
            if (TextUtils.isEmpty(contents))
                return Boolean.TRUE;
            adapter.add(new ChatMessageWrapper(contents, System.currentTimeMillis()));
            sendMessage(contents, friendName);
            messageContentsTextField.setText("");
            messageContentsTextField.requestFocus();
            return Boolean.TRUE;
        }

        private void sendMessage(String contents, String friendName) {
            new AsyncTask<String, Void, Void>() {
                @Override
                protected Void doInBackground(String... params) {
                    Friend target;
                    ChatMessageWrapper messageWrapper = new ChatMessageWrapper(params[0],
                            System.currentTimeMillis());
                    logString("debug", "Sending message " + params[0] + " to " + params[1]);
                    ChatBundleManager.addMessageToFriendChat(messageWrapper,
                            target = FriendManager.getInstance().findFriendByName(params[1]));
                    scrollListViewToBottom();
                    target.sendMessage(params[0]);
                    return null;
                }
            }.executeOnExecutor(Executors.newSingleThreadExecutor(), contents, friendName);
        }
    });

    conversationListView = (ListView) findViewById(android.R.id.list);
    conversationListView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);

    logString("debug", "Calling adapter constructor");
    adapter = new ChatRoomAdapter(getApplicationContext(),
            FriendManager.getInstance().findFriendByName(friendName));

    if (!TextUtils.isEmpty(friendName))
        conversationListView.setAdapter(adapter);

    scrollListViewToBottom();

    registerLocalBroadcastReceiver();
    scrollListViewToBottom();
}

From source file:com.inc.playground.playground.MainActivity.java

public void setPlayGroundActionBar() {
    String userLoginId, userFullName, userEmail, userPhoto;
    Bitmap imageBitmap = null;/* w w  w.  ja  v  a2 s. co m*/
    GlobalVariables globalVariables;
    final ActionBar actionBar = getActionBar();

    final String MY_PREFS_NAME = "Login";
    SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
    globalVariables = ((GlobalVariables) this.getApplication());
    if (prefs.getString("userid", null) != null) {
        userLoginId = prefs.getString("userid", null);
        userFullName = prefs.getString("fullname", null);
        userEmail = prefs.getString("emilid", null);
        userPhoto = prefs.getString("picture", null);
        globalVariables.GetCurrentUser().setPhotoUrl(userPhoto);
        actionBar.setCustomView(R.layout.actionbar_custom_view_home);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayUseLogoEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);

        ImageView logo_image = (ImageView) findViewById(R.id.img_profile_action_bar);
        logo_image.setBackgroundResource(R.drawable.pg_logo2);
        TextView userName = (TextView) findViewById(R.id.email);
        userName.setText(userFullName.replace("%20", "  "));
        ImageView img_profile = (ImageView) findViewById(R.id.profile_image);
        imageBitmap = globalVariables.GetUserPictureBitMap();
        if (imageBitmap == null) {
            Log.i(TAG, "downloading");
            try {
                imageBitmap = new DownloadImageBitmapTask().execute(userPhoto).get();
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }

        } else {
            Log.i(TAG, "Image found");
        }
        img_profile.setImageBitmap(imageBitmap);

        ImageView notificationBtn = (ImageView) findViewById(R.id.notification_btn);
        notificationBtn.setVisibility(View.VISIBLE);
        notificationBtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent iv = new Intent(MainActivity.this, NotificationsList.class);
                startActivity(iv);
                finish();
            }
        });
        TextView notificationNumber = (TextView) findViewById(R.id.notification__numberTxt);
        if (globalVariables.GetNotifications() != null && globalVariables.GetNotifications().size() != 0) {
            notificationNumber.setText(Integer.toString(globalVariables.GetNotifications().size()));
            notificationNumber.setVisibility(View.VISIBLE);
        } else {
            notificationNumber.setVisibility(View.INVISIBLE);
        }

        TextView loginTxt = (TextView) findViewById(R.id.login_txt);
        ImageView loginImg = (ImageView) findViewById(R.id.login_img);
        globalVariables.SetUserPictureBitMap(imageBitmap); // Make the imageBitMap global to all activities to avoid downloading twice
        loginTxt.setText("Logout");
        loginImg.setImageResource(R.drawable.pg_action_lock_close);
        // Register to notifications
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);

    }
}

From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java

/**
* 
*///from   w w w  .  jav a 2  s  .  co  m
@Override
public void onCreate(final Bundle savedInstanceState) {
    //Log.i("MAIN ACTIVITY", "onCreate");
    restoreInstance(savedInstanceState);
    super.onCreate(savedInstanceState);
    NetworkInfoCollector.init(this);
    networkInfoCollector = NetworkInfoCollector.getInstance();

    preferencesUpdate();
    setContentView(R.layout.main_with_navigation_drawer);

    if (VIEW_HIERARCHY_SERVER_ENABLED) {
        ViewServer.get(this).addWindow(this);
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.setDisplayUseLogoEnabled(true);

    // initialize the navigation drawer with the main menu list adapter:
    String[] mainTitles = getResources().getStringArray(R.array.navigation_main_titles);
    int[] navIcons = new int[] { R.drawable.ic_action_home, R.drawable.ic_action_history,
            R.drawable.ic_action_map, R.drawable.ic_action_stat, R.drawable.ic_action_help,
            R.drawable.ic_action_about, R.drawable.ic_action_settings, R.drawable.ic_action_about };

    MainMenuListAdapter mainMenuAdapter = new MainMenuListAdapter(this, mainTitles, navIcons);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerList = (ListView) findViewById(R.id.left_drawer);
    drawerLayout.setBackgroundResource(R.drawable.ic_drawer);

    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer,
            R.string.page_title_title_page, R.string.page_title_title_page) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            //refreshActionBar(null);
            exitAfterDrawerClose = false;
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };

    drawerLayout.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (KeyEvent.KEYCODE_BACK == event.getKeyCode() && exitAfterDrawerClose) {
                onBackPressed();
                return true;
            }
            return false;
        }
    });
    drawerLayout.setDrawerListener(drawerToggle);
    drawerList.setAdapter(mainMenuAdapter);
    drawerList.setOnItemClickListener(new OnItemClickListener() {
        final int[] menuIds = new int[] { R.id.action_title_page, R.id.action_history, R.id.action_map,
                R.id.action_stats, R.id.action_help, R.id.action_info, R.id.action_settings,
                R.id.action_netstat, R.id.action_log };

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectMenuItem(menuIds[position]);
            drawerLayout.closeDrawers();
        }
    });

    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    // Do something against banding effect in gradients
    // Dither flag might mess up on certain devices??
    final Window window = getWindow();
    window.setFormat(PixelFormat.RGBA_8888);
    window.addFlags(WindowManager.LayoutParams.FLAG_DITHER);

    // Setzt Default-Werte, wenn noch keine Werte vorhanden
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    final String uuid = ConfigHelper.getUUID(getApplicationContext());

    fm = getFragmentManager();
    final Fragment fragment = fm.findFragmentById(R.id.fragment_content);
    if (!ConfigHelper.isTCAccepted(this)) {
        if (fragment != null && fm.getBackStackEntryCount() >= 1)
            // clear fragment back stack
            fm.popBackStack(fm.getBackStackEntryAt(0).getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);

        getActionBar().hide();
        setLockNavigationDrawer(true);

        showTermsCheck();
    } else {
        currentMapOptions.put("highlight", uuid);
        if (fragment == null) {
            if (false) // deactivated for si // ! ConfigHelper.isNDTDecisionMade(this))
            {
                showTermsCheck();
                showNdtCheck();
            } else
                initApp(true);
        }
    }

    geoLocation = new MainGeoLocation(getApplicationContext());

    mNetworkStateChangedFilter = new IntentFilter();
    mNetworkStateChangedFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);

    mNetworkStateIntentReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(final Context context, final Intent intent) {
            if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
                final boolean connected = !intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,
                        false);
                final boolean isFailover = intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER, false);

                if (connected) {
                    if (networkInfoCollector != null) {
                        networkInfoCollector.setHasConnectionFromAndroidApi(true);
                    }
                } else {
                    if (networkInfoCollector != null) {
                        networkInfoCollector.setHasConnectionFromAndroidApi(false);
                    }
                }

                Log.i(DEBUG_TAG, "CONNECTED: " + connected + " FAILOVER: " + isFailover);
            }
        }
    };
}

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;
    }/*ww w.  ja v  a2  s  .co 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  .  ja  v  a  2s.  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;
}