diff --git a/app/src/main/java/com/readrops/app/AppModule.kt b/app/src/main/java/com/readrops/app/AppModule.kt index 88f3accd..9f111ce5 100644 --- a/app/src/main/java/com/readrops/app/AppModule.kt +++ b/app/src/main/java/com/readrops/app/AppModule.kt @@ -3,6 +3,7 @@ package com.readrops.app import com.readrops.app.repositories.FreshRSSRepository import com.readrops.app.repositories.LocalFeedRepository import com.readrops.app.repositories.NextNewsRepository +import com.readrops.app.utils.GlideApp import com.readrops.app.viewmodels.* import com.readrops.db.entities.account.Account import com.readrops.db.entities.account.AccountType @@ -46,4 +47,5 @@ val appModule = module { AccountViewModel(get()) } + single { GlideApp.with(androidApplication()) } } \ No newline at end of file diff --git a/app/src/main/java/com/readrops/app/activities/ItemActivity.java b/app/src/main/java/com/readrops/app/activities/ItemActivity.java index d7dfa2f4..8d45d45a 100644 --- a/app/src/main/java/com/readrops/app/activities/ItemActivity.java +++ b/app/src/main/java/com/readrops/app/activities/ItemActivity.java @@ -33,7 +33,7 @@ import com.bumptech.glide.request.transition.Transition; import com.readrops.api.utils.DateUtils; import com.readrops.app.R; import com.readrops.app.databinding.ActivityItemBinding; -import com.readrops.app.utils.GlideApp; +import com.readrops.app.utils.GlideRequests; import com.readrops.app.utils.PermissionManager; import com.readrops.app.utils.SharedPreferencesManager; import com.readrops.app.utils.Utils; @@ -42,6 +42,7 @@ import com.readrops.db.entities.Item; import com.readrops.db.pojo.ItemWithFeed; import org.koin.androidx.viewmodel.compat.ViewModelCompat; +import org.koin.java.KoinJavaComponent; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -93,7 +94,7 @@ public class ItemActivity extends AppCompatActivity { binding.appBarLayout.setExpanded(true); binding.collapsingLayout.setTitleEnabled(true); - GlideApp.with(this) + KoinJavaComponent.get(GlideRequests.class) .load(imageUrl) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(binding.collapsingLayoutImage); @@ -358,7 +359,7 @@ public class ItemActivity extends AppCompatActivity { } private void shareImage(String url) { - GlideApp.with(this) + KoinJavaComponent.get(GlideRequests.class) .asBitmap() .diskCacheStrategy(DiskCacheStrategy.ALL) .load(url) diff --git a/app/src/main/java/com/readrops/app/activities/MainActivity.java b/app/src/main/java/com/readrops/app/activities/MainActivity.java index c2102f2c..826b7001 100644 --- a/app/src/main/java/com/readrops/app/activities/MainActivity.java +++ b/app/src/main/java/com/readrops/app/activities/MainActivity.java @@ -37,7 +37,7 @@ import com.readrops.app.R; import com.readrops.app.adapters.MainItemListAdapter; import com.readrops.app.databinding.ActivityMainBinding; import com.readrops.app.utils.DrawerManager; -import com.readrops.app.utils.GlideApp; +import com.readrops.app.utils.GlideRequests; import com.readrops.app.utils.ReadropsItemTouchCallback; import com.readrops.app.utils.SharedPreferencesManager; import com.readrops.app.utils.Utils; @@ -51,6 +51,7 @@ import com.readrops.db.pojo.ItemWithFeed; import org.jetbrains.annotations.NotNull; import org.koin.androidx.viewmodel.compat.ViewModelCompat; +import org.koin.java.KoinJavaComponent; import java.lang.ref.WeakReference; import java.util.Collections; @@ -300,7 +301,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou private void initRecyclerView() { ViewPreloadSizeProvider preloadSizeProvider = new ViewPreloadSizeProvider(); - adapter = new MainItemListAdapter(GlideApp.with(this), preloadSizeProvider); + adapter = new MainItemListAdapter(KoinJavaComponent.get(GlideRequests.class), preloadSizeProvider); adapter.setOnItemClickListener(new MainItemListAdapter.OnItemClickListener() { @Override public void onItemClick(ItemWithFeed itemWithFeed, int position) { @@ -349,7 +350,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou binding.itemsRecyclerView.setRecyclerListener(viewHolder -> { MainItemListAdapter.ItemViewHolder vh = (MainItemListAdapter.ItemViewHolder) viewHolder; - GlideApp.with(this).clear(vh.getItemImage()); + KoinJavaComponent.get(GlideRequests.class).clear(vh.getItemImage()); }); LinearLayoutManager layoutManager = new LinearLayoutManager(this); diff --git a/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java b/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java index 385813e4..9363b85e 100644 --- a/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java +++ b/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java @@ -13,9 +13,11 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.readrops.app.R; import com.readrops.app.databinding.FeedLayoutBinding; -import com.readrops.app.utils.GlideApp; +import com.readrops.app.utils.GlideRequests; import com.readrops.db.pojo.FeedWithFolder; +import org.koin.java.KoinJavaComponent; + import java.util.List; public class FeedsAdapter extends ListAdapter { @@ -64,7 +66,7 @@ public class FeedsAdapter extends ListAdapter Unit) : - ListAdapter(DIFF_CALLBACK) { + ListAdapter(DIFF_CALLBACK), KoinComponent { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NotificationPermissionViewHolder { val binding = NotificationPermissionLayoutBinding.inflate(LayoutInflater.from(parent.context)) @@ -30,7 +33,7 @@ class NotificationPermissionListAdapter(var enableAll: Boolean, val listener: (f holder.itemView.setOnClickListener { if (enableAll) listener(getItem(position)) } - GlideApp.with(holder.itemView.context) + get() .load(feed.iconUrl) .diskCacheStrategy(DiskCacheStrategy.ALL) .placeholder(R.drawable.ic_rss_feed_grey) diff --git a/app/src/main/java/com/readrops/app/utils/SyncResultAnalyser.kt b/app/src/main/java/com/readrops/app/utils/SyncResultAnalyser.kt index 497c24fe..a95c37dd 100644 --- a/app/src/main/java/com/readrops/app/utils/SyncResultAnalyser.kt +++ b/app/src/main/java/com/readrops/app/utils/SyncResultAnalyser.kt @@ -9,11 +9,13 @@ import com.readrops.db.entities.Feed import com.readrops.db.entities.Item import com.readrops.db.entities.account.Account import com.readrops.api.services.SyncResult +import org.koin.core.KoinComponent +import org.koin.core.get /** * Simple class to get synchro notification content (title, content and largeIcon) according to some rules */ -class SyncResultAnalyser(val context: Context, private val syncResults: Map, val database: Database) { +class SyncResultAnalyser(val context: Context, private val syncResults: Map, val database: Database) : KoinComponent { private val notifContent = SyncResultNotifContent() @@ -66,7 +68,7 @@ class SyncResultAnalyser(val context: Context, private val syncResults: Map() .asBitmap() .load(it) .diskCacheStrategy(DiskCacheStrategy.ALL)