當前位置: 首頁>>代碼示例>>Java>>正文


Java UriMatcher.addURI方法代碼示例

本文整理匯總了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;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:27,代碼來源:DatabaseIdRange.java

示例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;
	}
}
 
開發者ID:miLLlulei,項目名稱:Accessibility,代碼行數:25,代碼來源:MultiprocessSharedPreferences.java

示例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;
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:20,代碼來源:TaskContentProvider.java

示例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;
}
 
開發者ID:nejtv,項目名稱:androidtv-sample,代碼行數:14,代碼來源:VideoProvider.java

示例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;
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:45,代碼來源:WeatherProvider.java

示例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;
}
 
開發者ID:laramartin,項目名稱:android_firebase_green_thumb,代碼行數:8,代碼來源:PlantProvider.java

示例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;
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:14,代碼來源:QuranDataProvider.java

示例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;
}
 
開發者ID:vixir,項目名稱:Perfect-Day,代碼行數:8,代碼來源:TaskItemsContentProvider.java

示例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;
}
 
開發者ID:harrynp,項目名稱:BakingApp,代碼行數:8,代碼來源:RecipesProvider.java

示例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;
}
 
開發者ID:agpyaephyo,項目名稱:PADC-SFC-News,代碼行數:12,代碼來源:MMNewsProvider.java

示例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;
}
 
開發者ID:OlgaKuklina,項目名稱:GitJourney,代碼行數:10,代碼來源:ActivityItemsProvider.java

示例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);
    }
}
 
開發者ID:vpaliyX,項目名稱:Melophile,代碼行數:8,代碼來源:MusicUriMatcher.java

示例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;
}
 
開發者ID:scaffeinate,項目名稱:Inflix,代碼行數:6,代碼來源:MediaProvider.java

示例14: getUriMatcherMailInfo

import android.content.UriMatcher; //導入方法依賴的package包/類
public static void getUriMatcherMailInfo(UriMatcher MATHCER)
{
    MATHCER.addURI(Constant_DB.AUTHORITY, TABLE_NAME, XXZXTYPE_INFO);
}
 
開發者ID:zhuyu1022,項目名稱:amap,代碼行數:5,代碼來源:XXZXTYPEInfoTable.java

示例15: getUriMatcherMailInfo

import android.content.UriMatcher; //導入方法依賴的package包/類
public static void getUriMatcherMailInfo(UriMatcher MATHCER)
{
    MATHCER.addURI(Constant_DB.AUTHORITY, TABLE_NAME, CHATROOMINFO_INFO);
}
 
開發者ID:zhuyu1022,項目名稱:amap,代碼行數:5,代碼來源:ChatRoomTable.java


注:本文中的android.content.UriMatcher.addURI方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。