コード例 #1
0
  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    AbstractRootActivity activity = (AbstractRootActivity) getActivity();

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    Object[] rawVals = Cart.ShippingMethods.getLabels().keySet().toArray();
    final String[] values = Arrays.copyOf(rawVals, rawVals.length, String[].class);
    final ShippingListArrayAdapter adapter =
        new ShippingListArrayAdapter(getActivity(), R.layout.shipping_method_list_item, values);

    builder
        .setTitle(getActivity().getString(R.string.select_shipping_method))
        .setAdapter(
            adapter,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                Log.d(TAG, "Selected shipping method " + values[which]);
                listener.onDialogSelect(ShippingMethodDialogFragment.this, values[which]);
              }
            });

    return builder.create();
  }
コード例 #2
0
  @Override
  public void onStart() {
    Log.d(TAG, "onStart");
    super.onStart();
    getActivity().setTitle("Shipping and payment methods");

    if (cart.shipping_method == null
        || cart.shipping_method.equals("")
        || !Cart.ShippingMethods.getLabels().containsKey(cart.shipping_method)) {
      cart.shipping_method = Cart.ShippingMethods.MAIL;
    }
    if (cart.payment_method == null
        || cart.payment_method.equals("")
        || !Cart.PaymentMethods.getLabels().containsKey(cart.payment_method)) {
      cart.payment_method = Cart.PaymentMethods.CREDIT_CARD;
    }
    shippingMethodField.setText(Cart.ShippingMethods.getLabel(cart.shipping_method));
    paymentMethodField.setText(Cart.PaymentMethods.getLabel(cart.payment_method));
  }
コード例 #3
0
 @Override
 public void onDialogSelect(ShippingMethodDialogFragment dialog, String method) {
   shippingMethodField.setText(Cart.ShippingMethods.getLabel(method));
   cart.shipping_method = method;
 }