Ejemplo n.º 1
0
  @OnClick(R.id.pay)
  public void pay(View view) {
    int total = prayer.friends.size() + prayer.phone.size();
    int ex = total - Global.FREE_FRIENDS_COUNT;

    prayer.dalant = ex * Global.DALANT_PER_PERSON;

    RestService.makePrayer(
        prayer,
        new CallBack<Response>() {
          @Override
          public void success(Response result) {
            succeed();
          }
        });

    //        Intent intent = Util.inviteIntent(prayer);
    //        startActivityForResult(intent, Global.SMS);

  }
  @Override
  protected void confirm() {
    if ("info".equals(type)) {
      backGroundRest(
          "friend",
          "POST",
          makeInvite(),
          Invite.class,
          new CallBack<Invite>() {
            @Override
            public void success(Invite result) {}
          });
    } else if ("team".equals(type)) {

      Invite invite = makeInvite();
      invite.team = team.id;
      invite.phone.addAll(selectionMap.values());

      backGroundRest(
          "team/invite",
          "POST",
          invite,
          Invite.class,
          new CallBack<Invite>() {
            @Override
            public void success(Invite result) {
              Intent intent = new Intent(ChooseContactsActivity.this, TeamDetailActivity.class);
              intent.putExtra("teamId", team.id);
              startActivity(intent);
            }
          });

    } else if ("invite".equals(type)) {

      Invite invite = makeInvite();
      invite.team = team.id;
      invite.friends = new ArrayList<Integer>();
      for (Friend friend : selectionMap.values()) {
        invite.friends.add(friend.friend);
      }
      //            invite.phone.addAll(selectionMap.values());

      backGroundRest(
          "team/invite",
          "POST",
          invite,
          Invite.class,
          new CallBack<Invite>() {
            @Override
            public void success(Invite result) {
              succeed();
            }
          });

    } else {

      prayer.friends = new ArrayList<Friend>();
      for (Integer id : selectionMap.keySet()) {
        Friend friend = new Friend();
        friend.friend = id;
        prayer.friends.add(friend);
      }

      prayer.phone = new ArrayList<String>();
      prayer.phone.addAll(contactSelectionMap.keySet());

      if (selectionMap.size() + contactSelectionMap.size() > Global.FREE_FRIENDS_COUNT) {

        int total = selectionMap.size() + contactSelectionMap.size();
        final int ex = total - Global.FREE_FRIENDS_COUNT;

        showDialog(EX_DIALOG);

      } else {
        RestService.makePrayer(
            prayer,
            new CallBack<Response>() {
              @Override
              public void success(Response result) {
                succeed();
              }
            });
      }
    }

    if (contactSelectionMap.size() > 0) {
      Toast toast = Toast.makeText(getApplicationContext(), "초대하였습니다.", Toast.LENGTH_LONG);
      //            toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
    }
  }