本文整理汇总了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);
}