@Override
 public boolean onOptionsItemSelected(MenuItem item) {
   DataManager.FetchingState fetchingState = mDataManager.getFetchingState();
   switch (item.getItemId()) {
     case R.id.menu_open_in_browser:
       navigateTo("http://vk.com/" + mGroup.screen_name);
       return true;
     case R.id.menu_leave_group:
       if (fetchingState == finished) {
         leaveGroup(mGroup);
       } else {
         showSnackbar(
             fetchingState == loading
                 ? R.string.loading_is_on
                 : R.string.data_was_not_loaded_else);
       }
       return true;
     case R.id.menu_join_group:
       if (fetchingState == finished) {
         joinGroup(mGroup);
       } else {
         showSnackbar(
             fetchingState == loading
                 ? R.string.loading_is_on
                 : R.string.data_was_not_loaded_else);
       }
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mGroup = getIntent().getParcelableExtra(EXTRA_GROUP);
    mDataManager = DataManager.get(this);

    setErrorTextViewVisibility(View.INVISIBLE);
    setRefreshLayoutEnable(false);
    setActionButtonVisibility(View.INVISIBLE);

    VKUsersArray friends;
    if (mGroup.id != 0) {
      friends = mDataManager.getFriendsInGroup(mGroup.id);
    } else {
      friends = mDataManager.getUsersFriends();
    }

    if (friends == null) {
      friends = new VKUsersArray();
    }
    setListFragment(
        FriendsListFragment.newInstance(friends, getString(R.string.no_friends_in_group)));
  }
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    if (mGroup.id == 0) {
      menu.findItem(R.id.menu_join_group).setVisible(false);
      menu.findItem(R.id.menu_leave_group).setVisible(false);
    }

    if (mDataManager.getUsersGroupById(mGroup.id) != null) {
      menu.findItem(R.id.menu_leave_group).setVisible(true);
      menu.findItem(R.id.menu_join_group).setVisible(false);
    } else {
      menu.findItem(R.id.menu_leave_group).setVisible(false);
      menu.findItem(R.id.menu_join_group).setVisible(true);
    }
    return super.onPrepareOptionsMenu(menu);
  }