/** Called when the Pay Now button is pressed */ public void onClick(View v) { if (v == mBuyButton) { if (BillingConstants.DEBUG) { Log.d(TAG, "buying: " + mItemName + " sku: " + mSku); } /** Update the object */ parkingLocationObj.setAmountPaid( mDurationTotalTimeMinutes * FLAT_PARKING_SPOT_RATE_PER_MINUTE); parkingLocationObj.setDuration(mDurationTotalTimeMinutes); parkingLocationObj.setRate(FLAT_PARKING_SPOT_RATE_PER_MINUTE); parkingLocationObj.setQuantity(mTimePeriods); parkingLocationObj.setStartTimestampMs(System.currentTimeMillis()); parkingLocationObj.setEndTimestampMs( System.currentTimeMillis() + mDurationTotalTimeMinutes * NUM_MILLIS_IN_A_MINUTE); /** Set latitude and longitude in application preferences */ AppPreferences.getInstance().setLastPaidLocationLatitude(parkingLocationObj.getLatitude()); AppPreferences.getInstance().setLastPaidLocationLongitude(parkingLocationObj.getLongitude()); /** Sanity check */ if (!mBillingService.requestPurchase(mSku, mPayloadContents)) { showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID); } } }
/** Sets up the UI. */ private void setupWidgets() { mBuyButton = (Button) findViewById(R.id.buy_button); mBuyButton.setEnabled(false); mBuyButton.setOnClickListener(this); mSelectLicensePlateSpinner = (Spinner) findViewById(R.id.license_plate_choices); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>( this, android.R.layout.simple_spinner_item, AppPreferences.getInstance().getLicensePlateList()); spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSelectLicensePlateSpinner.setAdapter(spinnerArrayAdapter); // mSelectItemSpinner = (Spinner) findViewById(R.id.item_choices); mCatalogAdapter = new CatalogAdapter(this, CATALOG); // mSelectItemSpinner.setAdapter(mCatalogAdapter); paymentCalculation(); // mSelectItemSpinner.setOnItemSelectedListener(this); }