Skip to content

Commit

Permalink
Support navigating up from IssuesViewActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsawicki committed Jan 21, 2013
1 parent ae07443 commit 8ccee48
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.github.mobile.ui.issue;

import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
import static com.github.mobile.Intents.EXTRA_ISSUE_NUMBERS;
import static com.github.mobile.Intents.EXTRA_POSITION;
import static com.github.mobile.Intents.EXTRA_REPOSITORIES;
Expand All @@ -23,6 +25,7 @@
import android.os.Bundle;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.MenuItem;
import com.github.mobile.Intents.Builder;
import com.github.mobile.R.id;
import com.github.mobile.R.layout;
Expand All @@ -34,6 +37,7 @@
import com.github.mobile.ui.PagerActivity;
import com.github.mobile.ui.UrlLauncher;
import com.github.mobile.ui.ViewPager;
import com.github.mobile.ui.repo.RepositoryViewActivity;
import com.github.mobile.util.AvatarLoader;
import com.google.inject.Inject;

Expand Down Expand Up @@ -172,6 +176,7 @@ public static Intent createIntent(Collection<? extends Issue> issues,
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

getSupportActionBar().setDisplayHomeAsUpEnabled(true);
issueNumbers = getIntArrayExtra(EXTRA_ISSUE_NUMBERS);
pullRequests = getBooleanArrayExtra(EXTRA_PULL_REQUESTS);
repoIds = getSerializableExtra(EXTRA_REPOSITORIES);
Expand Down Expand Up @@ -282,4 +287,31 @@ public void startActivity(Intent intent) {
protected FragmentProvider getProvider() {
return adapter;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Repository repository = repo;
if (repository == null) {
int position = pager.getCurrentItem();
RepositoryId repoId = repoIds.get(position);
if (repoId != null) {
RepositoryIssue issue = store.getIssue(repoId,
issueNumbers[position]);
if (issue != null)
repository = issue.getRepository();
}
}
if (repository != null) {
Intent intent = RepositoryViewActivity.createIntent(repository);
intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP
| FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

0 comments on commit 8ccee48

Please sign in to comment.