Skip to content

Commit

Permalink
Add ACTION_REPOS_GET_REPO action to GitHubApiService
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Ringle <eddie@eringle.net>
  • Loading branch information
EddieRingle committed Sep 2, 2012
1 parent 90be0c3 commit 7b3c3fc
Showing 1 changed file with 24 additions and 0 deletions.
Expand Up @@ -71,6 +71,8 @@ public class GitHubApiService extends IntentService {

public static final String ACTION_ORGS_USER_MEMBERSHIPS = "action_orgs_user_memberships";

public static final String ACTION_REPOS_GET_REPO = "action_repos_get_repo";

public static final String ACTION_REPOS_LIST_ORG_OWNED = "action_repos_list_org_owned";

public static final String ACTION_REPOS_LIST_SELF_OWNED = "action_repos_list_self_owned";
Expand Down Expand Up @@ -109,6 +111,10 @@ public class GitHubApiService extends IntentService {

public static final String PARAM_LOGIN = "param_login";

public static final String PARAM_REPO_OWNER = "param_repo_owner";

public static final String PARAM_REPO_NAME = "param_repo_name";

public static final String USER_AGENT = "Hubroid/GitHubJava";

private static String sApiHostname = HOST_API;
Expand Down Expand Up @@ -291,6 +297,24 @@ protected void onHandleIntent(Intent intent) {
resultIntent.putExtra(EXTRA_ERROR, true);
}
sendBroadcast(resultIntent);
} else if (intent.getAction().equals(ACTION_REPOS_GET_REPO)) {
final RepositoryService rs = new RepositoryService(mGitHubClient);
Repository result;
try {
result = rs.getRepository(intent.getStringExtra(PARAM_REPO_OWNER),
intent.getStringExtra(PARAM_REPO_NAME));
} catch (IOException e) {
result = null;
e.printStackTrace();
}

final Intent resultIntent = new Intent(ACTION_REPOS_GET_REPO);
if (result != null) {
resultIntent.putExtra(EXTRA_RESULT_JSON, GsonUtils.toJson(result));
} else {
resultIntent.putExtra(EXTRA_ERROR, true);
}
sendBroadcast(resultIntent);
} else if (intent.getAction().equals(ACTION_REPOS_LIST_ORG_OWNED)) {
final RepositoryService rs = new RepositoryService(mGitHubClient);
ArrayList<Repository> result = null;
Expand Down

0 comments on commit 7b3c3fc

Please sign in to comment.