Android Open Source - RideNdivide Places Auto Complete Adapter

From Project

Back to project page RideNdivide.


The source code is released under:

GNU General Public License

If you think the Android project RideNdivide 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

**//  w  ww .  j av a 2  s .  com
** RidenDivide- An open source project for the Android platform, helps users to carpool
** Application written in Java
** Application uses Google Places API
** Copyright (C) 2012 Harini Ramakrishnan and Vinutha Veerayya Hiremath
** Please see the file License in this distribution for license terms. 
** Below is the link to the file License.
** Following is the link for the repository-
** This program 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.
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with this program.  If not, see <>.
** Written by Harini Ramakrishnan <> and 
** Vinutha Veerayya Hiremath <>
** References -
** License-,
** License -

package oss.ridendivideapp;

import android.widget.ArrayAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.content.Context;
import java.util.ArrayList;
import oss.ridendivideapp.AutoCompleteAPI;

** PlacesAutoCompleteAdapter is used to provide the places autocomplete result to 
** AutoCompleteTextView. Also used in order to capture the user input from the AutoCompleteTextView 
** and pass it to the Places Autocomplete service.
public class PlacesAutoCompleteAdapter extends ArrayAdapter<String> implements Filterable {
    private ArrayList<String> resultList;
    AutoCompleteAPI ac=new AutoCompleteAPI();
    public PlacesAutoCompleteAdapter(Context context, int textViewResourceId) {
        super(context, textViewResourceId);
    public int getCount() {
        return resultList.size();

    public String getItem(int index) {
        return resultList.get(index);

    public Filter getFilter() {
        Filter filter = new Filter() {
            protected FilterResults performFiltering(CharSequence constraint) {
                FilterResults filterResults = new FilterResults();
                if (constraint != null) {
                    /* Retrieve the autocomplete results */
                    resultList = ac.autocomplete(constraint.toString());
                    /* Assign the data to the FilterResults */
                    filterResults.values = resultList;
                    filterResults.count = resultList.size();
                return filterResults;

            protected void publishResults(CharSequence constraint, FilterResults results) {
                if (results != null && results.count > 0) {
                else {
        return filter;

Java Source Code List