Commit 9e76476d authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

exclude picasso from project

parent ec6d3fc0
......@@ -77,10 +77,6 @@ dependencies {
//Constraint Layout
implementation "androidx.constraintlayout:constraintlayout:$constrainLayoutVersion"
//image loading store and cashe by url: Picasso
implementation "com.squareup.picasso:picasso:$picassoVersion"
implementation 'jp.wasabeef:picasso-transformations:2.2.1'
//Logger: Timber
implementation "com.jakewharton.timber:timber:$timberVersion"
......@@ -162,6 +158,7 @@ dependencies {
//Glide
implementation "com.github.bumptech.glide:glide:$glideVersion"
implementation 'jp.wasabeef:glide-transformations:4.0.0'
annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
//Tests
......
......@@ -5,7 +5,6 @@ import com.biganto.visual.roompark.BuildConfig
import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.DaggerAppComponent
import com.crashlytics.android.Crashlytics
import com.squareup.picasso.Picasso
import dagger.android.AndroidInjector
import dagger.android.DaggerApplication
import timber.log.Timber
......@@ -35,24 +34,6 @@ class RoomParkApplication : DaggerApplication() {
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
else Timber.plant(CrashlyticsTree())
val picassoBuilder = Picasso.Builder(this)
picassoBuilder.listener { _, uri, exception ->
Timber.e(exception)
Timber.e(exception, "PICASSO url = %s", uri.toString())
}
// Picasso.Builder creates the Picasso object to do the actual requests
val picasso = picassoBuilder.build()
try {
Picasso.setSingletonInstance(picasso)
} catch (ignored: IllegalStateException) {
Timber.e(ignored, "PICASSO")
// Picasso instance was already set
// cannot set it after Picasso.with(Context) was already in use
}
}
}
......
......@@ -10,7 +10,6 @@ import com.biganto.visual.roompark.data.repository.db.IDb
import com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import com.biganto.visual.roompark.data.repository.file.FileModule
import com.biganto.visual.roompark.domain.contract.*
import com.squareup.picasso.Picasso
import dagger.BindsInstance
import dagger.Component
import dagger.android.AndroidInjectionModule
......@@ -38,7 +37,6 @@ import javax.inject.Singleton
AndroidInjectionModule::class,
AndroidSupportInjectionModule::class,
// MappingProvider::class,
PicassoModule::class,
ActivityModule::class,
ContractRepositoryModule::class,
AppActivityModule ::class,
......@@ -64,8 +62,6 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun provideAppContext():Application
fun providePicassoAsync(): Picasso
fun provideFileSystem(): FileModule
......
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
package com.biganto.visual.roompark.presentation.screen.albums
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.View
......@@ -19,22 +18,22 @@ import com.biganto.visual.roompark.domain.model.PhotoModel
import com.biganto.visual.roompark.presentation.screen.albums.util.AlbumListAdapter
import com.biganto.visual.roompark.presentation.screen.albums.util.AlbumsHeaderAdapter
import com.biganto.visual.roompark.presentation.screen.photo.PhotoScreenController
import com.biganto.visual.roompark.util.extensions.scaleCenterCrop
import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.target.Target
import com.bumptech.glide.request.transition.Transition
import com.google.android.material.textview.MaterialTextView
import com.squareup.picasso.Picasso
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import jp.wasabeef.picasso.transformations.BlurTransformation
import jp.wasabeef.picasso.transformations.ColorFilterTransformation
import timber.log.Timber
import jp.wasabeef.glide.transformations.BlurTransformation
import jp.wasabeef.glide.transformations.ColorFilterTransformation
import java.util.concurrent.TimeUnit
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
......@@ -67,22 +66,22 @@ class AlbumsScreenController :
private val photosBackgroundTarget = object : com.squareup.picasso.Target {
override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
// nestedScrollView.background = placeHolderDrawable
}
override fun onBitmapFailed(e: Exception?, errorDrawable: Drawable?) {
Timber.e(e)
}
override fun onBitmapLoaded(bitmap: Bitmap?, from: Picasso.LoadedFrom?) {
bitmap?.scaleCenterCrop(nestedScrollView)?.let {
nestedScrollView.background = BitmapDrawable(activity?.resources, it)
}
}
}
//
// private val photosBackgroundTarget = object : com.squareup.picasso.Target {
// override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
//// nestedScrollView.background = placeHolderDrawable
// }
//
// override fun onBitmapFailed(e: Exception?, errorDrawable: Drawable?) {
// Timber.e(e)
// }
//
// override fun onBitmapLoaded(bitmap: Bitmap?, from: Picasso.LoadedFrom?) {
// bitmap?.scaleCenterCrop(nestedScrollView)?.let {
// nestedScrollView.background = BitmapDrawable(activity?.resources, it)
// }
// }
// }
private fun bindRecycler() {
......@@ -161,9 +160,6 @@ class AlbumsScreenController :
private fun render(viewState: AlbumsScreenViewState.SomeError) =
showError(viewState.exception)
@Inject
lateinit var picassoAsync:Picasso
private fun render(viewState: AlbumsScreenViewState.AlbumsListLoaded) {
(headersRecyclerView.adapter as AlbumsHeaderAdapter).setItems(
viewState.list.asSequence().sortedByDescending { it.published }.toList()
......@@ -177,13 +173,10 @@ class AlbumsScreenController :
viewState.list.first { it.albumId == viewState.selectedAlbumId }.let {
currentAlbomTitle.text = it.title
picassoAsync
.load(it.previewUrl)
.transform(BlurTransformation(activity, 13, 2))
.transform(ColorFilterTransformation(0xCC000000.toInt()))
.into(photosBackgroundTarget)
activity?.let { ctx ->
loadGlideBlurred(it.previewUrl, ctx, nestedBgTarget)
}
}
}
private fun render(viewState: AlbumsScreenViewState.HeaderAlbumChoosed) {
......@@ -193,11 +186,10 @@ class AlbumsScreenController :
}
currentAlbomTitle.text = viewState.item.title
picassoAsync
.load(viewState.item.previewUrl)
.transform(BlurTransformation(activity, 13, 2))
.transform(ColorFilterTransformation(0xCC000000.toInt()))
.into(photosBackgroundTarget)
activity?.let { ctx ->
loadGlideBlurred(viewState.item.previewUrl, ctx, nestedBgTarget)
}
}
private fun render(viewState: AlbumsScreenViewState.AlbumsSelected){
......@@ -206,7 +198,7 @@ class AlbumsScreenController :
)
}
private fun render(viewState: AlbumsScreenViewState.RestoreView){
private fun render(viewState: AlbumsScreenViewState.RestoreView) {
(albumsRecyclerView.adapter as AlbumListAdapter).setItems(
viewState.restore.albumList.asSequence().sortedByDescending { it.published }.toList()
)
......@@ -221,16 +213,27 @@ class AlbumsScreenController :
)
}
viewState.restore.albumsPreview.first { it.albumId == viewState.restore.currentIndex}
viewState.restore.albumsPreview.first { it.albumId == viewState.restore.currentIndex }
.let {
currentAlbomTitle.text = it.title
picassoAsync
.load(it.previewUrl)
.transform(BlurTransformation(activity, 13, 2))
.transform(ColorFilterTransformation(0xCC000000.toInt()))
.into(photosBackgroundTarget)
activity?.let { ctx ->
loadGlideBlurred(it.previewUrl, ctx, nestedBgTarget)
}
}
}
private val nestedBgTarget = object : SimpleTarget<Drawable>(){
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
nestedScrollView.background = resource
}
}
private fun loadGlideBlurred(url:String, context: Context, drawable: Target<Drawable>) =
Glide.with(context)
.load(url)
.transform(BlurTransformation(13, 2))
.transform(ColorFilterTransformation(0xCC000000.toInt()))
.into(drawable)
override fun onAlbumSelected(): Observable<AlbumPreviewModel>
= (headersRecyclerView.adapter as AlbumsHeaderAdapter)
......
......@@ -8,9 +8,7 @@ import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.squareup.picasso.Picasso
import java.text.SimpleDateFormat
import java.util.*
import com.bumptech.glide.Glide
/**
......@@ -32,22 +30,16 @@ class AlbumsHeaderAdapter : CommonRecyclerAdapter<AlbumsHeaderViewHolder, AlbumP
class AlbumsHeaderViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewModel>(itemView) {
private val dateFormatter = SimpleDateFormat("dd MMMM yyyy", Locale("ru"))
@BindView(R.id.preview) lateinit var preview:ImageView
@BindView(R.id.card_title) lateinit var articleTitle:TextView
@BindView(R.id.card_updated) lateinit var articleDate:TextView
override fun onViewBound(model: AlbumPreviewModel) {
// articleDate.text = dateFormatter.format(model.published)
articleTitle.text = model.title
Picasso.get()
Glide.with(itemView)
.load(model.previewUrl)
.centerCrop()
.fit()
.fitCenter()
.into(preview)
//
}
}
......@@ -6,13 +6,13 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager
import androidx.recyclerview.widget.StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS
import butterknife.BindView
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.domain.model.AlbumSortedModel
import com.biganto.visual.roompark.domain.model.PhotoModel
import com.biganto.visual.roompark.domain.model.PhotoResolutionModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import com.bumptech.glide.Glide
import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.view.detaches
import com.jakewharton.rxrelay2.BehaviorRelay
......@@ -83,16 +83,12 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
@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) {
model.resolutionList.lowelest()?.let {
picassoAsync
Glide.with(itemView)
.load(it.url)
.centerCrop()
.fit()
.fitCenter()
.into(photoPreview)
}}
}
......
......@@ -3,7 +3,6 @@ package com.biganto.visual.roompark.presentation.screen.article
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.webkit.WebView
import android.widget.ImageView
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.LinearLayoutManager
......@@ -17,10 +16,10 @@ import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.presentation.screen.article.util.HtmlPageAdapter
import com.biganto.visual.roompark.presentation.screen.article.util.HtmlTag
import com.biganto.visual.roompark.util.extensions.formatToSimple
import com.bumptech.glide.Glide
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.textview.MaterialTextView
import com.squareup.picasso.Picasso
import jp.wasabeef.picasso.transformations.BlurTransformation
import jp.wasabeef.glide.transformations.BlurTransformation
import timber.log.Timber
import javax.inject.Inject
......@@ -132,12 +131,12 @@ class ArticleScreenController :
articleDate.text = viewState.item.published.formatToSimple
Picasso.get()
Glide.with(blurPreview)
.load(viewState.item.previewUrl)
.transform(BlurTransformation(activity,40,4))
.transform(BlurTransformation(40,4))
.into(blurPreview)
Picasso.get()
Glide.with(articlePreview)
.load(viewState.item.previewUrl)
.into(articlePreview)
}
......
......@@ -9,7 +9,7 @@ import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import butterknife.ButterKnife
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.bumptech.glide.Glide
import com.google.android.material.textview.MaterialTextView
/**
......@@ -89,18 +89,13 @@ class HtmlTextViewHolder(itemView: View) : HtmlTagViewHolder<HtmlTag.Text>(itemV
}
class HtmlImageViewHolder(itemView: View) :HtmlTagViewHolder<HtmlTag.ImageSource>(itemView) {
private val picassoAsync by lazy {
return@lazy RoomParkApplication.component.providePicassoAsync()
}
override fun onViewBound(model: HtmlTag.ImageSource) {
val url = "https://room-park.ru${model.src}"
picassoAsync
Glide.with(itemView)
.load(url)
.into(itemView as ImageView)
}
}
private enum class HtmlViewType(val viewType:Int){
......
......@@ -17,9 +17,9 @@ import com.biganto.visual.roompark.util.extensions.toRubly
import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil
import com.bumptech.glide.Glide
import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.view.clicks
import com.squareup.picasso.Picasso
import io.reactivex.Observable
import io.reactivex.subjects.PublishSubject
......@@ -93,7 +93,7 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
statusLayout.invalidate()
model.tourPreview?.let {
Picasso.get()
Glide.with(tourScreen)
.load(it)
.into(tourScreen)
}
......
......@@ -9,9 +9,7 @@ import com.biganto.visual.roompark.domain.model.ArticlePreviewModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.biganto.visual.roompark.util.extensions.setGone
import com.jakewharton.rxbinding3.view.clicks
import com.squareup.picasso.Picasso
import io.reactivex.subjects.PublishSubject
import com.bumptech.glide.Glide
import java.text.SimpleDateFormat
import java.util.*
......@@ -44,7 +42,7 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(
articleTitle.text = model.title
articleIsRead.setGone(model.isRead)
Picasso.get()
Glide.with(preview)
.load(model.previewUrl)
.into(preview)
}
......
......@@ -10,8 +10,7 @@ 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.util.extensions.formatToSimple
import com.biganto.visual.roompark.util.extensions.setGone
import com.squareup.picasso.Picasso
import com.bumptech.glide.Glide
/**
* Created by Vladislav Bogdashkin on 15.10.2019.
......@@ -37,7 +36,7 @@ class ArticlePreviewViewHolder(itemView: View) : CommonViewHolder<ArticlePreview
articleTitle.text = model.title
articleIsRead.setGone(model.isRead)
Picasso.get()
Glide.with(preview)
.load(model.previewUrl)
.into(preview)
}
......
......@@ -8,7 +8,7 @@ import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.squareup.picasso.Picasso
import com.bumptech.glide.Glide
import java.text.SimpleDateFormat
import java.util.*
......@@ -41,10 +41,10 @@ class AlbumCardViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewModel>(
articleTitle.text = model.title
articleTitle.text = model.title
Picasso.get()
Glide.with(preview)
.load(model.previewUrl)
.centerCrop()
.fit()
.fitCenter()
.into(preview)
}
}
......@@ -12,7 +12,6 @@ import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.presentation.screen.photo.util.PhotoPreviewSlider
import com.biganto.visual.roompark.presentation.screen.photo.util.PhotosAdapter
import com.google.android.material.textview.MaterialTextView
import com.squareup.picasso.Picasso
import timber.log.Timber
import javax.inject.Inject
......@@ -105,9 +104,6 @@ class PhotoScreenController :
private fun render(viewState: PhotoScreenViewState.SomeError) =
showError(viewState.exception)
@Inject
lateinit var picassoAsync:Picasso
private fun render(viewState: PhotoScreenViewState.PhotoListLoaded) {
(photoViewPager.adapter as PhotosAdapter).setItems(
viewState.list.asSequence().sortedBy{it.sort}.toList()
......
......@@ -6,7 +6,6 @@ import android.view.View
import android.view.WindowManager
import butterknife.BindView
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.domain.model.PhotoModel
import com.biganto.visual.roompark.domain.model.PhotoResolutionModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
......@@ -48,11 +47,6 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
@BindView(R.id.photo_description)
lateinit var description: MaterialTextView
private val picassoAsync by lazy {
return@lazy RoomParkApplication.component.providePicassoAsync()
}
private val windowSize by lazy {
val pSize: Point = Point()
(itemView.context.getSystemService(Context.WINDOW_SERVICE) as WindowManager)
......
package com.biganto.visual.roompark.presentation.screen.photo.util
import android.app.Activity
import android.graphics.Bitmap
import android.graphics.Point
import android.graphics.drawable.Drawable
import android.util.DisplayMetrics
import android.view.View
import butterknife.BindView
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.domain.model.PhotoModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.github.chrisbanes.photoview.PhotoView
import com.google.android.material.textview.MaterialTextView
import com.squareup.picasso.Callback
import com.squareup.picasso.Picasso
import com.squareup.picasso.Target
import jp.wasabeef.picasso.transformations.BlurTransformation
import jp.wasabeef.picasso.transformations.ColorFilterTransformation
import timber.log.Timber
/**
* Created by Vladislav Bogdashkin on 15.10.2019.
*/
class PhotoViewerAdapter : CommonRecyclerAdapter<PhotoViewerViewHolder, PhotoModel>() {
override val vhKlazz = PhotoViewerViewHolder::class
override fun getVhLayout(): Int = R.layout.photo_page_viewholder
fun getItemPosition(model: PhotoModel) = getItemPosition(model.photoId)
fun getItemPosition(modelId: Int) = list.indexOfFirst {
it.photoId == modelId
}
}
class PhotoViewerViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView) {
@BindView(R.id.photo_view) lateinit var photoView:PhotoView
@BindView(R.id.photo_description) lateinit var photoDesc:MaterialTextView
private val displayMetrics = DisplayMetrics()
private val displaySize = Point()
private val picassoAsync: Picasso by lazy {
return@lazy RoomParkApplication.component.providePicassoAsync()
}
private val _t = object :Target{
override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
Timber.d("lalala")
}
override fun onBitmapFailed(e: java.lang.Exception?, errorDrawable: Drawable?) {
Timber.e(e)
}
override fun onBitmapLoaded(bitmap: Bitmap?, from: Picasso.LoadedFrom?) {
Timber.d("bitmap loaded: $bitmap")
photoView.setImageBitmap(bitmap)
}
}
override fun onViewBound(model: PhotoModel) {
photoDesc.visibility = if (model.description.isNullOrBlank()) View.GONE else View.VISIBLE
model.description?.let { photoDesc.text = it }
(itemView.context as Activity).windowManager.defaultDisplay.getSize(displaySize)
model.resolutionList.minBy { it.resHeight * it.resWidth }?.let { photoRes ->
picassoAsync
.load(photoRes.url)
.transform(BlurTransformation(itemView.context, 13, 1))
.transform(ColorFilterTransformation(0xCC000000.toInt()))
.into(photoView, object : Callback {
override fun onSuccess() {
model.optimalResolution(displaySize.x, displaySize.y).let {
Timber.d("goonna load image with ${it.resWidth} / ${it.resHeight}")
Picasso.get()
.load(it.url)
.into(_t)
}
}
override fun onError(e: Exception?) {
Timber.e(e)
}
})
}
}
}
import android.content.res.Resources
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.text.Html
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.google.android.material.textview.MaterialTextView
import com.squareup.picasso.Picasso
import com.squareup.picasso.Target
import timber.log.Timber
class PicassoImageGetter(private val target: MaterialTextView) : Html.ImageGetter {
override fun getDrawable(source: String): Drawable {
val drawable = BitmapDrawablePlaceHolder()
Picasso.get()
.load("https://room-park.ru$source")
.placeholder(R.drawable.ic_deals)
.into(drawable)
return drawable
}
private inner class BitmapDrawablePlaceHolder : BitmapDrawable(), Target{
protected var _drawable: Drawable? = null
private val resources: Resources = RoomParkApplication.component.provideAppContext().resources
override fun draw(canvas: Canvas) {
if (_drawable != null) {
_drawable!!.draw(canvas)
}
}
fun setDrawable(drawable: Drawable) {
this._drawable = drawable
var width = drawable.intrinsicWidth
var height = drawable.intrinsicHeight
Timber.d("WE GONNA WORK WITH DATA: ${target.width} / ${target.height}")
Timber.d("WE GONNA WORK WITH M DATA: ${target.measuredWidth} / ${target.measuredHeight}")
target.width.let{
val aspect = width.toFloat()/it.toFloat()
Timber.d("aspect is $aspect")
val imgWider = width>it
Timber.d("imgWider is $imgWider")
height = if (imgWider) (height.toFloat()/aspect).toInt()
else (height.toFloat()*aspect).toInt()
width = if (imgWider) it else it//imgWider
drawable.setBounds(0, 0, width, height)
setBounds(0, 0, width, height)
}
target.text=target.text
}
override fun onBitmapLoaded(bitmap: Bitmap, from: Picasso.LoadedFrom) {
setDrawable(BitmapDrawable(resources, bitmap))
}
override fun onBitmapFailed(e: Exception?, errorDrawable: Drawable?) {}
override fun onPrepareLoad(placeHolderDrawable: Drawable) {
}
}
}
\ No newline at end of file
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