Android Open Source - MassRoute Route Search Content Provider From Project Back to project page MassRoute .
License The source code is released under:
Copyright (c) 2010 Todd Anderson http://www.custardbelly.com/blog
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (th...
If you think the Android project MassRoute 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 package com.custardbelly.massdot.model;
/ * w w w . j a v a 2 s . c o m * /
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.List;
import android.app.SearchManager;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import android.provider.BaseColumns;
public class RouteSearchContentProvider extends ContentProvider
{
public static final String[] CURSOR_COLUMNS = new String[]{ BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_INTENT_DATA };
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
@Override
public String getType(Uri uri) {
return null;
}
@Override
public Uri insert(Uri uri, ContentValues values) {
return null;
}
@Override
public boolean onCreate() {
return true;
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
MatrixCursor cursor = new MatrixCursor( CURSOR_COLUMNS );
String entry = selectionArgs[0];
List<Route> routes = new WeakReference<List<Route>>( MassRouteModel.instance().getAvailableRoutes() ).get();
Iterator<Route> iterator = routes.iterator();
Route route;
String routeTitle;
int index = 0;
while ( iterator.hasNext() )
{
route = iterator.next();
routeTitle = route.getTitle();
if ( routeTitle.contains( entry ) )
cursor.addRow( new Object[]{ index++, routeTitle, routeTitle } );
}
// Add default row.
if ( cursor.getCount() == 0 )
cursor.addRow( new Object[]{ index, "No route found." , "none" } );
return cursor;
}
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
return 0;
}
}
Java Source Code List com.custardbelly.massdot.MassRoute.java com.custardbelly.massdot.enumeration.ActivityResultType.java com.custardbelly.massdot.enumeration.ActivityViewType.java com.custardbelly.massdot.enumeration.IntentExtraType.java com.custardbelly.massdot.exception.MassRouteParserException.java com.custardbelly.massdot.model.MassRouteModel.java com.custardbelly.massdot.model.RouteConfig.java com.custardbelly.massdot.model.RouteDirection.java com.custardbelly.massdot.model.RouteSearchContentProvider.java com.custardbelly.massdot.model.RouteStop.java com.custardbelly.massdot.model.Route.java com.custardbelly.massdot.model.StopPrediction.java com.custardbelly.massdot.model.StoredStopRequest.java com.custardbelly.massdot.model.StoredStopRequests.java com.custardbelly.massdot.parser.IRouteConfigParser.java com.custardbelly.massdot.parser.IRouteParser.java com.custardbelly.massdot.parser.IStopPredictionsParser.java com.custardbelly.massdot.parser.RouteConfigParser.java com.custardbelly.massdot.parser.RouteParser.java com.custardbelly.massdot.parser.StopPredictionsParser.java com.custardbelly.massdot.parser.handler.MassRouteServiceParserHandler.java com.custardbelly.massdot.service.IMassRouteService.java com.custardbelly.massdot.service.IPreferenceService.java com.custardbelly.massdot.service.IQueueableTaskResponder.java com.custardbelly.massdot.service.IQueueableTask.java com.custardbelly.massdot.service.IServiceTaskQueue.java com.custardbelly.massdot.service.MassRouteService.java com.custardbelly.massdot.service.PreferenceService.java com.custardbelly.massdot.service.RouteConfigTask.java com.custardbelly.massdot.service.RouteListTask.java com.custardbelly.massdot.service.ServiceTaskQueue.java com.custardbelly.massdot.service.StopPredictionTask.java com.custardbelly.massdot.service.responder.IMassRouteServiceResponder.java com.custardbelly.massdot.service.responder.IRoutesConfigServiceResponder.java com.custardbelly.massdot.service.responder.IRoutesServiceResponder.java com.custardbelly.massdot.service.responder.IStopPredictionsServiceResponder.java com.custardbelly.massdot.view.MassRouteServiceView.java com.custardbelly.massdot.view.RouteDirectionView.java com.custardbelly.massdot.view.RouteListView.java com.custardbelly.massdot.view.RouteStopsView.java com.custardbelly.massdot.view.StopPredictionsView.java com.custardbelly.massdot.view.adapter.RouteAdapter.java com.custardbelly.massdot.view.adapter.RouteDirectionAdapter.java com.custardbelly.massdot.view.adapter.RouteStopsAdapter.java com.custardbelly.massdot.view.adapter.StopPredictionsAdapter.java com.custardbelly.massdot.view.adapter.StoredStopRequestsAdapter.java