@Override
  public void viewDidLoad() {
    super.viewDidLoad();

    getTableView().setSeparatorStyle(UITableViewCellSeparatorStyle.None);
    getTableView().setBackgroundColor(UIColor.black());

    getNavigationItem().setTitleView(new UIImageView(UIImage.getImage("TitleFindFriends")));

    if (getNavigationController().getViewControllers().first() == this) {
      UIBarButtonItem dismissLeftBarButtonItem =
          new UIBarButtonItem(
              "Back",
              UIBarButtonItemStyle.Plain,
              new UIBarButtonItem.OnClickListener() {
                @Override
                public void onClick(UIBarButtonItem barButtonItem) {
                  getNavigationController().dismissViewController(true, null);
                }
              });
      getNavigationItem().setLeftBarButtonItem(dismissLeftBarButtonItem);
    } else {
      getNavigationItem().setLeftBarButtonItem(null);
    }

    if (MFMailComposeViewController.canSendMail() || MFMessageComposeViewController.canSendText()) {
      headerView = new UIView(new CGRect(0, 0, 320, 67));
      headerView.setBackgroundColor(UIColor.black());
      UIButton clearButton = new UIButton(UIButtonType.Custom);
      clearButton.setBackgroundColor(UIColor.clear());
      clearButton.addOnTouchUpInsideListener(inviteFriendsButtonAction);
      clearButton.setFrame(headerView.getFrame());
      headerView.addSubview(clearButton);
      String inviteString = "Invite friends";
      CGRect boundingRect =
          NSString.getBoundingRect(
              inviteString,
              new CGSize(310, Float.MAX_VALUE),
              NSStringDrawingOptions.with(
                  NSStringDrawingOptions.TruncatesLastVisibleLine,
                  NSStringDrawingOptions.UsesLineFragmentOrigin),
              new NSAttributedStringAttributes().setFont(UIFont.getBoldSystemFont(18)),
              null);
      CGSize inviteStringSize = boundingRect.getSize();

      UILabel inviteLabel =
          new UILabel(
              new CGRect(
                  10,
                  (headerView.getFrame().getSize().getHeight() - inviteStringSize.getHeight()) / 2,
                  inviteStringSize.getWidth(),
                  inviteStringSize.getHeight()));
      inviteLabel.setText(inviteString);
      inviteLabel.setFont(UIFont.getBoldSystemFont(18));
      inviteLabel.setTextColor(UIColor.white());
      inviteLabel.setBackgroundColor(UIColor.clear());
      headerView.addSubview(inviteLabel);
      getTableView().setTableHeaderView(headerView);
    }
  }
  @Override
  public void viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews();

    CGRect bounds = getView().getBounds();
    bounds.setY(bounds.getY() + bounds.getHeight() - BottomButtonView.HEIGHT);
    bounds.setHeight(BottomButtonView.HEIGHT);
    bottomView.setFrame(bounds);
  }
コード例 #3
0
  /**
   * Modifies keyboards size to fit screen
   *
   * @param showKeyboard
   * @param notificationInfo
   */
  private void adjustViewForKeyboardReveal(
      boolean showKeyboard,
      NSDictionary<NSString, ?> notificationInfo) { // notificationInfo:(NSDictionary
    // *)notificationInfo
    // the keyboard is showing so resize the table's height

    CGRect keyboardRect =
        NSValueExtensions.getRectValue(
            (NSValue) notificationInfo.get(UIKit.KeyboardFrameEndUserInfoKey()));
    double animationDuration =
        ((NSNumber) notificationInfo.get(UIKit.KeyboardAnimationDurationUserInfoKey()))
            .doubleValue();

    CGRect frame = this.textView.getFrame();

    // the keyboard rect's width and height are reversed in landscape
    double adjustDelta =
        isPortrait(this.getInterfaceOrientation())
            ? keyboardRect.getHeight()
            : keyboardRect.getWidth();

    if (showKeyboard) {
      frame.size().height(frame.size().height() - adjustDelta);
    } else {
      frame.size().height(frame.size().height() + adjustDelta);
    }

    UIView.beginAnimations("ResizeForKeyboard", null);
    UIView.setDurationForAnimation(animationDuration);
    this.textView.setFrame(frame);
    UIView.commitAnimations();
  }
コード例 #4
0
  @Override
  public void layoutSubviews() {
    super.layoutSubviews();

    CGRect bounds = getBounds();
    CGRect frame = name.getFrame();

    frame.setWidth(bounds.getWidth() - (PRICE_WIDTH + PADDING * 2));
    frame.setX(PADDING);
    frame.setY(PADDING);
    name.setFrame(frame);

    frame = price.getFrame();
    frame.setY(PADDING + (name.getFrame().getHeight() - frame.getHeight()) / 2);
    frame.setX(name.getFrame().getX() + name.getFrame().getWidth() + PADDING);
    frame.setWidth(PRICE_WIDTH);
    price.setFrame(frame);

    frame = bounds;
    frame.setY(name.getFrame().getY() + name.getFrame().getHeight());
    frame.setX(PADDING);
    frame.setWidth(frame.getWidth() - PADDING * 2);
    frame.setHeight(frame.getHeight() - frame.getY());
    descriptionLabel.setFrame(frame);
  }