All remote images views uses WebImageView

This commit is contained in:
Pierre HUBERT 2018-08-23 15:08:27 +02:00
parent 68297ae2fd
commit 2cb7bf7eb2
7 changed files with 28 additions and 45 deletions

View File

@ -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<Notif>{
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);

View File

@ -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<Integer> {
/**
* Informations about the members of the conversation
*/
private ArrayMap<Integer, UserInfo> usersInfos;
private ArrayMap<Integer, UserInfo> 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<Integer> IDs,
@NonNull ArrayMap<Integer, UserInfo> usersInfos){
@NonNull ArrayMap<Integer, UserInfo> 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<Integer> {
.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;

View File

@ -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<UserInfo> {
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;

View File

@ -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){

View File

@ -14,7 +14,7 @@
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp">
<ImageView
<org.communiquons.android.comunic.client.ui.views.WebUserAccountImage
android:id="@+id/user_account_image"
android:layout_width="@dimen/account_image_default_width"
android:layout_height="@dimen/account_image_default_height"

View File

@ -7,7 +7,7 @@
android:padding="4dp">
<!-- User image -->
<ImageView
<org.communiquons.android.comunic.client.ui.views.WebUserAccountImage
android:id="@+id/user_account_image"
android:layout_width="@dimen/account_image_default_width"
android:layout_height="@dimen/account_image_default_height"

View File

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
<org.communiquons.android.comunic.client.ui.views.WebUserAccountImage
android:id="@+id/user_account_image"
android:layout_width="@dimen/account_image_default_width"
android:layout_height="@dimen/account_image_default_height"