Search in sources :

Example 1 with LicenseModel

use of com.fastaccess.data.dao.LicenseModel 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());
}
Also used : LicenseModel(com.fastaccess.data.dao.LicenseModel) Repo(com.fastaccess.data.dao.model.Repo) TopicsAdapter(com.fastaccess.ui.adapter.TopicsAdapter)

Example 2 with LicenseModel

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

the class RepoPagerActivity method onClick.

@OnClick({ R.id.forkRepoLayout, R.id.starRepoLayout, R.id.watchRepoLayout, R.id.pinLayout, R.id.wikiLayout, R.id.licenseLayout })
void onClick(View view) {
    switch(view.getId()) {
        case R.id.forkRepoLayout:
            MessageDialogView.newInstance(getString(R.string.fork), String.format("%s %s/%s?", getString(R.string.fork), login, repoId), Bundler.start().put(BundleConstant.EXTRA, true).put(BundleConstant.YES_NO_EXTRA, true).end()).show(getSupportFragmentManager(), MessageDialogView.TAG);
            break;
        case R.id.starRepoLayout:
            if (!InputHelper.isEmpty(getPresenter().login()) && !InputHelper.isEmpty(getPresenter().repoId())) {
                GithubActionService.startForRepo(this, getPresenter().login(), getPresenter().repoId(), getPresenter().isStarred() ? GithubActionService.UNSTAR_REPO : GithubActionService.STAR_REPO, isEnterprise());
                getPresenter().onStar();
            }
            break;
        case R.id.watchRepoLayout:
            if (!InputHelper.isEmpty(getPresenter().login()) && !InputHelper.isEmpty(getPresenter().repoId())) {
                GithubActionService.startForRepo(this, getPresenter().login(), getPresenter().repoId(), getPresenter().isWatched() ? GithubActionService.UNWATCH_REPO : GithubActionService.WATCH_REPO, isEnterprise());
                getPresenter().onWatch();
            }
            break;
        case R.id.pinLayout:
            pinLayout.setEnabled(false);
            getPresenter().onPinUnpinRepo();
            break;
        case R.id.wikiLayout:
            ActivityHelper.startReveal(this, WikiActivity.Companion.getWiki(this, repoId, login), wikiLayout);
            break;
        case R.id.licenseLayout:
            if (getPresenter().getRepo() != null) {
                LicenseModel licenseModel = getPresenter().getRepo().getLicense();
                String license = !InputHelper.isEmpty(licenseModel.getSpdxId()) ? licenseModel.getSpdxId() : licenseModel.getName();
                RepoLicenseBottomSheet.Companion.newInstance(getPresenter().login(), getPresenter().repoId(), license).show(getSupportFragmentManager(), "RepoLicenseBottomSheet");
            }
            break;
    }
}
Also used : LicenseModel(com.fastaccess.data.dao.LicenseModel) OnClick(butterknife.OnClick)

Aggregations

LicenseModel (com.fastaccess.data.dao.LicenseModel)2 OnClick (butterknife.OnClick)1 Repo (com.fastaccess.data.dao.model.Repo)1 TopicsAdapter (com.fastaccess.ui.adapter.TopicsAdapter)1