本文整理汇总了Java中org.eclipse.egit.github.core.Gist类的典型用法代码示例。如果您正苦于以下问题:Java Gist类的具体用法?Java Gist怎么用?Java Gist使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Gist类属于org.eclipse.egit.github.core包,在下文中一共展示了Gist类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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();
}
示例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();
}
示例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());
}
示例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());
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}