use of com.box.androidsdk.content.models.BoxCollaborator in project box-android-sdk by box.
the class BoxAvatarView method updateAvatar.
protected void updateAvatar() {
if (mUser == null || mAvatarController == null) {
return;
}
if (Thread.currentThread() != Looper.getMainLooper().getThread()) {
post(new Runnable() {
@Override
public void run() {
updateAvatar();
}
});
return;
}
final File avatarFile = mAvatarController.getAvatarFile(mUser.getId());
if (avatarFile.exists()) {
// load avatar file into view.
mAvatar.setImageDrawable(Drawable.createFromPath(avatarFile.getAbsolutePath()));
mAvatar.setVisibility(View.VISIBLE);
mInitials.setVisibility(View.GONE);
} else {
String name = DEFAULT_NAME;
if (mUser instanceof BoxCollaborator) {
name = mUser.getName();
} else if (SdkUtils.isBlank(name) && mUser instanceof BoxUser) {
name = ((BoxUser) mUser).getLogin();
}
int numberOfCollab = 0;
try {
numberOfCollab = Integer.parseInt(name);
} catch (NumberFormatException ex) {
// do nothing
}
if (numberOfCollab == 0) {
SdkUtils.setInitialsThumb(getContext(), mInitials, name);
} else {
SdkUtils.setCollabNumberThumb(getContext(), mInitials, numberOfCollab);
}
mAvatar.setVisibility(View.GONE);
mInitials.setVisibility(View.VISIBLE);
mAvatarDownloadTaskRef = new WeakReference<BoxFutureTask<BoxDownload>>(mAvatarController.executeAvatarDownloadRequest(mUser.getId(), this));
}
}
Aggregations