/** 更新卸货地址信息 */
  private void updateUI() {
    if (info != null) {
      if (StringUtils.isNEmpty(info.areaName)) {
        mTvAddrDetail1.setText(getString(R.string.data_empty));
      } else {
        mTvAddrDetail1.setText(info.areaName);
      }
      if (StringUtils.isNEmpty(info.deliveryAddrDetail)) {
        mTvAddrDetail2.setText(getString(R.string.data_empty));
      } else {
        mTvAddrDetail2.setText(info.deliveryAddrDetail);
      }
      mItemPortWaterDepth.setContentText(
          info.uploadPortWaterDepth != 0
              ? String.valueOf(info.uploadPortWaterDepth)
              : getString(R.string.data_empty));
      mItemPortShipTon.setContentText(
          info.shippingTon != 0
              ? String.valueOf(info.shippingTon)
              : getString(R.string.data_empty));

      List<ImageInfoModel> imgUrl = info.addrImageList;
      if (BeanUtils.isEmpty(imgUrl)) {
        getView(R.id.item_devider_discharge_addr).setVisibility(View.GONE);
        getView(R.id.ll_addr_pic).setVisibility(View.GONE);
      } else {
        getView(R.id.item_devider_discharge_addr).setVisibility(View.VISIBLE);
        getView(R.id.ll_addr_pic).setVisibility(View.VISIBLE);
        int count = imgUrl.size();
        if (count >= 1) {
          mIvItemAddrPic1.setVisibility(View.VISIBLE);
          ImageLoaderManager.getIntance()
              .display(
                  this,
                  imgUrl.get(0) != null ? imgUrl.get(0).cloudThumbnailUrl : "",
                  mIvItemAddrPic1,
                  IMAGE_DEFAULT,
                  IMAGE_FAILED);
        }
        if (count >= 2) {
          mIvItemAddrPic2.setVisibility(View.VISIBLE);
          ImageLoaderManager.getIntance()
              .display(
                  this,
                  imgUrl.get(1) != null ? imgUrl.get(1).cloudThumbnailUrl : "",
                  mIvItemAddrPic2,
                  IMAGE_DEFAULT,
                  IMAGE_FAILED);
        } else {
          mIvItemAddrPic2.setVisibility(View.INVISIBLE);
        }
        if (count >= 3) {
          mIvItemAddrPic3.setVisibility(View.VISIBLE);
          ImageLoaderManager.getIntance()
              .display(
                  this,
                  imgUrl.get(2) != null ? imgUrl.get(2).cloudThumbnailUrl : "",
                  mIvItemAddrPic3,
                  IMAGE_DEFAULT,
                  IMAGE_FAILED);
        } else {
          mIvItemAddrPic3.setVisibility(View.INVISIBLE);
        }
      }
    }
  }
Ejemplo n.º 2
0
  @Override
  public View getChildView(
      int groupPosition,
      int childPosition,
      boolean isLastChild,
      View convertView,
      ViewGroup parent) {
    if (convertView == null) {
      convertView = View.inflate(mContext, R.layout.adapter_price_trend_item, null);
    }

    ForecastPriceModel model = getChild(groupPosition, childPosition);

    // 规格&大小
    TextView mTvProductSpec = ViewHolder.get(convertView, R.id.tv_product_spec);
    TextView mTvProductSpecSize = ViewHolder.get(convertView, R.id.tv_product_spec_size);

    if (model.productInfo != null) {
      // 显示规格名称
      String specName = model.productInfo.mSubCategoryName;
      if (StringUtils.isNotEmpty(specName)) {
        mTvProductSpec.setText(specName);
        mTvProductSpec.setVisibility(View.VISIBLE);
      } else {
        mTvProductSpec.setVisibility(View.GONE);
      }
      // 显示规格大小
      String specSize = SysCfgUtils.getSize(model.productInfo);
      if (StringUtils.isNotEmpty(specSize)) {
        mTvProductSpecSize.setText(specSize);
        mTvProductSpecSize.setVisibility(View.VISIBLE);
      } else {
        mTvProductSpecSize.setVisibility(View.GONE);
      }
    } else {
      mTvProductSpec.setVisibility(View.GONE);
      mTvProductSpecSize.setVisibility(View.GONE);
    }

    // 显示今日报价
    TextView mTvTodayPrice = ViewHolder.get(convertView, R.id.tv_product_today_price);
    if (StringUtils.isNEmpty(model.todayPrice)) {
      mTvTodayPrice.setText(mContext.getString(R.string.price_data_empty));
    } else {
      mTvTodayPrice.setText(model.todayPrice /* + mContext.getString(R.string.unit_price_ton)*/);
    }

    // 显示未来一周预测
    TextView mTvOneWeekPrice = ViewHolder.get(convertView, R.id.tv_product_oneweek_price);
    ImageView mIvOneWeekTrend = ViewHolder.get(convertView, R.id.iv_one_week_trend);
    if (StringUtils.isNEmpty(model.oneWeekForecastPrice)) {
      mTvOneWeekPrice.setText(mContext.getString(R.string.price_data_empty));
      mIvOneWeekTrend.setVisibility(View.GONE);
    } else {
      mTvOneWeekPrice.setText(
          model.oneWeekForecastPrice /* + mContext.getString(R.string.unit_price)*/);
      mIvOneWeekTrend.setVisibility(View.VISIBLE);
      if (StringUtils.isNEmpty(model.todayPrice)) {
        mIvOneWeekTrend.setVisibility(View.GONE);
      } else {
        if (Float.parseFloat(model.oneWeekForecastPrice) > Float.parseFloat(model.todayPrice)) {
          mIvOneWeekTrend.setBackgroundResource(R.drawable.ic_price_up);
        } else if (Float.parseFloat(model.oneWeekForecastPrice)
            < Float.parseFloat(model.todayPrice)) {
          mIvOneWeekTrend.setBackgroundResource(R.drawable.ic_price_down);
        } else {
          mIvOneWeekTrend.setVisibility(View.GONE);
        }
      }
    }

    // 显示未来两周预测
    TextView mTvTwoWeekPrice = ViewHolder.get(convertView, R.id.tv_product_twoweek_price);
    ImageView mIvTwoWeekTrend = ViewHolder.get(convertView, R.id.iv_two_week_trend);
    if (StringUtils.isNEmpty(model.twoWeekForecastPrice)) {
      mTvTwoWeekPrice.setText(mContext.getString(R.string.price_data_empty));
      mIvTwoWeekTrend.setVisibility(View.GONE);
    } else {
      mTvTwoWeekPrice.setText(
          model.twoWeekForecastPrice /* + mContext.getString(R.string.unit_price)*/);
      mIvTwoWeekTrend.setVisibility(View.VISIBLE);
      if (StringUtils.isNEmpty(model.todayPrice)) {
        mIvTwoWeekTrend.setVisibility(View.GONE);
      } else {
        if (Float.parseFloat(model.twoWeekForecastPrice) > Float.parseFloat(model.todayPrice)) {
          mIvTwoWeekTrend.setBackgroundResource(R.drawable.ic_price_up);
        } else if (Float.parseFloat(model.twoWeekForecastPrice)
            < Float.parseFloat(model.todayPrice)) {
          mIvTwoWeekTrend.setBackgroundResource(R.drawable.ic_price_down);
        } else {
          mIvTwoWeekTrend.setVisibility(View.GONE);
        }
      }
    }

    return convertView;
  }
Ejemplo n.º 3
0
  @Override
  protected void initData(AttributeSet attrs) {
    TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.BuyEditItemView);

    Drawable itemBg = null;
    Drawable itemIcon = null;

    CharSequence title = "";
    CharSequence secondTitle = "";
    CharSequence hintText = "";

    int contentWidth = 0;

    boolean isShowItemIcon = false;

    int inputType = EditorInfo.TYPE_NULL;

    final int N = array.getIndexCount();
    for (int i = 0; i < N; i++) {
      int attr = array.getIndex(i);
      switch (attr) {
        case R.styleable.BuyEditItemView_itemBg:
          itemBg = array.getDrawable(attr);
          break;
        case R.styleable.BuyEditItemView_itemIcon:
          itemIcon = array.getDrawable(attr);
          break;
        case R.styleable.BuyEditItemView_itemTitle:
          title = array.getText(attr);
          break;
        case R.styleable.BuyEditItemView_itemSecondTitle:
          secondTitle = array.getText(attr);
          break;
        case R.styleable.BuyEditItemView_itemEditHintText:
          hintText = array.getText(attr);
          break;
        case R.styleable.BuyEditItemView_itemEditWidth:
          contentWidth = array.getDimensionPixelSize(attr, -1);
          break;
        case R.styleable.BuyEditItemView_showItemIcon:
          isShowItemIcon = array.getBoolean(attr, false);
          break;
        case R.styleable.BuyEditItemView_itemInputType:
          inputType = array.getInt(attr, EditorInfo.TYPE_NULL);
          break;
      }
    }

    llContainer.setBackgroundDrawable(itemBg);
    mIvItemIcon.setBackgroundDrawable(itemIcon);

    int padding = getResources().getDimensionPixelSize(R.dimen.buy_item_padding);
    llContainer.setPadding(padding, 0, padding, 0);

    mTvItemTitle.setText(title);
    mTvItemSecondTitle.setText(secondTitle);

    if (hintText != null && StringUtils.isNotEmpty(hintText.toString())) {
      mEtItemContent.setHint(hintText);
    }

    if (contentWidth > 0) {
      LinearLayout.LayoutParams lp = (LayoutParams) mEtItemContent.getLayoutParams();
      lp.width = contentWidth;
    }

    mIvItemIcon.setVisibility(isShowItemIcon ? View.VISIBLE : View.GONE);

    if (inputType != EditorInfo.TYPE_NULL) {
      setEditInputType(inputType);
    }

    array.recycle();
  }