• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Gist类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.egit.github.core.Gist的典型用法代码示例。如果您正苦于以下问题:Java Gist类的具体用法?Java Gist怎么用?Java Gist使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Gist类属于org.eclipse.egit.github.core包,在下文中一共展示了Gist类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: updateFiles

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
private void updateFiles(Gist gist) {
    final Activity activity = getActivity();
    if (activity == null)
        return;

    for (View header : fileHeaders)
        adapter.removeHeader(header);
    fileHeaders.clear();

    Map<String, GistFile> files = gist.getFiles();
    if (files == null || files.isEmpty())
        return;

    final LayoutInflater inflater = activity.getLayoutInflater();
    final Typeface octicons = TypefaceUtils.getOcticons(activity);
    for (GistFile file : files.values()) {
        View fileView = inflater.inflate(layout.gist_file_item, null);
        ((TextView) fileView.findViewById(id.tv_file)).setText(file
                .getFilename());
        ((TextView) fileView.findViewById(id.tv_file_icon))
                .setTypeface(octicons);
        adapter.addHeader(fileView, file, true);
        fileHeaders.add(fileView);
    }
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:26,代码来源:GistFragment.java


示例2: starGist

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
private void starGist() {
    ToastUtils.show(getActivity(), string.starring_gist);

    new StarGistTask(getActivity(), gistId) {

        @Override
        protected void onSuccess(Gist gist) throws Exception {
            super.onSuccess(gist);

            starred = true;
        }

        @Override
        protected void onException(Exception e) throws RuntimeException {
            super.onException(e);

            ToastUtils.show((Activity) getContext(), e.getMessage());
        }

    }.execute();
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:22,代码来源:GistFragment.java


示例3: unstarGist

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
private void unstarGist() {
    ToastUtils.show(getActivity(), string.unstarring_gist);

    new UnstarGistTask(getActivity(), gistId) {

        @Override
        protected void onSuccess(Gist gist) throws Exception {
            super.onSuccess(gist);

            starred = false;
        }

        protected void onException(Exception e) throws RuntimeException {
            super.onException(e);

            ToastUtils.show((Activity) getContext(), e.getMessage());
        }

    }.execute();
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:21,代码来源:GistFragment.java


示例4: run

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
@Override
protected Gist run(Account account) throws Exception {
    PageIterator<Gist> pages = service.pagePublicGists(1);
    pages.next();
    int randomPage = 1 + (int) (Math.random() * ((pages.getLastPage() - 1) + 1));

    Collection<Gist> gists = service.pagePublicGists(randomPage, 1).next();

    // Make at least two tries since page numbers are volatile
    if (gists.isEmpty()) {
        randomPage = 1 + (int) (Math.random() * ((pages.getLastPage() - 1) + 1));
        gists = service.pagePublicGists(randomPage, 1).next();
    }

    if (gists.isEmpty())
        throw new IllegalArgumentException(getContext().getString(
                string.no_gists_found));

    return store.addGist(gists.iterator().next());
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:21,代码来源:RandomGistTask.java


示例5: update

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
@Override
protected void update(int position, Gist gist) {
    setText(0, gist.getId());

    String description = gist.getDescription();
    if (!TextUtils.isEmpty(description))
        setText(1, description);
    else
        setText(1, string.no_description_given);

    User user = gist.getUser();
    avatars.bind(imageView(5), user);

    StyledText authorText = new StyledText();
    if (user != null)
        authorText.bold(user.getLogin());
    else
        authorText.bold(anonymous);
    authorText.append(' ');
    authorText.append(gist.getCreatedAt());
    setText(2, authorText);

    setNumber(3, gist.getComments());
    setNumber(4, gist.getFiles().size());
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:26,代码来源:GistListAdapter.java


示例6: createGist

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
private void createGist() {
    final boolean isPublic = publicCheckBox.isChecked();

    String enteredDescription = descriptionText.getText().toString().trim();
    final String description = enteredDescription.length() > 0 ? enteredDescription
            : getString(string.gist_description_hint);

    String enteredName = nameText.getText().toString().trim();
    final String name = enteredName.length() > 0 ? enteredName
            : getString(string.gist_file_name_hint);

    final String content = contentText.getText().toString();

    new CreateGistTask(this, description, isPublic, name, content) {

        @Override
        protected void onSuccess(Gist gist) throws Exception {
            super.onSuccess(gist);

            startActivity(GistsViewActivity.createIntent(gist));
            setResult(RESULT_OK);
            finish();
        }
    }.create();
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:26,代码来源:CreateGistActivity.java


示例7: updateActionBar

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
private void updateActionBar(Gist gist, String gistId) {
    ActionBar actionBar = getSupportActionBar();
    if (gist == null) {
        actionBar.setSubtitle(null);
        actionBar.setLogo(null);
        actionBar.setIcon(drawable.app_icon);
    } else if (gist.getUser() != null) {
        avatars.bind(actionBar, gist.getUser());
        actionBar.setSubtitle(gist.getUser().getLogin());
    } else {
        actionBar.setSubtitle(string.anonymous);
        actionBar.setLogo(null);
        actionBar.setIcon(drawable.app_icon);
    }
    actionBar.setTitle(getString(string.gist_title) + gistId);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:17,代码来源:GistsViewActivity.java


示例8: getGist

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
/**
 * Parse a {@link Gist} from a non-null {@link Uri}
 *
 * @param uri
 * @return {@link Gist} or null if none found in given {@link Uri}
 */
public static Gist getGist(final Uri uri) {
    List<String> segments = uri.getPathSegments();
    if (segments == null)
        return null;
    if (segments.size() != 1)
        return null;

    String gistId = segments.get(0);
    if (TextUtils.isEmpty(gistId))
        return null;

    if (TextUtils.isDigitsOnly(gistId))
        return new Gist().setId(gistId);

    if (PATTERN.matcher(gistId).matches())
        return new Gist().setId(gistId);

    return null;
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:26,代码来源:GistUriMatcher.java


示例9: run

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
@Override
public FullGist run(Account account) throws Exception {
    Gist gist = store.refreshGist(id);
    List<Comment> comments;
    if (gist.getComments() > 0)
        comments = service.getComments(id);
    else
        comments = Collections.emptyList();
    for (Comment comment : comments) {
        String formatted = HtmlUtils.format(comment.getBodyHtml())
                .toString();
        comment.setBodyHtml(formatted);
        imageGetter.encode(comment, formatted);
    }
    return new FullGist(gist, service.isStarred(id), comments);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:17,代码来源:RefreshGistTask.java


示例10: uploadGist

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
public void uploadGist(Gist gist, GistCorrelationStrategy correlationStrategy) throws IOException {
Gist correlatedGist = correlationStrategy.correlate(gist, getGists());

if (correlatedGist != null) {
          if (comparator.isUpdateNeeded(gist, correlatedGist)) {
              log.debug("Updating existent gist");
              gist.setId(correlatedGist.getId());
              service.updateGist(gist);
          } else {
              log.debug("No update required");
          }
} else {
          log.debug("Creating new gist");
          service.createGist(gist);
}

  }
 
开发者ID:vromero,项目名称:gist-maven-plugin,代码行数:18,代码来源:GistUploader.java


示例11: correlate

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
/**
    * Correlate against the userGists the given gist using the description field
    * @param gist the gist to correlate
    * @param userGists list of gists to be iterated
    * @return gist correlated or null if not found
    */
@Override
   public Gist correlate(Gist gist, List<Gist> userGists) {

       if (gist == null) {
           throw new IllegalArgumentException("gist cannot be null");
       } else if (userGists == null) {
           throw new IllegalArgumentException("user gists cannot be null");
       }

       checkForDescriptionUniqueness(userGists);
       for (Gist candidate : userGists) {
		if (candidate.getDescription().equals(gist.getDescription())) {
			return candidate;
		}
	}
	
	return null;
}
 
开发者ID:vromero,项目名称:gist-maven-plugin,代码行数:25,代码来源:DescriptionGistCorrelationStrategy.java


示例12: fileSizeDifferTest

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
@Test
public void fileSizeDifferTest() {
    org.eclipse.egit.github.core.Gist original = new org.eclipse.egit.github.core.Gist();
    Gist candidate = new Gist();

    original.setDescription("QWERTY");
    candidate.setDescription("QWERTY");

    GistFile originalFile = new GistFile();
    Map<String, GistFile> originalFiles = new HashMap<String, GistFile>();
    originalFiles.put("asdf.txt", originalFile);
    original.setFiles(originalFiles);

    candidate.setFiles(new HashMap<String, GistFile>());

    Assert.assertTrue(comparator.isUpdateNeeded(original, candidate));
}
 
开发者ID:vromero,项目名称:gist-maven-plugin,代码行数:18,代码来源:GistContentComparatorTest.java


示例13: fileNameDifferTest

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
@Test
public void fileNameDifferTest() {
    org.eclipse.egit.github.core.Gist original = new org.eclipse.egit.github.core.Gist();
    Gist candidate = new Gist();

    original.setDescription("QWERTY");
    candidate.setDescription("QWERTY");

    GistFile originalFile = new GistFile();
    Map<String, GistFile> originalFiles = new HashMap<String, GistFile>();
    originalFiles.put("asdf.txt", originalFile);
    original.setFiles(originalFiles);

    GistFile candidateFile = new GistFile();
    Map<String, GistFile> candidateFiles = new HashMap<String, GistFile>();
    candidateFiles.put("zxcv.txt", candidateFile);
    candidate.setFiles(candidateFiles);

    Assert.assertTrue(comparator.isUpdateNeeded(original, candidate));
}
 
开发者ID:vromero,项目名称:gist-maven-plugin,代码行数:21,代码来源:GistContentComparatorTest.java


示例14: fileContentDifferTest

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
@Test
public void fileContentDifferTest() {
    org.eclipse.egit.github.core.Gist original = new org.eclipse.egit.github.core.Gist();
    Gist candidate = new Gist();

    original.setDescription("QWERTY");
    candidate.setDescription("QWERTY");

    GistFile originalFile = new GistFile();
    originalFile.setContent("asdf");
    Map<String, GistFile> originalFiles = new HashMap<String, GistFile>();
    originalFiles.put("asdf.txt", originalFile);
    original.setFiles(originalFiles);

    GistFile candidateFile = new GistFile();
    candidateFile.setContent("zxcv");
    Map<String, GistFile> candidateFiles = new HashMap<String, GistFile>();
    candidateFiles.put("asdf.txt", candidateFile);
    candidate.setFiles(candidateFiles);

    Assert.assertTrue(comparator.isUpdateNeeded(original, candidate));
}
 
开发者ID:vromero,项目名称:gist-maven-plugin,代码行数:23,代码来源:GistContentComparatorTest.java


示例15: nothingDiffersTest

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
@Test
public void nothingDiffersTest() {
    org.eclipse.egit.github.core.Gist original = new org.eclipse.egit.github.core.Gist();
    Gist candidate = new Gist();

    original.setDescription("QWERTY");
    candidate.setDescription("QWERTY");

    GistFile originalFile = new GistFile();
    originalFile.setContent("asdf");
    Map<String, GistFile> originalFiles = new HashMap<String, GistFile>();
    originalFiles.put("asdf.txt", originalFile);
    original.setFiles(originalFiles);

    GistFile candidateFile = new GistFile();
    candidateFile.setContent("asdf");
    Map<String, GistFile> candidateFiles = new HashMap<String, GistFile>();
    candidateFiles.put("asdf.txt", candidateFile);
    candidate.setFiles(candidateFiles);

    Assert.assertFalse(comparator.isUpdateNeeded(original, candidate));
}
 
开发者ID:vromero,项目名称:gist-maven-plugin,代码行数:23,代码来源:GistContentComparatorTest.java


示例16: testGistOnValidCorrelation

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
@Test
public void testGistOnValidCorrelation() {
    Gist candidate = new Gist();
    candidate.setDescription("valid description");

    Gist element1 = new Gist();
    element1.setId("element1");
    element1.setDescription("different description");

    Gist element2 = new Gist();
    element2.setId("element2");
    element2.setDescription("valid description");

    List<Gist> userGists = new ArrayList<Gist>();
    userGists.add(element1);
    userGists.add(element2);

    Gist correlated = strategy.correlate(candidate, userGists);

    Assert.assertNotNull(correlated);
    assertThat(correlated, instanceOf(Gist.class));
    assertThat(correlated.getId(), is(element2.getId()));
}
 
开发者ID:vromero,项目名称:gist-maven-plugin,代码行数:24,代码来源:DescriptionGistCorrelationStrategyTest.java


示例17: createUserGistRequest

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
/**
 * Create user gist paged request
 *
 * @param user
 * @param start
 * @param size
 * @return request
 */
protected PagedRequest<Gist> createUserGistRequest(String user, int start,
		int size) {
	if (user == null)
		throw new IllegalArgumentException("User cannot be null"); //$NON-NLS-1$
	if (user.length() == 0)
		throw new IllegalArgumentException("User cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder(SEGMENT_USERS);
	uri.append('/').append(user);
	uri.append(SEGMENT_GISTS);
	PagedRequest<Gist> request = createPagedRequest(start, size);
	request.setUri(uri).setType(new TypeToken<List<Gist>>() {
	}.getType());
	return request;
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:24,代码来源:GistService.java


示例18: createPager

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
@Override
protected ResourcePager<Gist> createPager() {
    return new GistPager(store) {

        @Override
        public PageIterator<Gist> createIterator(int page, int size) {
            return service.pageGists(accountProvider.get().getUsername(),
                    page, size);
        }
    };
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:12,代码来源:MyGistsFragment.java


示例19: run

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
@Override
public Gist run(Account account) throws Exception {
    Gist gist = new Gist();
    gist.setDescription(description);
    gist.setPublic(isPublic);

    GistFile file = new GistFile();
    file.setContent(content);
    file.setFilename(name);
    gist.setFiles(Collections.singletonMap(name, file));

    return service.createGist(gist);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:14,代码来源:CreateGistTask.java


示例20: updateList

import org.eclipse.egit.github.core.Gist; //导入依赖的package包/类
private void updateList(Gist gist, List<Comment> comments) {
    adapter.getWrappedAdapter().setItems(
            comments.toArray(new Comment[comments.size()]));
    adapter.removeHeader(loadingView);

    headerView.setVisibility(VISIBLE);
    updateHeader(gist);

    updateFiles(gist);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:11,代码来源:GistFragment.java



注:本文中的org.eclipse.egit.github.core.Gist类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GetCallerIdentityRequest类代码示例发布时间:2022-05-22
下一篇:
Java RenderingAttributes类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap