Android Open Source - Is-It-Here-Yet Stop List






From Project

Back to project page Is-It-Here-Yet.

License

The source code is released under:

GNU General Public License

If you think the Android project Is-It-Here-Yet listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * Is It Here Yet? is a simple Android application that reads the
 * NextBus public XML feed and displays the arrival times for
 * transit vehicles for a chosen stop. /*  www  .jav  a  2s  .  com*/
 * Copyright (C) 2011 Matthew Lam
 *
 * Is It Here Yet? is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Is It Here Yet? is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Is It Here Yet?.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.sudfiwe.iihy.data.stop;

import java.util.Arrays;
import java.util.Hashtable;

public class StopList implements IStopList {

  private StopDirection[] directionSortedList;
  private Hashtable<StopDirection,Stop[]> list;
  private Hashtable<StopDirection,Stop[]> sortedList;
  
  public StopList() {
    
    directionSortedList=new StopDirection[0];
    list=new Hashtable<StopDirection,Stop[]>();
    sortedList=new Hashtable<StopDirection,Stop[]>();
  }
  
  public StopList(Hashtable<StopDirection,Stop[]> pList) {
    
    setList(pList);
  }
  
  public void setList(Hashtable<StopDirection,Stop[]> pList) {
    
    list=pList;
    sortedList=new Hashtable<StopDirection,Stop[]>();
    
    directionSortedList=
      list.keySet().toArray(new StopDirection[list.size()]);
    
    Arrays.sort(directionSortedList);
    
    for (StopDirection dir:directionSortedList) {
      
      Stop[] rawList=list.get(dir).clone();
      Arrays.sort(rawList);
      sortedList.put(dir,rawList);
    }
  }
  
  public void regenerateList() {
    
  }
  
  public StopDirection[] getDirections() {
    
    return directionSortedList;
  }
  
  public StopDirection getDirection(String dirTag) {
    
    StopDirection ret=null;
    
    int index=Arrays.binarySearch(directionSortedList,
        new StopDirection(dirTag));
    
    if (index>=0&&index<directionSortedList.length) {
      
      ret=directionSortedList
      [Arrays.binarySearch(directionSortedList,
          new StopDirection(dirTag))];
    } else {
      ret=directionSortedList[0];
    }
    
    return ret;
  }
  
  public Stop getItem(String dirTag,String stopTag) {

    Stop[] rawList=sortedList.get(getDirection(dirTag));
    
    return rawList[Arrays.binarySearch(rawList,
        new Stop(stopTag))];
  }

  public Stop[] getList(String dirTag) {
    
    return list.get(getDirection(dirTag));
  }
}




Java Source Code List

com.sudfiwe.iihy.activity.IsItHereYet.java
com.sudfiwe.iihy.activity.ResultActivity.java
com.sudfiwe.iihy.activity.SelectActivity.java
com.sudfiwe.iihy.data.Preferences.java
com.sudfiwe.iihy.data.agency.AgencyListProxy.java
com.sudfiwe.iihy.data.agency.AgencyList.java
com.sudfiwe.iihy.data.agency.Agency.java
com.sudfiwe.iihy.data.agency.IAgencyList.java
com.sudfiwe.iihy.data.predict.IPredictionListUtil.java
com.sudfiwe.iihy.data.predict.IPredictionList.java
com.sudfiwe.iihy.data.predict.PredictionDirection.java
com.sudfiwe.iihy.data.predict.PredictionListProxy.java
com.sudfiwe.iihy.data.predict.PredictionList.java
com.sudfiwe.iihy.data.predict.Prediction.java
com.sudfiwe.iihy.data.route.IRouteList.java
com.sudfiwe.iihy.data.route.RouteListProxy.java
com.sudfiwe.iihy.data.route.RouteList.java
com.sudfiwe.iihy.data.route.Route.java
com.sudfiwe.iihy.data.stop.IStopList.java
com.sudfiwe.iihy.data.stop.StopDirection.java
com.sudfiwe.iihy.data.stop.StopListProxy.java
com.sudfiwe.iihy.data.stop.StopList.java
com.sudfiwe.iihy.data.stop.Stop.java
com.sudfiwe.iihy.io.DBFacade.java
com.sudfiwe.iihy.io.DBResult.java
com.sudfiwe.iihy.io.IDBResult.java
com.sudfiwe.iihy.io.mapper.AbstractFeedMapper.java
com.sudfiwe.iihy.io.mapper.AgencyListMapper.java
com.sudfiwe.iihy.io.mapper.IMapper.java
com.sudfiwe.iihy.io.mapper.MapperFactory.java
com.sudfiwe.iihy.io.mapper.PredictionListMapper.java
com.sudfiwe.iihy.io.mapper.PreferencesMapper.java
com.sudfiwe.iihy.io.mapper.RouteListMapper.java
com.sudfiwe.iihy.io.mapper.StopListMapper.java
com.sudfiwe.iihy.uiinterface.DataManager.java
com.sudfiwe.iihy.uiinterface.IPredictionDirection.java
com.sudfiwe.iihy.uiinterface.IPredictionItem.java
com.sudfiwe.iihy.uiinterface.IPredictions.java
com.sudfiwe.iihy.util.Constants.java
com.sudfiwe.iihy.util.Filter.java