diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-04-20 12:17:07 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-04-20 12:17:07 +0300 |
commit | e74c360bee0da192dc31bff874f4893ad69dbede (patch) | |
tree | 73db920c68fb2847c93bdc187a1c42c5d690f2b4 | |
parent | 6e7f1a438993c1c6e0caf147323745f0e7e67761 (diff) |
Fix some todos
7 files changed, 12 insertions, 14 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index 952f4eea9..41c9c492c 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -455,7 +455,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener }; boardsLiveData.observe(this, boardsLiveDataObserver); - ViewUtil.addAvatar(this, headerBinding.drawerCurrentAccount, this.currentAccount.getUrl(), this.currentAccount.getUserName(), R.mipmap.ic_launcher_round); + ViewUtil.addAvatar(headerBinding.drawerCurrentAccount, this.currentAccount.getUrl(), this.currentAccount.getUserName(), R.mipmap.ic_launcher_round); headerBinding.drawerUsernameFull.setText(currentAccount.getName()); accountChooserActive = false; inflateAccountMenu(); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlAdapter.java index b6689cb8c..8beb96bed 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlAdapter.java @@ -73,7 +73,7 @@ public class AccessControlAdapter extends RecyclerView.Adapter<RecyclerView.View if (context != null) { try { - ViewUtil.addAvatar(context, ownerHolder.binding.avatar, SingleAccountHelper.getCurrentSingleSignOnAccount(context).url, ac.getUser().getUid(), R.drawable.ic_person_grey600_24dp); + ViewUtil.addAvatar(ownerHolder.binding.avatar, SingleAccountHelper.getCurrentSingleSignOnAccount(context).url, ac.getUser().getUid(), R.drawable.ic_person_grey600_24dp); } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) { e.printStackTrace(); } @@ -83,7 +83,7 @@ public class AccessControlAdapter extends RecyclerView.Adapter<RecyclerView.View if (context != null) { try { - ViewUtil.addAvatar(context, acHolder.binding.avatar, SingleAccountHelper.getCurrentSingleSignOnAccount(context).url, ac.getUser().getUid(), R.drawable.ic_person_grey600_24dp); + ViewUtil.addAvatar(acHolder.binding.avatar, SingleAccountHelper.getCurrentSingleSignOnAccount(context).url, ac.getUser().getUid(), R.drawable.ic_person_grey600_24dp); } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) { e.printStackTrace(); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/UserAutoCompleteAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/UserAutoCompleteAdapter.java index a8f3b0c2c..f1fc65e9a 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/UserAutoCompleteAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/UserAutoCompleteAdapter.java @@ -49,7 +49,6 @@ public class UserAutoCompleteAdapter extends AutoCompleteAdapter<User> { try { SingleSignOnAccount account = SingleAccountHelper.getCurrentSingleSignOnAccount(activity); ViewUtil.addAvatar( - activity, holder.binding.icon, account.url, getItem(position).getUid(), diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java index 9feae2032..412f33418 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java @@ -81,7 +81,7 @@ public class CardCommentsAdapter extends RecyclerView.Adapter<ItemCommentViewHol final Context context = holder.itemView.getContext(); final DeckComment comment = comments.get(position); - ViewUtil.addAvatar(context, holder.binding.avatar, account.getUrl(), comment.getActorId(), DimensionUtil.dpToPx(context, R.dimen.icon_size_details), R.drawable.ic_person_grey600_24dp); + ViewUtil.addAvatar(holder.binding.avatar, account.getUrl(), comment.getActorId(), DimensionUtil.dpToPx(context, R.dimen.icon_size_details), R.drawable.ic_person_grey600_24dp); holder.binding.message.setText(comment.getMessage()); holder.binding.actorDisplayName.setText(comment.getActorDisplayName()); holder.binding.creationDateTime.setText(DateUtil.getRelativeDateTimeString(context, comment.getCreationDateTime().getTime())); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java index c6428d6e0..46a44ec44 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java @@ -384,7 +384,7 @@ public class CardDetailsFragment extends BrandedFragment implements OnDateSetLis } binding.peopleList.addView(avatar); avatar.requestLayout(); - ViewUtil.addAvatar(getContext(), avatar, baseUrl, user.getUid(), avatarSize, R.drawable.ic_person_grey600_24dp); + ViewUtil.addAvatar(avatar, baseUrl, user.getUid(), avatarSize, R.drawable.ic_person_grey600_24dp); } @Override diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/preparecreate/AccountAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/preparecreate/AccountAdapter.java index febbbb90e..35a98efd7 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/preparecreate/AccountAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/preparecreate/AccountAdapter.java @@ -41,7 +41,7 @@ public class AccountAdapter extends AbstractAdapter<Account> { if (item != null) { binding.username.setText(item.getUserName()); binding.instance.setText(item.getUrl()); - ViewUtil.addAvatar(binding.avatar.getContext(), binding.avatar, item.getUrl(), item.getUserName(), DimensionUtil.dpToPx(binding.avatar.getContext(), R.dimen.icon_size_details), R.drawable.ic_person_grey600_24dp); + ViewUtil.addAvatar(binding.avatar, item.getUrl(), item.getUserName(), DimensionUtil.dpToPx(binding.avatar.getContext(), R.dimen.icon_size_details), R.drawable.ic_person_grey600_24dp); } else { DeckLog.logError(new IllegalArgumentException("No item for position " + position)); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/util/ViewUtil.java b/app/src/main/java/it/niedermann/nextcloud/deck/util/ViewUtil.java index c0fd47ae1..4b5be2fae 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/util/ViewUtil.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/util/ViewUtil.java @@ -10,6 +10,7 @@ import android.widget.TextView; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; +import androidx.annotation.Px; import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.widget.TextViewCompat; @@ -25,15 +26,13 @@ public final class ViewUtil { private ViewUtil() { } - public static void addAvatar(Context context, ImageView avatar, String baseUrl, String userId, @DrawableRes int errorResource) { - // TODO get context from ImageView? - addAvatar(context, avatar, baseUrl, userId, DimensionUtil.dpToPx(context, R.dimen.avatar_size), errorResource); + public static void addAvatar(@NonNull ImageView avatar, @NonNull String baseUrl, @NonNull String userId, @DrawableRes int errorResource) { + addAvatar(avatar, baseUrl, userId, DimensionUtil.dpToPx(avatar.getContext(), R.dimen.avatar_size), errorResource); } - public static void addAvatar(Context context, ImageView avatar, String baseUrl, String userId, int avatarSize, @DrawableRes int errorResource) { - // TODO get context from ImageView? - String uri = baseUrl + "/index.php/avatar/" + Uri.encode(userId) + "/" + avatarSize; - Glide.with(context) + public static void addAvatar(@NonNull ImageView avatar, @NonNull String baseUrl, @NonNull String userId, @Px int avatarSizeInPx, @DrawableRes int errorResource) { + final String uri = baseUrl + "/index.php/avatar/" + Uri.encode(userId) + "/" + avatarSizeInPx; + Glide.with(avatar.getContext()) .load(uri) .error(errorResource) .apply(RequestOptions.circleCropTransform()) |