@Override
 public int getChildrenCount(int groupPosition) {
   ClassicSector sector = mCard.getSector(groupPosition);
   if (!(sector instanceof UnauthorizedClassicSector)) {
     List<ClassicBlock> blocks = sector.getBlocks();
     return (blocks == null) ? 0 : blocks.size();
   } else {
     return 0;
   }
 }
Пример #2
0
  public OVChipTransitData(ClassicCard card) {
    mIndex = new OVChipIndex(card.getSector(39).readBlocks(11, 4));

    OVChipParser parser = new OVChipParser(card, mIndex);
    mCredit = parser.getCredit();
    mPreamble = parser.getPreamble();
    mInfo = parser.getInfo();

    List<OVChipTransaction> transactions =
        new ArrayList<OVChipTransaction>(Arrays.asList(parser.getTransactions()));
    Collections.sort(transactions, OVChipTransaction.ID_ORDER);

    List<OVChipTrip> trips = new ArrayList<OVChipTrip>();

    for (int i = 0; i < transactions.size(); i++) {
      OVChipTransaction transaction = transactions.get(i);

      if (transaction.getValid() != 1) {
        continue;
      }

      if (i < (transactions.size() - 1)) {
        OVChipTransaction nextTransaction = transactions.get(i + 1);
        if (transaction.isSameTrip(nextTransaction)) {
          trips.add(new OVChipTrip(transaction, nextTransaction));
          i++;
          continue;
        }
      }

      trips.add(new OVChipTrip(transaction));
    }

    Collections.sort(trips, OVChipTrip.ID_ORDER);
    mTrips = trips.toArray(new OVChipTrip[trips.size()]);

    List<OVChipSubscription> subs = new ArrayList<OVChipSubscription>();
    subs.addAll(Arrays.asList(parser.getSubscriptions()));
    Collections.sort(
        subs,
        new Comparator<OVChipSubscription>() {
          @Override
          public int compare(OVChipSubscription s1, OVChipSubscription s2) {
            return Integer.valueOf(s1.getId()).compareTo(s2.getId());
          }
        });

    mSubscriptions = subs.toArray(new OVChipSubscription[subs.size()]);
  }
  @Override
  public boolean onListChildClick(
      ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
    ClassicSector sector = mCard.getSector(groupPosition);
    ClassicBlock block = sector.getBlock(childPosition);

    String data = Utils.getHexString(block.getData(), "");

    String sectorTitle = getString(R.string.sector_title_format, sector.getIndex());
    String blockTitle = getString(R.string.block_title_format, block.getIndex());
    new AlertDialog.Builder(getActivity())
        .setTitle(String.format("%s, %s", sectorTitle, blockTitle))
        .setPositiveButton(android.R.string.ok, null)
        .setMessage(data)
        .show();

    return true;
  }
 @Override
 public int getGroupCount() {
   return mCard.getSectors().size();
 }
 @Override
 public Object getChild(int groupPosition, int childPosition) {
   return mCard.getSector(groupPosition).getBlocks().get(childPosition);
 }
 @Override
 public Object getGroup(int groupPosition) {
   return mCard.getSector(groupPosition);
 }