Пример #1
0
  private void publishOrderOnFB(String message) {

    // set the order message to be published
    mParentFragment.setPublishOrderMessage(message);

    // publish it on wall
    mParentFragment.publishOrderOnFB();
  }
Пример #2
0
  @Override
  public View getGroupView(
      int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    if (convertView == null) {
      LayoutInflater inflater =
          (LayoutInflater)
              mParentFragment.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = inflater.inflate(R.layout.order_tab_group, null);
    }

    // solve category data part
    String categoryName = getGroup(groupPosition);
    TextView categoryNameView = (TextView) convertView.findViewById(R.id.order_tab_category_name);
    categoryNameView.setText(categoryName);

    // solve facebook share part
    ImageView shareCategoryItemView =
        (ImageView) convertView.findViewById(R.id.order_tab_category_fb_share);
    shareCategoryItemView.setOnClickListener(new OrderCategoryShareClickListener(groupPosition));

    return convertView;
  }
Пример #3
0
  @Override
  public View getChildView(
      int groupPosition,
      int childPosition,
      boolean isLastChild,
      View convertView,
      ViewGroup parent) {

    if (convertView == null) {
      LayoutInflater inflater =
          (LayoutInflater)
              mParentFragment.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = inflater.inflate(R.layout.order_tab_item, null);
    }

    // solve item content part
    Map<String, Object> itemMapping = getChild(groupPosition, childPosition);
    TextView itemNameView = (TextView) convertView.findViewById(R.id.order_tab_item_name);
    TextView itemQuantityView = (TextView) convertView.findViewById(R.id.order_tab_item_quantity);
    TextView itemPriceView = (TextView) convertView.findViewById(R.id.order_tab_item_price);

    String itemName = (String) itemMapping.get(OrderFeature.ITEM);
    int itemQuantity = (Integer) itemMapping.get("quantity");
    double itemPrice = (Double) itemMapping.get(OrderFeature.ITEM_PRICE);
    double itemCumulatedPrice = itemPrice * itemQuantity;

    itemNameView.setText(itemName);
    itemQuantityView.setText("" + itemQuantity);
    itemPriceView.setText(new DecimalFormat("#.##").format(itemCumulatedPrice) + " RON");

    // solve facebook share part
    ImageView shareOrderItemView =
        (ImageView) convertView.findViewById(R.id.order_tab_item_fb_share);
    shareOrderItemView.setOnClickListener(
        new OrderItemShareClickListener(groupPosition, childPosition));

    return convertView;
  }
Пример #4
0
  private void showOrderPostDialog(String message) {
    final String statusMessage = message;

    // build the dialog for facebook message post request
    /*
    Context context = mParentFragment.getActivity();
    ContextThemeWrapper ctw = new ContextThemeWrapper(context, R.style.EnvivedDialogTheme);

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctw);
    //AlertDialog.Builder alertDialogBuilder = new OrderCustomAlertDialogFragment(ctw);

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.order_tab_fb_share_dialog, null);
    TextView messageView = (TextView)layout.findViewById(R.id.order_tab_fb_share_dialog_message);
    messageView.setText(statusMessage);

    // set title
    alertDialogBuilder.setTitle("Post status to Wall");

    // set content
    alertDialogBuilder.setView(layout);

    // set buttons
    alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
    	@Override
    	public void onClick(DialogInterface dialog, int which) {
    		publishOrderOnFB(statusMessage);
    	}
    });
    alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
    	@Override
    	public void onClick(DialogInterface dialog, int which) {
    		dialog.cancel();
    	}
    });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

    // show it
    alertDialog.show();
    */

    Context context = mParentFragment.getActivity();
    OrderCustomAlertDialogFragment orderPostDialog =
        OrderCustomAlertDialogFragment.newInstance("Post Status to Wall", null, "OK", "Cancel");

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE);
    View messageView = inflater.inflate(R.layout.order_tab_fb_share_dialog, null);
    TextView messageTextView =
        (TextView) messageView.findViewById(R.id.order_tab_fb_share_dialog_message);
    messageTextView.setText(statusMessage);

    orderPostDialog.setMessageView(messageView);
    orderPostDialog.setOrderNoticeAlertDialogListener(
        new OrderNoticeAlertDialogListener() {

          @Override
          public void onDialogPositiveClick(DialogFragment dialog) {
            dialog.dismiss();
            publishOrderOnFB(statusMessage);
          }

          @Override
          public void onDialogNegativeClick(DialogFragment dialog) {
            dialog.dismiss();
          }
        });
    orderPostDialog.show(mParentFragment.getFragmentManager(), "dialog");
  }