public void setLoadingState(final boolean isLoading) {
    mIsLoading = isLoading;
    mNavigationHelper.onLoadingStateChanged();
    invalidateOptionsMenu();
    updateViews();
    if (!isLoading) mFileManager.updatePlugins(false);

    if (mSearchTerm != null && !isLoading) {
      new Handler()
          .postDelayed(
              new Runnable() {
                @Override
                public void run() {
                  // switchToPane(Pane.MAP);
                  mIitcWebView.loadUrl("javascript:search('" + mSearchTerm + "');");
                  mSearchTerm = null;
                }
              },
              5000);
    }
  }
 /** onClick handler for R.id.btnToggleMapVisibility, assigned in activity_main.xml */
 public void onToggleMapVisibility(final View v) {
   mShowMapInDebug = !mShowMapInDebug;
   updateViews();
 }
  @Override
  public boolean onOptionsItemSelected(final MenuItem item) {
    if (mNavigationHelper.onOptionsItemSelected(item)) return true;

    // Handle item selection
    final int itemId = item.getItemId();

    switch (itemId) {
      case android.R.id.home:
        switchToPane(Pane.MAP);
        return true;
      case R.id.reload_button:
        reloadIITC();
        return true;
      case R.id.toggle_fullscreen:
        mIitcWebView.toggleFullscreen();
        return true;
      case R.id.layer_chooser:
        mNavigationHelper.openRightDrawer();
        return true;
      case R.id.locate: // get the users current location and focus it on map
        switchToPane(Pane.MAP);

        if (mUserLocation.hasCurrentLocation()) {
          // if gps location is displayed we can use a better location without any costs
          mUserLocation.locate(mPersistentZoom);
        } else {
          // get location from network by default
          mIitcWebView.loadUrl(
              "javascript: window.map.locate({setView : true"
                  + (mPersistentZoom ? ", maxZoom : map.getZoom()" : "")
                  + "});");
        }
        return true;
      case R.id.action_settings: // start settings activity
        final Intent intent = new Intent(this, PreferenceActivity.class);
        try {
          intent.putExtra("iitc_version", mFileManager.getIITCVersion());
        } catch (final IOException e) {
          Log.w(e);
          return true;
        }
        startActivity(intent);
        return true;
      case R.id.menu_clear_cookies:
        final CookieManager cm = CookieManager.getInstance();
        cm.removeAllCookie();
        return true;
      case R.id.menu_send_screenshot:
        sendScreenshot();
        return true;
      case R.id.menu_debug:
        mDebugging = !mDebugging;
        updateViews();
        invalidateOptionsMenu();

        // TODO remove debugging stuff from JS?
        return true;
      default:
        return false;
    }
  }