Search in sources :

Example 1 with SearchStationAdapter

use of be.brunoparmentier.openbikesharing.app.adapters.SearchStationAdapter in project OpenBikeSharing by bparmentier.

the class StationsListActivity method loadData.

private void loadData(String query) {
    ArrayList<Station> queryStations = new ArrayList<>();
    String[] columns = new String[] { "_id", "text" };
    Object[] temp = new Object[] { 0, "default" };
    MatrixCursor cursor = new MatrixCursor(columns);
    if (stations != null) {
        for (int i = 0; i < stations.size(); i++) {
            Station station = stations.get(i);
            if (station.getName().toLowerCase().contains(query.toLowerCase())) {
                temp[0] = i;
                temp[1] = station.getName();
                cursor.addRow(temp);
                queryStations.add(station);
            }
        }
    }
    searchView.setSuggestionsAdapter(new SearchStationAdapter(this, cursor, queryStations));
}
Also used : Station(be.brunoparmentier.openbikesharing.app.models.Station) SearchStationAdapter(be.brunoparmentier.openbikesharing.app.adapters.SearchStationAdapter) ArrayList(java.util.ArrayList) MatrixCursor(android.database.MatrixCursor)

Aggregations

MatrixCursor (android.database.MatrixCursor)1 SearchStationAdapter (be.brunoparmentier.openbikesharing.app.adapters.SearchStationAdapter)1 Station (be.brunoparmentier.openbikesharing.app.models.Station)1 ArrayList (java.util.ArrayList)1