コード例 #1
0
ファイル: TapsListAdapter.java プロジェクト: klajmajk/vycep
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.tap_item, null);
    }
    TextView barrel = (TextView) convertView.findViewById(R.id.barrel);
    TextView poured = (TextView) convertView.findViewById(R.id.poured);

    TextView note = (TextView) convertView.findViewById(R.id.note);
    TextView newKegNotification = (TextView) convertView.findViewById(R.id.new_barrel_notification);
    Button newKegButton = (Button) convertView.findViewById(R.id.button);
    newKegButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Controller.getInstanceOf().getBarrelsFromREST(mContext);
          }
        });

    TextView activePoured = (TextView) convertView.findViewById(R.id.activePoured);
    ProgressBar progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);

    DecimalFormat df = new DecimalFormat("####0.00 L");

    if (getItem(position).getNote() != null) note.setText(getItem(position).getNote());

    if (getItem(position).getKeg() == null) {
      barrel.setText("Nenaraženo");
      activePoured.setText("-");
    } else {
      barrel.setText(
          getItem(position).getKeg().getKind().getBrewery().getName()
              + " "
              + getItem(position).getKeg().getKind().getName()
              + " "
              + getItem(position).getKeg().getVolume() / 1000
              + " L");
      activePoured.setText(df.format(((double) getItem(position).getActivePoured()) / 1000));
      progressBar.setProgress(getProgress(position));
    }

    if (Controller.getInstanceOf().getTapController().showNewKegNotification()) {
      newKegNotification.setVisibility(View.VISIBLE);
      newKegButton.setVisibility(View.VISIBLE);
      newKegButton.setEnabled(true);
    } else {
      newKegNotification.setVisibility(View.INVISIBLE);
      newKegButton.setVisibility(View.INVISIBLE);
      newKegButton.setEnabled(false);
    }
    // Log.d("Tap_adapter: ", getItem(position).toString());
    poured.setText("Vyčepováno: " + df.format(((double) getItem(position).getPoured()) / 1000));

    return convertView;
  }
コード例 #2
0
ファイル: TapsListAdapter.java プロジェクト: klajmajk/vycep
 private int getProgress(final int position) {
   return Controller.getInstanceOf().getTapController().getProgress(getItem(position));
 }