package com.mapswithme.maps.widget;

import android.app.Activity;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.mapswithme.maps.R;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;

public class ToolbarController
{
  @NonNull
  private final Activity mActivity;
  @NonNull
  private final Toolbar mToolbar;
  private final View.OnClickListener mNavigationClickListener = new View.OnClickListener()
  {
    @Override
    public void onClick(View view)
    {
      onUpClick();
    }
  };

  public ToolbarController(@NonNull View root, @NonNull Activity activity)
  {
    mActivity = activity;
    mToolbar = root.findViewById(getToolbarId());

    if (useExtendedToolbar())
      UiUtils.extendViewWithStatusBar(getToolbar());
    setupNavigationListener();
    setSupportActionBar();
  }

  private void setSupportActionBar()
  {
    AppCompatActivity appCompatActivity = (AppCompatActivity) mActivity;
    appCompatActivity.setSupportActionBar(mToolbar);
  }

  protected boolean useExtendedToolbar()
  {
    return true;
  }

  private void setupNavigationListener()
  {
    View customNavigationButton = getToolbar().findViewById(R.id.back);
    if (customNavigationButton != null)
    {
      customNavigationButton.setOnClickListener(mNavigationClickListener);
    }
    else
    {
      UiUtils.showHomeUpButton(getToolbar());
      getToolbar().setNavigationOnClickListener(mNavigationClickListener);
    }
  }

  @IdRes
  private int getToolbarId()
  {
    return R.id.toolbar;
  }

  public void onUpClick()
  {
    Utils.navigateToParent(getActivity());
  }

  public ToolbarController setTitle(CharSequence title)
  {
    getToolbar().setTitle(title);
    return this;
  }

  public ToolbarController setTitle(@StringRes int title)
  {
    getToolbar().setTitle(title);
    return this;
  }

  public View findViewById(@IdRes int res)
  {
    return getToolbar().findViewById(res);
  }

  @NonNull
  public Activity getActivity()
  {
    return mActivity;
  }

  @NonNull
  public Toolbar getToolbar()
  {
    return mToolbar;
  }
}

@@ -184,24 +184,65 @@
 .StringRes;%0A
+import android.support.v7.app.ActionBar;%0A
 import andro
@@ -1895,37 +1895,46 @@
 tle)%0A  %7B%0A    get
-Toolb
+SupportActionB
 ar().setTitle(ti
@@ -2026,29 +2026,38 @@
 %0A  %7B%0A    get
-Toolb
+SupportActionB
 ar().setTitl
@@ -2080,32 +2080,261 @@
 turn this;%0A  %7D%0A%0A
+  @SuppressWarnings(%22ConstantConditions%22)%0A  @NonNull%0A  private ActionBar getSupportActionBar()%0A  %7B%0A    AppCompatActivity appCompatActivity = (AppCompatActivity) mActivity;%0A    return appCompatActivity.getSupportActionBar();%0A  %7D%0A%0A
   public View fi

Change setTitle for Toolbar to setTitle ActionBar