本文整理匯總了Java中android.net.Uri.getEncodedFragment方法的典型用法代碼示例。如果您正苦於以下問題:Java Uri.getEncodedFragment方法的具體用法?Java Uri.getEncodedFragment怎麽用?Java Uri.getEncodedFragment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.net.Uri
的用法示例。
在下文中一共展示了Uri.getEncodedFragment方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLineNo
import android.net.Uri; //導入方法依賴的package包/類
public static String[] getLineNo(@Nullable String url) {
String lineNo[] = null;
if (url != null) {
try {
Uri uri = Uri.parse(url);
String lineNumber = uri.getEncodedFragment();
if (lineNumber != null) {
lineNo = lineNumber.replaceAll("L", "").split("-");
}
} catch (Exception ignored) {}
}
return lineNo;
}
示例2: getBlobBuilder
import android.net.Uri; //導入方法依賴的package包/類
@NonNull static Uri getBlobBuilder(@NonNull Uri uri) {
boolean isSvg = "svg".equalsIgnoreCase(MimeTypeMap.getFileExtensionFromUrl(uri.toString()));
List<String> segments = uri.getPathSegments();
if (isSvg) {
Uri svgBlob = Uri.parse(uri.toString().replace("blob/", ""));
return svgBlob.buildUpon().authority(RAW_AUTHORITY).build();
}
Uri.Builder urlBuilder = new Uri.Builder();
String owner = segments.get(0);
String repo = segments.get(1);
String branch = segments.get(3);
urlBuilder.scheme("https")
.authority(API_AUTHORITY)
.appendPath("repos")
.appendPath(owner)
.appendPath(repo)
.appendPath("contents");
for (int i = 4; i < segments.size(); i++) {
urlBuilder.appendPath(segments.get(i));
}
if (uri.getQueryParameterNames() != null) {
for (String query : uri.getQueryParameterNames()) {
urlBuilder.appendQueryParameter(query, uri.getQueryParameter(query));
}
}
if (uri.getEncodedFragment() != null) {
urlBuilder.encodedFragment(uri.getEncodedFragment());
}
urlBuilder.appendQueryParameter("ref", branch);
return urlBuilder.build();
}
示例3: getPullRequestIntent
import android.net.Uri; //導入方法依賴的package包/類
@Nullable private static Intent getPullRequestIntent(@NonNull Context context, @NonNull Uri uri, boolean showRepoBtn) {
List<String> segments = uri.getPathSegments();
if (segments == null || segments.size() < 3) return null;
String owner = null;
String repo = null;
String number = null;
String fragment = uri.getEncodedFragment();//#issuecomment-332236665
Long commentId = null;
if (!InputHelper.isEmpty(fragment) && fragment.split("-").length > 1) {
fragment = fragment.split("-")[1];
if (!InputHelper.isEmpty(fragment)) {
try {
commentId = Long.parseLong(fragment);
} catch (Exception ignored) {}
}
}
if (segments.size() > 3) {
if (("pull".equals(segments.get(2)) || "pulls".equals(segments.get(2)))) {
owner = segments.get(0);
repo = segments.get(1);
number = segments.get(3);
} else if (("pull".equals(segments.get(3)) || "pulls".equals(segments.get(3))) && 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;
return null; // TODO: 10/30/17 return PullRequest activity
// return PullRequestPagerActivity.createIntent(context, repo, owner, issueNumber, showRepoBtn,
// LinkParserHelper.isEnterprise(uri.toString()), commentId == null ? 0 : commentId);
}
示例4: getIssueIntent
import android.net.Uri; //導入方法依賴的package包/類
@Nullable private static Intent getIssueIntent(@NonNull Context context, @NonNull Uri uri, boolean showRepoBtn) {
List<String> segments = uri.getPathSegments();
if (segments == null || segments.size() < 3) return null;
String owner = null;
String repo = null;
String number = null;
String fragment = uri.getEncodedFragment();//#issuecomment-332236665
Long commentId = null;
if (!InputHelper.isEmpty(fragment) && fragment.split("-").length > 1) {
fragment = fragment.split("-")[1];
if (!InputHelper.isEmpty(fragment)) {
try {
commentId = Long.parseLong(fragment);
} catch (Exception ignored) {}
}
}
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;
Logger.e(commentId);
return null; // TODO: 10/30/17 return issue pager activity
// return IssuePagerActivity.createIntent(context, repo, owner, issueNumber, showRepoBtn,
// LinkParserHelper.isEnterprise(uri.toString()), commentId == null ? 0 : commentId);
}