Search in sources :

Example 6 with NameParser

use of com.fastaccess.data.dao.NameParser in project FastHub by k0shk0sh.

the class ReleasesListActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        NameParser parser = new NameParser("");
        parser.setName(repoId);
        parser.setUsername(login);
        parser.setEnterprise(isEnterprise());
        RepoPagerActivity.startRepoPager(this, parser);
        finish();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : NameParser(com.fastaccess.data.dao.NameParser)

Example 7 with NameParser

use of com.fastaccess.data.dao.NameParser in project FastHub by k0shk0sh.

the class CommitFilesPresenter method onSubmitComment.

@Override
public void onSubmitComment(@NonNull String comment, @NonNull CommitLinesModel item, @Nullable Bundle bundle) {
    if (bundle != null) {
        String blob = bundle.getString(BundleConstant.ITEM);
        String path = bundle.getString(BundleConstant.EXTRA);
        if (path == null || sha == null)
            return;
        CommentRequestModel commentRequestModel = new CommentRequestModel();
        commentRequestModel.setBody(comment);
        commentRequestModel.setPath(path);
        commentRequestModel.setPosition(item.getPosition());
        commentRequestModel.setLine(item.getRightLineNo() > 0 ? item.getRightLineNo() : item.getLeftLineNo());
        NameParser nameParser = new NameParser(blob);
        onSubmit(nameParser.getUsername(), nameParser.getName(), commentRequestModel);
    }
}
Also used : CommentRequestModel(com.fastaccess.data.dao.CommentRequestModel) NameParser(com.fastaccess.data.dao.NameParser)

Example 8 with NameParser

use of com.fastaccess.data.dao.NameParser in project FastHub by k0shk0sh.

the class GithubHelper method parseReadme.

@NonNull
private static String parseReadme(@NonNull String source, @NonNull String baseUrl, boolean isWiki) {
    NameParser nameParser = new NameParser(baseUrl);
    String owner = nameParser.getUsername();
    String repoName = nameParser.getName();
    Uri uri = Uri.parse(baseUrl);
    ArrayList<String> paths = new ArrayList<>(uri.getPathSegments());
    StringBuilder builder = new StringBuilder();
    builder.append(owner).append("/").append(repoName).append("/");
    boolean containsMaster = paths.size() > 3;
    if (!containsMaster) {
        builder.append("master/");
    } else {
        paths.remove("blob");
    }
    paths.remove(owner);
    paths.remove(repoName);
    for (String path : paths) {
        if (!path.equalsIgnoreCase(uri.getLastPathSegment())) {
            builder.append(path).append("/");
        }
    }
    String baseLinkUrl = !isWiki ? getLinkBaseUrl(baseUrl) : baseUrl;
    return getParsedHtml(source, owner, repoName, !isWiki ? builder.toString() : baseUrl, baseLinkUrl, isWiki);
}
Also used : ArrayList(java.util.ArrayList) Uri(android.net.Uri) NameParser(com.fastaccess.data.dao.NameParser) NonNull(android.support.annotation.NonNull)

Aggregations

NameParser (com.fastaccess.data.dao.NameParser)8 Uri (android.net.Uri)3 Repo (com.fastaccess.data.dao.model.Repo)3 ArrayList (java.util.ArrayList)3 Intent (android.content.Intent)2 NonNull (android.support.annotation.NonNull)2 CommentRequestModel (com.fastaccess.data.dao.CommentRequestModel)1 PayloadModel (com.fastaccess.data.dao.PayloadModel)1 SimpleUrlsModel (com.fastaccess.data.dao.SimpleUrlsModel)1 AbstractRepo (com.fastaccess.data.dao.model.AbstractRepo)1