Search in sources :

Example 1 with DataService

use of org.eclipse.egit.github.core.service.DataService in project Bitocle by mthli.

the class RepoContentTask method onPreExecute.

@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();
    flag = fragment.getFlag();
    adapter = fragment.getContentItemAdapter();
    list = fragment.getContentItemList();
    bookmark = fragment.getBookmark();
    GitHubClient client = fragment.getClient();
    dataService = new DataService(client);
    owner = fragment.getOwner();
    name = fragment.getName();
    root = fragment.getRoot();
    entry = fragment.getEntry();
    if (flag == Flag.REPO_CONTENT_FIRST || flag == Flag.REPO_CONTENT_REFRESH) {
        fragment.setContentEmpty(false);
        fragment.setContentShown(false);
        bookmark.setVisible(false);
    }
}
Also used : GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) DataService(org.eclipse.egit.github.core.service.DataService)

Example 2 with DataService

use of org.eclipse.egit.github.core.service.DataService in project Bitocle by mthli.

the class StarContentTask method onPreExecute.

@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();
    flag = fragment.getFlag();
    adapter = fragment.getContentItemAdapter();
    list = fragment.getContentItemList();
    bookmark = fragment.getBookmark();
    GitHubClient client = fragment.getClient();
    dataService = new DataService(client);
    owner = fragment.getOwner();
    name = fragment.getName();
    root = fragment.getRoot();
    entry = fragment.getEntry();
    if (flag == Flag.STAR_CONTENT_FIRST || flag == Flag.STAR_CONTENT_REFRESH) {
        fragment.setContentEmpty(false);
        fragment.setContentShown(false);
        bookmark.setVisible(false);
    }
}
Also used : GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) DataService(org.eclipse.egit.github.core.service.DataService)

Example 3 with DataService

use of org.eclipse.egit.github.core.service.DataService in project Bitocle by mthli.

the class WebViewTask method doInBackground.

@Override
protected Boolean doInBackground(Void... params) {
    GitHubClient client = fragment.getClient();
    RepositoryId id = RepositoryId.create(owner, name);
    DataService dataService = new DataService(client);
    MarkdownService markdownService = new MarkdownService(client);
    Blob blob;
    try {
        blob = dataService.getBlob(id, sha);
    } catch (IOException i) {
        return false;
    }
    if (isCancelled()) {
        return false;
    }
    String base64 = blob.getContent();
    if (!MimeType.isImage(filename)) {
        byte[] bytes = EncodingUtils.fromBase64(base64);
        content = new String(bytes);
    }
    if (MimeType.isImage(filename)) {
        String imageUrl = GetImage.getImageUrl(base64, MimeType.getImageExtension(filename));
        image = GetImage.getImage(imageUrl);
    } else if (MimeType.isMarkdown(filename)) {
        try {
            content = markdownService.getHtml(content, MarkdownService.MODE_GFM);
            content = StyleMarkdown.styleMarkdown(content);
        } catch (IOException i) {
            return false;
        }
    } else {
        content = SyntaxCode.syntaxCode(content, css);
    }
    if (isCancelled()) {
        return false;
    }
    return true;
}
Also used : GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) Blob(org.eclipse.egit.github.core.Blob) MarkdownService(org.eclipse.egit.github.core.service.MarkdownService) IOException(java.io.IOException) RepositoryId(org.eclipse.egit.github.core.RepositoryId) DataService(org.eclipse.egit.github.core.service.DataService)

Aggregations

GitHubClient (org.eclipse.egit.github.core.client.GitHubClient)3 DataService (org.eclipse.egit.github.core.service.DataService)3 IOException (java.io.IOException)1 Blob (org.eclipse.egit.github.core.Blob)1 RepositoryId (org.eclipse.egit.github.core.RepositoryId)1 MarkdownService (org.eclipse.egit.github.core.service.MarkdownService)1