当前位置: 首页>>代码示例>>Java>>正文


Java Uri.getEncodedFragment方法代码示例

本文整理汇总了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;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:14,代码来源:PrettifyWebView.java

示例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();
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:32,代码来源:LinkParserHelper.java

示例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);
    }
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:42,代码来源:SchemeParser.java

示例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);
    }
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:44,代码来源:SchemeParser.java


注:本文中的android.net.Uri.getEncodedFragment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。