use of com.instructure.canvasapi.model.CanvasColor in project instructure-android by instructure.
the class HomeActivity method setupCallbacks.
private void setupCallbacks() {
avatarTarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
avatar.setImageBitmap(bitmap);
}
@Override
public void onBitmapFailed(Drawable drawable) {
avatar.setImageResource(R.drawable.ic_cv_student);
}
@Override
public void onPrepareLoad(Drawable drawable) {
}
};
userCallback = new UserCallback(this) {
@Override
public void cachedUser(User user) {
if (user != null && user.getAvatarURL() != null) {
Picasso.with(getContext()).load(user.getAvatarURL()).into(avatarTarget);
userName.setText(user.getName());
}
}
@Override
public void user(User user, Response response) {
Picasso.with(getContext()).load(user.getAvatarURL()).into(avatarTarget);
userName.setText(user.getName());
}
};
courseColorsCallback = new CanvasCallback<CanvasColor>(this) {
@Override
public void cache(CanvasColor canvasColor) {
}
@Override
public void firstPage(CanvasColor canvasColor, LinkHeaders linkHeaders, Response response) {
if (response.getStatus() == 200) {
// Replaces the current cache with the updated fresh one from the api.
CanvasContextColor.addToCache(canvasColor);
// Sends a broadcast so the course grid can refresh it's colors if needed.
// When first logging in this will probably get called/return after the courses.
Intent intent = new Intent(com.instructure.pandautils.utils.Const.COURSE_THING_CHANGED);
Bundle extras = new Bundle();
extras.putBoolean(com.instructure.pandautils.utils.Const.COURSE_COLOR, true);
intent.putExtras(extras);
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
}
}
};
}
Aggregations