コード例 #1
0
  public void getIntentExtras() {
    Intent i = getIntent();
    if (getIntent().hasExtra(PSQConsts.EXTRAS_EVENT_ID)) {
      mEventId = getIntent().getStringExtra(PSQConsts.EXTRAS_EVENT_ID);
    }

    if (i.hasExtra(PSQConsts.EXTRAS_EVENT_POSITION)) {
      position = i.getIntExtra(PSQConsts.EXTRAS_EVENT_POSITION, -1);
    }

    if (i.hasExtra(PSQConsts.EXTRAS_PARTICIPANTS)) {
      mParticipantList = i.getParcelableArrayListExtra(PSQConsts.EXTRAS_PARTICIPANTS);
    }

    if (position >= 0) {
      mEventData = ((PurpleSQ) mActivity.getApplication()).getEventsData().get(position);
    }

    if (mEventData != null && !mParticipantList.isEmpty()) {
      mAmount = mEventData.getCost().getTotal() * mParticipantList.size();
    }

    authVo = AuthDataManager.getAuthData(PaymentActivity.this);
  }
コード例 #2
0
  private void shareOnFB() {
    // Create an object
    Set<String> permissions = AccessToken.getCurrentAccessToken().getPermissions();
    if (!permissions.contains("publish_actions")) {
      LoginManager.getInstance()
          .registerCallback(
              callbackManager,
              new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                  if (AccessToken.getCurrentAccessToken()
                      .getPermissions()
                      .contains("publish_actions")) {
                    shareOnFB();
                  }
                }

                @Override
                public void onCancel() {}

                @Override
                public void onError(FacebookException e) {}
              });
      LoginManager.getInstance()
          .logInWithPublishPermissions(PaymentActivity.this, Arrays.asList("publish_actions"));
    } else {
      String dateString = "";
      String dateString2 = "";
      try {
        Date date = new Date(mEventData.getSchedule().getStart_date());
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ENGLISH);
        dateString = sdf2.format(date);
        date.setTime(mEventData.getSchedule().getEnd_date());
        dateString2 = sdf2.format(date);

      } catch (Exception e) {
        e.printStackTrace();
        Crashlytics.logException(e);
      }

      String url = "http://purplesq.com/event/" + mEventData.get_id();

      ShareOpenGraphObject eventObject =
          new ShareOpenGraphObject.Builder()
              .putString("fb:app_id", "852292264845107")
              .putString("og:type", "purplesquirrel:event")
              .putString("og:title", mEventData.getName())
              .putString("og:description", mEventData.getSummary())
              .putString("og:url", url)
              .putString("og:image", mEventData.getThumbnail())
              .build();

      ShareOpenGraphAction action =
          new ShareOpenGraphAction.Builder()
              .setActionType("purplesquirrel:attend")
              .putString("start_time", dateString)
              .putString("expires_time", dateString2)
              .putObject("event", eventObject)
              .build();

      ShareOpenGraphContent content =
          new ShareOpenGraphContent.Builder()
              .setPreviewPropertyName("event")
              .setAction(action)
              .build();

      if (ShareDialog.canShow(ShareOpenGraphContent.class)) {
        ShareDialog shareDialog = new ShareDialog(this);
        shareDialog.registerCallback(
            callbackManager,
            new FacebookCallback<Result>() {
              @Override
              public void onSuccess(Result result) {
                if (!TextUtils.isEmpty(result.getPostId())) {
                  if (Config.DEBUG) {
                    Log.i("Nish", "FB Share Success : " + result.getPostId());
                  }
                  findViewById(R.id.activity_payment_coupon_cardview).setVisibility(View.GONE);
                } else {
                  if (Config.DEBUG) {
                    Log.i("Nish", "FB Share Success without postId ");
                  }
                }
              }

              @Override
              public void onCancel() {}

              @Override
              public void onError(FacebookException e) {}
            });
        shareDialog.show(content);
      }
    }
  }
コード例 #3
0
  private void populateUI() {

    LinearLayout participantslayout =
        (LinearLayout) findViewById(R.id.activity_payment_layout_participants);
    Button btnPay = (Button) findViewById(R.id.activity_payment_btn_pay);
    Button btnCod = (Button) findViewById(R.id.activity_payment_btn_cod);
    TextView tvAmount = (TextView) findViewById(R.id.activity_payment_tv_eventamount);
    TextView tvHeading = (TextView) findViewById(R.id.activity_payment_tv_eventname);
    TextView tvDate = (TextView) findViewById(R.id.activity_payment_tv_eventdate);
    tvDiscount = (TextView) findViewById(R.id.activity_payment_tv_coupon_applied);

    final EditText etCoupons = (EditText) findViewById(R.id.activity_payment_et_coupon);

    String eventDay = "";
    try {
      Date date = new Date(mEventData.getSchedule().getStart_date());
      SimpleDateFormat sdf2 = new SimpleDateFormat("dd MMM", Locale.ENGLISH);
      eventDay = sdf2.format(date);
    } catch (Exception e) {
      e.printStackTrace();
      Crashlytics.logException(e);
    }
    tvHeading.setText(mEventData.getName());
    tvDate.setText(eventDay + ", " + mEventData.getLocation().getCity());

    for (int i = 0; i < mParticipantList.size(); i++) {
      View participantView =
          getLayoutInflater()
              .inflate(R.layout.item_payment_participants, participantslayout, false);

      ((TextView) participantView.findViewById(R.id.item_payment_participants_tv_name))
          .setText(
              mParticipantList.get(i).getFirstname() + " " + mParticipantList.get(i).getLastname());
      ((TextView) participantView.findViewById(R.id.item_payment_participants_tv_insitute))
          .setText(mParticipantList.get(i).getInstitute());
      ((TextView) participantView.findViewById(R.id.item_payment_participants_tv_number))
          .setText((i + 1) + "");

      participantslayout.addView(participantView);
    }

    Typeface font = Typeface.createFromAsset(getAssets(), "fontawesome.ttf");
    tvAmount.setTypeface(font);
    tvAmount.setText(PSQConsts.UNICODE_RUPEE + " " + (int) mAmount);

    btnPay.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (authVo != null) {
              PurpleSQ.showLoadingDialog(PaymentActivity.this);
              new RegisterParticipantsTask(
                      mEventId,
                      authVo.getToken(),
                      couponCode,
                      mParticipantList,
                      PaymentActivity.this)
                  .execute((Void) null);
            }
          }
        });

    btnCod.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(mActivity, CodActivity.class);
            intent.putExtra(PSQConsts.EXTRAS_EVENT_POSITION, position);
            intent.putExtra("discount", discountedPrice);
            intent.putExtra("coupon", couponCode);
            intent.putExtra("discount-string", tvDiscount.getText());
            intent.putParcelableArrayListExtra(PSQConsts.EXTRAS_PARTICIPANTS, mParticipantList);
            startActivity(intent);
          }
        });

    findViewById(R.id.activity_payment_tv_coupon_apply)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                couponCode = etCoupons.getText().toString();
                if (!TextUtils.isEmpty(couponCode)) {
                  new CheckCouponTask(
                          authVo.getToken(),
                          couponCode,
                          mEventData.getId(),
                          (int) mAmount,
                          PaymentActivity.this)
                      .execute();
                }
              }
            });

    findViewById(R.id.activity_payment_fbshare_cardview)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                shareOnFB();
              }
            });

    etCoupons.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            etCoupons.setError(null);
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });

    findViewById(R.id.activity_payment_coupon_cardview).setVisibility(View.VISIBLE);
  }