Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -792,13 +792,10 @@ public static class AvatarGenerationTask extends AsyncTask<String, Void, Drawabl


public AvatarGenerationTask(AvatarGenerationListener avatarGenerationListener, Object callContext,
FileDataStorageManager storageManager, Account account, Resources resources,
float avatarRadius, String userId, String serverName, Context context) {
Account account, Resources resources, float avatarRadius, String userId,
String serverName, Context context) {
mAvatarGenerationListener = new WeakReference<>(avatarGenerationListener);
mCallContext = callContext;
if (storageManager == null) {
throw new IllegalArgumentException("storageManager must not be NULL");
}
mAccount = account;
mResources = resources;
mAvatarRadius = avatarRadius;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
Expand Down Expand Up @@ -317,7 +318,7 @@ protected void setupDrawerMenu(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(final MenuItem menuItem) {
public boolean onNavigationItemSelected(@NonNull final MenuItem menuItem) {
mDrawerLayout.closeDrawers();
// pending runnable will be executed after the drawer has been closed
pendingRunnable = new Runnable() {
Expand Down Expand Up @@ -611,7 +612,7 @@ public void updateAccountList() {
accountEndView.setTag(mAvatars[1].name);

DisplayUtils.setAvatar(mAvatars[1], this, mOtherAccountAvatarRadiusDimension, getResources(),
getStorageManager(), accountEndView, this);
accountEndView, this);
mAccountEndAccountAvatar.setVisibility(View.VISIBLE);
} else {
mAccountEndAccountAvatar.setVisibility(View.GONE);
Expand All @@ -623,7 +624,7 @@ public void updateAccountList() {
accountMiddleView.setTag(mAvatars[2].name);

DisplayUtils.setAvatar(mAvatars[2], this, mOtherAccountAvatarRadiusDimension, getResources(),
getStorageManager(), accountMiddleView, this);
accountMiddleView, this);
mAccountMiddleAccountAvatar.setVisibility(View.VISIBLE);
} else {
mAccountMiddleAccountAvatar.setVisibility(View.GONE);
Expand Down Expand Up @@ -657,7 +658,7 @@ private void repopulateAccountList(ArrayList<Account> accounts) {
account.name)
.setIcon(TextDrawable.createAvatar(account.name, mMenuAccountAvatarRadiusDimension));
DisplayUtils.setAvatar(account, this, mMenuAccountAvatarRadiusDimension, getResources(),
getStorageManager(), accountMenuItem, this);
accountMenuItem, this);
}
} catch (Exception e) {
Log_OC.e(TAG, "Error calculating RGB value for account menu item.", e);
Expand Down Expand Up @@ -729,7 +730,7 @@ protected void setAccountInDrawer(Account account) {
currentAccountView.setTag(account.name);

DisplayUtils.setAvatar(account, this, mCurrentAccountAvatarRadiusDimension, getResources(),
getStorageManager(), currentAccountView, this);
currentAccountView, this);

// check and show quota info if available
getAndDisplayUserQuota();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private void populateUserInfoUi(UserInfo userInfo) {
userName.setText(account.name);
avatar.setTag(account.name);
DisplayUtils.setAvatar(account, UserInfoActivity.this, mCurrentAccountAvatarRadiusDimension, getResources(),
getStorageManager(), avatar, this);
avatar, this);

int tint = ThemeUtils.primaryColor(account, true, this);

Expand Down Expand Up @@ -482,16 +482,17 @@ public void setData(List<UserInfoDetailsItem> displayList) {
notifyDataSetChanged();
}

@NonNull
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View view = inflater.inflate(R.layout.user_info_details_table_item, parent, false);
ViewHolder holder = new ViewHolder(view);
return holder;
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
UserInfoDetailsItem item = mDisplayList.get(position);
holder.icon.setImageResource(item.icon);
holder.text.setText(item.text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ public AccountListAdapter(BaseActivity context, List<AccountListItem> values, Dr
this.mTintedCheck = tintedCheck;
}

@NonNull
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
AccountViewHolderItem viewHolder;
View view = convertView;

Expand Down Expand Up @@ -152,8 +153,8 @@ private void setAvatar(AccountViewHolderItem viewHolder, Account account) {
try {
View viewItem = viewHolder.imageViewItem;
viewItem.setTag(account.name);
DisplayUtils.setAvatar(account, this, mAccountAvatarRadiusDimension, mContext.getResources(),
mContext.getStorageManager(), viewItem, mContext);
DisplayUtils.setAvatar(account, this, mAccountAvatarRadiusDimension, mContext.getResources(), viewItem,
mContext);
} catch (Exception e) {
Log_OC.e(TAG, "Error calculating RGB value for account list item.", e);
// use user icon as a fallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void onBindViewHolder(@NonNull UserViewHolder holder, int position) {
} else {
holder.avatar.setTag(share.getShareWith());
DisplayUtils.setAvatar(account, share.getShareWith(), this, avatarRadiusDimension,
context.getResources(), storageManager, holder.avatar, context);
context.getResources(), holder.avatar, context);
}
holder.name.setText(name);

Expand Down
15 changes: 5 additions & 10 deletions src/main/java/com/owncloud/android/utils/DisplayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.lib.common.OwnCloudAccount;
Expand Down Expand Up @@ -439,18 +438,16 @@ public interface AvatarGenerationListener {
* @param account the account to be used to connect to server
* @param avatarRadius the avatar radius
* @param resources reference for density information
* @param storageManager reference for caching purposes
* @param callContext which context is called to set the generated avatar
*/
public static void setAvatar(@NonNull Account account, AvatarGenerationListener listener,
float avatarRadius, Resources resources, FileDataStorageManager storageManager,
Object callContext, Context context) {
float avatarRadius, Resources resources, Object callContext, Context context) {

AccountManager accountManager = AccountManager.get(context);
String userId = accountManager.getUserData(account,
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);

setAvatar(account, userId, listener, avatarRadius, resources, storageManager, callContext, context);
setAvatar(account, userId, listener, avatarRadius, resources, callContext, context);
}

/**
Expand All @@ -460,12 +457,10 @@ public static void setAvatar(@NonNull Account account, AvatarGenerationListener
* @param userId the userId which avatar should be set
* @param avatarRadius the avatar radius
* @param resources reference for density information
* @param storageManager reference for caching purposes
* @param callContext which context is called to set the generated avatar
*/
public static void setAvatar(@NonNull Account account, @NonNull String userId, AvatarGenerationListener listener,
float avatarRadius, Resources resources, FileDataStorageManager storageManager,
Object callContext, Context context) {
float avatarRadius, Resources resources, Object callContext, Context context) {
if (callContext instanceof View) {
((View) callContext).setContentDescription(account.name);
}
Expand Down Expand Up @@ -493,8 +488,8 @@ public static void setAvatar(@NonNull Account account, @NonNull String userId, A
// check for new avatar, eTag is compared, so only new one is downloaded
if (ThumbnailsCacheManager.cancelPotentialAvatarWork(userId, callContext)) {
final ThumbnailsCacheManager.AvatarGenerationTask task =
new ThumbnailsCacheManager.AvatarGenerationTask(listener, callContext, storageManager,
account, resources, avatarRadius, userId, serverName, context);
new ThumbnailsCacheManager.AvatarGenerationTask(listener, callContext, account, resources,
avatarRadius, userId, serverName, context);

final ThumbnailsCacheManager.AsyncAvatarDrawable asyncDrawable =
new ThumbnailsCacheManager.AsyncAvatarDrawable(resources, avatar, task);
Expand Down