/** * Attempt to parse a {@link User} from the given {@link Uri} * * @param uri * @return {@link User} or null if unparseable */ public static User getUser(Uri uri) { List<String> segments = uri.getPathSegments(); if (segments == null) return null; if (segments.size() != 1) return null; String login = segments.get(0); if (!RepositoryUtils.isValidOwner(login)) return null; return new User().setLogin(login); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); User owner = repository.getOwner(); ActionBar actionBar = getSupportActionBar(); actionBar.setTitle(repository.getName()); actionBar.setSubtitle(owner.getLogin()); actionBar.setDisplayHomeAsUpEnabled(true); if (owner.getAvatarUrl() != null && RepositoryUtils.isComplete(repository)) configurePager(); else { avatars.bind(getSupportActionBar(), owner); ViewUtils.setGone(loadingBar, false); setGone(true); new RefreshRepositoryTask(this, repository) { @Override protected void onSuccess(Repository fullRepository) throws Exception { super.onSuccess(fullRepository); repository = fullRepository; configurePager(); } @Override protected void onException(Exception e) throws RuntimeException { super.onException(e); ToastUtils.show(RepositoryViewActivity.this, string.error_repo_load); ViewUtils.setGone(loadingBar, true); } }.execute(); } }