Search in sources :

Example 11 with Repository

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

the class RepositoryReadmeFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    webview = (WebView) view;
    final Repository repo = getParcelableExtra(Intents.EXTRA_REPOSITORY);
    WebSettings settings = webview.getSettings();
    settings.setJavaScriptEnabled(true);
    webview.addJavascriptInterface(this, "Readme");
    ServiceGenerator.createService(getActivity(), RepositoryContentService.class).getReadmeHtml(repo.owner().login(), repo.name(), null).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).as(AutoDisposeUtils.bindToLifecycle(this)).subscribe(response -> {
        String baseUrl = String.format("https://github.com/%s/%s/raw/%s/", repo.owner().login(), repo.name(), "master");
        String data = PAGE_START + response.body() + PAGE_END;
        webview.loadDataWithBaseURL(baseUrl, data, "text/html", "UTF-8", null);
    });
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) WebSettings(android.webkit.WebSettings) RepositoryContentService(com.meisolsson.githubsdk.service.repositories.RepositoryContentService)

Example 12 with Repository

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

the class OrganizationRepositories method store.

@Override
public void store(SQLiteDatabase db, List<Repository> repos) {
    db.delete("repos", "orgId=?", new String[] { Integer.toString(org.id().intValue()) });
    if (repos.isEmpty()) {
        return;
    }
    ContentValues values = new ContentValues(12);
    for (Repository repo : repos) {
        values.clear();
        User owner = repo.owner();
        values.put("repoId", repo.id());
        values.put("name", repo.name());
        values.put("orgId", org.id());
        values.put("ownerId", owner.id());
        values.put("private", repo.isPrivate() ? 1 : 0);
        values.put("fork", repo.isFork() ? 1 : 0);
        values.put("description", repo.description());
        values.put("forks", repo.forksCount());
        values.put("watchers", repo.watchersCount());
        values.put("language", repo.language());
        values.put("hasIssues", repo.hasIssues() ? 1 : 0);
        values.put("mirrorUrl", repo.mirrorUrl());
        values.put("permissions_admin", repo.permissions().admin() ? 1 : 0);
        values.put("permissions_pull", repo.permissions().pull() ? 1 : 0);
        values.put("permissions_push", repo.permissions().push() ? 1 : 0);
        db.replace("repos", null, values);
        values.clear();
        values.put("id", owner.id());
        values.put("name", owner.login());
        values.put("avatarurl", owner.avatarUrl());
        db.replace("users", null, values);
    }
}
Also used : ContentValues(android.content.ContentValues) Repository(com.meisolsson.githubsdk.model.Repository) User(com.meisolsson.githubsdk.model.User)

Example 13 with Repository

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

the class NewsFragment method onItemClick.

@Override
public void onItemClick(@NonNull Item item, @NonNull View view) {
    if (!(item instanceof NewsItem)) {
        return;
    }
    GitHubEvent event = ((NewsItem) item).getGitHubEvent();
    if (DownloadEvent.equals(event.type())) {
        openDownload(event);
        return;
    }
    if (PushEvent.equals(event.type())) {
        openPush(event);
        return;
    }
    if (CommitCommentEvent.equals(event.type())) {
        openCommitComment(event);
        return;
    }
    Issue issue = IssueEventMatcher.getIssue(event);
    if (issue != null) {
        Repository repo = ConvertUtils.eventRepoToRepo(event.repo());
        viewIssue(issue, repo);
        return;
    }
    Gist gist = GistEventMatcher.getGist(event);
    if (gist != null) {
        startActivity(GistsViewActivity.createIntent(gist));
        return;
    }
    Repository repo = RepositoryEventMatcher.getRepository(event);
    if (repo != null) {
        viewRepository(repo);
    }
    UserPair users = UserEventMatcher.getUsers(event);
    if (users != null) {
        viewUser(users);
    }
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) Gist(com.meisolsson.githubsdk.model.Gist) Issue(com.meisolsson.githubsdk.model.Issue) UserPair(com.github.pockethub.android.core.user.UserEventMatcher.UserPair) GitHubEvent(com.meisolsson.githubsdk.model.GitHubEvent) NewsItem(com.github.pockethub.android.ui.item.news.NewsItem)

Example 14 with Repository

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

the class RepositoryViewActivity method forkRepository.

private void forkRepository() {
    ServiceGenerator.createService(this, RepositoryForkService.class).createFork(repository.owner().login(), repository.name()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).as(AutoDisposeUtils.bindToLifecycle(this)).subscribe(response -> {
        Repository repo = response.body();
        UriLauncherActivity.launchUri(this, Uri.parse(repo.htmlUrl()));
    }, e -> ToastUtils.show(this, R.string.error_forking_repository));
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) RepositoryForkService(com.meisolsson.githubsdk.service.repositories.RepositoryForkService)

Example 15 with Repository

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

the class UserRepositoryListFragment method onItemClick.

@Override
public void onItemClick(@NonNull Item item, @NonNull View view) {
    if (item instanceof RepositoryItem) {
        Repository repo = ((RepositoryItem) item).getRepo();
        startActivityForResult(RepositoryViewActivity.createIntent(repo), REPOSITORY_VIEW);
    }
}
Also used : RepositoryItem(com.github.pockethub.android.ui.item.repository.RepositoryItem) Repository(com.meisolsson.githubsdk.model.Repository)

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