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);
}
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);
}
}
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);
}
Aggregations