use of com.fastaccess.data.dao.model.Repo in project FastHub by k0shk0sh.
the class RepoPagerActivity method onInitRepo.
@Override
public void onInitRepo() {
hideProgress();
if (getPresenter().getRepo() == null) {
return;
}
switch(showWhich) {
case 1:
onLongClick(watchRepoLayout);
break;
case 2:
onLongClick(starRepoLayout);
break;
case 3:
onLongClick(forkRepoLayout);
break;
case 4:
MilestoneDialogFragment.newInstance(login, repoId).show(getSupportFragmentManager(), "MilestoneDialogFragment");
break;
case 5:
LabelsDialogFragment.newInstance(null, repoId, login).show(getSupportFragmentManager(), "LabelsDialogFragment");
break;
}
showWhich = -1;
setTaskName(getPresenter().getRepo().getFullName());
Repo repoModel = getPresenter().getRepo();
if (repoModel.isHasProjects()) {
bottomNavigation.inflateMenu(R.menu.repo_with_project_bottom_nav_menu);
}
bottomNavigation.setOnMenuItemClickListener(getPresenter());
if (repoModel.getTopics() != null && !repoModel.getTopics().isEmpty()) {
tagsIcon.setVisibility(View.VISIBLE);
topicsList.setAdapter(new TopicsAdapter(repoModel.getTopics()));
} else {
topicsList.setVisibility(View.GONE);
}
onRepoPinned(AbstractPinnedRepos.isPinned(repoModel.getFullName()));
wikiLayout.setVisibility(repoModel.isHasWiki() ? View.VISIBLE : View.GONE);
pinText.setText(R.string.pin);
detailsIcon.setVisibility(InputHelper.isEmpty(repoModel.getDescription()) ? View.GONE : View.VISIBLE);
language.setVisibility(InputHelper.isEmpty(repoModel.getLanguage()) ? View.GONE : View.VISIBLE);
if (!InputHelper.isEmpty(repoModel.getLanguage())) {
language.setText(repoModel.getLanguage());
language.setTextColor(ColorsProvider.getColorAsColor(repoModel.getLanguage(), language.getContext()));
}
forkRepo.setText(numberFormat.format(repoModel.getForksCount()));
starRepo.setText(numberFormat.format(repoModel.getStargazersCount()));
watchRepo.setText(numberFormat.format(repoModel.getSubsCount()));
if (repoModel.getOwner() != null) {
avatarLayout.setUrl(repoModel.getOwner().getAvatarUrl(), repoModel.getOwner().getLogin(), repoModel.getOwner().isOrganizationType(), LinkParserHelper.isEnterprise(repoModel.getHtmlUrl()));
} else if (repoModel.getOrganization() != null) {
avatarLayout.setUrl(repoModel.getOrganization().getAvatarUrl(), repoModel.getOrganization().getLogin(), true, LinkParserHelper.isEnterprise(repoModel.getHtmlUrl()));
}
long repoSize = repoModel.getSize() > 0 ? (repoModel.getSize() * 1000) : repoModel.getSize();
date.setText(SpannableBuilder.builder().append(ParseDateFormat.getTimeAgo(repoModel.getPushedAt())).append(" ,").append(" ").append(Formatter.formatFileSize(this, repoSize)));
size.setVisibility(View.GONE);
title.setText(repoModel.getFullName());
TextViewCompat.setTextAppearance(title, R.style.TextAppearance_AppCompat_Medium);
title.setTextColor(ViewHelper.getPrimaryTextColor(this));
if (repoModel.getLicense() != null) {
licenseLayout.setVisibility(View.VISIBLE);
LicenseModel licenseModel = repoModel.getLicense();
license.setText(!InputHelper.isEmpty(licenseModel.getSpdxId()) ? licenseModel.getSpdxId() : licenseModel.getName());
}
supportInvalidateOptionsMenu();
if (!PrefGetter.isRepoGuideShowed()) {
}
onRepoWatched(getPresenter().isWatched());
onRepoStarred(getPresenter().isStarred());
onRepoForked(getPresenter().isForked());
}
use of com.fastaccess.data.dao.model.Repo in project FastHub by k0shk0sh.
the class RepoFilesActivity method getIntent.
public static Intent getIntent(@NonNull Context context, @NonNull String url) {
boolean isEnterprise = LinkParserHelper.isEnterprise(url);
if (isEnterprise) {
url = url.replace("api/v3/", "");
if (url.contains("/raw")) {
url = url.replace("/raw", "");
}
}
Uri uri = Uri.parse(url);
if (uri.getPathSegments() != null && uri.getPathSegments().size() > 3) {
String login = null;
String repoId = null;
String branch = null;
StringBuilder path = new StringBuilder();
boolean startWithRepo = false;
if (uri.getPathSegments().get(0).equalsIgnoreCase("repos")) {
login = uri.getPathSegments().get(1);
repoId = uri.getPathSegments().get(2);
branch = uri.getQueryParameter("ref");
startWithRepo = true;
} else if (uri.getPathSegments().get(0).equalsIgnoreCase("repositories")) {
String id = uri.getPathSegments().get(1);
try {
long longRepoId = Long.valueOf(id);
if (longRepoId != 0) {
Repo repo = AbstractRepo.getRepo(longRepoId);
if (repo != null) {
NameParser nameParser = new NameParser(repo.getHtmlUrl());
if (nameParser.getUsername() != null && nameParser.getName() != null) {
login = nameParser.getUsername();
repoId = nameParser.getName();
branch = uri.getQueryParameter("ref");
}
}
}
} catch (NumberFormatException ignored) {
return new Intent(context, MainActivity.class);
}
} else {
login = uri.getPathSegments().get(0);
repoId = uri.getPathSegments().get(1);
branch = uri.getPathSegments().get(2);
}
for (int i = startWithRepo ? 4 : 3; i < uri.getPathSegments().size() - 1; i++) {
String appendedPath = uri.getPathSegments().get(i);
path.append("/").append(appendedPath);
}
if (!InputHelper.isEmpty(repoId) && !InputHelper.isEmpty(login)) {
Intent intent = new Intent(context, RepoFilesActivity.class);
intent.putExtras(Bundler.start().put(BundleConstant.ID, repoId).put(BundleConstant.EXTRA, login).put(BundleConstant.EXTRA_TWO, path.toString()).put(BundleConstant.EXTRA_THREE, branch).put(BundleConstant.IS_ENTERPRISE, isEnterprise).end());
return intent;
}
return new Intent(context, MainActivity.class);
}
return new Intent(context, MainActivity.class);
}
use of com.fastaccess.data.dao.model.Repo in project FastHub by k0shk0sh.
the class FeedsPresenter method onItemClick.
@Override
public void onItemClick(int position, View v, Event item) {
if (item.getType() == EventsType.ForkEvent) {
NameParser parser = new NameParser(item.getPayload().getForkee().getHtmlUrl());
RepoPagerActivity.startRepoPager(v.getContext(), parser);
} else {
PayloadModel payloadModel = item.getPayload();
if (payloadModel != null) {
if (payloadModel.getHead() != null) {
if (payloadModel.getCommits() != null && payloadModel.getCommits().size() > 1) {
sendToView(view -> view.onOpenCommitChooser(payloadModel.getCommits()));
} else {
Repo repoModel = item.getRepo();
NameParser nameParser = new NameParser(repoModel.getUrl());
Intent intent = CommitPagerActivity.createIntent(v.getContext(), nameParser.getName(), nameParser.getUsername(), payloadModel.getHead(), true, LinkParserHelper.isEnterprise(repoModel.getUrl()));
v.getContext().startActivity(intent);
}
} else if (payloadModel.getIssue() != null) {
SchemeParser.launchUri(v.getContext(), Uri.parse(payloadModel.getIssue().getHtmlUrl()), true);
} else if (payloadModel.getPullRequest() != null) {
SchemeParser.launchUri(v.getContext(), Uri.parse(payloadModel.getPullRequest().getHtmlUrl()), true);
} else if (payloadModel.getComment() != null) {
SchemeParser.launchUri(v.getContext(), Uri.parse(payloadModel.getComment().getHtmlUrl()), true);
} else if (item.getType() == EventsType.ReleaseEvent && payloadModel.getRelease() != null) {
NameParser nameParser = new NameParser(payloadModel.getRelease().getHtmlUrl());
v.getContext().startActivity(ReleasesListActivity.getIntent(v.getContext(), nameParser.getUsername(), nameParser.getName(), payloadModel.getRelease().getId(), LinkParserHelper.isEnterprise(payloadModel.getRelease().getHtmlUrl())));
} else if (item.getType() == EventsType.CreateEvent && "tag".equalsIgnoreCase(payloadModel.getRefType())) {
Repo repoModel = item.getRepo();
NameParser nameParser = new NameParser(repoModel.getUrl());
v.getContext().startActivity(ReleasesListActivity.getIntent(v.getContext(), nameParser.getUsername(), nameParser.getName(), payloadModel.getRef(), LinkParserHelper.isEnterprise(repoModel.getUrl())));
} else if (item.getType() == EventsType.GollumEvent) {
Repo repoModel = item.getRepo();
NameParser parser = new NameParser(repoModel.getUrl());
v.getContext().startActivity(WikiActivity.Companion.getWiki(v.getContext(), parser.getName(), parser.getUsername()));
} else {
Repo repoModel = item.getRepo();
NameParser parser = new NameParser(repoModel.getUrl());
RepoPagerActivity.startRepoPager(v.getContext(), parser);
}
}
}
}
use of com.fastaccess.data.dao.model.Repo in project FastHub by k0shk0sh.
the class FeedsPresenter method onItemLongClick.
@Override
public void onItemLongClick(int position, View v, Event item) {
if (item.getType() == EventsType.ForkEvent) {
if (getView() != null) {
getView().onOpenRepoChooser(Stream.of(new SimpleUrlsModel(item.getRepo().getName(), item.getRepo().getUrl()), new SimpleUrlsModel(item.getPayload().getForkee().getFullName(), item.getPayload().getForkee().getHtmlUrl())).collect(Collectors.toCollection(ArrayList::new)));
}
} else {
Repo repo = item.getRepo();
if (repo != null) {
NameParser parser = new NameParser(repo.getUrl());
RepoPagerActivity.startRepoPager(v.getContext(), parser);
}
}
}
use of com.fastaccess.data.dao.model.Repo in project FastHub by k0shk0sh.
the class PinnedReposViewHolder method bind.
@Override
public void bind(@NonNull PinnedRepos pinnedRepos) {
Repo repo = pinnedRepos.getPinnedRepo();
if (repo == null)
return;
if (repo.isFork()) {
title.setText(SpannableBuilder.builder().append(" " + forked + " ", new LabelSpan(forkColor)).append(" ").append(repo.getName(), new LabelSpan(Color.TRANSPARENT)));
} else if (repo.isPrivateX()) {
title.setText(SpannableBuilder.builder().append(" " + privateRepo + " ", new LabelSpan(privateColor)).append(" ").append(repo.getName(), new LabelSpan(Color.TRANSPARENT)));
} else {
title.setText(repo.getFullName());
}
String avatar = repo.getOwner() != null ? repo.getOwner().getAvatarUrl() : null;
String login = repo.getOwner() != null ? repo.getOwner().getLogin() : null;
boolean isOrg = repo.getOwner() != null && repo.getOwner().isOrganizationType();
if (avatarLayout != null) {
avatarLayout.setVisibility(View.VISIBLE);
avatarLayout.setUrl(avatar, login, isOrg, LinkParserHelper.isEnterprise(repo.getHtmlUrl()));
}
if (stars != null && forks != null && date != null && language != null) {
NumberFormat numberFormat = NumberFormat.getNumberInstance();
stars.setText(numberFormat.format(repo.getStargazersCount()));
forks.setText(numberFormat.format(repo.getForks()));
date.setText(ParseDateFormat.getTimeAgo(repo.getUpdatedAt()));
if (!InputHelper.isEmpty(repo.getLanguage())) {
language.setText(repo.getLanguage());
language.setTextColor(ColorsProvider.getColorAsColor(repo.getLanguage(), language.getContext()));
language.setVisibility(View.VISIBLE);
}
}
}
Aggregations