use of org.eclipse.egit.github.core.User in project maven-plugins by apache.
the class GitHubDownloaderTestCase method testCreateIssue.
public void testCreateIssue() throws IOException {
IssueManagement issueManagement = newGitHubIssueManagement();
GitHubDownloader gitHubDownloader = newGitHubDownloader(issueManagement);
org.eclipse.egit.github.core.Issue githubIssue = new org.eclipse.egit.github.core.Issue();
githubIssue.setNumber(1);
githubIssue.setBody("Body");
githubIssue.setTitle("Title");
User user = new User();
githubIssue.setUser(user);
Issue issue = gitHubDownloader.createIssue(githubIssue);
assertEquals(Integer.toString(githubIssue.getNumber()), issue.getId());
assertEquals(Integer.toString(githubIssue.getNumber()), issue.getKey());
assertEquals(githubIssue.getTitle(), issue.getTitle());
assertEquals(githubIssue.getTitle(), issue.getSummary());
assertEquals(issueManagement.getUrl() + githubIssue.getNumber(), issue.getLink());
}
use of org.eclipse.egit.github.core.User in project camel by apache.
the class MockCommitService method addRepositoryCommit.
public synchronized RepositoryCommit addRepositoryCommit() {
User author = new User();
// TODO change
author.setEmail("someguy@gmail.com");
author.setHtmlUrl("http://github/someguy");
author.setLogin("someguy");
RepositoryCommit rc = new RepositoryCommit();
rc.setAuthor(author);
rc.setSha(fakeSha.incrementAndGet() + "");
LOG.debug("In MockCommitService added commit with sha " + rc.getSha());
commitsList.add(rc);
return rc;
}
use of org.eclipse.egit.github.core.User in project camel by apache.
the class MockPullRequestService method addComment.
public CommitComment addComment(Long pullRequestId, String bodyText) {
CommitComment commitComment = new CommitComment();
User author = createAuthor();
commitComment.setUser(author);
commitComment.setCommitId("" + pullRequestId);
commitComment.setId(commentId.getAndIncrement());
commitComment.setBody(bodyText);
commitComment.setBodyText(bodyText);
List<CommitComment> comments;
if (allComments.containsKey(pullRequestId)) {
comments = allComments.get(pullRequestId);
} else {
comments = new ArrayList<CommitComment>();
}
comments.add(commitComment);
allComments.put(pullRequestId, comments);
return commitComment;
}
use of org.eclipse.egit.github.core.User in project hubroid by EddieRingle.
the class BaseDashboardActivity method onCreate.
@Override
protected void onCreate(Bundle icicle, int layout) {
super.onCreate(icicle, layout);
if (icicle != null) {
mShowingDash = icicle.getBoolean(EXTRA_SHOWING_DASH, false);
}
mDrawerGarment = new DrawerGarment(this, R.layout.dashboard);
mDrawerGarment.setDrawerMaxWidth(Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics())));
mDrawerGarment.setSlideTarget(DrawerGarment.SLIDE_TARGET_CONTENT);
mDrawerGarment.setDrawerCallbacks(new DrawerGarment.IDrawerCallbacks() {
@Override
public void onDrawerOpened() {
mShowingDash = true;
supportInvalidateOptionsMenu();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public void onDrawerClosed() {
if (mTargetIntent == null) {
mShowingDash = false;
supportInvalidateOptionsMenu();
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
} else {
startActivity(mTargetIntent);
overridePendingTransition(0, 0);
finish();
}
}
});
if (getIntent() != null) {
mFromDashboard = getIntent().getBooleanExtra(ARG_FROM_DASHBOARD, false);
if (!mFromDashboard) {
getDrawerGarment().setDrawerEnabled(false);
mShowingDash = false;
} else if (getIntent().hasExtra(EXTRA_SHOWING_DASH)) {
mShowingDash = getIntent().getBooleanExtra(EXTRA_SHOWING_DASH, mShowingDash);
}
}
mTargetIntent = null;
final ArrayList<DashboardListAdapter.DashboardEntry> dashboardEntries = new ArrayList<DashboardListAdapter.DashboardEntry>();
DashboardListAdapter.DashboardEntry entry = new DashboardListAdapter.DashboardEntry();
entry.label = getString(R.string.dash_events);
entry.icon = (new OcticonView(this)).setOcticon(OcticonView.IC_FEED).setGlyphColor(Color.parseColor("#2c2c2c")).setGlyphSize(72.0f).toDrawable();
entry.selected = false;
if (this instanceof EventsActivity) {
entry.selected = true;
}
entry.onEntryClickListener = new DashboardListAdapter.DashboardEntry.OnEntryClickListener() {
@Override
public void onClick(DashboardListAdapter.DashboardEntry entry, int i) {
final Intent eventsIntent = new Intent(BaseDashboardActivity.this, EventsActivity.class);
eventsIntent.setFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_NEW_TASK);
eventsIntent.putExtra(ARG_FROM_DASHBOARD, true);
eventsIntent.putExtra(ARG_TARGET_USER, GsonUtils.toJson(new User().setLogin(getCurrentContextLogin())));
eventsIntent.putExtra(ARG_EVENT_LIST_TYPE, LIST_USER_PRIVATE);
mTargetIntent = eventsIntent;
getDrawerGarment().closeDrawer();
}
};
dashboardEntries.add(entry);
entry = new DashboardListAdapter.DashboardEntry();
entry.label = getString(R.string.dash_profile);
entry.icon = (new OcticonView(this)).setOcticon(OcticonView.IC_PERSON).setGlyphColor(Color.parseColor("#2c2c2c")).setGlyphSize(72.0f).toDrawable();
entry.selected = false;
if (this instanceof ProfileActivity) {
entry.selected = true;
}
entry.onEntryClickListener = new DashboardListAdapter.DashboardEntry.OnEntryClickListener() {
@Override
public void onClick(DashboardListAdapter.DashboardEntry entry, int i) {
final Intent profileIntent = new Intent(BaseDashboardActivity.this, ProfileActivity.class);
profileIntent.setFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_NEW_TASK);
profileIntent.putExtra(ARG_FROM_DASHBOARD, true);
profileIntent.putExtra(ARG_TARGET_USER, GsonUtils.toJson(new User().setLogin(getCurrentContextLogin())));
mTargetIntent = profileIntent;
getDrawerGarment().closeDrawer();
}
};
dashboardEntries.add(entry);
mDashboardListAdapter = new DashboardListAdapter(this);
mDashboardListAdapter.fillWithItems(dashboardEntries);
final LinearLayout headerLayout = (LinearLayout) getLayoutInflater().inflate(R.layout.dashboard_account_header, null);
mContextSpinner = (Spinner) headerLayout.findViewById(R.id.context_spinner);
mContextSpinner.setEnabled(false);
mOnContextItemSelectedListener = new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
if (mReadyForContext) {
/* Remove the listener so we don't handle any more events */
mContextSpinner.setOnItemSelectedListener(null);
/*
* Reboot the app with the new context loaded
*/
final User target = mContextListAdapter.getItem(i);
setCurrentContextLogin(target.getLogin());
final Intent rebootIntent = new Intent(BaseDashboardActivity.this, HomeActivity.class);
rebootIntent.setFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_NEW_TASK);
startActivity(rebootIntent);
finish();
} else {
mReadyForContext = true;
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
};
mDashboardListView = (ListView) mDrawerGarment.findViewById(R.id.list);
if (isLoggedIn()) {
mDashboardListView.addHeaderView(headerLayout);
}
mDashboardListView.setAdapter(mDashboardListAdapter);
mDashboardListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (isLoggedIn()) {
if (i == 0) {
return;
} else {
i--;
}
}
final DashboardListAdapter.DashboardEntry entry = mDashboardListAdapter.getItem(i);
if (entry != null) {
if (entry.onEntryClickListener != null) {
entry.onEntryClickListener.onClick(entry, i);
}
}
}
});
if (isLoggedIn()) {
final IntentFilter contextFilter = new IntentFilter(ACTION_ORGS_SELF_MEMBERSHIPS);
registerReceiver(mContextReceiver, contextFilter);
if (icicle == null) {
final Intent getContextsIntent = new Intent(this, GitHubApiService.class);
getContextsIntent.setAction(ACTION_ORGS_SELF_MEMBERSHIPS);
getContextsIntent.putExtra(ARG_ACCOUNT, getCurrentUserAccount());
startService(getContextsIntent);
} else {
if (icicle.containsKey(EXTRA_CONTEXTS)) {
final String contextsJson = icicle.getString(EXTRA_CONTEXTS);
if (contextsJson != null) {
TypeToken<List<User>> token = new TypeToken<List<User>>() {
};
List<User> contexts = GsonUtils.fromJson(contextsJson, token.getType());
/*
* Loop through the list of users/organizations to find the
* current context the user is browsing as and rearrange the
* list so that it's at the top.
*/
int len = contexts.size();
for (int i = 0; i < len; i++) {
if (contexts.get(i).getLogin().equals(getCurrentContextLogin())) {
Collections.swap(contexts, i, 0);
break;
}
}
mContextListAdapter = new ContextListAdapter(BaseDashboardActivity.this);
mContextListAdapter.fillWithItems(contexts);
mContextSpinner.setAdapter(mContextListAdapter);
mContextSpinner.setOnItemSelectedListener(mOnContextItemSelectedListener);
mContextSpinner.setEnabled(true);
}
}
}
}
}
use of org.eclipse.egit.github.core.User in project hubroid by EddieRingle.
the class UserListFragment method onItemClick.
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
/*
* Send the user off to the Profile activity
*/
final User target = getListAdapter().getWrappedAdapter().getItem(position);
final Bundle args = new Bundle();
args.putString(ARG_TARGET_USER, GsonUtils.toJson(target));
final Intent startProfile = new Intent(getBaseActivity(), ProfileActivity.class);
startProfile.putExtras(args);
getBaseActivity().startActivity(startProfile);
}
Aggregations