use of io.plaidapp.data.api.dribbble.DribbbleService 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) {
}
});
}
Aggregations