コード例 #1
0
  protected void sendSMSMessage(String phone) {
    Log.i("Send SMS", "in sms");

    ParseUser currentUser = ParseUser.getCurrentUser();
    currentUser.fetchInBackground();
    String phoneNo = (currentUser.getNumber("phoneNumber")).toString();
    String curr_fname = currentUser.getString("firstName");
    String curr_lname = currentUser.getString("lastName");
    String curr_name = curr_fname + curr_lname;
    Toast.makeText(getBaseContext(), "user number - " + phoneNo, Toast.LENGTH_SHORT).show();

    try {
      SmsManager smsManager = SmsManager.getDefault();
      smsManager.sendTextMessage(
          phone,
          null,
          "A Donor has responded to your blood Request. You can contact "
              + curr_name
              + " on - "
              + phoneNo,
          null,
          null);
      Toast.makeText(getBaseContext(), "SMS sent.", Toast.LENGTH_LONG).show();
    } catch (Exception e) {
      Toast.makeText(getBaseContext(), "SMS failed, please try again.", Toast.LENGTH_LONG).show();
      e.printStackTrace();
    }
  }
コード例 #2
0
ファイル: EditRecibo.java プロジェクト: cdiezmoran/Medidors
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_recibo);
    ButterKnife.bind(this);

    setSupportActionBar(mToolbar);

    assert getSupportActionBar() != null;
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    getTarifas();

    mDateFormatter = new SimpleDateFormat("dd/MM/yyyy", Locale.US);

    mSpinner.setSelection(0);
    mUltimaLectura.setText(mUser.getNumber(ParseConstants.KEY_LECTURA_ANTERIOR).toString());
    mUltimoPago.setText(mUser.getNumber(ParseConstants.KEY_ULTIMO_PAGO).toString());
    mFechaAnterior.setText(mDateFormatter.format(mUser.getDate(ParseConstants.KEY_FECHA_LECTURA)));

    mUltimaLectura.requestFocus();

    setDateField();
  }
コード例 #3
0
ファイル: RewardActivity.java プロジェクト: hhz1992/SeatMe
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reward);
    mCredit = (TextView) findViewById(R.id.my_credit);
    mSubmit = (Button) findViewById(R.id.radio_submit);
    mClear = (Button) findViewById(R.id.clear_choice);
    mRedeemChoice = (RadioGroup) findViewById(R.id.radio_group);
    mHome = (Button) findViewById(R.id.back_home);
    mRedeemText = (TextView) findViewById(R.id.redeem_hint);

    user = ParseUser.getCurrentUser();
    // if guest user, ask them to signin or signup
    if (user == null) {
      mRedeemChoice.setVisibility(View.INVISIBLE);
      mClear.setVisibility(View.INVISIBLE);
      mSubmit.setVisibility(View.INVISIBLE);
      mRedeemText.setVisibility(View.INVISIBLE);
      mHome.setText(R.string.back_home);

      mCredit.setText(R.string.reward_requirelogin);
      mHome.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent intent = new Intent(getBaseContext(), LoginActivity.class);
              startActivity(intent);
            }
          });

    }
    // if signed in user, check if they are qualified to redeem any rewards
    else {
      mHome.setVisibility(View.INVISIBLE);

      credit = (int) user.getNumber(Constants.CREDIT);
      mCredit.setText(mCredit.getText().toString() + credit);

      mRedeemChoice.clearCheck();
      mRedeemChoice.setOnCheckedChangeListener(
          new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
              RadioButton rb = (RadioButton) group.findViewById(checkedId);
              if (null != rb && checkedId > -1) {
                if (checkedId == R.id.radio_starbuck) {
                  if (credit - 200 < 0) {
                    isRedeemable = false;
                    if (!isClear) {
                      Toast.makeText(
                              getBaseContext(), R.string.not_enough_credit, Toast.LENGTH_SHORT)
                          .show();
                    } else isClear = false;

                  } else isRedeemable = true;
                } else {
                  if (credit - 1000 < 0) {
                    isRedeemable = false;
                    if (!isClear) {
                      Toast.makeText(
                              getBaseContext(), R.string.not_enough_credit, Toast.LENGTH_SHORT)
                          .show();
                    } else isClear = false;
                  } else isRedeemable = true;
                }
              }
            }
          });
      mClear.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              isClear = true;
              mRedeemChoice.clearCheck();
            }
          });

      // decrease user's credits when user use them to get specific item.
      mSubmit.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {

              if (isRedeemable) {
                if (mRedeemChoice.getCheckedRadioButtonId() == R.id.radio_starbuck) {
                  user.increment(Constants.CREDIT, -200);
                  credit -= 200;
                } else {
                  user.increment(Constants.CREDIT, -1000);
                  credit -= 1000;
                }
                mCredit.setText(R.string.you_current_credit + credit);
                try {
                  user.save();
                } catch (ParseException e) {
                  e.printStackTrace();
                }
                Toast.makeText(getBaseContext(), R.string.redeem_succeed, Toast.LENGTH_LONG).show();
              } else Toast.makeText(getBaseContext(), R.string.thankyou, Toast.LENGTH_LONG).show();
              isClear = true;
              mRedeemChoice.clearCheck();
            }
          });
    }
  }