Commit 1783753f authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

create picasso async provides method

parent b715e5e9
...@@ -11,6 +11,7 @@ import com.biganto.visual.roompark.data.repository.db.requrey.DbModule ...@@ -11,6 +11,7 @@ import com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import com.biganto.visual.roompark.domain.contract.AuthContract import com.biganto.visual.roompark.domain.contract.AuthContract
import com.biganto.visual.roompark.domain.contract.DevProgressContract import com.biganto.visual.roompark.domain.contract.DevProgressContract
import com.biganto.visual.roompark.domain.contract.FeedsContract import com.biganto.visual.roompark.domain.contract.FeedsContract
import com.squareup.picasso.Picasso
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component import dagger.Component
import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjectionModule
...@@ -38,6 +39,7 @@ import javax.inject.Singleton ...@@ -38,6 +39,7 @@ import javax.inject.Singleton
AndroidInjectionModule::class, AndroidInjectionModule::class,
AndroidSupportInjectionModule::class, AndroidSupportInjectionModule::class,
// MappingProvider::class, // MappingProvider::class,
PicassoModule::class,
ActivityModule::class, ActivityModule::class,
ContractRepositoryModule::class, ContractRepositoryModule::class,
AppActivityModule ::class]) AppActivityModule ::class])
...@@ -58,6 +60,8 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{ ...@@ -58,6 +60,8 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun provideAppContext():Application fun provideAppContext():Application
fun providePicassoAsync(): Picasso
@Component.Factory @Component.Factory
interface Factory{ interface Factory{
......
package com.biganto.visual.roompark.di.dagger
import android.app.Application
import com.squareup.picasso.Picasso
import dagger.Module
import dagger.Provides
import java.util.concurrent.Executors
import javax.inject.Singleton
/**
* Created by Vladislav Bogdashkin on 16.12.2019.
*/
private const val THREAD_POOL_COUNT = 4
@Module
class PicassoModule{
@Provides
@Singleton
fun providePicassoAsyncSingleton(context: Application): Picasso {
val executor = Executors.newFixedThreadPool(THREAD_POOL_COUNT)
return Picasso.Builder(context)
.executor(executor)
.build()
}
}
\ No newline at end of file
...@@ -13,8 +13,6 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc ...@@ -13,8 +13,6 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import com.squareup.picasso.Picasso
import java.util.concurrent.Executors
/** /**
* Created by Vladislav Bogdashkin on 16.10.2019. * Created by Vladislav Bogdashkin on 16.10.2019.
...@@ -53,18 +51,17 @@ class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() { ...@@ -53,18 +51,17 @@ class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() {
override fun getVhLayout(): Int = R.layout.photo_preview_viewholder override fun getVhLayout(): Int = R.layout.photo_preview_viewholder
} }
val exSercv = Executors.newFixedThreadPool(4)
val picoAbuilder= Picasso.Builder(RoomParkApplication.component.provideAppContext())
.executor(exSercv)
.build()
class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView) { class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView) {
@BindView(R.id.photo_preview_imageview) lateinit var photoPreview: RoundedImageView @BindView(R.id.photo_preview_imageview) lateinit var photoPreview: RoundedImageView
private val picassoAsync by lazy {
return@lazy RoomParkApplication.component.providePicassoAsync()
}
override fun onViewBound(model: PhotoModel) { override fun onViewBound(model: PhotoModel) {
model.resolutionList.lowelest()?.let { model.resolutionList.lowelest()?.let {
picoAbuilder picassoAsync
.load(it.url) .load(it.url)
.centerCrop() .centerCrop()
.fit() .fit()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment