Example usage for android.util SparseArray SparseArray

List of usage examples for android.util SparseArray SparseArray

Introduction

In this page you can find the example usage for android.util SparseArray SparseArray.

Prototype

public SparseArray() 

Source Link

Document

Creates a new SparseArray containing no mappings.

Usage

From source file:net.naonedbus.fragment.impl.FavorisFragment.java

@Override
protected AsyncResult<ListAdapter> loadContent(final Context context, final Bundle bundle) {
    if (DBG)/*from   w  w w  .ja  v  a 2 s. co  m*/
        Log.d(LOG_TAG, "loadContent");

    final HoraireManager horaireManager = HoraireManager.getInstance();

    final AsyncResult<ListAdapter> result = new AsyncResult<ListAdapter>();
    final List<Favori> favoris = mFavorisViewManager.getAll(context.getContentResolver(), mSelectedGroupes);
    Collections.sort(favoris, comparators.get(mCurrentSort));

    int position = 0;
    for (final Favori favori : favoris) {
        if (getActivity() != null) {
            favori.setDelay(FavorisUtil.formatDelayLoading(getActivity(), favori.getNextHoraire()));
        }

        if (favori.getNextHoraire() == null) {
            final NextHoraireTask horaireTask = new NextHoraireTask();
            horaireTask.setContext(context);
            horaireTask.setArret(favori);
            horaireTask.setId(position);
            horaireTask.setLimit(1);
            horaireTask.setActionCallback(ACTION_UPDATE_DELAYS);

            horaireManager.schedule(horaireTask);
        }
        position++;
    }

    final FavoriArrayAdapter adapter = new FavoriArrayAdapter(context, favoris);

    if (mGroupes.isEmpty() == false) {
        final SparseArray<String> groupes = new SparseArray<String>();
        for (final Groupe groupe : mGroupes) {
            groupes.append(groupe.getId(), groupe.getNom());
        }
        adapter.setIndexer(new FavoriArrayIndexer(groupes));
    }

    result.setResult(adapter);

    return result;
}

From source file:fr.outadev.android.timeo.TimeoRequestHandler.java

/**
 * Gets the list of the supported bus networks.
 *
 * @return an array containing the network names; the index is their code, and they're associated with their name
 *///from ww w.j  a  v a 2  s . c o  m
public static SparseArray<String> getNetworksList() {
    SparseArray<String> networks = new SparseArray<>();

    networks.put(105, "Le Mans");
    networks.put(117, "Pau");
    networks.put(120, "Soissons");
    networks.put(135, "Aix-en-Provence");
    networks.put(147, "Caen");
    networks.put(217, "Dijon");
    networks.put(297, "Brest");
    networks.put(402, "Pau-Agen");
    networks.put(416, "Blois");
    networks.put(422, "Saint-tienne");
    networks.put(440, "Nantes");
    networks.put(457, "Montargis");
    networks.put(497, "Angers");
    networks.put(691, "Macon-Villefranche");
    networks.put(910, "pinay-sur-Orge");
    networks.put(999, "Rennes");

    return networks;
}

From source file:org.akvo.caddisfly.sensor.colorimetry.liquid.ColorimetryLiquidActivity.java

private void setResultIntent() {
    // Get the average color across the results
    int color = SwatchHelper.getAverageColor(mResults);

    // If this is a test and it was successful then build the result to return
    if (!mIsCalibration && (mResult > -1 || color != Color.TRANSPARENT)) {
        Intent intent = getIntent();//from  ww  w. jav a  2s . co m

        String resultText = String.format(Locale.getDefault(), "%.2f", mResult);

        // Add 'greater than' symbol if result could be an unknown high value
        if (mHighLevelsFound) {
            resultText = "> " + resultText;
        }

        Intent resultIntent = new Intent(intent);
        resultIntent.putExtra(SensorConstants.RESULT, resultText);
        resultIntent.putExtra(SensorConstants.COLOR, color);

        String resultImageUrl = EMPTY_STRING;
        if (getIntent().getBooleanExtra(Constant.SEND_IMAGE_IN_RESULT, false)) {
            // Save photo taken during the test
            resultImageUrl = UUID.randomUUID().toString() + ".png";
            String path = FileUtil.writeBitmapToExternalStorage(mCroppedBitmap, "/result-images",
                    resultImageUrl);
            resultIntent.putExtra(SensorConstants.IMAGE, path);
        }

        TestInfo testInfo = CaddisflyApp.getApp().getCurrentTestInfo();

        SparseArray<String> results = new SparseArray<>();
        results.put(testInfo.getSubTests().get(0).getId(), resultText);

        JSONObject resultJson = TestConfigHelper.getJsonResult(testInfo, results, color, resultImageUrl, null);

        resultIntent.putExtra(SensorConstants.RESPONSE, resultJson.toString());

        // TODO: Remove this when obsolete
        // Backward compatibility. Return plain text result
        resultIntent.putExtra(SensorConstants.RESPONSE_COMPAT, resultText);

        setResult(Activity.RESULT_OK, resultIntent);

    }
}

From source file:com.transitionseverywhere.Transition.java

/**
 * This method, essentially a wrapper around all calls to createAnimator for all
 * possible target views, is called with the entire set of start/end
 * values. The implementation in Transition iterates through these lists
 * and calls {@link #createAnimator(ViewGroup, TransitionValues, TransitionValues)}
 * with each set of start/end values on this transition. The
 * TransitionSet subclass overrides this method and delegates it to
 * each of its children in succession./*from  w ww  . jav a  2  s.co  m*/
 *
 * @hide
 */
protected void createAnimators(ViewGroup sceneRoot, TransitionValuesMaps startValues,
        TransitionValuesMaps endValues, ArrayList<TransitionValues> startValuesList,
        ArrayList<TransitionValues> endValuesList) {
    if (DBG) {
        Log.d(LOG_TAG, "createAnimators() for " + this);
    }
    ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
    long minStartDelay = Long.MAX_VALUE;
    int minAnimator = mAnimators.size();
    SparseArray<Long> startDelays = new SparseArray<Long>();
    int startValuesListCount = startValuesList.size();
    for (int i = 0; i < startValuesListCount; ++i) {
        TransitionValues start = startValuesList.get(i);
        TransitionValues end = endValuesList.get(i);
        if (start != null && !start.targetedTransitions.contains(this)) {
            start = null;
        }
        if (end != null && !end.targetedTransitions.contains(this)) {
            end = null;
        }
        if (start == null && end == null) {
            continue;
        }
        // Only bother trying to animate with values that differ between start/end
        boolean isChanged = start == null || end == null || isTransitionRequired(start, end);
        if (isChanged) {
            if (DBG) {
                View view = (end != null) ? end.view : start.view;
                Log.d(LOG_TAG, "  differing start/end values for view " + view);
                if (start == null || end == null) {
                    Log.d(LOG_TAG, "    "
                            + ((start == null) ? "start null, end non-null" : "start non-null, end null"));
                } else {
                    for (String key : start.values.keySet()) {
                        Object startValue = start.values.get(key);
                        Object endValue = end.values.get(key);
                        if (startValue != endValue && !startValue.equals(endValue)) {
                            Log.d(LOG_TAG, "    " + key + ": start(" + startValue + "), end(" + endValue + ")");
                        }
                    }
                }
            }
            // TODO: what to do about targetIds and itemIds?
            Animator animator = createAnimator(sceneRoot, start, end);
            if (animator != null) {
                // Save animation info for future cancellation purposes
                View view;
                TransitionValues infoValues = null;
                if (end != null) {
                    view = end.view;
                    String[] properties = getTransitionProperties();
                    if (view != null && properties != null && properties.length > 0) {
                        infoValues = new TransitionValues();
                        infoValues.view = view;
                        TransitionValues newValues = endValues.viewValues.get(view);
                        if (newValues != null) {
                            for (int j = 0; j < properties.length; ++j) {
                                infoValues.values.put(properties[j], newValues.values.get(properties[j]));
                            }
                        }
                        synchronized (sRunningAnimators) {
                            int numExistingAnims = runningAnimators.size();
                            for (int j = 0; j < numExistingAnims; ++j) {
                                Animator anim = runningAnimators.keyAt(j);
                                AnimationInfo info = runningAnimators.get(anim);
                                if (info.values != null && info.view == view
                                        && ((info.name == null && getName() == null)
                                                || (info.name != null && info.name.equals(getName())))) {
                                    if (info.values.equals(infoValues)) {
                                        // Favor the old animator
                                        animator = null;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                } else {
                    view = start.view;
                }
                if (animator != null) {
                    if (mPropagation != null) {
                        long delay = mPropagation.getStartDelay(sceneRoot, this, start, end);
                        startDelays.put(mAnimators.size(), delay);
                        minStartDelay = Math.min(delay, minStartDelay);
                    }
                    AnimationInfo info = new AnimationInfo(view, getName(), this,
                            ViewUtils.getWindowId(sceneRoot), infoValues);
                    runningAnimators.put(animator, info);
                    mAnimators.add(animator);
                }
            }
        }
    }
    if (startDelays.size() != 0) {
        for (int i = 0; i < startDelays.size(); i++) {
            int index = startDelays.keyAt(i);
            Animator animator = mAnimators.get(index);
            long delay = startDelays.valueAt(i) - minStartDelay + animator.getStartDelay();
            animator.setStartDelay(delay);
        }
    }
}

From source file:android.transitions.everywhere.Transition.java

/**
 * This method, essentially a wrapper around all calls to createAnimator for all
 * possible target views, is called with the entire set of start/end
 * values. The implementation in Transition iterates through these lists
 * and calls {@link #createAnimator(ViewGroup, TransitionValues, TransitionValues)}
 * with each set of start/end values on this transition. The
 * TransitionSet subclass overrides this method and delegates it to
 * each of its children in succession.//from ww  w .  j a v a 2 s. c o  m
 *
 * @hide
 */
protected void createAnimators(ViewGroup sceneRoot, TransitionValuesMaps startValues,
        TransitionValuesMaps endValues, ArrayList<TransitionValues> startValuesList,
        ArrayList<TransitionValues> endValuesList) {
    if (DBG) {
        Log.d(LOG_TAG, "createAnimators() for " + this);
    }
    ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
    long minStartDelay = Long.MAX_VALUE;
    int minAnimator = mAnimators.size();
    SparseArray<Long> startDelays = new SparseArray<Long>();
    int startValuesListCount = startValuesList.size();
    for (int i = 0; i < startValuesListCount; ++i) {
        TransitionValues start = startValuesList.get(i);
        TransitionValues end = endValuesList.get(i);
        if (start != null && !start.targetedTransitions.contains(this)) {
            start = null;
        }
        if (end != null && !end.targetedTransitions.contains(this)) {
            end = null;
        }
        if (start == null && end == null) {
            continue;
        }
        // Only bother trying to animate with values that differ between start/end
        boolean isChanged = start == null || end == null || areValuesChanged(start, end);
        if (isChanged) {
            if (DBG) {
                View view = (end != null) ? end.view : start.view;
                Log.d(LOG_TAG, "  differing start/end values for view " + view);
                if (start == null || end == null) {
                    Log.d(LOG_TAG, "    "
                            + ((start == null) ? "start null, end non-null" : "start non-null, end null"));
                } else {
                    for (String key : start.values.keySet()) {
                        Object startValue = start.values.get(key);
                        Object endValue = end.values.get(key);
                        if (startValue != endValue && !startValue.equals(endValue)) {
                            Log.d(LOG_TAG, "    " + key + ": start(" + startValue + "), end(" + endValue + ")");
                        }
                    }
                }
            }
            // TODO: what to do about targetIds and itemIds?
            Animator animator = createAnimator(sceneRoot, start, end);
            if (animator != null) {
                // Save animation info for future cancellation purposes
                View view = null;
                TransitionValues infoValues = null;
                if (end != null) {
                    view = end.view;
                    String[] properties = getTransitionProperties();
                    if (view != null && properties != null && properties.length > 0) {
                        infoValues = new TransitionValues();
                        infoValues.view = view;
                        TransitionValues newValues = endValues.viewValues.get(view);
                        if (newValues != null) {
                            for (int j = 0; j < properties.length; ++j) {
                                infoValues.values.put(properties[j], newValues.values.get(properties[j]));
                            }
                        }
                        int numExistingAnims = runningAnimators.size();
                        for (int j = 0; j < numExistingAnims; ++j) {
                            Animator anim = runningAnimators.keyAt(j);
                            AnimationInfo info = runningAnimators.get(anim);
                            if (info.values != null && info.view == view
                                    && ((info.name == null && getName() == null)
                                            || info.name.equals(getName()))) {
                                if (info.values.equals(infoValues)) {
                                    // Favor the old animator
                                    animator = null;
                                    break;
                                }
                            }
                        }
                    }
                } else {
                    view = (start != null) ? start.view : null;
                }
                if (animator != null) {
                    if (mPropagation != null) {
                        long delay = mPropagation.getStartDelay(sceneRoot, this, start, end);
                        startDelays.put(mAnimators.size(), delay);
                        minStartDelay = Math.min(delay, minStartDelay);
                    }
                    AnimationInfo info = new AnimationInfo(view, getName(), this,
                            ViewUtils.getWindowId(sceneRoot), infoValues);
                    runningAnimators.put(animator, info);
                    mAnimators.add(animator);
                }
            }
        }
    }
    if (minStartDelay != 0) {
        for (int i = 0; i < startDelays.size(); i++) {
            int index = startDelays.keyAt(i);
            Animator animator = mAnimators.get(index);
            long delay = startDelays.valueAt(i) - minStartDelay + animator.getStartDelay();
            animator.setStartDelay(delay);
        }
    }
}

From source file:ee.ioc.phon.android.speak.RecognizerIntentActivity.java

private SparseArray<String> createErrorMessages() {
    SparseArray<String> errorMessages = new SparseArray<String>();
    errorMessages.put(RecognizerIntent.RESULT_AUDIO_ERROR, getString(R.string.errorResultAudioError));
    errorMessages.put(RecognizerIntent.RESULT_CLIENT_ERROR, getString(R.string.errorResultClientError));
    errorMessages.put(RecognizerIntent.RESULT_NETWORK_ERROR, getString(R.string.errorResultNetworkError));
    errorMessages.put(RecognizerIntent.RESULT_SERVER_ERROR, getString(R.string.errorResultServerError));
    errorMessages.put(RecognizerIntent.RESULT_NO_MATCH, getString(R.string.errorResultNoMatch));
    return errorMessages;
}

From source file:com.bmd.android.collection.SparseArrayTest.java

@Override
protected void setUp() throws Exception {

    super.setUp();

    final SparseArray<String> array = new SparseArray<String>();

    for (int i = 0; i < 5; i++) {

        array.append(i, String.valueOf(i));
    }/*from  www. j  a v  a  2  s  . c om*/

    mArray = array;
}

From source file:fr.cph.chicago.parser.XmlParser.java

@NonNull
public final synchronized List<Eta> parseTrainsFollow(@NonNull final InputStream is,
        @NonNull final TrainData data) throws ParserException {
    SparseArray<TrainArrival> arrivals = new SparseArray<>();
    try {//from w  w w  . j ava 2 s  . c  o m
        parser.setInput(is, "UTF-8");
        int eventType = parser.getEventType();
        XmlArrivalTrainTag tag = null;
        //         Date tmst = null;
        //         Integer errCd = null;
        //         String errNum = null;
        String tagName = null;
        Integer staId = null;
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                tagName = parser.getName();
                switch (tagName) {
                case "tmst":
                    tag = XmlArrivalTrainTag.TMST;
                    break;
                case "errCd":
                    tag = XmlArrivalTrainTag.ERRCD;
                    break;
                case "errNm":
                    tag = XmlArrivalTrainTag.ERRNM;
                    break;
                case "eta":
                    tag = XmlArrivalTrainTag.ETA;
                    break;
                default:
                    tag = XmlArrivalTrainTag.OTHER;
                    break;
                }
            } else if (eventType == XmlPullParser.END_TAG) {
                tag = null;
            } else if (eventType == XmlPullParser.TEXT) {
                String text = parser.getText();
                switch (tag) {
                case ETA:
                    break;
                case OTHER:
                    switch (tagName) {
                    case "staId": {
                        staId = Integer.parseInt(text);
                        final TrainArrival arri = arrivals.get(staId, new TrainArrival());
                        //arri.setErrorCode(errCd);
                        //arri.setErrorMessage(errNum);
                        //arri.setTimeStamp(tmst);
                        List<Eta> etas = arri.getEtas();
                        if (etas == null) {
                            etas = new ArrayList<>();
                            arri.setEtas(etas);
                        }
                        final Eta eta = new Eta();
                        final Optional<Station> station = data.getStation(Integer.parseInt(text));
                        eta.setStation(station.orElse(new Station()));
                        etas.add(eta);

                        arrivals.append(staId, arri);
                        break;
                    }
                    case "stpId": {
                        final TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            final Stop stop = data.getStop(Integer.parseInt(text));
                            currentEta.setStop(stop);
                        }
                        break;
                    }
                    case "staNm": {
                        final TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            final Station station = currentEta.getStation();
                            station.setName(text);
                        }
                        break;
                    }
                    case "stpDe": {
                        final TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            final Stop stop = currentEta.getStop();
                            stop.setDescription(text);
                        }
                        break;
                    }
                    case "rn": {
                        final TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setRunNumber(Integer.parseInt(text));
                        }
                        break;
                    }
                    case "rt": {
                        final TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            final TrainLine line = TrainLine.fromXmlString(text);
                            currentEta.setRouteName(line);
                        }
                        break;
                    }
                    case "destSt": {
                        final TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            final Integer i = Integer.parseInt(text);
                            currentEta.setDestSt(i);
                        }
                        break;
                    }
                    case "destNm": {
                        final TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setDestName(text);
                        }
                        break;
                    }
                    case "trDr": {
                        //                     final TrainArrival arri = arrivals.get(staId, null);
                        //                     if (arri != null) {
                        //                        final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                        //                        currentEta.setTrainRouteDirectionCode(Integer.parseInt(text));
                        //                     }
                        break;
                    }
                    case "prdt": {
                        final TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setPredictionDate(simpleDateFormatTrain.parse(text));
                        }
                        break;
                    }
                    case "arrT": {
                        final TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setArrivalDepartureDate(simpleDateFormatTrain.parse(text));
                        }
                        break;
                    }
                    case "isApp": {
                        final TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setApp(Util.textNumberToBoolean(text));
                        }
                        break;
                    }
                    case "isSch": {
                        //                     final TrainArrival arri = arrivals.get(staId, null);
                        //                     if (arri != null) {
                        //                        final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                        //                        currentEta.setIsSch(Util.textNumberToBoolean(text));
                        //                     }
                        break;
                    }
                    case "isDly": {
                        final TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setDly(Util.textNumberToBoolean(text));
                        }
                        break;
                    }
                    case "isFlt": {
                        //                     final TrainArrival arri = arrivals.get(staId, null);
                        //                     if (arri != null) {
                        //                        final Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                        //                        currentEta.setIsFlt(Util.textNumberToBoolean(text));
                        //                     }
                        break;
                    }
                    }
                    break;
                case TMST:
                    //tmst = simpleDateFormatTrain.parse(text);
                    break;
                case ERRCD:
                    //errCd = Integer.parseInt(text);
                    break;
                case ERRNM:
                    //errNum = text;
                    break;
                default:
                    break;
                }
            }
            eventType = parser.next();
        }
    } catch (XmlPullParserException | ParseException | IOException e) {
        throw new ParserException(TrackerException.ERROR, e);
    } finally {
        IOUtils.closeQuietly(is);
    }
    final List<Eta> res = new ArrayList<>();
    int index = 0;
    while (index < arrivals.size()) {
        final TrainArrival arri = arrivals.valueAt(index++);
        final List<Eta> etas = arri.getEtas();
        if (etas != null && etas.size() != 0) {
            res.add(etas.get(0));
        }
    }
    Collections.sort(res);
    return res;
}

From source file:de.eidottermihi.rpicheck.activity.MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    // saving query data of current device
    if (currentDevice != null) {
        LOGGER.debug("Saving instance state (current device)");
        outState.putSerializable(CURRENT_DEVICE, currentDevice);
        if (allDevices == null) {
            LOGGER.debug("Saving new instance of all devices.");
            allDevices = new SparseArray<RaspberryDeviceBean>();
            allDevices.put(currentDevice.getId(), currentDevice);
        } else {//from ww w  . j  a v a  2s. c om
            LOGGER.debug("Adding current device to all devices.");
            allDevices.put(currentDevice.getId(), currentDevice);
        }
    }
    if (allDevices != null) {
        outState.putSparseParcelableArray(ALL_DEVICES, allDevices);
    }
    outState.putString("bug:fix", "no empty outstate");
    super.onSaveInstanceState(outState);
}

From source file:fr.cph.chicago.xml.Xml.java

public final List<Eta> parseTrainsFollow(final String xml, final TrainData data) throws ParserException {
    InputStream is = new ByteArrayInputStream(xml.getBytes());
    SparseArray<TrainArrival> arrivals = null;
    try {//ww w  .  j  a va  2 s  .  com
        parser.setInput(is, "UTF-8");
        int eventType = parser.getEventType();
        XmlArrivalTrainTag tag = null;
        Date tmst = null;
        Integer errCd = null;
        String errNum = null;
        String tagName = null;
        Integer staId = null;
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_DOCUMENT) {
                arrivals = new SparseArray<TrainArrival>();
            } else if (eventType == XmlPullParser.START_TAG) {
                tagName = parser.getName();
                if (tagName.equals("tmst")) {
                    tag = XmlArrivalTrainTag.TMST;
                } else if (tagName.equals("errCd")) {
                    tag = XmlArrivalTrainTag.ERRCD;
                } else if (tagName.equals("errNm")) {
                    tag = XmlArrivalTrainTag.ERRNM;
                } else if (tagName.equals("eta")) {
                    tag = XmlArrivalTrainTag.ETA;
                } else {
                    tag = XmlArrivalTrainTag.OTHER;
                }
            } else if (eventType == XmlPullParser.END_TAG) {
                tag = null;
            } else if (eventType == XmlPullParser.TEXT) {
                String text = parser.getText();
                switch (tag) {
                case ETA:
                    break;
                case OTHER:
                    if (tagName.equals("staId")) {
                        staId = Integer.valueOf(text);
                        TrainArrival arri = arrivals.get(staId, new TrainArrival());
                        arri.setErrorCode(errCd);
                        arri.setErrorMessage(errNum);
                        arri.setTimeStamp(tmst);
                        List<Eta> etas = arri.getEtas();
                        if (etas == null) {
                            etas = new ArrayList<Eta>();
                            arri.setEtas(etas);
                        }
                        Eta eta = new Eta();
                        Station station = data.getStation(Integer.valueOf(text));
                        eta.setStation(station);
                        etas.add(eta);

                        arrivals.append(staId, arri);
                    } else if (tagName.equals("stpId")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            Stop stop = data.getStop(Integer.valueOf(text));
                            currentEta.setStop(stop);
                        }
                    } else if (tagName.equals("staNm")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            Station station = currentEta.getStation();
                            station.setName(text);
                        }

                    } else if (tagName.equals("stpDe")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            Stop stop = currentEta.getStop();
                            stop.setDescription(text);
                        }
                    } else if (tagName.equals("rn")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setRunNumber(Integer.valueOf(text));
                        }
                    } else if (tagName.equals("rt")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            TrainLine line = TrainLine.fromXmlString(text);
                            currentEta.setRouteName(line);
                        }
                    } else if (tagName.equals("destSt")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            Integer i = Integer.valueOf(text);
                            currentEta.setDestSt(i);
                        }
                    } else if (tagName.equals("destNm")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setDestName(text);
                        }
                    } else if (tagName.equals("trDr")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setTrainRouteDirectionCode(Integer.valueOf(text));
                        }
                    } else if (tagName.equals("prdt")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setPredictionDate(dfTrain.parse(text));
                        }
                    } else if (tagName.equals("arrT")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setArrivalDepartureDate(dfTrain.parse(text));
                        }
                    } else if (tagName.equals("isApp")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setIsApp(BooleanUtils.toBoolean(Integer.valueOf(text)));
                        }
                    } else if (tagName.equals("isSch")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setIsSch(BooleanUtils.toBoolean(Integer.valueOf(text)));
                        }
                    } else if (tagName.equals("isDly")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setIsDly(BooleanUtils.toBoolean(Integer.valueOf(text)));
                        }
                    } else if (tagName.equals("isFlt")) {
                        TrainArrival arri = arrivals.get(staId, null);
                        if (arri != null) {
                            Eta currentEta = arri.getEtas().get(arri.getEtas().size() - 1);
                            currentEta.setIsFlt(BooleanUtils.toBoolean(Integer.valueOf(text)));
                        }
                    }
                    break;
                case TMST:
                    tmst = dfTrain.parse(text);
                    break;
                case ERRCD:
                    errCd = Integer.valueOf(text);
                    break;
                case ERRNM:
                    errNum = text;
                    break;
                default:
                    break;
                }
            }
            eventType = parser.next();
        }
    } catch (XmlPullParserException e) {
        throw new ParserException(TrackerException.ERROR, e);
    } catch (ParseException e) {
        throw new ParserException(TrackerException.ERROR, e);
    } catch (IOException e) {
        throw new ParserException(TrackerException.ERROR, e);
    }
    List<Eta> res = new ArrayList<Eta>();
    int index = 0;
    while (index < arrivals.size()) {
        TrainArrival arri = arrivals.valueAt(index++);
        List<Eta> etas = arri.getEtas();
        if (etas != null && etas.size() != 0) {
            res.add(etas.get(0));
        }
    }
    Collections.sort(res);
    return res;
}