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