本文整理汇总了Java中android.content.UriMatcher.addURI方法的典型用法代码示例。如果您正苦于以下问题:Java UriMatcher.addURI方法的具体用法?Java UriMatcher.addURI怎么用?Java UriMatcher.addURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.UriMatcher
的用法示例。
在下文中一共展示了UriMatcher.addURI方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFromContentProviderResults
import android.content.UriMatcher; //导入方法依赖的package包/类
@Nullable
public static DatabaseIdRange createFromContentProviderResults(ContentProviderResult[] results, String path){
UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
sUriMatcher.addURI(MessengerContentProvider.AUTHORITY, path, MATCH_CODE);
Integer f = null;
Integer l = null;
for(ContentProviderResult result : results){
if(result.uri != null && !result.uri.toString().isEmpty()){
if(sUriMatcher.match(result.uri) != MATCH_CODE){
continue;
}
int dbid = Integer.parseInt(result.uri.getPathSegments().get(1));
if(f == null || dbid < f){
f = dbid;
}
if(l == null || dbid > l){
l = dbid;
}
}
}
return nonNull(f) && nonNull(l) ? new DatabaseIdRange(f, l) : null;
}
示例2: onCreate
import android.content.UriMatcher; //导入方法依赖的package包/类
@Override
public boolean onCreate() {
/*if (KillSelfHelper.DEBUG) {
LogUtils.d(KillSelfHelper.TAG, TAG + ".onCreate = " + android.os.Process.myPid());
}*/
if (checkInitAuthority(getContext())) {
mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_ALL, GET_ALL);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_STRING, GET_STRING);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_INT, GET_INT);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_LONG, GET_LONG);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_FLOAT, GET_FLOAT);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_BOOLEAN, GET_BOOLEAN);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_CONTAINS, CONTAINS);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_APPLY, APPLY);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_COMMIT, COMMIT);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_REGISTER_ON_SHARED_PREFERENCE_CHANGE_LISTENER, REGISTER_ON_SHARED_PREFERENCE_CHANGE_LISTENER);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_UNREGISTER_ON_SHARED_PREFERENCE_CHANGE_LISTENER, UNREGISTER_ON_SHARED_PREFERENCE_CHANGE_LISTENER);
mUriMatcher.addURI(AUTHORITY, PATH_WILDCARD + PATH_GET_STRING_SET, GET_STRING_SET);
return true;
} else {
return false;
}
}
示例3: buildUriMatcher
import android.content.UriMatcher; //导入方法依赖的package包/类
/**
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;
}
示例4: buildUriMatcher
import android.content.UriMatcher; //导入方法依赖的package包/类
static UriMatcher buildUriMatcher() {
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
final String authority = VideoContract.CONTENT_AUTHORITY;
// For each type of URI to add, create a corresponding code.
matcher.addURI(authority, VideoContract.PATH_VIDEO, VIDEO);
matcher.addURI(authority, VideoContract.PATH_VIDEO + "/*", VIDEO_WITH_CATEGORY);
// Search related URIs.
matcher.addURI(authority, SearchManager.SUGGEST_URI_PATH_QUERY, SEARCH_SUGGEST);
matcher.addURI(authority, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", SEARCH_SUGGEST);
return matcher;
}
示例5: buildUriMatcher
import android.content.UriMatcher; //导入方法依赖的package包/类
/**
* 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;
}
示例6: buildUriMatcher
import android.content.UriMatcher; //导入方法依赖的package包/类
public static UriMatcher buildUriMatcher() {
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
final String authority = DbContract.CONTENT_AUTHORITY;
matcher.addURI(authority, DbContract.PATH_PLANT, MATCH_CODE_PLANT);
matcher.addURI(authority, DbContract.PATH_PLANT + "/#", MATCH_CODE_PLANT_ID);
return matcher;
}
示例7: buildUriMatcher
import android.content.UriMatcher; //导入方法依赖的package包/类
private static UriMatcher buildUriMatcher() {
UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
matcher.addURI(AUTHORITY, "quran/search", SEARCH_VERSES);
matcher.addURI(AUTHORITY, "quran/search/*", SEARCH_VERSES);
matcher.addURI(AUTHORITY, "quran/search/*/*", SEARCH_VERSES);
matcher.addURI(AUTHORITY, "quran/verse/#/#", GET_VERSE);
matcher.addURI(AUTHORITY, "quran/verse/*/#/#", GET_VERSE);
matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY,
SEARCH_SUGGEST);
matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*",
SEARCH_SUGGEST);
return matcher;
}
示例8: buildUriMatcher
import android.content.UriMatcher; //导入方法依赖的package包/类
public static UriMatcher buildUriMatcher() {
UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
uriMatcher.addURI(TaskItemsContract.AUTHORITY, TaskItemsContract.PATH_TASK_ITEMS, ITEM_TASKS);
uriMatcher.addURI(TaskItemsContract.AUTHORITY, TaskItemsContract.PATH_TASK_ITEMS + "/#", ITEM_TASKS_WITH_ID);
uriMatcher.addURI(TaskItemsContract.AUTHORITY, TaskItemsContract.PATH_TASK_ITEMS + "/" + COLUMN_NAME_IS_TODAY + "/#", ITEM_TASKS_TODAY);
return uriMatcher;
}
示例9: buildUriMatcher
import android.content.UriMatcher; //导入方法依赖的package包/类
private static UriMatcher buildUriMatcher() {
UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
uriMatcher.addURI(RecipesContract.CONTENT_AUTHORITY, RecipesContract.PATH_RECIPES, RECIPES);
uriMatcher.addURI(RecipesContract.CONTENT_AUTHORITY, RecipesContract.PATH_RECIPES + "/#", RECIPES_WITH_ID);
uriMatcher.addURI(RecipesContract.CONTENT_AUTHORITY, RecipesContract.PATH_RECIPES + "/*", RECIPES_WITH_NAME);
return uriMatcher;
}
示例10: buildUriMatcher
import android.content.UriMatcher; //导入方法依赖的package包/类
private static UriMatcher buildUriMatcher() {
UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
uriMatcher.addURI(MMNewsContract.CONTENT_AUTHORITY, MMNewsContract.PATH_ACTED_USERS, ACTED_USERS);
uriMatcher.addURI(MMNewsContract.CONTENT_AUTHORITY, MMNewsContract.PATH_PUBLICATIONS, PUBLICATIONS);
uriMatcher.addURI(MMNewsContract.CONTENT_AUTHORITY, MMNewsContract.PATH_NEWS, NEWS);
uriMatcher.addURI(MMNewsContract.CONTENT_AUTHORITY, MMNewsContract.PATH_IMAGES_IN_NEWS, IMAGES_IN_NEWS);
uriMatcher.addURI(MMNewsContract.CONTENT_AUTHORITY, MMNewsContract.PATH_FAVORITE_ACTIONS, FAVORITE_ACTIONS);
uriMatcher.addURI(MMNewsContract.CONTENT_AUTHORITY, MMNewsContract.PATH_COMMENT_ACTIONS, COMMENT_ACTIONS);
uriMatcher.addURI(MMNewsContract.CONTENT_AUTHORITY, MMNewsContract.PATH_SENT_TO_ACTIONS, SENT_TO_ACTIONS);
return uriMatcher;
}
示例11: buildUriMatcher
import android.content.UriMatcher; //导入方法依赖的package包/类
private static UriMatcher buildUriMatcher() {
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
final String authority = ActivityItemsContract.CONTENT_AUTHORITY;
matcher.addURI(authority, "items", ITEMS);
matcher.addURI(authority, "items/#", ITEMS_ID);
matcher.addURI(authority, "range/#/#", ITEMS_RANGE);
return matcher;
}
示例12: buildUriMatcher
import android.content.UriMatcher; //导入方法依赖的package包/类
private void buildUriMatcher(){
uriMatcher=new UriMatcher(UriMatcher.NO_MATCH);
MusicMatchEnum[] enums=MusicMatchEnum.values();
for(MusicMatchEnum uriEnum:enums){
uriMatcher.addURI(MusicContract.CONTENT_AUTHORITY,uriEnum.path,uriEnum.code);
}
}
示例13: builderUriMatcher
import android.content.UriMatcher; //导入方法依赖的package包/类
private static UriMatcher builderUriMatcher() {
UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
uriMatcher.addURI(DataContract.MEDIA_AUTHORITY, DataContract.MEDIA_PATH + "/#", MEDIA);
return uriMatcher;
}
示例14: getUriMatcherMailInfo
import android.content.UriMatcher; //导入方法依赖的package包/类
public static void getUriMatcherMailInfo(UriMatcher MATHCER)
{
MATHCER.addURI(Constant_DB.AUTHORITY, TABLE_NAME, XXZXTYPE_INFO);
}
示例15: getUriMatcherMailInfo
import android.content.UriMatcher; //导入方法依赖的package包/类
public static void getUriMatcherMailInfo(UriMatcher MATHCER)
{
MATHCER.addURI(Constant_DB.AUTHORITY, TABLE_NAME, CHATROOMINFO_INFO);
}