From 2cb7bf7eb2efa2e91351518ccd9b77abae3c2399 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 23 Aug 2018 15:08:27 +0200 Subject: [PATCH] All remote images views uses WebImageView --- .../ui/adapters/NotificationsAdapter.java | 17 +++++------- .../ui/adapters/UsersAsysncInfoAdapter.java | 27 ++++++++----------- .../client/ui/adapters/UsersBasicAdapter.java | 11 +++----- .../fragments/UserAccessDeniedFragment.java | 12 ++++----- .../layout/fragment_user_access_denied.xml | 2 +- app/src/main/res/layout/notification_item.xml | 2 +- .../res/layout/user_basic_adapter_item.xml | 2 +- 7 files changed, 28 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/NotificationsAdapter.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/NotificationsAdapter.java index 402fa97..2fa0d38 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/NotificationsAdapter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/NotificationsAdapter.java @@ -8,19 +8,16 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; -import android.widget.ImageView; import android.widget.TextView; import org.communiquons.android.comunic.client.R; -import org.communiquons.android.comunic.client.data.helpers.ImageLoadHelper; -import org.communiquons.android.comunic.client.data.models.GroupInfo; -import org.communiquons.android.comunic.client.data.models.UserInfo; -import org.communiquons.android.comunic.client.data.models.Notif; import org.communiquons.android.comunic.client.data.arrays.NotifsList; +import org.communiquons.android.comunic.client.data.models.GroupInfo; +import org.communiquons.android.comunic.client.data.models.Notif; +import org.communiquons.android.comunic.client.data.models.UserInfo; import org.communiquons.android.comunic.client.data.utils.NotifsUtils; import org.communiquons.android.comunic.client.data.utils.Utilities; - -import java.lang.reflect.Array; +import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage; /** * Notifications list adapter @@ -77,10 +74,8 @@ public class NotificationsAdapter extends ArrayAdapter{ assert notif != null; //Update the user account image - ImageView image = convertView.findViewById(R.id.user_account_image); - ImageLoadHelper.remove(image); - ImageLoadHelper.load(getContext(), - mUsersInfo.get(notif.getFrom_user_id()).getAcountImageURL(), image); + WebUserAccountImage accountImage = convertView.findViewById(R.id.user_account_image); + accountImage.setUser(mUsersInfo.get(notif.getFrom_user_id())); //Update the message of the notification TextView message = convertView.findViewById(R.id.notification_message); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/UsersAsysncInfoAdapter.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/UsersAsysncInfoAdapter.java index d580dbc..8e6b101 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/UsersAsysncInfoAdapter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/UsersAsysncInfoAdapter.java @@ -8,14 +8,11 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; -import android.widget.ImageView; import android.widget.TextView; - import org.communiquons.android.comunic.client.R; -import org.communiquons.android.comunic.client.data.helpers.ImageLoadHelper; import org.communiquons.android.comunic.client.data.models.UserInfo; -import org.communiquons.android.comunic.client.ui.utils.UiUtils; +import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage; import java.util.ArrayList; @@ -34,21 +31,21 @@ public class UsersAsysncInfoAdapter extends ArrayAdapter { /** * Informations about the members of the conversation */ - private ArrayMap usersInfos; + private ArrayMap usersInfo; /** * Constructor * @param context The context of the application * @param IDs The list of IDs of users - * @param usersInfos Informations about the users (can be updated asynchronously with the list + * @param usersInfo Information about the users (can be updated asynchronously with the list * of users ID) */ public UsersAsysncInfoAdapter(Context context, @NonNull ArrayList IDs, - @NonNull ArrayMap usersInfos){ + @NonNull ArrayMap usersInfo){ super(context, 0, IDs); //Save user information array map - this.usersInfos = usersInfos; + this.usersInfo = usersInfo; } @NonNull @@ -60,25 +57,23 @@ public class UsersAsysncInfoAdapter extends ArrayAdapter { .inflate(R.layout.user_basic_adapter_item, parent, false); //Get the views - ImageView account_image = convertView.findViewById(R.id.user_account_image); + WebUserAccountImage account_image = convertView.findViewById(R.id.user_account_image); TextView account_name = convertView.findViewById(R.id.user_name); //Empty the entry - ImageLoadHelper.remove(account_image); - account_image.setImageDrawable(UiUtils.getDrawable(getContext(), - R.drawable.default_account_image)); + account_image.removeUser(); account_name.setText(""); //Get user ID int userID = getItem(position); - //Check if we go user informations - if(usersInfos.containsKey(userID)){ + //Check if we go user information + if(usersInfo.containsKey(userID)){ - UserInfo user = usersInfos.get(userID); + UserInfo user = usersInfo.get(userID); account_name.setText(user.getDisplayFullName()); - ImageLoadHelper.load(getContext(), user.getAcountImageURL(), account_image); + account_image.setUser(user); } return convertView; diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/UsersBasicAdapter.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/UsersBasicAdapter.java index c930ae6..2050b1d 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/UsersBasicAdapter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/UsersBasicAdapter.java @@ -7,13 +7,11 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; -import android.widget.ImageView; import android.widget.TextView; import org.communiquons.android.comunic.client.R; -import org.communiquons.android.comunic.client.data.helpers.ImageLoadHelper; import org.communiquons.android.comunic.client.data.models.UserInfo; -import org.communiquons.android.comunic.client.ui.utils.UiUtils; +import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage; import java.util.ArrayList; @@ -57,11 +55,8 @@ public class UsersBasicAdapter extends ArrayAdapter { setText(userInfos.getDisplayFullName()); //Set account image - ImageView account_image = convertView.findViewById(R.id.user_account_image); - ImageLoadHelper.remove(account_image); - account_image.setImageDrawable(UiUtils.getDrawable(getContext(), - R.drawable.default_account_image)); - ImageLoadHelper.load(getContext(), userInfos.getAcountImageURL(), account_image); + WebUserAccountImage account_image = convertView.findViewById(R.id.user_account_image); + account_image.setUser(userInfos); } return convertView; diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserAccessDeniedFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserAccessDeniedFragment.java index 3d3324b..b9ce423 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserAccessDeniedFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserAccessDeniedFragment.java @@ -1,15 +1,14 @@ package org.communiquons.android.comunic.client.ui.fragments; -import android.support.annotation.NonNull; -import android.support.v4.app.Fragment; import android.os.AsyncTask; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; -import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; @@ -17,11 +16,10 @@ import android.widget.Toast; import org.communiquons.android.comunic.client.R; import org.communiquons.android.comunic.client.data.helpers.FriendsListHelper; import org.communiquons.android.comunic.client.data.helpers.GetUsersHelper; -import org.communiquons.android.comunic.client.data.helpers.ImageLoadHelper; import org.communiquons.android.comunic.client.data.models.FriendshipStatus; import org.communiquons.android.comunic.client.data.models.UserInfo; -import org.communiquons.android.comunic.client.ui.activities.MainActivity; import org.communiquons.android.comunic.client.ui.listeners.onOpenUsersPageListener; +import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage; /** * User access denied fragment @@ -70,7 +68,7 @@ public class UserAccessDeniedFragment extends Fragment implements View.OnClickLi /** * User account image */ - private ImageView mUserImage; + private WebUserAccountImage mUserImage; /** * User account name @@ -204,7 +202,7 @@ public class UserAccessDeniedFragment extends Fragment implements View.OnClickLi //Append user information mUserName.setText(mUserInfo.getDisplayFullName()); - ImageLoadHelper.load(getActivity(), mUserInfo.getAcountImageURL(), mUserImage); + mUserImage.setUser(mUserInfo); //Check if we have got the friends if(mFriendshipStatus == null){ diff --git a/app/src/main/res/layout/fragment_user_access_denied.xml b/app/src/main/res/layout/fragment_user_access_denied.xml index f39625f..1e23b1c 100644 --- a/app/src/main/res/layout/fragment_user_access_denied.xml +++ b/app/src/main/res/layout/fragment_user_access_denied.xml @@ -14,7 +14,7 @@ app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="16dp"> - - -