use of com.meisolsson.githubsdk.model.Gist in project PocketHub by pockethub.
the class GistsViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pager);
gists = getStringArrayExtra(EXTRA_GIST_IDS);
gist = getParcelableExtra(EXTRA_GIST);
initialPosition = getIntExtra(EXTRA_POSITION);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// in the intent but not currently present in the store
if (gists == null && gist != null) {
if (gist.createdAt() != null) {
Gist stored = store.getGist(gist.id());
if (stored == null) {
store.addGist(gist);
}
}
gists = new String[] { gist.id() };
}
adapter = new GistsPagerAdapter(this, gists);
pager.setAdapter(adapter);
pager.addOnPageChangeListener(this);
pager.scheduleSetItem(initialPosition, this);
onPageSelected(initialPosition);
}
use of com.meisolsson.githubsdk.model.Gist in project PocketHub by pockethub.
the class GistsViewActivity method createIntent.
/**
* Create an intent to show gists with an initial selected Gist
*
* @param items
* @param position
* @return intent
*/
public static Intent createIntent(List<Item> items, int position) {
String[] ids = new String[items.size()];
int index = 0;
for (Item item : items) {
Gist gist = ((GistItem) item).getGist();
ids[index++] = gist.id();
}
return new Builder("gists.VIEW").add(EXTRA_GIST_IDS, (Serializable) ids).add(EXTRA_POSITION, position).toIntent();
}
use of com.meisolsson.githubsdk.model.Gist in project PocketHub by pockethub.
the class GistUriMatcherTest method testPublicGist.
/**
* Verify public Gist id
*/
public void testPublicGist() {
Gist gist = GistUriMatcher.getGist(Uri.parse("https://gist.github.com/1234"));
assertNotNull(gist);
assertEquals("1234", gist.id());
}
use of com.meisolsson.githubsdk.model.Gist in project PocketHub by pockethub.
the class GistUriMatcherTest method testPrivateGist.
/**
* Verify public Gist id
*/
public void testPrivateGist() {
Gist gist = GistUriMatcher.getGist(Uri.parse("https://gist.github.com/abcd1234abcd1234abcd"));
assertNotNull(gist);
assertEquals("abcd1234abcd1234abcd", gist.id());
}
use of com.meisolsson.githubsdk.model.Gist 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);
}
}
Aggregations