@Override
 protected void setUp() throws Exception {
   super.setUp();
   MyLog.i(this, "setUp started");
   TestSuite.initializeWithData(this);
   ma =
       MyContextHolder.get()
           .persistentAccounts()
           .fromAccountName(TestSuite.GNUSOCIAL_TEST_ACCOUNT_NAME);
   assertTrue(TestSuite.GNUSOCIAL_TEST_ACCOUNT_NAME + " exists", ma.isValid());
 }
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   MyLog.i(this, "setUp started");
   TestSuite.initializeWithData(this);
   ma =
       MyContextHolder.get()
           .persistentAccounts()
           .fromAccountName(TestSuite.CONVERSATION_ACCOUNT_NAME);
   assertTrue(ma.isValid());
   selectedMessageId =
       MyQuery.oidToId(
           OidEnum.MSG_OID, ma.getOriginId(), TestSuite.CONVERSATION_ENTRY_MESSAGE_OID);
   assertTrue("Selected message exists", selectedMessageId != 0);
   MyLog.i(this, "setUp ended");
 }
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    TestSuite.initializeWithData(this);
    iteration = (iteration >= 4 ? 1 : iteration + 1);
    switch (iteration) {
      case 2:
        showAttachedImages = showAttachedImagesOld;
        showAvatars = !showAvatarsOld;
        break;
      case 3:
        showAttachedImages = !showAttachedImagesOld;
        showAvatars = showAvatarsOld;
        break;
      case 4:
        showAttachedImages = !showAttachedImagesOld;
        showAvatars = !showAvatarsOld;
        break;
      default:
        showAttachedImagesOld = MyPreferences.showAttachedImages();
        showAvatarsOld = MyPreferences.showAvatars();
        showAttachedImages = showAttachedImagesOld;
        showAvatars = showAvatarsOld;
        break;
    }
    setPreferences();
    MyLog.setLogToFile(true);
    logStartStop("setUp started");

    MyAccount ma =
        MyContextHolder.get()
            .persistentAccounts()
            .fromAccountName(TestSuite.CONVERSATION_ACCOUNT_NAME);
    assertTrue(ma.isValid());
    MyContextHolder.get().persistentAccounts().setCurrentAccount(ma);

    Intent intent =
        new Intent(
            Intent.ACTION_VIEW,
            MatchedUri.getTimelineUri(ma.getUserId(), TimelineType.HOME, false, 0));
    setActivityIntent(intent);

    activity = getActivity();

    assertTrue("MyService is available", MyServiceManager.isServiceAvailable());
    logStartStop("setUp ended");
  }
 public boolean onContextItemSelected(MenuItem item) {
   MyAccount ma = getMyActor();
   if (ma.isValid()) {
     UserListContextMenuItem contextMenuItem = UserListContextMenuItem.fromId(item.getItemId());
     MyLog.v(
         this,
         "onContextItemSelected: "
             + contextMenuItem
             + "; actor="
             + ma.getAccountName()
             + "; user="
             + getViewItem().mbUser.getNamePreferablyWebFingerId());
     return contextMenuItem.execute(this, ma);
   } else {
     return false;
   }
 }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    final String method = "onCreateContextMenu";
    super.onCreateContextMenu(menu, v, menuInfo);
    if (getViewItem() == null) {
      return;
    }
    MyAccount myActor = getMyActor();
    if (!myActor.isValid() || !myActor.getOrigin().equals(getOrigin())) {
      setMyActor(getMyContext().persistentAccounts().getFirstSucceededForOrigin(getOrigin()));
    }

    int order = 0;
    try {
      new ContextMenuHeader(getActivity(), menu)
          .setTitle(getViewItem().mbUser.toUserTitle(false))
          .setSubtitle(getMyActor().getAccountName());
      String shortName = getViewItem().mbUser.getUserName();
      if (getViewItem().mbUser.isIdentified()) {
        UserListContextMenuItem.USER_MESSAGES.addTo(
            menu,
            order++,
            String.format(
                getActivity().getText(R.string.menu_item_user_messages).toString(), shortName));
        UserListContextMenuItem.FRIENDS.addTo(
            menu,
            order++,
            String.format(getActivity().getText(R.string.friends_of).toString(), shortName));
        UserListContextMenuItem.FOLLOWERS.addTo(
            menu,
            order++,
            String.format(getActivity().getText(R.string.followers_of).toString(), shortName));
        if (getViewItem().userIsFollowedBy(getMyActor())) {
          UserListContextMenuItem.STOP_FOLLOWING.addTo(
              menu,
              order++,
              String.format(
                  getActivity().getText(R.string.menu_item_stop_following_user).toString(),
                  shortName));
        } else if (getViewItem().getUserId() != getMyActor().getUserId()) {
          UserListContextMenuItem.FOLLOW.addTo(
              menu,
              order++,
              String.format(
                  getActivity().getText(R.string.menu_item_follow_user).toString(), shortName));
        }
        switch (getMyActor().numberOfAccountsOfThisOrigin()) {
          case 0:
          case 1:
            break;
          case 2:
            UserListContextMenuItem.ACT_AS_FIRST_OTHER_USER.addTo(
                menu,
                order++,
                String.format(
                    getActivity().getText(R.string.menu_item_act_as_user).toString(),
                    getMyActor()
                        .firstOtherAccountOfThisOrigin()
                        .getShortestUniqueAccountName(getMyContext())));
            break;
          default:
            UserListContextMenuItem.ACT_AS.addTo(menu, order++, R.string.menu_item_act_as);
            break;
        }
      }
      UserListContextMenuItem.GET_USER.addTo(menu, order++, R.string.get_user);
    } catch (Exception e) {
      MyLog.e(this, method, e);
    }
  }