コード例 #1
0
  private void initConsume() {
    int len = consumeList.size();

    for (int i = 0; i < len; i++) {
      mList = mInflater.inflate(R.layout.mix_list_item, null);
      mItemName = (TextView) mList.findViewById(R.id.mix_list_name);
      mItemNum = (TextView) mList.findViewById(R.id.mix_list_num);
      ImageView mItemImg = (ImageView) mList.findViewById(R.id.mix_list_img);
      mItemImg.setBackgroundResource(R.drawable.unknown);
      Consume mConsume = consumeList.get(i);
      mItemName.setText(mConsume.name);
      String handCount = "";
      int count = BackPackItemProvider.getInstance().getPorpCount(mConsume.id);
      if (count != 0) {
        handCount = String.valueOf(count);
        mItemNum.setText(handCount + "/" + String.valueOf(mConsume.num));
      } else if (mConsume.t == 0) {
        mItemNum.setText(String.valueOf(mConsume.num));
      } else {
        handCount = "0";
        mItemNum.setText(handCount + "/" + String.valueOf(mConsume.num));
      }

      if (mConsume.t == 0) {
        mItemImg.setImageResource(R.drawable.dj_ledou);
      } else {
        setImageRes(mConsume.logo, mItemImg);
        mItemImg.setScaleType(ScaleType.CENTER_CROP);
      }

      cousumeItems.addView(mList, i);
      cousumeItem = (RelativeLayout) mList.findViewById(R.id.mix_list_item);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      lp.setMargins(7, 0, 0, 0);
      cousumeItem.setLayoutParams(lp);
    }
  }
コード例 #2
0
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case HANDLER_MIX_SUCCESS:
              // 合成成功
              BackPackActivity.needRefreshBackpack = true;
              String successed = UtilHelper.parseStatusXml(msg.obj.toString(), "successed");
              CardZoneProtocolListener.getInstance(MixActivity.this)
                  .requestBackPackList(userID, mMixHandler);
              if (mContext != null) {
                SysPopDialog dialog =
                    new SysPopDialog(
                        MixActivity.this,
                        "",
                        mResource.getString(R.string.Ensure),
                        mResource.getString(R.string.package_synthetic_success)
                            + mixInfo.name
                            + successed
                            + mResource.getString(R.string.package_input_you_package),
                        null);

                dialog.show();
              }

              break;

            case HANDLER_MIX_RATE_FAIL:
              // 合成概率失败
              int num_ = msg.arg1;
              int bean_ = HallDataManager.getInstance().getUserMe().bean;
              bean_ = bean_ - mixInfo.beanCost * num_;
              HallDataManager.getInstance().getUserMe().setBean(bean_);
              // 合成失败 HANDLER_MIX_FAIL
              String _toolinfo = UtilHelper.parseStatusXml(msg.obj.toString(), "toolinfo");
              if (mContext != null) {
                SysPopDialog dialog =
                    new SysPopDialog(
                        MixActivity.this,
                        "",
                        mResource.getString(R.string.Ensure),
                        _toolinfo,
                        null);

                dialog.show();
              }
              break;

            case HANDLER_MIX_FAIL:
              // 合成失败 HANDLER_MIX_FAIL
              String toolinfo = UtilHelper.parseStatusXml(msg.obj.toString(), "toolinfo");
              if (mContext != null) {
                SysPopDialog dialog =
                    new SysPopDialog(
                        MixActivity.this, "", mResource.getString(R.string.Ensure), toolinfo, null);

                dialog.show();
              }
              break;

            case CardZoneProtocolListener.HANDLER_PACK_QUERY_SUCCESS: // 获取背包列表数据成功
              for (int i = 0; i < consumeList.size(); i++) {
                String handCount = "";
                Consume mConsume = consumeList.get(i);
                mItemNum = (TextView) cousumeItems.getChildAt(i).findViewById(R.id.mix_list_num);
                int count = BackPackItemProvider.getInstance().getPorpCount(mConsume.id);
                if (count != 0) {
                  handCount = String.valueOf(count);
                  mItemNum.setText(handCount + "/" + String.valueOf(mConsume.num));
                } else if (mConsume.t == 0) {
                  mItemNum.setText(String.valueOf(mConsume.num));
                } else {
                  handCount = "0";
                  mItemNum.setText(handCount + "/" + String.valueOf(mConsume.num));
                }
              }
              mMixNum.setText("1");
              mMixCost.setText(String.valueOf(mixInfo.beanCost));

              break;

            case CardZoneProtocolListener.HANDLER_PACK_QUERY_SUCCESS_NODATA:
              Log.e("mix", "我的物品没有数据!");
              break;

            default:
              break;
          }
        }
コード例 #3
0
 @Override
 public void onClick(View v) {
   int id = v.getId();
   if (id == R.id.tvBack) {
     finish();
   } else if (id == R.id.btn_mix) {
     boolean enough = true;
     short i = Short.parseShort(mMixNum.getText().toString());
     if (userInfo.memberOrder >= mixInfo.vip && userInfo.exp >= mixInfo.exp) {
       int len = consumeList.size();
       for (int j = 0; j < len; j++) {
         Consume mConsume = consumeList.get(j);
         //
         int count = BackPackItemProvider.getInstance().getPorpCount(mConsume.id);
         if (count != 0) {
           int hand = count;
           int need = mConsume.num;
           enough = enough && (hand >= need * i);
         } else {
           enough = false;
         }
       }
       if (enough) {
         requestMix(mixInfo, i);
       } else {
         Toast.makeText(
                 getApplication(),
                 mResource.getString(R.string.package_synthetic_material_shortage),
                 Toast.LENGTH_SHORT)
             .show();
       }
     } else {
       Toast.makeText(
               getApplication(), mResource.getString(R.string.package_level), Toast.LENGTH_SHORT)
           .show();
     }
   } else if (id == R.id.btnReduce) {
     int numReduce = Integer.valueOf(mMixNum.getText().toString());
     if (numReduce > 1) {
       numReduce--;
     }
     mMixNum.setText(Integer.toString(numReduce));
     mMixCost.setText(String.valueOf((mixInfo.beanCost) * numReduce));
     for (int j = 0; j < consumeList.size(); j++) {
       String handCount = "";
       Consume mConsume = consumeList.get(j);
       mItemNum = (TextView) cousumeItems.getChildAt(j).findViewById(R.id.mix_list_num);
       int count = BackPackItemProvider.getInstance().getPorpCount(mConsume.id);
       if (count != 0) {
         handCount = String.valueOf(count);
         mItemNum.setText(handCount + "/" + String.valueOf(mConsume.num * numReduce));
       } else if (mConsume.t == 0) {
         mItemNum.setText(String.valueOf(mConsume.num * numReduce));
       } else {
         handCount = "0";
         mItemNum.setText(handCount + "/" + String.valueOf(mConsume.num * numReduce));
       }
     }
   } else if (id == R.id.btnIncrease) {
     int numIncrease = Integer.valueOf(mMixNum.getText().toString());
     numIncrease++;
     mMixNum.setText(Integer.toString(numIncrease));
     mMixCost.setText(String.valueOf((mixInfo.beanCost) * numIncrease));
     for (int j = 0; j < consumeList.size(); j++) {
       String handCount = "";
       Consume mConsume = consumeList.get(j);
       mItemNum = (TextView) cousumeItems.getChildAt(j).findViewById(R.id.mix_list_num);
       int count = BackPackItemProvider.getInstance().getPorpCount(mConsume.id);
       if (count != 0) {
         handCount = String.valueOf(count);
         mItemNum.setText(handCount + "/" + String.valueOf(mConsume.num * numIncrease));
       } else if (mConsume.t == 0) {
         mItemNum.setText(String.valueOf(mConsume.num * numIncrease));
       } else {
         handCount = "0";
         mItemNum.setText(handCount + "/" + String.valueOf(mConsume.num * numIncrease));
       }
     }
   }
 }