public void handleMessage(Message msg) {
          switch (msg.what) {
            case REFLASH_LISTVIEW:
              if (mixtureAdapter != null) mixtureAdapter.notifyDataSetChanged(); // 刷新UI
              break;

            case REFLASH_LISTVIEW_FAIL:
              Toast.makeText(
                      getApplication(),
                      MixGridActivity.this.getResources().getString(R.string.package_net_error),
                      Toast.LENGTH_SHORT)
                  .show();
              Log.e("合成列表", "合成道具图片下载失败,错误码为:" + msg.arg1);
              break;

            case CardZoneProtocolListener.HANDLER_PACK_QUERY_SUCCESS: // 获取背包列表数据成功
              flag = true;
              break;

            case CardZoneProtocolListener.HANDLER_PACK_QUERY_SUCCESS_NODATA:
              flag = true;
              break;
            case START_ANIM:
              if (btnFreeBean != null) {
                AnimationDrawable ad = (AnimationDrawable) btnFreeBean.getBackground();
                ad.stop();
                ad.start();
              }
              break;
            default:
              break;
          }
        }
示例#2
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));
       }
     }
   }
 }