Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to GitHubSdk 0.5 #1158

Merged
merged 9 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ dependencies {
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

implementation 'com.github.meisolsson:githubsdk:0.4.5'
implementation 'com.github.meisolsson:githubsdk:0.5.1'
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
implementation 'com.xwray:groupie:2.0.3'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.meisolsson.githubsdk.model.GitHubEvent;
import com.meisolsson.githubsdk.model.GitHubEventType;
import com.meisolsson.githubsdk.model.Issue;
import com.meisolsson.githubsdk.model.ReferenceType;
import com.meisolsson.githubsdk.model.Repository;
import com.meisolsson.githubsdk.model.Team;
import com.meisolsson.githubsdk.model.User;
Expand Down Expand Up @@ -59,7 +60,7 @@ public class NewsEventTextTest extends InstrumentationTestCase {

private User actor;

private Repository repo;
private GitHubEvent.RepoIdentifier repo;

private AvatarLoader avatarLoader;

Expand All @@ -70,7 +71,10 @@ protected void setUp() throws Exception {
super.setUp();

actor = User.builder().login("user").build();
repo = Repository.builder().name("user/repo").build();
repo = GitHubEvent.RepoIdentifier.builder()
.repoWithUserName("user/repo")
.build();

Context context = getInstrumentation().getTargetContext();
avatarLoader = new AvatarLoader(context);
layoutInflater = LayoutInflater.from(context);
Expand Down Expand Up @@ -100,7 +104,7 @@ private void updateView(GitHubEvent event) {
NewsItem.ViewHolder viewHolder = item.createViewHolder(itemView);
item.bind(viewHolder, 0);

text = viewHolder.event;
text = viewHolder.getEvent();
assertNotNull(text);
}

Expand All @@ -122,7 +126,7 @@ public void testCommitCommentEvent() {
@UiThreadTest
public void testCreateRepositoryEvent() {
CreatePayload payload = CreatePayload.builder()
.refType("repository")
.refType(ReferenceType.Repository)
.build();

GitHubEvent event = createEvent(GitHubEventType.CreateEvent, payload);
Expand All @@ -137,7 +141,7 @@ public void testCreateRepositoryEvent() {
@UiThreadTest
public void testCreateBranchEvent() {
CreatePayload payload = CreatePayload.builder()
.refType("branch")
.refType(ReferenceType.Branch)
.ref("b1")
.build();

Expand All @@ -153,7 +157,7 @@ public void testCreateBranchEvent() {
@UiThreadTest
public void testDelete() {
DeletePayload payload = DeletePayload.builder()
.refType("branch")
.refType(ReferenceType.Branch)
.ref("b1")
.build();

Expand Down Expand Up @@ -192,7 +196,7 @@ public void testGist() {
.build();

GistPayload payload = GistPayload.builder()
.action("create")
.action(GistPayload.Action.Created)
.gist(gist)
.build();

Expand Down Expand Up @@ -242,7 +246,7 @@ public void testIssue() {
.build();

IssuesPayload payload = IssuesPayload.builder()
.action("closed")
.action(IssuesPayload.Action.Closed)
.issue(issue)
.build();

Expand Down Expand Up @@ -300,13 +304,13 @@ public void testWatch() {
public void testPullRequest() {
PullRequestPayload payload = PullRequestPayload.builder()
.number(30)
.action("merged")
.action(PullRequestPayload.Action.Closed)
.build();

GitHubEvent event = createEvent(GitHubEventType.PullRequestEvent, payload);
updateView(event);

verify("user merged pull request 30 on user/repo");
verify("user closed pull request 30 on user/repo");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public void testHttpUri() {
CommitMatch commit = CommitUriMatcher.getCommit(Uri
.parse("https://github.com/defunkt/resque/commit/abcd"));
assertNotNull(commit);
assertEquals("abcd", commit.commit);
assertNotNull(commit.repository);
assertEquals("resque", commit.repository.name());
assertNotNull(commit.repository.owner());
assertEquals("defunkt", commit.repository.owner().login());
assertEquals("abcd", commit.getCommit());
assertNotNull(commit.getRepository());
assertEquals("resque", commit.getRepository().name());
assertNotNull(commit.getRepository().owner());
assertEquals("defunkt", commit.getRepository().owner().login());
}

/**
Expand All @@ -62,11 +62,11 @@ public void testHttpsUri() {
CommitMatch commit = CommitUriMatcher.getCommit(Uri
.parse("https://github.com/defunkt/resque/commit/1234"));
assertNotNull(commit);
assertEquals("1234", commit.commit);
assertNotNull(commit.repository);
assertEquals("resque", commit.repository.name());
assertNotNull(commit.repository.owner());
assertEquals("defunkt", commit.repository.owner().login());
assertEquals("1234", commit.getCommit());
assertNotNull(commit.getRepository());
assertEquals("resque", commit.getRepository().name());
assertNotNull(commit.getRepository().owner());
assertEquals("defunkt", commit.getRepository().owner().login());
}

/**
Expand All @@ -77,10 +77,10 @@ public void testCommentUri() {
.getCommit(Uri
.parse("https://github.com/defunkt/resque/commit/a1b2#commitcomment-1605701"));
assertNotNull(commit);
assertEquals("a1b2", commit.commit);
assertNotNull(commit.repository);
assertEquals("resque", commit.repository.name());
assertNotNull(commit.repository.owner());
assertEquals("defunkt", commit.repository.owner().login());
assertEquals("a1b2", commit.getCommit());
assertNotNull(commit.getRepository());
assertEquals("resque", commit.getRepository().name());
assertNotNull(commit.getRepository().owner());
assertEquals("defunkt", commit.getRepository().owner().login());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void testEqualFilter() {
assertEquals(filter1.hashCode(), filter2.hashCode());

User user = User.builder()
.id(2)
.id(2L)
.build();

filter1.setAssignee(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class RecentRepositoriesTest extends AndroidTestCase {
*/
public void testBadInput() {
User org = User.builder()
.id(20)
.id(20L)
.build();

RecentRepositories recent = new RecentRepositories(getContext(), org);
Expand All @@ -45,7 +45,7 @@ public void testBadInput() {
*/
public void testMaxReached() {
User org = User.builder()
.id(20)
.id(20L)
.build();

RecentRepositories recent = new RecentRepositories(getContext(), org);
Expand All @@ -69,7 +69,7 @@ public void testMaxReached() {
*/
public void testIO() {
User org = User.builder()
.id(20)
.id(20L)
.build();

RecentRepositories recent1 = new RecentRepositories(getContext(), org);
Expand All @@ -86,7 +86,7 @@ public void testIO() {
*/
public void testScopedStorage() {
User org1 = User.builder()
.id(20)
.id(20L)
.build();

RecentRepositories recent1 = new RecentRepositories(getContext(), org1);
Expand All @@ -95,7 +95,7 @@ public void testScopedStorage() {
assertTrue(recent1.contains(id1));

User org2 = User.builder()
.id(40)
.id(40L)
.build();

RecentRepositories recent2 = new RecentRepositories(getContext(), org2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private void add(final GitTreeEntry entry) {
return;
}

if (entry.type() == GitEntryType.blob) {
if (entry.type() == GitEntryType.Blob) {
String[] segments = path.split("/");
if (segments.length > 1) {
Folder folder = folders.get(segments[0]);
Expand All @@ -141,7 +141,7 @@ private void add(final GitTreeEntry entry) {
Entry file = new Entry(entry, this);
files.put(file.name, file);
}
} else if (entry.type() == GitEntryType.tree) {
} else if (entry.type() == GitEntryType.Tree) {
String[] segments = path.split("/");
if (segments.length > 1) {
Folder folder = folders.get(segments[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
import com.meisolsson.githubsdk.model.Repository;
import com.meisolsson.githubsdk.model.payload.ForkPayload;

import static com.meisolsson.githubsdk.model.GitHubEventType.*;
import static com.meisolsson.githubsdk.model.GitHubEventType.CreateEvent;
import static com.meisolsson.githubsdk.model.GitHubEventType.ForkEvent;
import static com.meisolsson.githubsdk.model.GitHubEventType.PublicEvent;
import static com.meisolsson.githubsdk.model.GitHubEventType.WatchEvent;

/**
* Helper to find a {@link RepositoryEventMatcher} to open for an event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
import com.meisolsson.githubsdk.model.User;
import com.meisolsson.githubsdk.service.activity.WatchingService;
import com.meisolsson.githubsdk.service.repositories.RepositoryService;
import javax.inject.Inject;
import javax.inject.Provider;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import javax.inject.Provider;

import retrofit2.Response;

/**
Expand Down Expand Up @@ -80,15 +80,15 @@ public Cursor getCursor(SQLiteDatabase readableDatabase) {
"repos.watchers", "repos.language", "repos.hasIssues", "repos.mirrorUrl",
"repos.permissions_admin", "repos.permissions_pull", "repos.permissions_push" },
"repos.orgId=?",
new String[] { Integer.toString(org.id()) }, null, null,
new String[] { Integer.toString(org.id().intValue()) }, null, null,
null);
}

@Override
public Repository loadFrom(Cursor cursor) {
User owner = User.builder()
.login(cursor.getString(3))
.id(cursor.getInt(2))
.id(cursor.getLong(2))
.avatarUrl(cursor.getString(4))
.build();

Expand Down Expand Up @@ -117,7 +117,7 @@ public Repository loadFrom(Cursor cursor) {
@Override
public void store(SQLiteDatabase db, List<Repository> repos) {
db.delete("repos", "orgId=?",
new String[] { Integer.toString(org.id()) });
new String[] { Integer.toString(org.id().intValue()) });
if (repos.isEmpty()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
import com.meisolsson.githubsdk.model.User;
import com.meisolsson.githubsdk.service.organizations.OrganizationService;
import com.meisolsson.githubsdk.service.users.UserService;
import javax.inject.Inject;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

/**
* Cache of organization under an account
*/
Expand Down Expand Up @@ -62,7 +63,7 @@ public Cursor getCursor(SQLiteDatabase readableDatabase) {
@Override
public User loadFrom(Cursor cursor) {
return User.builder()
.id(cursor.getInt(0))
.id(cursor.getLong(0))
.login(cursor.getString(1))
.avatarUrl(cursor.getString(2))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.IntentCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -66,15 +64,16 @@
import com.github.pockethub.android.util.ToastUtils;
import com.meisolsson.githubsdk.core.TokenStore;
import com.meisolsson.githubsdk.model.User;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;

import butterknife.BindView;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
Expand Down Expand Up @@ -286,8 +285,8 @@ private void setUpNavigationMenu() {
SubMenu organizationsMenu = organizationContainer.getSubMenu();
for (int i = 1; i < orgs.size(); i++) {
User organization = orgs.get(i);
if (organizationsMenu.findItem(organization.id()) == null) {
MenuItem organizationMenuItem = organizationsMenu.add(Menu.NONE, organization.id(), Menu.NONE, organization.name() != null ? organization.name() : organization.login());
if (organizationsMenu.findItem(organization.id().intValue()) == null) {
MenuItem organizationMenuItem = organizationsMenu.add(Menu.NONE, organization.id().intValue(), Menu.NONE, organization.name() != null ? organization.name() : organization.login());
organizationMenuItem.setIcon(R.drawable.ic_github_organization_black_24dp);
//Because of tinting the real image would became a grey block
//avatars.bind(organizationMenuItem, organization);
Expand Down
Loading