use of com.meisolsson.githubsdk.model.User in project PocketHub by pockethub.
the class PagedUserFragment method onListItemClick.
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
User user = (User) l.getItemAtPosition(position);
startActivity(UserViewActivity.createIntent(user));
}
use of com.meisolsson.githubsdk.model.User in project PocketHub by pockethub.
the class UserNewsFragment method viewRepository.
@Override
protected void viewRepository(Repository repository) {
User owner = repository.owner();
if (owner != null && org.login().equals(owner.login())) {
repository = repository.toBuilder().owner(org).build();
}
super.viewRepository(repository);
}
use of com.meisolsson.githubsdk.model.User in project PocketHub by pockethub.
the class UserViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
user = getIntent().getParcelableExtra(EXTRA_USER);
loadingBar = finder.find(R.id.pb_loading);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(user.login());
if (!TextUtils.isEmpty(user.avatarUrl())) {
configurePager();
} else {
ViewUtils.setGone(loadingBar, false);
setGone(true);
ServiceGenerator.createService(this, UserService.class).getUser(user.login()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).compose(this.<User>bindToLifecycle()).subscribe(new ObserverAdapter<User>() {
@Override
public void onSuccess(User fullUser) {
user = fullUser;
configurePager();
}
@Override
public void onError(Throwable e) {
ToastUtils.show(UserViewActivity.this, R.string.error_person_load);
ViewUtils.setGone(loadingBar, true);
}
});
}
}
use of com.meisolsson.githubsdk.model.User in project PocketHub by pockethub.
the class AvatarLoader method bind.
/**
* Sets the logo on the {@link ActionBar} to the user's avatar.
*
* @param actionBar An ActionBar object on which you're placing the user's avatar.
* @param userReference An AtomicReference that points to the desired user.
* @return this helper
*/
public void bind(final ActionBar actionBar, final AtomicReference<User> userReference) {
if (userReference == null) {
return;
}
final User user = userReference.get();
if (user == null) {
return;
}
String avatarUrl = user.avatarUrl();
if (TextUtils.isEmpty(avatarUrl)) {
return;
}
// Remove the URL params as they are not needed and break cache
if (avatarUrl.contains("?") && !avatarUrl.contains("gravatar")) {
avatarUrl = avatarUrl.substring(0, avatarUrl.indexOf("?"));
}
final String url = avatarUrl;
new FetchAvatarTask(context) {
@Override
public BitmapDrawable call() throws Exception {
Bitmap image = Bitmap.createScaledBitmap(p.load(url).get(), avatarSize, avatarSize, false);
return new BitmapDrawable(context.getResources(), ImageUtils.roundCorners(image, cornerRadius));
}
@Override
protected void onSuccess(BitmapDrawable image) throws Exception {
// compute inset in pixels
int insetPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, context.getResources().getDisplayMetrics());
actionBar.setLogo(new InsetDrawable(image, 0, 0, insetPx, 0));
}
}.execute();
}
use of com.meisolsson.githubsdk.model.User in project PocketHub by pockethub.
the class ConvertUtilsTest method setup.
@Before
public void setup() {
User user = User.builder().login(REPO_OWNER_LOGIN).build();
repo = Repository.builder().name(REPO_NAME).owner(user).build();
}
Aggregations