Search in sources :

Example 51 with Repository

use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.

the class SearchRepositoryListFragment method openRepositoryMatch.

/**
 * Check if the search query is an exact repository name/owner match and
 * open the repository activity and finish the current activity when it is
 *
 * @param query
 * @return true if query opened as repository, false otherwise
 */
private boolean openRepositoryMatch(final String query) {
    if (TextUtils.isEmpty(query)) {
        return false;
    }
    Repository repoId = InfoUtils.createRepoFromUrl(query.trim());
    if (repoId == null) {
        return false;
    }
    ServiceGenerator.createService(getContext(), RepositoryService.class).getRepository(repoId.owner().login(), repoId.name()).subscribe(response -> {
        if (response.isSuccessful()) {
            startActivity(RepositoryViewActivity.createIntent(response.body()));
            final Activity activity = getActivity();
            if (activity != null) {
                activity.finish();
            }
        }
    });
    return true;
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) RepositoryViewActivity(com.github.pockethub.android.ui.repo.RepositoryViewActivity) Activity(android.app.Activity)

Example 52 with Repository

use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.

the class NewsEventTextTest method testTeamAdd.

/**
 * Verify text of push event
 */
@UiThreadTest
public void testTeamAdd() {
    Team team = Team.builder().name("t1").build();
    Repository repo = Repository.builder().name("r2").build();
    TeamAddPayload payload = TeamAddPayload.builder().repository(repo).team(team).build();
    GitHubEvent event = createEvent(GitHubEventType.TeamAddEvent, payload);
    updateView(event);
    verify("user added r2 to team t1");
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) TeamAddPayload(com.meisolsson.githubsdk.model.payload.TeamAddPayload) Team(com.meisolsson.githubsdk.model.Team) GitHubEvent(com.meisolsson.githubsdk.model.GitHubEvent) UiThreadTest(android.test.UiThreadTest)

Example 53 with Repository

use of com.meisolsson.githubsdk.model.Repository in project gh4a by slapperwan.

the class RepositoryFragment method fillData.

private void fillData() {
    TextView tvRepoName = mContentView.findViewById(R.id.tv_repo_name);
    IntentSpan repoSpan = new IntentSpan(tvRepoName.getContext(), context -> UserActivity.makeIntent(context, mRepository.owner()));
    SpannableStringBuilder repoName = new SpannableStringBuilder();
    repoName.append(mRepository.owner().login());
    repoName.append("/");
    repoName.append(mRepository.name());
    repoName.setSpan(repoSpan, 0, mRepository.owner().login().length(), 0);
    tvRepoName.setText(repoName);
    tvRepoName.setMovementMethod(UiUtils.CHECKING_LINK_METHOD);
    TextView tvParentRepo = mContentView.findViewById(R.id.tv_parent);
    if (mRepository.isFork() && mRepository.parent() != null) {
        Repository parent = mRepository.parent();
        tvParentRepo.setVisibility(View.VISIBLE);
        tvParentRepo.setText(getString(R.string.forked_from, parent.owner().login() + "/" + parent.name()));
        tvParentRepo.setOnClickListener(this);
        tvParentRepo.setTag(parent);
    } else {
        tvParentRepo.setVisibility(View.GONE);
    }
    fillTextView(R.id.tv_desc, 0, mRepository.description());
    fillTextView(R.id.tv_language, R.string.repo_language, mRepository.language());
    fillTextView(R.id.tv_url, 0, !StringUtils.isBlank(mRepository.homepage()) ? mRepository.homepage() : mRepository.htmlUrl());
    mContentView.findViewById(R.id.cell_stargazers).setOnClickListener(this);
    mContentView.findViewById(R.id.cell_forks).setOnClickListener(this);
    mContentView.findViewById(R.id.cell_pull_requests).setOnClickListener(this);
    mContentView.findViewById(R.id.tv_contributors_label).setOnClickListener(this);
    mContentView.findViewById(R.id.other_info).setOnClickListener(this);
    mContentView.findViewById(R.id.tv_releases_label).setOnClickListener(this);
    mReadmeTitleView.setOnClickListener(this);
    Permissions permissions = mRepository.permissions();
    updateClickableLabel(R.id.tv_collaborators_label, permissions != null && permissions.push());
    updateClickableLabel(R.id.tv_wiki_label, mRepository.hasWiki());
    TextView tvStargazersCount = mContentView.findViewById(R.id.tv_stargazers_count);
    tvStargazersCount.setText(String.valueOf(mRepository.watchersCount()));
    TextView tvForksCount = mContentView.findViewById(R.id.tv_forks_count);
    tvForksCount.setText(String.valueOf(mRepository.forksCount()));
    LinearLayout llIssues = mContentView.findViewById(R.id.cell_issues);
    if (mRepository.hasIssues()) {
        llIssues.setVisibility(View.VISIBLE);
        llIssues.setOnClickListener(this);
    // value will be filled when PR count arrives
    } else {
        llIssues.setVisibility(View.GONE);
    }
    mContentView.findViewById(R.id.tv_private).setVisibility(mRepository.isPrivate() ? View.VISIBLE : View.GONE);
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) IntentSpan(com.gh4a.widget.IntentSpan) Permissions(com.meisolsson.githubsdk.model.Permissions) TextView(android.widget.TextView) SpannableStringBuilder(android.text.SpannableStringBuilder) LinearLayout(android.widget.LinearLayout)

Example 54 with Repository

use of com.meisolsson.githubsdk.model.Repository in project gh4a by slapperwan.

the class UserFragment method onClick.

@Override
public void onClick(View view) {
    int id = view.getId();
    Intent intent = null;
    if (id == R.id.cell_followers) {
        if (mUser.type() == UserType.Organization) {
            intent = OrganizationMemberListActivity.makeIntent(getActivity(), mUser.login());
        } else {
            intent = FollowerFollowingListActivity.makeIntent(getActivity(), mUser.login(), true);
        }
    } else if (id == R.id.cell_following) {
        intent = FollowerFollowingListActivity.makeIntent(getActivity(), mUser.login(), false);
    } else if (id == R.id.cell_repos || id == R.id.btn_repos) {
        intent = RepositoryListActivity.makeIntent(getActivity(), mUser.login(), mUser.type() == UserType.Organization);
    } else if (id == R.id.cell_gists) {
        intent = GistListActivity.makeIntent(getActivity(), mUser.login());
    } else if (id == R.id.cell_org_members) {
        intent = OrganizationMemberListActivity.makeIntent(getActivity(), mUser.login());
    } else if (view.getTag() instanceof Repository) {
        intent = RepositoryActivity.makeIntent(getActivity(), (Repository) view.getTag());
    } else if (view.getTag() instanceof User) {
        intent = UserActivity.makeIntent(getActivity(), (User) view.getTag());
    }
    if (intent != null) {
        startActivity(intent);
    }
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) User(com.meisolsson.githubsdk.model.User) Intent(android.content.Intent)

Example 55 with Repository

use of com.meisolsson.githubsdk.model.Repository in project gh4a by slapperwan.

the class UserFragment method loadTopRepositories.

private void loadTopRepositories(boolean force) {
    RepositoryService service = ServiceFactory.get(RepositoryService.class, force, null, null, 5);
    final Single<Response<Page<Repository>>> observable;
    Map<String, String> filterData = new HashMap<>();
    filterData.put("sort", "pushed");
    filterData.put("affiliation", "owner,collaborator");
    if (mIsSelf) {
        observable = service.getUserRepositories(filterData, 1);
    } else if (mUser.type() == UserType.Organization) {
        observable = service.getOrganizationRepositories(mUser.login(), filterData, 1);
    } else {
        observable = service.getUserRepositories(mUser.login(), filterData, 1);
    }
    observable.map(ApiHelpers::throwOnFailure).map(Page::items).compose(makeLoaderSingle(ID_LOADER_REPO_LIST, force)).doOnSubscribe(disposable -> {
        mContentView.findViewById(R.id.pb_top_repos).setVisibility(View.VISIBLE);
        mContentView.findViewById(R.id.ll_top_repos).setVisibility(View.GONE);
    }).subscribe(this::fillTopRepos, this::handleLoadFailure);
}
Also used : Response(retrofit2.Response) LinearLayout(android.widget.LinearLayout) Repository(com.meisolsson.githubsdk.model.Repository) Bundle(android.os.Bundle) OrganizationMemberListActivity(com.gh4a.activities.OrganizationMemberListActivity) ImageView(android.widget.ImageView) Intent(android.content.Intent) HashMap(java.util.HashMap) Response(retrofit2.Response) Single(io.reactivex.Single) MenuItem(android.view.MenuItem) UserActivity(com.gh4a.activities.UserActivity) User(com.meisolsson.githubsdk.model.User) AvatarHandler(com.gh4a.utils.AvatarHandler) MenuInflater(android.view.MenuInflater) Page(com.meisolsson.githubsdk.model.Page) Map(java.util.Map) Menu(android.view.Menu) R(com.gh4a.R) View(android.view.View) StringUtils(com.gh4a.utils.StringUtils) ApiHelpers(com.gh4a.utils.ApiHelpers) OrganizationService(com.meisolsson.githubsdk.service.organizations.OrganizationService) LayoutInflater(android.view.LayoutInflater) UserFollowerService(com.meisolsson.githubsdk.service.users.UserFollowerService) Collection(java.util.Collection) FollowerFollowingListActivity(com.gh4a.activities.FollowerFollowingListActivity) RepositoryService(com.meisolsson.githubsdk.service.repositories.RepositoryService) GistListActivity(com.gh4a.activities.GistListActivity) UserType(com.meisolsson.githubsdk.model.UserType) ViewGroup(android.view.ViewGroup) DateFormat(android.text.format.DateFormat) RepositoryListActivity(com.gh4a.activities.RepositoryListActivity) List(java.util.List) TextView(android.widget.TextView) RepositoryActivity(com.gh4a.activities.RepositoryActivity) RxUtils(com.gh4a.utils.RxUtils) Gh4Application(com.gh4a.Gh4Application) ServiceFactory(com.gh4a.ServiceFactory) Repository(com.meisolsson.githubsdk.model.Repository) HashMap(java.util.HashMap) ApiHelpers(com.gh4a.utils.ApiHelpers) RepositoryService(com.meisolsson.githubsdk.service.repositories.RepositoryService)

Aggregations

Repository (com.meisolsson.githubsdk.model.Repository)68 User (com.meisolsson.githubsdk.model.User)18 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)9 Issue (com.meisolsson.githubsdk.model.Issue)9 Intent (android.content.Intent)8 View (android.view.View)8 TextView (android.widget.TextView)6 Bundle (android.os.Bundle)5 ImageView (android.widget.ImageView)5 LayoutInflater (android.view.LayoutInflater)4 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4 Test (org.junit.Test)4 Uri (android.net.Uri)3 Menu (android.view.Menu)3 ViewGroup (android.view.ViewGroup)3 LinearLayout (android.widget.LinearLayout)3 R (com.gh4a.R)3 RepositoryActivity (com.gh4a.activities.RepositoryActivity)3 UserActivity (com.gh4a.activities.UserActivity)3 ApiHelpers (com.gh4a.utils.ApiHelpers)3