use of io.plaidapp.data.api.designernews.model.User in project plaid by nickbutcher.
the class DesignerNewsLogin method showLoggedInUser.
private void showLoggedInUser() {
final Call<User> authedUser = designerNewsPrefs.getApi().getAuthedUser();
authedUser.enqueue(new Callback<User>() {
@Override
public void onResponse(Call<User> call, Response<User> response) {
final User user = response.body();
designerNewsPrefs.setLoggedInUser(user);
final Toast confirmLogin = new Toast(getApplicationContext());
final View v = LayoutInflater.from(DesignerNewsLogin.this).inflate(R.layout.toast_logged_in_confirmation, null, false);
((TextView) v.findViewById(R.id.name)).setText(user.display_name.toLowerCase());
// need to use app context here as the activity will be destroyed shortly
Glide.with(getApplicationContext()).load(user.portrait_url).placeholder(R.drawable.avatar_placeholder).transform(new CircleTransform(getApplicationContext())).into((ImageView) v.findViewById(R.id.avatar));
v.findViewById(R.id.scrim).setBackground(ScrimUtil.makeCubicGradientScrimDrawable(ContextCompat.getColor(DesignerNewsLogin.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) {
Log.e(getClass().getCanonicalName(), t.getMessage(), t);
}
});
}
Aggregations