Example #1
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.building_button:
       {
         //                Pair pair = PairFactory.newInstance(0,0,1,1);
         //                List<Pair> list = new Price().getPrice(pair);
         //                for(Pair p:list){
         //                    Logs.d(p.toString());
         //                }
         //                if(temp<4){
         //                    Pair pair = PairFactory.newInstance(Pair.TYPE_BUILDING,
         // temp<=App.get().getKeysAmount(type)?);
         //                    App.get().addPair(pair);
         //                    //                List<Pair> list =
         // DataManager.get().readAll(Pair.TYPE_SUPPLIES);
         //                    //                Logs.d(list.size() + "");
         //                    buildingAdapter.notifyDataSetChanged();
         //                }
         //                temp = temp>=4?0:temp+1;
         for (int i = 0; i < PairFactory.getKeysAmount(type); i++) {
           Pair pair = App.get().getPair(type, i);
           if (pair == null) {
             App.get().newPair(type, i);
             break;
           } else {
             pair.setGrowth(1);
             pair.grow(1);
           }
         }
         refresh();
         break;
       }
   }
 }
Example #2
0
 @Override
 public void onClick(View v) {
   if (pair != null) {
     if (App.get().consumes(pair)) {
       pair.add(1);
     }
     MainActivity.instance.refresh();
   }
 }
Example #3
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    holder = null;
    if (null == convertView) {
      holder = new ViewHolder();
      if (null == mInflater) {
        mInflater = LayoutInflater.from(MainActivity.instance);
      }
      convertView = mInflater.inflate(R.layout.unit_supplies, null, false);
      holder.tvTitle = (TextView) convertView.findViewById(R.id.supplies_unit_title);
      holder.tvValue = (TextView) convertView.findViewById(R.id.supplies_unit_value);
      holder.tvGrowth = (TextView) convertView.findViewById(R.id.supplies_unit_growth);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    Pair pair = (Pair) getItem(position);
    holder.tvTitle.setText(pair.getTitle());
    holder.tvValue.setText(Strs.f(pair.getValue()));
    holder.tvGrowth.setText(Strs.f(pair.getGrowth()));
    return convertView;
  }
Example #4
0
 public void onItemClick(Pair pair, int position) {
   tvSelect.setText(pair.getTitle());
   lnSelectBuy.setPair(pair);
   selectPosition = position;
 }