public OrderDetailAdapter(Context context, int resource, List<Product> objects) {
    super(context, resource, objects);
    this.objects = objects;
    this.context = context;
    imageCacheLoader = new ImageCacheLoader(context);
    retailer = Helper.getSharedHelper().reatiler;
    this.quntities = new HashMap<String, String>();
    selectedCurrencyCode = Helper.getSharedHelper().currency_symbol;
    if (conversionValue == 0) {
      conversionValue = 1.0f;
      selectedCurrencyCode = Helper.getSharedHelper().reatiler.defaultCurrency;
    }

    setQuantities();
  }
  void initialize(View view) {
    activity = this.getActivity();
    context = this.getActivity();

    spref = PreferenceManager.getDefaultSharedPreferences(activity);
    listViewVoucher = (ListView) view.findViewById(R.id.lv_vouchers);
    linAdMob = (LinearLayout) view.findViewById(R.id.linAdMob);

    retailer = Helper.getSharedHelper().reatiler;
    getVouchers();

    // sqliteHelper.openDataBase();
    // voucherList = sqliteHelper.getVouchers();
    // sqliteHelper.close();

    adapter = new VouchersListAdapter(context, R.layout.row_voucher, voucherList, this);

    listViewVoucher.setAdapter(adapter);
    listViewVoucher.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            Voucher voucher = voucherList.get(position);
            if (voucher.getPid() != null) {
              loadProductDetail(voucher.getPid());
            }
          }
        });

    new AsyncGetPublisherId().execute();
  }
  void initialize(View view) {
    retailer = Helper.getSharedHelper().reatiler;

    RelativeLayout header = (RelativeLayout) view.findViewById(R.id.header);
    LinearLayout bottonView = (LinearLayout) view.findViewById(R.id.bottonView);
    header.setVisibility(View.GONE);
    bottonView.setVisibility(View.GONE);
    View lineBot = (View) view.findViewById(R.id.lineBot);
    View lineTop = (View) view.findViewById(R.id.lineTop);
    Button btn_agree = (Button) view.findViewById(R.id.btn_agree);

    try {

      lineTop.setBackgroundColor(Color.parseColor("#" + retailer.getHeaderColor()));
      lineBot.setBackgroundColor(Color.parseColor("#" + retailer.getHeaderColor()));
      btn_agree.setTextColor(Color.parseColor("#" + retailer.getRetailerTextColor()));
      btn_agree.setBackgroundDrawable(
          Helper.getSharedHelper().getGradientDrawable(retailer.getHeaderColor()));

    } catch (Exception e) {

    }

    // url = "http://appwizlive.com/";

    w = (WebView) view.findViewById(R.id.webView);
    w.setWebViewClient(new WebViewClient());
    w.getSettings().setJavaScriptEnabled(true);
    if (!url.startsWith("http://")) {
      url = "http://" + url;
    }
    // url =
    // "https://www.google.com/calendar/[email protected]&mode=Agenda";
    w.loadUrl(url);
    //		String calenderText = "<html><body><iframe
    // src=\"https://www.google.com/calendar/[email protected]&ctz=Asia/Calcutta\"
    // style=\"border: 0\" width=\"800\" height=\"600\" frameborder=\"0\"
    // scrolling=\"yes\"></iframe></body></html>";
    //		w.loadData(calenderText, "text/html", "UTF-8");
    //		Map<String, String> extraHeaders = new HashMap<String, String>();
    //		extraHeaders.put("X-Frame-Options", "SAMEORIGIN");
    //		w.loadUrl(calenderText, extraHeaders);
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {

    ViewHolderShoppingCart holder = null;
    // ImageView imageView = null;

    ImageView imageView;
    TextView shortDesc;
    TextView newPrice, oldPrice;

    TextView tvRewardsPoints, tvOptions, tvGiftMessage, tvOldPriceDetails, tvNewPriceDetails;
    LinearLayout llFirstOption, llSecondOption;

    if (null == convertView) {
      LayoutInflater vi =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = vi.inflate(R.layout.row_order_item, null);
      imageView = (ImageView) convertView.findViewById(R.id.iv_eshop);
      shortDesc = (TextView) convertView.findViewById(R.id.tv_eshop_short_desc);
      newPrice = (TextView) convertView.findViewById(R.id.tv_price);
      oldPrice = (TextView) convertView.findViewById(R.id.oldPrice);
      llFirstOption = (LinearLayout) convertView.findViewById(R.id.llFirstOption);
      llSecondOption = (LinearLayout) convertView.findViewById(R.id.llSecondOption);

      tvRewardsPoints = (TextView) convertView.findViewById(R.id.tvRewardsPoints);
      tvOptions = (TextView) convertView.findViewById(R.id.tvOptions);
      tvGiftMessage = (TextView) convertView.findViewById(R.id.tvGiftMessage);
      tvOldPriceDetails = (TextView) convertView.findViewById(R.id.tvOldPriceDetails);
      tvNewPriceDetails = (TextView) convertView.findViewById(R.id.tvNewPriceDetails);
      convertView.setTag(
          new ViewHolderShoppingCart(
              imageView,
              shortDesc,
              newPrice,
              oldPrice,
              tvRewardsPoints,
              tvOptions,
              tvGiftMessage,
              tvOldPriceDetails,
              tvNewPriceDetails));
    }
    holder = (ViewHolderShoppingCart) convertView.getTag();

    try {
      Product object = objects.get(position);

      holder.shortDesc.setText(object.getName().trim());

      Float price = Float.parseFloat(object.getNewPrice());

      int qty = Integer.parseInt(object.quantity);
      float itemTotal = qty * price;

      imageView = holder.image;
      imageCacheLoader.displayImage(object.getImage(), R.drawable.image_placeholder, imageView);
      holder.shortDesc.setTypeface(Helper.getSharedHelper().boldFont);
      holder.newPrice.setTypeface(Helper.getSharedHelper().boldFont);
      holder.oldPrice.setTypeface(Helper.getSharedHelper().normalFont);
      holder.tvOldPriceDetails.setTypeface(Helper.getSharedHelper().normalFont);
      holder.tvNewPriceDetails.setTypeface(Helper.getSharedHelper().normalFont);

      holder.tvRewardsPoints.setTypeface(Helper.getSharedHelper().normalFont);
      holder.tvOptions.setTypeface(Helper.getSharedHelper().normalFont);
      holder.tvGiftMessage.setTypeface(Helper.getSharedHelper().normalFont);

      holder.oldPrice.setPaintFlags(holder.oldPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

      String optiontext = null;
      if (object.prodOptions != null && object.prodOptions.length() > 0) {
        optiontext = object.prodOptions;
      }

      if (optiontext != null) {
        holder.tvOptions.setText("Options: " + optiontext);
        holder.tvOptions.setVisibility(View.VISIBLE);
      } else {
        holder.tvOptions.setVisibility(View.GONE);
      }
      String rewardPoints = object.reward_points;
      if (rewardPoints == null) {
        rewardPoints = "0";
      }
      try {
        int rewardsInt = Integer.parseInt(rewardPoints);
        rewardsInt = rewardsInt * qty;
        rewardPoints = Integer.toString(rewardsInt);
      } catch (Exception e) {
        // TODO: handle exception
      }

      if (Helper.getSharedHelper().reatiler.enableRewards.equalsIgnoreCase("1")
          && !rewardPoints.equalsIgnoreCase("0")) {
        holder.tvRewardsPoints.setVisibility(View.VISIBLE);
      } else {
        holder.tvRewardsPoints.setVisibility(View.GONE);
      }
      SpannableString spanableText = new SpannableString(rewardPoints + " Credit Points");
      spanableText.setSpan(new StyleSpan(Typeface.BOLD), 0, rewardPoints.length(), 0);
      holder.tvRewardsPoints.setText(spanableText);
      String priceDetail =
          qty
              + "X"
              + Helper.getSharedHelper().conertfloatToSTring(price)
              + "="
              + Helper.getSharedHelper()
                  .getCurrencySymbol(Helper.getSharedHelper().reatiler.defaultCurrency)
              + Helper.getSharedHelper().conertfloatToSTring(itemTotal);
      holder.tvOldPriceDetails.setText(
          Helper.getSharedHelper().getCurrencySymbol(selectedCurrencyCode) + object.oldPrice);
      holder.tvOldPriceDetails.setPaintFlags(
          holder.tvOldPriceDetails.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
      holder.tvNewPriceDetails.setText(
          Helper.getSharedHelper().getCurrencySymbol(selectedCurrencyCode) + object.newPrice);

    } catch (Exception e) {
      // TODO: handle exception
    }

    return convertView;
  }
Example #5
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolderEShop holder = null;
    ImageView imageView = null;

    if (null == convertView) {
      LayoutInflater vi =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      // if (Helper.getSharedHelper().disablePayment.endsWith("1")) {
      // convertView = vi.inflate(R.layout.row_eshop_with_delete, null);
      // }else{
      //
      // }
      convertView = vi.inflate(R.layout.row_eshop, null);

      holder = new ViewHolderEShop(convertView);
      convertView.setTag(holder);
    }
    holder = (ViewHolderEShop) convertView.getTag();

    Product object = objects.get(position);

    holder.getName().setText(object.getName());
    holder.getShortDesc().setText(object.getShortDescription().trim());
    // String oldPrice = object.getOldPrice();
    float conversionValue = 0.0f;
    try {
      conversionValue =
          Float.parseFloat(
              Helper.getSharedHelper()
                  .currency_conversion_map
                  .get(Helper.getSharedHelper().currency_code));
    } catch (Exception e) {
      // TODO: handle exception
    }

    float newPrice = Float.parseFloat(object.getNewPrice());
    String selectedCurrencyCode = Helper.getSharedHelper().currency_code;
    if (conversionValue == 0) {
      conversionValue = 1.0f;
      selectedCurrencyCode = Helper.getSharedHelper().reatiler.defaultCurrency;
    }
    if (object.getOldPrice() != null) {
      float oldProce = Float.parseFloat(object.getOldPrice());
      oldProce = oldProce * conversionValue;
      holder
          .getOldPrice()
          .setText(selectedCurrencyCode + Helper.getSharedHelper().conertfloatToSTring(oldProce));
      holder.getOldPrice().setVisibility(View.VISIBLE);
    } else {
      holder.getOldPrice().setVisibility(View.GONE);
    }

    newPrice = newPrice * conversionValue;

    holder
        .getNewPrice()
        .setText(selectedCurrencyCode + Helper.getSharedHelper().conertfloatToSTring(newPrice));
    //		if (Helper.getSharedHelper().enableRating.equals("1")) {
    //			holder.getProductRatingBar().setRating(
    //					Float.parseFloat(object.getProductRating()));
    //			holder.getProductRatingBar().setVisibility(View.VISIBLE);
    //		} else {
    //			holder.getProductRatingBar().setVisibility(View.GONE);
    //		}

    holder
        .getOldPrice()
        .setPaintFlags(holder.getOldPrice().getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
    // ivStroke = holder.getStroke();
    //
    // // ImageView ivStrike = (ImageView)findViewById(R.id.ivStrike);
    //
    // float textSize = holder.getOldPrice().getTextSize() / 2;
    // int textLength = holder.getOldPrice().getText().length();
    // int totalLengthApprox = (int) (textLength * textSize) - textLength;
    // int height = 2; // YOUR_REQUIRED_HEIGHT
    //
    // RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(
    // totalLengthApprox, height);
    // param.addRule(RelativeLayout.CENTER_VERTICAL
    // | RelativeLayout.ALIGN_PARENT_LEFT);
    // param.setMargins(4, 0, 0, 0);
    // ivStroke.setLayoutParams(param);

    imageView = holder.getImage();

    imageCacheLoader.displayImage(object.getImage(), R.drawable.image_placeholder, imageView);
    try {
      holder.getShortDesc().setTypeface(Helper.getSharedHelper().normalFont);
      holder.getOldPrice().setTypeface(Helper.getSharedHelper().normalFont);
      holder.getNewPrice().setTypeface(Helper.getSharedHelper().boldFont);
      holder.getTvQtyIndicator().setTypeface(Helper.getSharedHelper().normalFont);
      holder.getTvSaleIndicator().setTypeface(Helper.getSharedHelper().normalFont);
      holder.getTvDistance().setTypeface(Helper.getSharedHelper().boldFont);
      holder.getTvAddress().setTypeface(Helper.getSharedHelper().normalFont);
    } catch (Exception e) {

    }

    int width = imageView.getWidth();
    int height = imageView.getHeight();

    if (object.availQty != null) {
      if (Integer.parseInt(object.availQty) <= 0) {
        holder.getTvQtyIndicator().setText("Sold Out");
        holder.getTvQtyIndicator().setVisibility(View.VISIBLE);
      } else if (Integer.parseInt(object.availQty) > 5) {
        holder.getTvQtyIndicator().setVisibility(View.GONE);
      } else {
        holder.getTvQtyIndicator().setText(object.availQty + " Left");
        holder.getTvQtyIndicator().setVisibility(View.VISIBLE);
      }
    }
    if (object.onSale != null && object.onSale.equalsIgnoreCase("1")) {
      holder.getTvSaleIndicator().setVisibility(View.GONE);
    } else {
      holder.getTvSaleIndicator().setVisibility(View.GONE);
    }

    return convertView;
  }