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


Java Uri.getPathSegments方法代碼示例

本文整理匯總了Java中android.net.Uri.getPathSegments方法的典型用法代碼示例。如果您正苦於以下問題:Java Uri.getPathSegments方法的具體用法?Java Uri.getPathSegments怎麽用?Java Uri.getPathSegments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.net.Uri的用法示例。


在下文中一共展示了Uri.getPathSegments方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: query

import android.net.Uri; //導入方法依賴的package包/類
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection,
                    @Nullable String[] selectionArgs, @Nullable String sortOrder)
        throws UnsupportedOperationException {
    final SQLiteDatabase db = mDbHelper.getReadableDatabase();
    int match = sUriMatcher.match(uri);
    Cursor cursor = null;
    switch (match) {
        case MEDIA:
            List<String> pathSegments = uri.getPathSegments();
            if (pathSegments != null && pathSegments.size() > 1) {
                String id = uri.getPathSegments().get(1);
                cursor = db.query(MediaEntry.TABLE_NAME, projection, MediaEntry.COLUMN_MEDIA_ID + " = ? ", new String[]{id}, null, null, sortOrder);
            }
            break;
        default:
            throw new UnsupportedOperationException("Unknown uri: " + uri);
    }

    mContext.getContentResolver().notifyChange(uri, null);
    return cursor;
}
 
開發者ID:scaffeinate,項目名稱:Inflix,代碼行數:24,代碼來源:MediaProvider.java

示例2: fromUri

import android.net.Uri; //導入方法依賴的package包/類
public static DocumentMetadata fromUri(Uri uri, SmbClient client) throws IOException {
final List<String> pathSegments = uri.getPathSegments();
if (pathSegments.isEmpty()) {
  throw new UnsupportedOperationException("Can't load metadata for workgroup or server.");
}

final StructStat stat = client.stat(uri.toString());
  final DirectoryEntry entry = new DirectoryEntry(
      OsConstants.S_ISDIR(stat.st_mode) ? DirectoryEntry.DIR : DirectoryEntry.FILE,
      "",
      uri.getLastPathSegment());
  final DocumentMetadata metadata = new DocumentMetadata(uri, entry);
  metadata.mStat.set(stat);

  return metadata;
}
 
開發者ID:google,項目名稱:samba-documents-provider,代碼行數:17,代碼來源:DocumentMetadata.java

示例3: insert

import android.net.Uri; //導入方法依賴的package包/類
public Uri insert(Uri uri, ContentValues values) {
	SQLiteDatabase sqlDb = dbHelper.getWritableDatabase();
	
	List<String> segments = uri.getPathSegments();
	String recordId = segments.get(1);
	String name = segments.get(3);

       String insertView = "Insert or replace into views (record_id, name, query, date_synced) values(?,?,?,?)";

       SQLiteStatement insertViewStmt = sqlDb.compileStatement(insertView);

       insertViewStmt.bindString(1, recordId);
       insertViewStmt.bindString(2, name);
       insertViewStmt.bindString(3, values.getAsString("query"));
       insertViewStmt.bindString(4, values.getAsString("date_synced"));
       insertViewStmt.execute();
       
       getContext()
               .getContentResolver()
               .notifyChange(uri, null);
      
       return uri;
}
 
開發者ID:Microsoft,項目名稱:healthvault-java-sdk,代碼行數:24,代碼來源:ViewProvider.java

示例4: update

import android.net.Uri; //導入方法依賴的package包/類
public int update(Uri uri, ContentValues values, String selection,
		String[] selectionArgs) {
	int updateCount = 0;

	SQLiteDatabase sqlDb = dbHelper.getWritableDatabase();

	List<String> segments = uri.getPathSegments();
	String recordId = segments.get(1);
	String name = segments.get(3);

	String updateView = "update views set query = ?, date_synced = ? where record_id = ? and name = ?";
       SQLiteStatement updateViewStmt = sqlDb.compileStatement(updateView);

	updateViewStmt.bindString(1, values.getAsString("query"));
	updateViewStmt.bindString(2, values.getAsString("date_synced"));
	updateViewStmt.bindString(3, recordId);
	updateViewStmt.bindString(4, name);
	
	updateCount = updateViewStmt.executeUpdateDelete();

	if (updateCount > 0) { 
	      getContext().getContentResolver().notifyChange(uri, null); 
	} 

	return updateCount; 
}
 
開發者ID:Microsoft,項目名稱:healthvault-java-sdk,代碼行數:27,代碼來源:ViewProvider.java

示例5: querySingleFromAnyRepo

import android.net.Uri; //導入方法依賴的package包/類
private QuerySelection querySingleFromAnyRepo(Uri uri, boolean includeAlias) {
    String alias = includeAlias ? "apk." : "";

    String selection =
            alias + Cols.VERSION_CODE + " = ? AND " +
            alias + Cols.APP_ID + " IN (" + getMetadataIdFromPackageNameQuery() + ")";

    List<String> pathSegments = uri.getPathSegments();
    List<String> args = new ArrayList<>(3);
    args.add(pathSegments.get(1)); // First (0th) path segment is the word "apk" and we are not interested in it.
    args.add(pathSegments.get(2));

    if (pathSegments.size() >= 4) {
        selection += " AND " + alias + Cols.SIGNATURE + " = ? ";
        args.add(pathSegments.get(3));
    }

    return new QuerySelection(selection, args);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:20,代碼來源:ApkProvider.java

示例6: delete

import android.net.Uri; //導入方法依賴的package包/類
@Override
public int delete(final Uri uri, final String selection, final String[] selectionArgs) {
    final List<String> pathSegments = uri.getPathSegments();
    if (pathSegments.size() != 1)
        throw new IllegalArgumentException(uri.toString());

    final String address = uri.getLastPathSegment();

    final int count = helper.getWritableDatabase().delete(DATABASE_TABLE, KEY_ADDRESS + "=?",
            new String[] { address });

    if (count > 0)
        getContext().getContentResolver().notifyChange(uri, null);

    return count;
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:17,代碼來源:AddressBookProvider.java

示例7: getUser

import android.net.Uri; //導入方法依賴的package包/類
@Nullable private static Intent getUser(@NonNull Context context, @NonNull Uri uri) {
        List<String> segments = uri.getPathSegments();
        if (segments != null && !segments.isEmpty() && segments.size() == 1) {
            return ProfileActivity.createIntent(context, segments.get(0));
        } else if (segments != null && !segments.isEmpty() && segments.size() > 1 && segments.get(0).equalsIgnoreCase("orgs")) {
            if ("invitation".equalsIgnoreCase(uri.getLastPathSegment())) {
                return null;
            } else if ("search".equalsIgnoreCase(uri.getLastPathSegment())) {
                String query = uri.getQueryParameter("q");
//                return SearchActivity.getIntent(context, query);
            } else {
                return ProfileActivity.createIntent(context, segments.get(1), true);
            }
        }
        return null;
    }
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:17,代碼來源:SchemeParser.java

示例8: getVerse

import android.net.Uri; //導入方法依賴的package包/類
private Cursor getVerse(Uri uri) {
  int sura = 1;
  int ayah = 1;
  String langType = getActiveTranslation();
  String lang = (TextUtils.isEmpty(langType)) ? null : langType;
  if (lang == null) {
    return null;
  }

  List<String> parts = uri.getPathSegments();
  for (String s : parts) {
    Timber.d("uri part: %s", s);
  }

  final DatabaseHandler handler = DatabaseHandler.getDatabaseHandler(getContext(), lang);
  return handler.getVerse(sura, ayah);
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:18,代碼來源:QuranDataProvider.java

示例9: getScopeFromUrl

import android.net.Uri; //導入方法依賴的package包/類
/**
 * Generates a scope URL based on the passed in URL. It should be used if the Web Manifest
 * does not specify a scope URL.
 * @param url The url to convert to a scope.
 * @return The scope.
 */
@CalledByNative
public static String getScopeFromUrl(String url) {
    // Scope URL is generated by:
    // - Removing last component of the URL.
    // - Clearing the URL's query and fragment.

    Uri uri = Uri.parse(url);
    List<String> path = uri.getPathSegments();
    int endIndex = path.size();

    // If there is at least one path element, remove the last one.
    if (endIndex > 0) {
        endIndex -= 1;
    }

    // Make sure the path starts and ends with a slash (or is only a slash if there is no path).
    Uri.Builder builder = uri.buildUpon();
    String scope_path = "/" + TextUtils.join("/", path.subList(0, endIndex));
    if (scope_path.length() > 1) {
        scope_path += "/";
    }
    builder.path(scope_path);

    builder.fragment("");
    builder.query("");
    return builder.build().toString();
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:34,代碼來源:ShortcutHelper.java

示例10: getForIssue

import android.net.Uri; //導入方法依賴的package包/類
public static PullsIssuesParser getForIssue(@NonNull String url) {
    Uri uri = Uri.parse(url);
    List<String> segments = uri.getPathSegments();
    if (segments == null || segments.size() < 3) return null;
    String owner = null;
    String repo = null;
    String number = null;
    if (segments.size() > 3) {
        if (segments.get(2).equalsIgnoreCase("issues")) {
            owner = segments.get(0);
            repo = segments.get(1);
            number = segments.get(3);
        } else if (segments.get(3).equalsIgnoreCase("issues") && segments.size() > 4) {
            owner = segments.get(1);
            repo = segments.get(2);
            number = segments.get(4);
        } else {
            return null;
        }
    }
    if (InputHelper.isEmpty(number))
        return null;
    int issueNumber;
    try {
        issueNumber = Integer.parseInt(number);
    } catch (NumberFormatException nfe) {
        return null;
    }
    if (issueNumber < 1) return null;
    PullsIssuesParser model = new PullsIssuesParser();
    model.setLogin(owner);
    model.setRepoId(repo);
    model.setNumber(issueNumber);
    return model;
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:36,代碼來源:PullsIssuesParser.java

示例11: getDocumentId

import android.net.Uri; //導入方法依賴的package包/類
/**
 * Extract the {@link dev.jibovico.apps.sharem.model.DocumentsContract.Document#COLUMN_DOCUMENT_ID} from the given URI.
 *
 * @see #isDocumentUri(android.content.Context, android.net.Uri)
 */
public static String getDocumentId(Uri documentUri) {
    final List<String> paths = documentUri.getPathSegments();
    if (paths.size() >= 2 && PATH_DOCUMENT.equals(paths.get(0))) {
        return paths.get(1);
    }
    if (paths.size() >= 4 && PATH_TREE.equals(paths.get(0))
            && PATH_DOCUMENT.equals(paths.get(2))) {
        return paths.get(3);
    }
    throw new IllegalArgumentException("Invalid URI: " + documentUri);
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:17,代碼來源:DocumentsContract.java

示例12: query

import android.net.Uri; //導入方法依賴的package包/類
public Cursor query(
           Uri uri, 
           String[] projection,
           String selection, 
           String[] selectionArgs, 
           String sortOrder) {
	SQLiteDatabase db = dbHelper.getReadableDatabase();

	List<String> segments = uri.getPathSegments();
	String recordId = segments.get(1);
	String name = segments.size() == 4
			? segments.get(3)
               : null;

    SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
    builder.setTables("views");
    builder.appendWhere("record_id = '" + recordId + "'");
    
    if (name != null) {
    	builder.appendWhere(" and name = '" + name + "'");
    }

       Cursor cursor = 
       builder.query(
              db, 
              projection, 
              selection, 
              selectionArgs,
              null, 
              null, 
              sortOrder);
       
       return cursor;
}
 
開發者ID:Microsoft,項目名稱:healthvault-java-sdk,代碼行數:35,代碼來源:ViewProvider.java

示例13: getZipPathFromUri

import android.net.Uri; //導入方法依賴的package包/類
/**return zip path from a uri like this : zip://path/to/zip.zip/entry

     would return /path/to/zip.zip
     */
    public static String getZipPathFromUri(Uri uri){
        String toTest = "";
        for(String seg : uri.getPathSegments()){
            if(!seg.startsWith("/"))
                toTest+="/";
            toTest+=seg;
            if(new File(toTest).isFile()) // then we have our zip file
                break;
        }
        return toTest;
    }
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:16,代碼來源:ZipUtils.java

示例14: getTreeDocumentId

import android.net.Uri; //導入方法依賴的package包/類
/**
 * Extract the via {@link dev.jibovico.apps.sharem.model.DocumentsContract.Document#COLUMN_DOCUMENT_ID} from the given URI.
 */
public static String getTreeDocumentId(Uri documentUri) {
    final List<String> paths = documentUri.getPathSegments();
    if (paths.size() >= 2 && PATH_TREE.equals(paths.get(0))) {
        return paths.get(1);
    }
    throw new IllegalArgumentException("Invalid URI: " + documentUri);
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:11,代碼來源:DocumentsContract.java

示例15: getEnterpriseGistUrl

import android.net.Uri; //導入方法依賴的package包/類
public static String getEnterpriseGistUrl(@NonNull String url, boolean isEnterprise) {
    if (isEnterprise) {
        Uri uri = Uri.parse(url);
        boolean isGist = uri == null || uri.getPathSegments() == null ? url.contains("gist/") : uri.getPathSegments().get(0).equals("gist");
        if (isGist) {
            String enterpriseUrl = PrefGetter.getEnterpriseUrl();
            if (!url.contains(enterpriseUrl + "/raw/")) {
                url = url.replace(enterpriseUrl, enterpriseUrl + "/raw");
            }
        }
    }
    return url;
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:14,代碼來源:LinkParserHelper.java


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