Java Code Examples for android.content.UriMatcher#NO_MATCH
The following examples show how to use
android.content.UriMatcher#NO_MATCH .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoviesProvider.java From Popular-Movies-App with Apache License 2.0 | 6 votes |
static UriMatcher buildUriMatcher() { final UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); final String authority = MoviesContract.CONTENT_AUTHORITY; uriMatcher.addURI(authority, MoviesContract.PATH_MOVIES, MOVIES); uriMatcher.addURI(authority, MoviesContract.PATH_MOVIES + "/#", MOVIE_BY_ID); uriMatcher.addURI(authority, MoviesContract.PATH_MOVIES + "/" + MoviesContract.PATH_MOST_POPULAR, MOST_POPULAR_MOVIES); uriMatcher.addURI(authority, MoviesContract.PATH_MOVIES + "/" + MoviesContract.PATH_HIGHEST_RATED, HIGHEST_RATED_MOVIES); uriMatcher.addURI(authority, MoviesContract.PATH_MOVIES + "/" + MoviesContract.PATH_MOST_RATED, MOST_RATED_MOVIES); uriMatcher.addURI(authority, MoviesContract.PATH_MOVIES + "/" + MoviesContract.PATH_FAVORITES, FAVORITES); return uriMatcher; }
Example 2
Source File: WeatherProvider.java From android-weather with MIT License | 6 votes |
static UriMatcher buildUriMatcher() { // I know what you're thinking. Why create a UriMatcher when you can use regular // expressions instead? Because you're not crazy, that's why. // All paths added to the UriMatcher have a corresponding code to return when a match is // found. The code passed into the constructor represents the code to return for the root // URI. It's common to use NO_MATCH as the code for this case. final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); final String authority = WeatherContract.CONTENT_AUTHORITY; // For each type of URI you want to add, create a corresponding code. matcher.addURI(authority, WeatherContract.PATH_WEATHER, WEATHER); matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/*", WEATHER_WITH_LOCATION); matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/*/#", WEATHER_WITH_LOCATION_AND_DATE); matcher.addURI(authority, WeatherContract.PATH_LOCATION, LOCATION); return matcher; }
Example 3
Source File: ClipboardHelper.java From ProjectX with Apache License 2.0 | 6 votes |
protected void onCreate() { mMatcher = new UriMatcher(UriMatcher.NO_MATCH); mTypes.clear(); final int count = getAdapterCount(); if (count <= 0) return; for (int i = 0; i < count; i++) { final Adapter adapter = getAdapter(i); if (adapter == null) continue; final String type = adapter.getType(); final String subType = adapter.getSubType(); mTypes.put(i, type); mMatcher.addURI(getAuthority(), getPath() + "/" + subType, i); } }
Example 4
Source File: TaskContentProvider.java From android-dev-challenge with Apache License 2.0 | 6 votes |
/** Initialize a new matcher object without any matches, then use .addURI(String authority, String path, int match) to add matches */ public static UriMatcher buildUriMatcher() { // Initialize a UriMatcher with no matches by passing in NO_MATCH to the constructor UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); /* All paths added to the UriMatcher have a corresponding int. For each kind of uri you may want to access, add the corresponding match with addURI. The two calls below add matches for the task directory and a single item by ID. */ uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS, TASKS); uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS + "/#", TASK_WITH_ID); return uriMatcher; }
Example 5
Source File: TaskContentProvider.java From android-dev-challenge with Apache License 2.0 | 6 votes |
/** Initialize a new matcher object without any matches, then use .addURI(String authority, String path, int match) to add matches */ public static UriMatcher buildUriMatcher() { // Initialize a UriMatcher with no matches by passing in NO_MATCH to the constructor UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); /* All paths added to the UriMatcher have a corresponding int. For each kind of uri you may want to access, add the corresponding match with addURI. The two calls below add matches for the task directory and a single item by ID. */ uriMatcher.addURI(AUTHORITY, PATH_TASKS, TASKS); uriMatcher.addURI(AUTHORITY, PATH_TASKS + "/#", TASK_WITH_ID); return uriMatcher; }
Example 6
Source File: TaskContentProvider.java From android-dev-challenge with Apache License 2.0 | 6 votes |
/** Initialize a new matcher object without any matches, then use .addURI(String authority, String path, int match) to add matches */ public static UriMatcher buildUriMatcher() { // Initialize a UriMatcher with no matches by passing in NO_MATCH to the constructor UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); /* All paths added to the UriMatcher have a corresponding int. For each kind of uri you may want to access, add the corresponding match with addURI. The two calls below add matches for the task directory and a single item by ID. */ uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS, TASKS); uriMatcher.addURI(TaskContract.AUTHORITY, TaskContract.PATH_TASKS + "/#", TASK_WITH_ID); return uriMatcher; }
Example 7
Source File: AbstractVideoItemProvider.java From android-tv-leanback with Apache License 2.0 | 5 votes |
private static UriMatcher buildUriMatcher() { final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); final String authority = VideoItemContract.CONTENT_AUTHORITY; matcher.addURI(authority, "videoitem", VIDEOITEM); matcher.addURI(authority, "videoitem/#", VIDEOITEM__ID); return matcher; }
Example 8
Source File: ClipboardProvider.java From ProjectX with Apache License 2.0 | 5 votes |
@Override public boolean onCreate() { final ClipboardHelper helper = getClipboardHelper(); if (helper == null) return false; mMatcher = new UriMatcher(UriMatcher.NO_MATCH); mMatcher.addURI(helper.getAuthority(), helper.getPath() + "/*", helper.getCode()); return true; }
Example 9
Source File: ContentProvider.java From clear-todolist with GNU General Public License v3.0 | 5 votes |
private Class<? extends Model> getModelType(Uri uri) { final int code = URI_MATCHER.match(uri); if (code != UriMatcher.NO_MATCH) { return TYPE_CODES.get(code); } return null; }
Example 10
Source File: WeatherProvider.java From android-dev-challenge with Apache License 2.0 | 5 votes |
/** * Creates the UriMatcher that will match each URI to the CODE_WEATHER and * CODE_WEATHER_WITH_DATE constants defined above. * <p> * It's possible you might be thinking, "Why create a UriMatcher when you can use regular * expressions instead? After all, we really just need to match some patterns, and we can * use regular expressions to do that right?" Because you're not crazy, that's why. * <p> * UriMatcher does all the hard work for you. You just have to tell it which code to match * with which URI, and it does the rest automagically. Remember, the best programmers try * to never reinvent the wheel. If there is a solution for a problem that exists and has * been tested and proven, you should almost always use it unless there is a compelling * reason not to. * * @return A UriMatcher that correctly matches the constants for CODE_WEATHER and CODE_WEATHER_WITH_DATE */ public static UriMatcher buildUriMatcher() { /* * All paths added to the UriMatcher have a corresponding code to return when a match is * found. The code passed into the constructor of UriMatcher here represents the code to * return for the root URI. It's common to use NO_MATCH as the code for this case. */ final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); final String authority = WeatherContract.CONTENT_AUTHORITY; /* * For each type of URI you want to add, create a corresponding code. Preferably, these are * constant fields in your class so that you can use them throughout the class and you no * they aren't going to change. In Sunshine, we use CODE_WEATHER or CODE_WEATHER_WITH_DATE. */ /* This URI is content://com.example.android.sunshine/weather/ */ matcher.addURI(authority, WeatherContract.PATH_WEATHER, CODE_WEATHER); /* * This URI would look something like content://com.example.android.sunshine/weather/1472214172 * The "/#" signifies to the UriMatcher that if PATH_WEATHER is followed by ANY number, * that it should return the CODE_WEATHER_WITH_DATE code */ matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/#", CODE_WEATHER_WITH_DATE); return matcher; }
Example 11
Source File: CapturedPlayerFriendDescriptor.java From PADListener with GNU General Public License v2.0 | 5 votes |
private static UriMatcher buildUriMatcher() { final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); matcher.addURI(AUTHORITY, Paths.ALL.path, Paths.ALL.id); matcher.addURI(AUTHORITY, Paths.ALL_WITH_INFO.path, Paths.ALL_WITH_INFO.id); return matcher; }
Example 12
Source File: AbstractVideoItemProvider.java From android-tv-leanback with Apache License 2.0 | 5 votes |
private static UriMatcher buildUriMatcher() { final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); final String authority = VideoItemContract.CONTENT_AUTHORITY; matcher.addURI(authority, "videoitem", VIDEOITEM); matcher.addURI(authority, "videoitem/#", VIDEOITEM__ID); return matcher; }
Example 13
Source File: WeatherProvider.java From mobilecloud-15 with Apache License 2.0 | 5 votes |
/** * Build the UriMatcher for this Content Provider. */ public static UriMatcher buildUriMatcher() { // Add default 'no match' result to matcher. final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); // Initialize the matcher with the URIs used to access each // table. matcher.addURI(WeatherContract.AUTHORITY, WeatherContract.WeatherValuesEntry.WEATHER_VALUES_TABLE_NAME, WEATHER_VALUES_ITEMS); matcher.addURI(WeatherContract.AUTHORITY, WeatherContract.WeatherValuesEntry.WEATHER_VALUES_TABLE_NAME + "/#", WEATHER_VALUES_ITEM); matcher.addURI(WeatherContract.AUTHORITY, WeatherContract.WeatherConditionsEntry.WEATHER_CONDITIONS_TABLE_NAME, WEATHER_CONDITIONS_ITEMS); matcher.addURI(WeatherContract.AUTHORITY, WeatherContract.WeatherConditionsEntry.WEATHER_CONDITIONS_TABLE_NAME + "/#", WEATHER_CONDITIONS_ITEM); matcher.addURI(WeatherContract.AUTHORITY, WeatherContract.ACCESS_ALL_DATA_FOR_LOCATION_PATH, ACCESS_ALL_DATA_FOR_LOCATION_ITEM); return matcher; }
Example 14
Source File: SymbolProvider.java From ministocks with MIT License | 5 votes |
/** * Sets up a uri matcher for search suggestion and shortcut refresh queries. */ private static UriMatcher buildUriMatcher() { UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, SEARCH_SUGGEST); matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", SEARCH_SUGGEST); matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_SHORTCUT, SHORTCUT_REFRESH); matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_SHORTCUT + "/*", SHORTCUT_REFRESH); return matcher; }
Example 15
Source File: WeatherProvider.java From android-dev-challenge with Apache License 2.0 | 5 votes |
/** * Creates the UriMatcher that will match each URI to the CODE_WEATHER and * CODE_WEATHER_WITH_DATE constants defined above. * <p> * It's possible you might be thinking, "Why create a UriMatcher when you can use regular * expressions instead? After all, we really just need to match some patterns, and we can * use regular expressions to do that right?" Because you're not crazy, that's why. * <p> * UriMatcher does all the hard work for you. You just have to tell it which code to match * with which URI, and it does the rest automagically. Remember, the best programmers try * to never reinvent the wheel. If there is a solution for a problem that exists and has * been tested and proven, you should almost always use it unless there is a compelling * reason not to. * * @return A UriMatcher that correctly matches the constants for CODE_WEATHER and CODE_WEATHER_WITH_DATE */ public static UriMatcher buildUriMatcher() { /* * All paths added to the UriMatcher have a corresponding code to return when a match is * found. The code passed into the constructor of UriMatcher here represents the code to * return for the root URI. It's common to use NO_MATCH as the code for this case. */ final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); final String authority = WeatherContract.CONTENT_AUTHORITY; /* * For each type of URI you want to add, create a corresponding code. Preferably, these are * constant fields in your class so that you can use them throughout the class and you no * they aren't going to change. In Sunshine, we use CODE_WEATHER or CODE_WEATHER_WITH_DATE. */ /* This URI is content://com.example.android.sunshine/weather/ */ matcher.addURI(authority, WeatherContract.PATH_WEATHER, CODE_WEATHER); /* * This URI would look something like content://com.example.android.sunshine/weather/1472214172 * The "/#" signifies to the UriMatcher that if PATH_WEATHER is followed by ANY number, * that it should return the CODE_WEATHER_WITH_DATE code */ matcher.addURI(authority, WeatherContract.PATH_WEATHER + "/#", CODE_WEATHER_WITH_DATE); return matcher; }
Example 16
Source File: ProviGenProvider.java From MultiChoiceAdapter with Apache License 2.0 | 5 votes |
@Override public boolean onCreate() { openHelper = new ProviGenOpenHelper(getContext(), this, databaseName, contracts.getVersionSum()); uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); for (ContractHolder contract : contracts) { uriMatcher.addURI(contract.getAuthority(), contract.getTable(), ITEM); uriMatcher.addURI(contract.getAuthority(), contract.getTable() + "/#", ITEM_ID); } return true; }
Example 17
Source File: PredatorProvider.java From Capstone-Project with MIT License | 5 votes |
private static UriMatcher buildUriMatcher() { UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.PostsEntry.PATH_POSTS_ADD, POSTS_ADD); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.PostsEntry.PATH_POSTS_DELETE_ALL, POSTS_DELETE); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.PostsEntry.PATH_POSTS, POSTS_GET); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.PostsEntry.PATH_POSTS + "/#", POSTS_GET_BY_ID); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.PostsEntry.PATH_POSTS_UPDATE, POSTS_UPDATE); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.UsersEntry.PATH_USERS_ADD, USERS_ADD); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.UsersEntry.PATH_USERS_DELETE_ALL, USERS_DELETE); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.UsersEntry.PATH_USERS, USERS_GET); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.UsersEntry.PATH_USERS + "/#", USERS_GET_BY_ID); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CommentsEntry.PATH_COMMENTS_ADD, COMMENTS_ADD); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CommentsEntry.PATH_COMMENTS_DELETE_ALL, COMMENTS_DELETE); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CommentsEntry.PATH_COMMENTS, COMMENTS_GET); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CommentsEntry.PATH_COMMENTS + "/#", COMMENTS_GET_BY_ID); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.InstallLinksEntry.PATH_INSTALL_LINKS_ADD, INSTALL_LINKS_ADD); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.InstallLinksEntry.PATH_INSTALL_LINKS_DELETE_ALL, INSTALL_LINKS_DELETE); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.InstallLinksEntry.PATH_INSTALL_LINKS, INSTALL_LINKS_GET); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.InstallLinksEntry.PATH_INSTALL_LINKS + "/#", INSTALL_LINKS_GET_BY_ID); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.MediaEntry.PATH_MEDIA_ADD, MEDIA_ADD); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.MediaEntry.PATH_MEDIA_DELETE_ALL, MEDIA_DELETE); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.MediaEntry.PATH_MEDIA, MEDIA_GET); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.MediaEntry.PATH_MEDIA + "/#", MEDIA_GET_BY_ID); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CollectionsEntry.PATH_COLLECTIONS_ADD, COLLECTIONS_ADD); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CollectionsEntry.PATH_COLLECTIONS_DELETE_ALL, COLLECTIONS_DELETE); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CollectionsEntry.PATH_COLLECTIONS, COLLECTIONS_GET); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CollectionsEntry.PATH_COLLECTIONS + "/#", COLLECTIONS_GET_BY_ID); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CategoryEntry.PATH_CATEGORY_ADD, CATEGORY_ADD); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CategoryEntry.PATH_CATEGORY_DELETE_ALL, CATEGORY_DELETE); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CategoryEntry.PATH_CATEGORY, CATEGORY_GET); uriMatcher.addURI(PredatorDbHelper.CONTENT_AUTHORITY, PredatorContract.CategoryEntry.PATH_CATEGORY + "/#", CATEGORY_GET_BY_ID); return uriMatcher; }
Example 18
Source File: UriMatcherHelper.java From QuantumFlux with Apache License 2.0 | 5 votes |
public void init(Context context, TableDetailsCache detailsCache) { mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); int matcherInterval = MATCHER_CODE_INTERVALS; for (Class<?> dataModelObject : ReflectionHelper.getDomainClasses(context, ReflectionHelper.TableType.TABLE)) { TableDetails tableDetails = detailsCache.findTableDetails(context, dataModelObject); mMatcherCodes.put(matcherInterval, tableDetails); mUriMatcher.addURI(mAuthority, tableDetails.getTableName(), matcherInterval + MATCHER_ALL); mUriMatcher.addURI(mAuthority, tableDetails.getTableName() + "/*", matcherInterval + MATCHER_SINGLE); matcherInterval += MATCHER_CODE_INTERVALS; } }
Example 19
Source File: OllieProvider.java From Ollie with Apache License 2.0 | 5 votes |
private Class<? extends Model> getModelType(Uri uri) { final int code = URI_MATCHER.match(uri); if (code != UriMatcher.NO_MATCH) { return TYPE_CODES.get(code); } return null; }
Example 20
Source File: TrackLayer.java From android_maplib with GNU Lesser General Public License v3.0 | 4 votes |
public TrackLayer( Context context, File path) { super(context, path); if (!(getContext() instanceof IGISApplication)) { throw new IllegalArgumentException( "The context should be the instance of IGISApplication"); } IGISApplication app = (IGISApplication) getContext(); mMap = (MapContentProviderHelper) MapBase.getInstance(); mAuthority = app.getAuthority(); if (mMap == null) { throw new IllegalArgumentException( "Cannot get access to DB (context's MapBase is null)"); } mContentUriTracks = Uri.parse("content://" + mAuthority + "/" + TABLE_TRACKS); mContentUriTrackpoints = Uri.parse("content://" + mAuthority + "/" + TABLE_TRACKPOINTS); mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); mUriMatcher.addURI(mAuthority, TABLE_TRACKS, TYPE_TRACKS); mUriMatcher.addURI(mAuthority, TABLE_TRACKS + "/#", TYPE_SINGLE_TRACK); mUriMatcher.addURI(mAuthority, TABLE_TRACKPOINTS, TYPE_TRACKPOINTS); if (null == CONTENT_TYPE) { CONTENT_TYPE = "vnd.android.cursor.dir/vnd." + mAuthority + "." + TABLE_TRACKS; } if (null == CONTENT_TYPE_TRACKPOINTS) { CONTENT_TYPE_TRACKPOINTS = "vnd.android.cursor.dir/vnd." + mAuthority + "." + TABLE_TRACKPOINTS; } if (null == CONTENT_ITEM_TYPE) { CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd." + mAuthority + "." + TABLE_TRACKS; } initDB(); mLayerType = Constants.LAYERTYPE_TRACKS; mRenderer = new TrackRenderer(this); mTracks = new HashMap<>(); }