I am having one issue on display a default image name here R.drawable.avatar_placeholder. When the link from webservice is non empty, but error 404. means there isn't any image on that link path. Which if i run this function below, the string "path not empty" is shown, but it failed to display the image. Any suggestion is welcomed. Thanks.
private void loadProfileDetails() {
Logger.d(UI_LoginFragmentWithPin.class, "loadProfileDetails profile image: " + PrefUtils.readString(Constant.PREF_PROFILE_IMAGE));
if (!TextUtils.isEmpty(PrefUtils.readString(Constant.PREF_PROFILE_IMAGE))){
Utils.println("path not empty");
LPicasso.getInstance(getActivity())
.load(PrefUtils.readString(Constant.PREF_PROFILE_IMAGE))
.config(Bitmap.Config.RGB_565)
.resize(200, 200)
.centerCrop()
.into(imgProfile);
}else {
Utils.println("path empty");
LPicasso.getInstance(getActivity())
.load(R.drawable.avatar_placeholder)
.config(Bitmap.Config.RGB_565)
.resize(200, 200)
.centerCrop()
.into(imgProfile);
}
tvEmail.setText(PrefUtils.readString(Constant.PREF_EMAIL));
tvName.setText(PrefUtils.readString(Constant.PREF_USER_NAME) + " " + PrefUtils.readString(Constant.PREF_USER_SURNAME));
}
Picasso are not manging android memorey & slow , so i am higley recommend you to not to use it and instade of it just use Glide libeary .
(You can download image and make her circle with glide , download image a Bitmap and much more )
add to Gradle:
and just:
for load a pic:
and you can add a lot more functionality by glide , for example if you want a placeholder until the photo will load you are just adding .placeholder(): :
and if you want a to display photo incase of the photo you are trying to load is broken or have any problem , just add .error()
:
Try this,
Try this,
Set error image as your place holder image
gradle: