Skip to content

Commit

Permalink
remove squareUp picasso
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 committed Sep 21, 2023
1 parent c51584b commit d3d272c
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 61 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ dependencies {
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.28'
implementation 'com.google.android:flexbox:2.0.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.firebase:firebase-jobdispatcher:0.8.6'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,50 @@ import android.graphics.Typeface
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.widget.*
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.DatePicker
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import com.bumptech.glide.Glide
import com.google.android.flexbox.FlexDirection
import com.google.android.flexbox.FlexboxLayout
import com.squareup.picasso.Callback
import com.squareup.picasso.Picasso
import io.realm.Case
import io.realm.RealmObject
import io.realm.Sort
import kotlinx.android.synthetic.main.alert_health_list.view.*
import kotlinx.android.synthetic.main.card_profile_bell.view.*
import kotlinx.android.synthetic.main.fragment_home_bell.view.*
import kotlinx.android.synthetic.main.home_card_courses.view.*
import kotlinx.android.synthetic.main.home_card_library.view.*
import kotlinx.android.synthetic.main.home_card_meetups.view.*
import kotlinx.android.synthetic.main.home_card_teams.view.*
import kotlinx.android.synthetic.main.item_library_home.view.*
import kotlinx.android.synthetic.main.alert_health_list.view.btn_add_member
import kotlinx.android.synthetic.main.alert_health_list.view.et_search
import kotlinx.android.synthetic.main.alert_health_list.view.list
import kotlinx.android.synthetic.main.alert_health_list.view.spn_sort
import kotlinx.android.synthetic.main.card_profile_bell.view.txtFullName
import kotlinx.android.synthetic.main.card_profile_bell.view.txtRole
import kotlinx.android.synthetic.main.card_profile_bell.view.txtVisits
import kotlinx.android.synthetic.main.fragment_home_bell.view.ic_close
import kotlinx.android.synthetic.main.fragment_home_bell.view.ll_prompt
import kotlinx.android.synthetic.main.home_card_courses.view.count_course
import kotlinx.android.synthetic.main.home_card_library.view.count_library
import kotlinx.android.synthetic.main.home_card_library.view.flexboxLayout
import kotlinx.android.synthetic.main.home_card_meetups.view.count_meetup
import kotlinx.android.synthetic.main.home_card_teams.view.count_team
import kotlinx.android.synthetic.main.item_library_home.view.detail
import kotlinx.android.synthetic.main.item_library_home.view.title
import org.ole.planet.myplanet.R
import org.ole.planet.myplanet.base.BaseResourceFragment
import org.ole.planet.myplanet.callback.NotificationCallback
import org.ole.planet.myplanet.callback.SyncListener
import org.ole.planet.myplanet.datamanager.DatabaseService
import org.ole.planet.myplanet.model.*
import org.ole.planet.myplanet.model.RealmMeetup
import org.ole.planet.myplanet.model.RealmMyCourse
import org.ole.planet.myplanet.model.RealmMyLibrary
import org.ole.planet.myplanet.model.RealmMyLife
import org.ole.planet.myplanet.model.RealmMyTeam
import org.ole.planet.myplanet.model.RealmNews
import org.ole.planet.myplanet.model.RealmTeamNotification
import org.ole.planet.myplanet.model.RealmTeamTask
import org.ole.planet.myplanet.model.RealmUserModel
import org.ole.planet.myplanet.service.TransactionSyncManager
import org.ole.planet.myplanet.service.UserProfileDbHandler
import org.ole.planet.myplanet.ui.dashboard.notification.NotificationFragment
Expand All @@ -43,8 +63,8 @@ import org.ole.planet.myplanet.ui.userprofile.UserProfileFragment
import org.ole.planet.myplanet.utilities.Constants
import org.ole.planet.myplanet.utilities.FileUtils
import org.ole.planet.myplanet.utilities.Utilities
import java.io.File
import java.util.*
import java.util.Calendar
import java.util.UUID

open class BaseDashboardFragment : BaseDashboardFragmentPlugin(), NotificationCallback,
SyncListener {
Expand All @@ -70,16 +90,17 @@ open class BaseDashboardFragment : BaseDashboardFragmentPlugin(), NotificationCa
v.ll_prompt.visibility = View.GONE
}
val imageView = v.findViewById<ImageView>(R.id.imageView)
if (!TextUtils.isEmpty(model.userImage)) Picasso.get().load(model.userImage)
.placeholder(R.drawable.profile).into(imageView, object : Callback {
override fun onSuccess() {}
override fun onError(e: Exception) {
e.printStackTrace()
val f = File(model.userImage)
Picasso.get().load(f).placeholder(R.drawable.profile).error(R.drawable.profile)
.into(imageView)
}
})
if (!TextUtils.isEmpty(model.userImage)) {
Glide.with(requireActivity())
.load(model.userImage)
.placeholder(R.drawable.profile)
.error(R.drawable.profile)
.into(imageView)
} else {
imageView.setImageResource(R.drawable.profile)
}


v.txtVisits.text = "${profileDbHandler.offlineVisits} ${getString(R.string.visits)}"
v.txtRole.text = "- ${model.roleAsString}"
v.txtFullName.text = fullName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.ImageView
import android.widget.TextView
import com.squareup.picasso.Callback
import com.squareup.picasso.Picasso
import com.bumptech.glide.Glide
import org.ole.planet.myplanet.R
import org.ole.planet.myplanet.model.RealmUserModel
import org.ole.planet.myplanet.utilities.TimeUtils
import java.io.File

class UserListArrayAdapter(activity: Activity, val view: Int, var list: List<RealmUserModel>) :
ArrayAdapter<RealmUserModel>(activity, view, list) {
Expand All @@ -26,18 +24,16 @@ class UserListArrayAdapter(activity: Activity, val view: Int, var list: List<Rea
tvName?.text = """${um?.fullName} (${um?.name})"""
joined?.text = "${context.getString(R.string.joined_colon)} ${TimeUtils.formatDate(um!!.joinDate)}"

if (!TextUtils.isEmpty(um.userImage)) Picasso.get().load(um.userImage)
.placeholder(R.drawable.profile).into(image, object : Callback {
override fun onSuccess() {}
override fun onError(e: Exception) {
e.printStackTrace()
val f = File(um.userImage)
Picasso.get().load(f).placeholder(R.drawable.profile).error(R.drawable.profile)
.into(image)
}
}) else {
if (!TextUtils.isEmpty(um.userImage)) {
Glide.with(context)
.load(um.userImage)
.placeholder(R.drawable.profile)
.error(R.drawable.profile)
.into(image!!)
} else {
image?.setImageResource(R.drawable.profile)
}

return v!!;
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package org.ole.planet.myplanet.ui.team.teamMember;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;

import org.ole.planet.myplanet.R;
import org.ole.planet.myplanet.model.RealmMyTeam;
Expand Down Expand Up @@ -60,7 +59,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
String[] overflowMenuOptions;
((ViewHolderUser) holder).tvTitle.setText(list.get(position).toString());
((ViewHolderUser) holder).tvDescription.setText(list.get(position).getRoleAsString() + " (" + RealmTeamLog.getVisitCount(mRealm, list.get(position).getName(), teamId) + " " + context.getString(R.string.visits) + " )");
Picasso.get()
Glide.with(context)
.load(list.get(position).getUserImage())
.placeholder(R.drawable.profile)
.error(R.drawable.profile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@


import static android.app.Activity.RESULT_OK;
import static org.ole.planet.myplanet.MainApplication.context;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
Expand All @@ -16,12 +18,17 @@
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;

import org.ole.planet.myplanet.R;
import org.ole.planet.myplanet.datamanager.DatabaseService;
Expand Down Expand Up @@ -119,20 +126,30 @@ private void populateUserData(View v) {
+ Utilities.checkNA(model.getEmail()));
String dob = TextUtils.isEmpty(model.getDob()) ? "N/A" : TimeUtils.getFormatedDate(model.getDob(), "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
((TextView) v.findViewById(R.id.txt_dob)).setText(getString(R.string.date_of_birth) + dob);
if (!TextUtils.isEmpty(model.getUserImage()))
Picasso.get().load(model.getUserImage()).placeholder(R.drawable.profile).into(imageView, new Callback() {
@Override
public void onSuccess() {
}

@Override
public void onError(Exception e) {
Picasso.get().load(new File(model.getUserImage())).placeholder(R.drawable.profile).error(R.drawable.profile).into(imageView);
}
});
else {
if (!TextUtils.isEmpty(model.getUserImage())) {
Glide.with(context)
.load(model.getUserImage())
.apply(new RequestOptions()
.placeholder(R.drawable.profile)
.error(R.drawable.profile))
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
imageView.setImageResource(R.drawable.profile);
return false;
}

@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
})
.into(imageView);
} else {
imageView.setImageResource(R.drawable.profile);
}

final LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
map.put("Community Name", Utilities.checkNA(model.getPlanetCode()));
map.put("Last Login : ", Utilities.getRelativeTime(handler.getLastVisit()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Environment;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Base64;
Expand All @@ -17,7 +16,7 @@
import android.widget.ImageView;
import android.widget.Toast;

import com.squareup.picasso.Picasso;
import com.bumptech.glide.Glide;

import org.ole.planet.myplanet.MainApplication;
import org.ole.planet.myplanet.R;
Expand Down Expand Up @@ -106,7 +105,11 @@ public static String getUserName(SharedPreferences settings) {
public static void loadImage(String userImage, ImageView imageView) {
Utilities.log("User image " + userImage);
if (!TextUtils.isEmpty(userImage)) {
Picasso.get().load(userImage).placeholder(R.drawable.profile).error(R.drawable.profile).into(imageView);
Glide.with(context)
.load(userImage)
.placeholder(R.drawable.profile)
.error(R.drawable.profile)
.into(imageView);
} else {
imageView.setImageResource(R.drawable.ole_logo);
}
Expand Down

0 comments on commit d3d272c

Please sign in to comment.