use of io.plaidapp.data.api.dribbble.model.User in project plaid by nickbutcher.
the class DribbbleLogin method showLoggedInUser.
void showLoggedInUser() {
final Call<User> authenticatedUser = dribbblePrefs.getApi().getAuthenticatedUser();
authenticatedUser.enqueue(new Callback<User>() {
@Override
public void onResponse(Call<User> call, Response<User> response) {
final User user = response.body();
dribbblePrefs.setLoggedInUser(user);
final Toast confirmLogin = new Toast(getApplicationContext());
final View v = LayoutInflater.from(DribbbleLogin.this).inflate(R.layout.toast_logged_in_confirmation, null, false);
((TextView) v.findViewById(R.id.name)).setText(user.name.toLowerCase());
// need to use app context here as the activity will be destroyed shortly
Glide.with(getApplicationContext()).load(user.avatar_url).placeholder(R.drawable.ic_player).transform(new CircleTransform(getApplicationContext())).into((ImageView) v.findViewById(R.id.avatar));
v.findViewById(R.id.scrim).setBackground(ScrimUtil.makeCubicGradientScrimDrawable(ContextCompat.getColor(DribbbleLogin.this, R.color.scrim), 5, Gravity.BOTTOM));
confirmLogin.setView(v);
confirmLogin.setGravity(Gravity.BOTTOM | Gravity.FILL_HORIZONTAL, 0, 0);
confirmLogin.setDuration(Toast.LENGTH_LONG);
confirmLogin.show();
}
@Override
public void onFailure(Call<User> call, Throwable t) {
}
});
}
use of io.plaidapp.data.api.dribbble.model.User in project sbt-android by scala-android.
the class DribbbleLogin method showLoggedInUser.
private void showLoggedInUser() {
Gson gson = new GsonBuilder().setDateFormat(DribbbleService.DATE_FORMAT).create();
RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(DribbbleService.ENDPOINT).setConverter(new GsonConverter(gson)).setRequestInterceptor(new AuthInterceptor(dribbblePrefs.getAccessToken())).build();
DribbbleService dribbbleApi = restAdapter.create((DribbbleService.class));
dribbbleApi.getAuthenticatedUser(new Callback<User>() {
@Override
public void success(User user, Response response) {
dribbblePrefs.setLoggedInUser(user);
Toast confirmLogin = new Toast(getApplicationContext());
View v = LayoutInflater.from(DribbbleLogin.this).inflate(R.layout.toast_logged_in_confirmation, null, false);
((TextView) v.findViewById(R.id.name)).setText(user.name);
// need to use app context here as the activity will be destroyed shortly
Glide.with(getApplicationContext()).load(user.avatar_url).placeholder(R.drawable.ic_player).transform(new CircleTransform(getApplicationContext())).into((ImageView) v.findViewById(R.id.avatar));
v.findViewById(R.id.scrim).setBackground(ScrimUtil.makeCubicGradientScrimDrawable(ContextCompat.getColor(DribbbleLogin.this, R.color.scrim), 5, Gravity.BOTTOM));
confirmLogin.setView(v);
confirmLogin.setGravity(Gravity.BOTTOM | Gravity.FILL_HORIZONTAL, 0, 0);
confirmLogin.setDuration(Toast.LENGTH_LONG);
confirmLogin.show();
}
@Override
public void failure(RetrofitError error) {
}
});
}
use of io.plaidapp.data.api.dribbble.model.User in project plaid by nickbutcher.
the class DribbbleSearchConverter method parsePlayer.
private static User parsePlayer(Element element) {
final Element userBlock = element.select("a.url").first();
String avatarUrl = userBlock.select("img.photo").first().attr("src");
if (avatarUrl.contains("/mini/")) {
avatarUrl = avatarUrl.replace("/mini/", "/normal/");
}
final Matcher matchId = PATTERN_PLAYER_ID.matcher(avatarUrl);
Long id = -1l;
if (matchId.find() && matchId.groupCount() == 1) {
id = Long.parseLong(matchId.group(1));
}
final String slashUsername = userBlock.attr("href");
final String username = TextUtils.isEmpty(slashUsername) ? null : slashUsername.substring(1);
return new User.Builder().setId(id).setName(userBlock.text()).setUsername(username).setHtmlUrl(HOST + slashUsername).setAvatarUrl(avatarUrl).setPro(element.select("span.badge-pro").size() > 0).build();
}
use of io.plaidapp.data.api.dribbble.model.User in project sbt-android by scala-android.
the class DribbbleSearch method parsePlayer.
private static User parsePlayer(Element element) {
Element userBlock = element.select("a.url").first();
String avatarUrl = userBlock.select("img.photo").first().attr("src");
if (avatarUrl.contains("/mini/")) {
avatarUrl = avatarUrl.replace("/mini/", "/normal/");
}
Matcher matchId = PATTERN_PLAYER_ID.matcher(avatarUrl);
Long id = -1l;
if (matchId.find() && matchId.groupCount() == 1) {
id = Long.parseLong(matchId.group(1));
}
String slashUsername = userBlock.attr("href");
String username = TextUtils.isEmpty(slashUsername) ? null : slashUsername.substring(1);
return new User.Builder().setId(id).setName(userBlock.text()).setUsername(username).setHtmlUrl(HOST + slashUsername).setAvatarUrl(avatarUrl).setPro(element.select("span.badge-pro").size() > 0).build();
}
Aggregations