Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
008819d4
Commit
008819d4
authored
Mar 10, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/glide' into develop
parents
23fc8814
9e76476d
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
93 additions
and
372 deletions
+93
-372
build.gradle
app/build.gradle
+1
-4
RoomParkApplication.kt
...a/com/biganto/visual/roompark/base/RoomParkApplication.kt
+0
-19
AppComponent.kt
...ava/com/biganto/visual/roompark/di/dagger/AppComponent.kt
+0
-4
PicassoModule.kt
...va/com/biganto/visual/roompark/di/dagger/PicassoModule.kt
+0
-27
ScreenController.kt
...l/roompark/presentation/screen/albums/ScreenController.kt
+49
-46
AlbumHeaderAdapter.kt
...ark/presentation/screen/albums/util/AlbumHeaderAdapter.kt
+3
-11
AlbumListAdapter.kt
...mpark/presentation/screen/albums/util/AlbumListAdapter.kt
+3
-7
ScreenController.kt
.../roompark/presentation/screen/article/ScreenController.kt
+5
-6
textAdapter.kt
.../roompark/presentation/screen/article/util/textAdapter.kt
+3
-8
Adapter.kt
...visual/roompark/presentation/screen/deals/util/Adapter.kt
+2
-2
Adapter.kt
...al/roompark/presentation/screen/feed_list/util/Adapter.kt
+2
-4
ArticlesPreviewAdapter.kt
...presentation/screen/feeds/utils/ArticlesPreviewAdapter.kt
+2
-3
DevProgressPreviewAdapter.kt
...sentation/screen/feeds/utils/DevProgressPreviewAdapter.kt
+3
-3
ScreenController.kt
...al/roompark/presentation/screen/photo/ScreenController.kt
+1
-5
PhotoViewAdapter.kt
...ompark/presentation/screen/photo/util/PhotoViewAdapter.kt
+19
-52
PhotoViewerAdapter.kt
...park/presentation/screen/photo/util/PhotoViewerAdapter.kt
+0
-96
PicassoImageGetter.kt
...isual/roompark/util/view_utils/html/PicassoImageGetter.kt
+0
-75
No files found.
app/build.gradle
View file @
008819d4
...
@@ -77,10 +77,6 @@ dependencies {
...
@@ -77,10 +77,6 @@ dependencies {
//Constraint Layout
//Constraint Layout
implementation
"androidx.constraintlayout:constraintlayout:$constrainLayoutVersion"
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
//Logger: Timber
implementation
"com.jakewharton.timber:timber:$timberVersion"
implementation
"com.jakewharton.timber:timber:$timberVersion"
...
@@ -162,6 +158,7 @@ dependencies {
...
@@ -162,6 +158,7 @@ dependencies {
//Glide
//Glide
implementation
"com.github.bumptech.glide:glide:$glideVersion"
implementation
"com.github.bumptech.glide:glide:$glideVersion"
implementation
'jp.wasabeef:glide-transformations:4.0.0'
annotationProcessor
"com.github.bumptech.glide:compiler:$glideVersion"
annotationProcessor
"com.github.bumptech.glide:compiler:$glideVersion"
//Tests
//Tests
...
...
app/src/main/java/com/biganto/visual/roompark/base/RoomParkApplication.kt
View file @
008819d4
...
@@ -5,7 +5,6 @@ import com.biganto.visual.roompark.BuildConfig
...
@@ -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.AppComponent
import
com.biganto.visual.roompark.di.dagger.DaggerAppComponent
import
com.biganto.visual.roompark.di.dagger.DaggerAppComponent
import
com.crashlytics.android.Crashlytics
import
com.crashlytics.android.Crashlytics
import
com.squareup.picasso.Picasso
import
dagger.android.AndroidInjector
import
dagger.android.AndroidInjector
import
dagger.android.DaggerApplication
import
dagger.android.DaggerApplication
import
timber.log.Timber
import
timber.log.Timber
...
@@ -35,24 +34,6 @@ class RoomParkApplication : DaggerApplication() {
...
@@ -35,24 +34,6 @@ class RoomParkApplication : DaggerApplication() {
if
(
BuildConfig
.
DEBUG
)
Timber
.
plant
(
Timber
.
DebugTree
())
if
(
BuildConfig
.
DEBUG
)
Timber
.
plant
(
Timber
.
DebugTree
())
else
Timber
.
plant
(
CrashlyticsTree
())
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
}
}
}
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/di/dagger/AppComponent.kt
View file @
008819d4
...
@@ -10,7 +10,6 @@ import com.biganto.visual.roompark.data.repository.db.IDb
...
@@ -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.db.requrey.DbModule
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.domain.contract.*
import
com.biganto.visual.roompark.domain.contract.*
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,7 +37,6 @@ import javax.inject.Singleton
...
@@ -38,7 +37,6 @@ 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
,
...
@@ -64,8 +62,6 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
...
@@ -64,8 +62,6 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun
provideAppContext
():
Application
fun
provideAppContext
():
Application
fun
providePicassoAsync
():
Picasso
fun
provideFileSystem
():
FileModule
fun
provideFileSystem
():
FileModule
...
...
app/src/main/java/com/biganto/visual/roompark/di/dagger/PicassoModule.kt
deleted
100644 → 0
View file @
23fc8814
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
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenController.kt
View file @
008819d4
package
com.biganto.visual.roompark.presentation.screen.albums
package
com.biganto.visual.roompark.presentation.screen.albums
import
android.graphics.Bitmap
import
android.content.Context
import
android.graphics.drawable.BitmapDrawable
import
android.graphics.drawable.Drawable
import
android.graphics.drawable.Drawable
import
android.os.Bundle
import
android.os.Bundle
import
android.view.View
import
android.view.View
...
@@ -19,22 +18,22 @@ import com.biganto.visual.roompark.domain.model.PhotoModel
...
@@ -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.AlbumListAdapter
import
com.biganto.visual.roompark.presentation.screen.albums.util.AlbumsHeaderAdapter
import
com.biganto.visual.roompark.presentation.screen.albums.util.AlbumsHeaderAdapter
import
com.biganto.visual.roompark.presentation.screen.photo.PhotoScreenController
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.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
com.bluelinelabs.conductor.changehandler.VerticalChangeHandler
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.google.android.material.textview.MaterialTextView
import
com.squareup.picasso.Picasso
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
import
jp.wasabeef.picasso.transformations.BlurTransformation
import
jp.wasabeef.glide.transformations.BlurTransformation
import
jp.wasabeef.picasso.transformations.ColorFilterTransformation
import
jp.wasabeef.glide.transformations.ColorFilterTransformation
import
timber.log.Timber
import
java.util.concurrent.TimeUnit
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
*/
...
@@ -67,22 +66,22 @@ class AlbumsScreenController :
...
@@ -67,22 +66,22 @@ class AlbumsScreenController :
//
private
val
photosBackgroundTarget
=
object
:
com
.
squareup
.
picasso
.
Target
{
//
private val photosBackgroundTarget = object : com.squareup.picasso.Target {
override
fun
onPrepareLoad
(
placeHolderDrawable
:
Drawable
?)
{
//
override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
// nestedScrollView.background = placeHolderDrawable
//
//
nestedScrollView.background = placeHolderDrawable
}
//
}
//
override
fun
onBitmapFailed
(
e
:
Exception
?,
errorDrawable
:
Drawable
?)
{
//
override fun onBitmapFailed(e: Exception?, errorDrawable: Drawable?) {
Timber
.
e
(
e
)
//
Timber.e(e)
}
//
}
//
override
fun
onBitmapLoaded
(
bitmap
:
Bitmap
?,
from
:
Picasso
.
LoadedFrom
?)
{
//
override fun onBitmapLoaded(bitmap: Bitmap?, from: Picasso.LoadedFrom?) {
bitmap
?.
scaleCenterCrop
(
nestedScrollView
)
?.
let
{
//
bitmap?.scaleCenterCrop(nestedScrollView)?.let {
nestedScrollView
.
background
=
BitmapDrawable
(
activity
?.
resources
,
it
)
//
nestedScrollView.background = BitmapDrawable(activity?.resources, it)
}
//
}
}
//
}
}
//
}
private
fun
bindRecycler
()
{
private
fun
bindRecycler
()
{
...
@@ -161,9 +160,6 @@ class AlbumsScreenController :
...
@@ -161,9 +160,6 @@ class AlbumsScreenController :
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
SomeError
)
=
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
SomeError
)
=
showError
(
viewState
.
exception
)
showError
(
viewState
.
exception
)
@Inject
lateinit
var
picassoAsync
:
Picasso
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsListLoaded
)
{
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsListLoaded
)
{
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
).
setItems
(
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
).
setItems
(
viewState
.
list
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
viewState
.
list
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
...
@@ -177,13 +173,10 @@ class AlbumsScreenController :
...
@@ -177,13 +173,10 @@ class AlbumsScreenController :
viewState
.
list
.
first
{
it
.
albumId
==
viewState
.
selectedAlbumId
}.
let
{
viewState
.
list
.
first
{
it
.
albumId
==
viewState
.
selectedAlbumId
}.
let
{
currentAlbomTitle
.
text
=
it
.
title
currentAlbomTitle
.
text
=
it
.
title
picassoAsync
activity
?.
let
{
ctx
->
.
load
(
it
.
previewUrl
)
loadGlideBlurred
(
it
.
previewUrl
,
ctx
,
nestedBgTarget
)
.
transform
(
BlurTransformation
(
activity
,
13
,
2
))
}
.
transform
(
ColorFilterTransformation
(
0
xCC000000
.
toInt
()))
.
into
(
photosBackgroundTarget
)
}
}
}
}
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
HeaderAlbumChoosed
)
{
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
HeaderAlbumChoosed
)
{
...
@@ -193,11 +186,10 @@ class AlbumsScreenController :
...
@@ -193,11 +186,10 @@ class AlbumsScreenController :
}
}
currentAlbomTitle
.
text
=
viewState
.
item
.
title
currentAlbomTitle
.
text
=
viewState
.
item
.
title
picassoAsync
activity
?.
let
{
ctx
->
.
load
(
viewState
.
item
.
previewUrl
)
loadGlideBlurred
(
viewState
.
item
.
previewUrl
,
ctx
,
nestedBgTarget
)
.
transform
(
BlurTransformation
(
activity
,
13
,
2
))
}
.
transform
(
ColorFilterTransformation
(
0
xCC000000
.
toInt
()))
.
into
(
photosBackgroundTarget
)
}
}
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsSelected
){
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsSelected
){
...
@@ -206,7 +198,7 @@ class AlbumsScreenController :
...
@@ -206,7 +198,7 @@ class AlbumsScreenController :
)
)
}
}
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
RestoreView
){
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
RestoreView
)
{
(
albumsRecyclerView
.
adapter
as
AlbumListAdapter
).
setItems
(
(
albumsRecyclerView
.
adapter
as
AlbumListAdapter
).
setItems
(
viewState
.
restore
.
albumList
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
viewState
.
restore
.
albumList
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
)
)
...
@@ -221,17 +213,28 @@ class AlbumsScreenController :
...
@@ -221,17 +213,28 @@ class AlbumsScreenController :
)
)
}
}
viewState
.
restore
.
albumsPreview
.
first
{
it
.
albumId
==
viewState
.
restore
.
currentIndex
}
viewState
.
restore
.
albumsPreview
.
first
{
it
.
albumId
==
viewState
.
restore
.
currentIndex
}
.
let
{
.
let
{
currentAlbomTitle
.
text
=
it
.
title
currentAlbomTitle
.
text
=
it
.
title
picassoAsync
activity
?.
let
{
ctx
->
.
load
(
it
.
previewUrl
)
loadGlideBlurred
(
it
.
previewUrl
,
ctx
,
nestedBgTarget
)
.
transform
(
BlurTransformation
(
activity
,
13
,
2
))
}
.
transform
(
ColorFilterTransformation
(
0
xCC000000
.
toInt
()))
}
.
into
(
photosBackgroundTarget
)
}
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
(
0
xCC000000
.
toInt
()))
.
into
(
drawable
)
override
fun
onAlbumSelected
():
Observable
<
AlbumPreviewModel
>
override
fun
onAlbumSelected
():
Observable
<
AlbumPreviewModel
>
=
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
)
=
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
)
.
onItemClicked
.
onItemClicked
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/util/AlbumHeaderAdapter.kt
View file @
008819d4
...
@@ -8,9 +8,7 @@ import com.biganto.visual.roompark.R
...
@@ -8,9 +8,7 @@ import com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.domain.model.AlbumPreviewModel
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.CommonRecyclerAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
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.*
/**
/**
...
@@ -32,22 +30,16 @@ class AlbumsHeaderAdapter : CommonRecyclerAdapter<AlbumsHeaderViewHolder, AlbumP
...
@@ -32,22 +30,16 @@ class AlbumsHeaderAdapter : CommonRecyclerAdapter<AlbumsHeaderViewHolder, AlbumP
class
AlbumsHeaderViewHolder
(
itemView
:
View
)
:
CommonViewHolder
<
AlbumPreviewModel
>(
itemView
)
{
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
.
preview
)
lateinit
var
preview
:
ImageView
@BindView
(
R
.
id
.
card_title
)
lateinit
var
articleTitle
:
TextView
@BindView
(
R
.
id
.
card_title
)
lateinit
var
articleTitle
:
TextView
@BindView
(
R
.
id
.
card_updated
)
lateinit
var
articleDate
:
TextView
@BindView
(
R
.
id
.
card_updated
)
lateinit
var
articleDate
:
TextView
override
fun
onViewBound
(
model
:
AlbumPreviewModel
)
{
override
fun
onViewBound
(
model
:
AlbumPreviewModel
)
{
// articleDate.text = dateFormatter.format(model.published)
articleTitle
.
text
=
model
.
title
articleTitle
.
text
=
model
.
title
Picasso
.
get
(
)
Glide
.
with
(
itemView
)
.
load
(
model
.
previewUrl
)
.
load
(
model
.
previewUrl
)
.
centerCrop
()
.
centerCrop
()
.
fit
()
.
fit
Center
()
.
into
(
preview
)
.
into
(
preview
)
//
}
}
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/util/AlbumListAdapter.kt
View file @
008819d4
...
@@ -6,13 +6,13 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager
...
@@ -6,13 +6,13 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager
import
androidx.recyclerview.widget.StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS
import
androidx.recyclerview.widget.StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS
import
butterknife.BindView
import
butterknife.BindView
import
com.biganto.visual.roompark.R
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.AlbumSortedModel
import
com.biganto.visual.roompark.domain.model.PhotoModel
import
com.biganto.visual.roompark.domain.model.PhotoModel
import
com.biganto.visual.roompark.domain.model.PhotoResolutionModel
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.CommonRecyclerAdapter
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.bumptech.glide.Glide
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.view.detaches
import
com.jakewharton.rxbinding3.view.detaches
import
com.jakewharton.rxrelay2.BehaviorRelay
import
com.jakewharton.rxrelay2.BehaviorRelay
...
@@ -83,16 +83,12 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
...
@@ -83,16 +83,12 @@ 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
{
picassoAsync
Glide
.
with
(
itemView
)
.
load
(
it
.
url
)
.
load
(
it
.
url
)
.
centerCrop
()
.
centerCrop
()
.
fit
()
.
fit
Center
()
.
into
(
photoPreview
)
.
into
(
photoPreview
)
}}
}}
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/article/ScreenController.kt
View file @
008819d4
...
@@ -3,7 +3,6 @@ package com.biganto.visual.roompark.presentation.screen.article
...
@@ -3,7 +3,6 @@ package com.biganto.visual.roompark.presentation.screen.article
import
android.os.Bundle
import
android.os.Bundle
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.webkit.WebView
import
android.widget.ImageView
import
android.widget.ImageView
import
androidx.core.os.bundleOf
import
androidx.core.os.bundleOf
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.LinearLayoutManager
...
@@ -17,10 +16,10 @@ import com.biganto.visual.roompark.conductor.BigantoBaseController
...
@@ -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.HtmlPageAdapter
import
com.biganto.visual.roompark.presentation.screen.article.util.HtmlTag
import
com.biganto.visual.roompark.presentation.screen.article.util.HtmlTag
import
com.biganto.visual.roompark.util.extensions.formatToSimple
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.floatingactionbutton.FloatingActionButton
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
com.squareup.picasso.Picasso
import
jp.wasabeef.glide.transformations.BlurTransformation
import
jp.wasabeef.picasso.transformations.BlurTransformation
import
timber.log.Timber
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -132,12 +131,12 @@ class ArticleScreenController :
...
@@ -132,12 +131,12 @@ class ArticleScreenController :
articleDate
.
text
=
viewState
.
item
.
published
.
formatToSimple
articleDate
.
text
=
viewState
.
item
.
published
.
formatToSimple
Picasso
.
get
(
)
Glide
.
with
(
blurPreview
)
.
load
(
viewState
.
item
.
previewUrl
)
.
load
(
viewState
.
item
.
previewUrl
)
.
transform
(
BlurTransformation
(
activity
,
40
,
4
))
.
transform
(
BlurTransformation
(
40
,
4
))
.
into
(
blurPreview
)
.
into
(
blurPreview
)
Picasso
.
get
(
)
Glide
.
with
(
articlePreview
)
.
load
(
viewState
.
item
.
previewUrl
)
.
load
(
viewState
.
item
.
previewUrl
)
.
into
(
articlePreview
)
.
into
(
articlePreview
)
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/article/util/textAdapter.kt
View file @
008819d4
...
@@ -9,7 +9,7 @@ import android.widget.ImageView
...
@@ -9,7 +9,7 @@ import android.widget.ImageView
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
butterknife.ButterKnife
import
butterknife.ButterKnife
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.R
import
com.b
iganto.visual.roompark.base.RoomParkApplication
import
com.b
umptech.glide.Glide
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
/**
/**
...
@@ -89,18 +89,13 @@ class HtmlTextViewHolder(itemView: View) : HtmlTagViewHolder<HtmlTag.Text>(itemV
...
@@ -89,18 +89,13 @@ class HtmlTextViewHolder(itemView: View) : HtmlTagViewHolder<HtmlTag.Text>(itemV
}
}
class
HtmlImageViewHolder
(
itemView
:
View
)
:
HtmlTagViewHolder
<
HtmlTag
.
ImageSource
>(
itemView
)
{
class
HtmlImageViewHolder
(
itemView
:
View
)
:
HtmlTagViewHolder
<
HtmlTag
.
ImageSource
>(
itemView
)
{
private
val
picassoAsync
by
lazy
{
return
@lazy
RoomParkApplication
.
component
.
providePicassoAsync
()
}
override
fun
onViewBound
(
model
:
HtmlTag
.
ImageSource
)
{
override
fun
onViewBound
(
model
:
HtmlTag
.
ImageSource
)
{
val
url
=
"https://room-park.ru${model.src}"
val
url
=
"https://room-park.ru${model.src}"
picassoAsync
Glide
.
with
(
itemView
)
.
load
(
url
)
.
load
(
url
)
.
into
(
itemView
as
ImageView
)
.
into
(
itemView
as
ImageView
)
}
}
}
}
private
enum
class
HtmlViewType
(
val
viewType
:
Int
){
private
enum
class
HtmlViewType
(
val
viewType
:
Int
){
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deals/util/Adapter.kt
View file @
008819d4
...
@@ -17,9 +17,9 @@ import com.biganto.visual.roompark.util.extensions.toRubly
...
@@ -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.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.StatusProgressAnimationState
import
com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil
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.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.view.clicks
import
com.jakewharton.rxbinding3.view.clicks
import
com.squareup.picasso.Picasso
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.subjects.PublishSubject
import
io.reactivex.subjects.PublishSubject
...
@@ -93,7 +93,7 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
...
@@ -93,7 +93,7 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
statusLayout
.
invalidate
()
statusLayout
.
invalidate
()
model
.
tourPreview
?.
let
{
model
.
tourPreview
?.
let
{
Picasso
.
get
(
)
Glide
.
with
(
tourScreen
)
.
load
(
it
)
.
load
(
it
)
.
into
(
tourScreen
)
.
into
(
tourScreen
)
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/util/Adapter.kt
View file @
008819d4
...
@@ -9,9 +9,7 @@ import com.biganto.visual.roompark.domain.model.ArticlePreviewModel
...
@@ -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.CommonRecyclerAdapter
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.extensions.setGone
import
com.biganto.visual.roompark.util.extensions.setGone
import
com.jakewharton.rxbinding3.view.clicks
import
com.bumptech.glide.Glide
import
com.squareup.picasso.Picasso
import
io.reactivex.subjects.PublishSubject
import
java.text.SimpleDateFormat
import
java.text.SimpleDateFormat
import
java.util.*
import
java.util.*
...
@@ -44,7 +42,7 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(
...
@@ -44,7 +42,7 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(
articleTitle
.
text
=
model
.
title
articleTitle
.
text
=
model
.
title
articleIsRead
.
setGone
(
model
.
isRead
)
articleIsRead
.
setGone
(
model
.
isRead
)
Picasso
.
get
(
)
Glide
.
with
(
preview
)
.
load
(
model
.
previewUrl
)
.
load
(
model
.
previewUrl
)
.
into
(
preview
)
.
into
(
preview
)
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/utils/ArticlesPreviewAdapter.kt
View file @
008819d4
...
@@ -10,8 +10,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc
...
@@ -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.presentation.screen.settings.util.CommonViewHolder
import
com.biganto.visual.roompark.util.extensions.formatToSimple
import
com.biganto.visual.roompark.util.extensions.formatToSimple
import
com.biganto.visual.roompark.util.extensions.setGone
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.
* Created by Vladislav Bogdashkin on 15.10.2019.
...
@@ -37,7 +36,7 @@ class ArticlePreviewViewHolder(itemView: View) : CommonViewHolder<ArticlePreview
...
@@ -37,7 +36,7 @@ class ArticlePreviewViewHolder(itemView: View) : CommonViewHolder<ArticlePreview
articleTitle
.
text
=
model
.
title
articleTitle
.
text
=
model
.
title
articleIsRead
.
setGone
(
model
.
isRead
)
articleIsRead
.
setGone
(
model
.
isRead
)
Picasso
.
get
(
)
Glide
.
with
(
preview
)
.
load
(
model
.
previewUrl
)
.
load
(
model
.
previewUrl
)
.
into
(
preview
)
.
into
(
preview
)
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/utils/DevProgressPreviewAdapter.kt
View file @
008819d4
...
@@ -8,7 +8,7 @@ import com.biganto.visual.roompark.R
...
@@ -8,7 +8,7 @@ import com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.domain.model.AlbumPreviewModel
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.CommonRecyclerAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
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.text.SimpleDateFormat
import
java.util.*
import
java.util.*
...
@@ -41,10 +41,10 @@ class AlbumCardViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewModel>(
...
@@ -41,10 +41,10 @@ class AlbumCardViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewModel>(
articleTitle
.
text
=
model
.
title
articleTitle
.
text
=
model
.
title
articleTitle
.
text
=
model
.
title
articleTitle
.
text
=
model
.
title
Picasso
.
get
(
)
Glide
.
with
(
preview
)
.
load
(
model
.
previewUrl
)
.
load
(
model
.
previewUrl
)
.
centerCrop
()
.
centerCrop
()
.
fit
()
.
fit
Center
()
.
into
(
preview
)
.
into
(
preview
)
}
}
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/photo/ScreenController.kt
View file @
008819d4
...
@@ -12,7 +12,6 @@ import com.biganto.visual.roompark.conductor.BigantoBaseController
...
@@ -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.PhotoPreviewSlider
import
com.biganto.visual.roompark.presentation.screen.photo.util.PhotosAdapter
import
com.biganto.visual.roompark.presentation.screen.photo.util.PhotosAdapter
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
com.squareup.picasso.Picasso
import
timber.log.Timber
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -46,7 +45,7 @@ class PhotoScreenController :
...
@@ -46,7 +45,7 @@ class PhotoScreenController :
private
fun
bindRecycler
()
{
private
fun
bindRecycler
()
{
photoViewPager
.
isNestedScrollingEnabled
=
false
photoViewPager
.
isNestedScrollingEnabled
=
false
photoViewPager
.
offscreenPageLimit
=
2
photoViewPager
.
offscreenPageLimit
=
1
photoViewPager
.
adapter
=
PhotosAdapter
()
photoViewPager
.
adapter
=
PhotosAdapter
()
setVewPager
()
setVewPager
()
}
}
...
@@ -105,9 +104,6 @@ class PhotoScreenController :
...
@@ -105,9 +104,6 @@ class PhotoScreenController :
private
fun
render
(
viewState
:
PhotoScreenViewState
.
SomeError
)
=
private
fun
render
(
viewState
:
PhotoScreenViewState
.
SomeError
)
=
showError
(
viewState
.
exception
)
showError
(
viewState
.
exception
)
@Inject
lateinit
var
picassoAsync
:
Picasso
private
fun
render
(
viewState
:
PhotoScreenViewState
.
PhotoListLoaded
)
{
private
fun
render
(
viewState
:
PhotoScreenViewState
.
PhotoListLoaded
)
{
(
photoViewPager
.
adapter
as
PhotosAdapter
).
setItems
(
(
photoViewPager
.
adapter
as
PhotosAdapter
).
setItems
(
viewState
.
list
.
asSequence
().
sortedBy
{
it
.
sort
}.
toList
()
viewState
.
list
.
asSequence
().
sortedBy
{
it
.
sort
}.
toList
()
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/photo/util/PhotoViewAdapter.kt
View file @
008819d4
...
@@ -6,15 +6,15 @@ import android.view.View
...
@@ -6,15 +6,15 @@ import android.view.View
import
android.view.WindowManager
import
android.view.WindowManager
import
butterknife.BindView
import
butterknife.BindView
import
com.biganto.visual.roompark.R
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.PhotoModel
import
com.biganto.visual.roompark.domain.model.PhotoResolutionModel
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.CommonRecyclerAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.engine.DiskCacheStrategy
import
com.github.chrisbanes.photoview.PhotoView
import
com.github.chrisbanes.photoview.PhotoView
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
timber.log.Timber
import
timber.log.Timber
import
javax.security.auth.callback.Callback
import
kotlin.math.absoluteValue
import
kotlin.math.absoluteValue
/**
/**
...
@@ -47,11 +47,6 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
...
@@ -47,11 +47,6 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
@BindView
(
R
.
id
.
photo_description
)
@BindView
(
R
.
id
.
photo_description
)
lateinit
var
description
:
MaterialTextView
lateinit
var
description
:
MaterialTextView
private
val
picassoAsync
by
lazy
{
return
@lazy
RoomParkApplication
.
component
.
providePicassoAsync
()
}
private
val
windowSize
by
lazy
{
private
val
windowSize
by
lazy
{
val
pSize
:
Point
=
Point
()
val
pSize
:
Point
=
Point
()
(
itemView
.
context
.
getSystemService
(
Context
.
WINDOW_SERVICE
)
as
WindowManager
)
(
itemView
.
context
.
getSystemService
(
Context
.
WINDOW_SERVICE
)
as
WindowManager
)
...
@@ -64,54 +59,26 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
...
@@ -64,54 +59,26 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
description
.
visibility
=
if
(
model
.
description
!=
null
)
View
.
VISIBLE
else
View
.
GONE
description
.
visibility
=
if
(
model
.
description
!=
null
)
View
.
VISIBLE
else
View
.
GONE
model
.
description
?.
let
{
description
.
text
=
it
}
model
.
description
?.
let
{
description
.
text
=
it
}
model
.
resolutionList
.
lowelest
()
?.
let
{
model
.
resolutionList
picassoAsync
.
minBy
{
.
load
(
it
.
url
)
((
windowSize
.
x
-
it
.
resWidth
+
.
1f
).
absoluteValue
.
centerCrop
()
+
(
windowSize
.
y
-
it
.
resHeight
+
.
1f
).
absoluteValue
.
fit
()
)
.
into
(
photoPreview
,
object
:
Callback
,
com
.
squareup
.
picasso
.
Callback
{
}
override
fun
onSuccess
()
{
?.
let
{
photo
->
model
.
resolutionList
Timber
.
d
(
"val: ${photo.resWidth} : ${photo.resHeight}"
)
.
onEach
{
Timber
.
d
(
"val ensure: ${it.resWidth} : ${it.resHeight}"
)
}
Glide
.
with
(
photoPreview
)
.
minBy
{
.
load
(
photo
.
url
)
((
windowSize
.
x
-
it
.
resWidth
+
.
1f
).
absoluteValue
.
thumbnail
(
model
.
resolutionList
.
lowelest
()
?.
let
{
thumb
->
+
(
windowSize
.
y
-
it
.
resHeight
+
.
1f
).
absoluteValue
Glide
.
with
(
photoPreview
).
load
(
thumb
.
url
).
diskCacheStrategy
(
DiskCacheStrategy
.
ALL
)
)
})
}
.
diskCacheStrategy
(
DiskCacheStrategy
.
ALL
)
?.
let
{
photo
->
.
into
(
photoPreview
)
Timber
.
d
(
"val: ${photo.resWidth} : ${photo.resHeight}"
)
}
picassoAsync
.
load
(
photo
.
url
)
.
centerCrop
()
.
fit
()
.
into
(
photoPreview
)
}
}
override
fun
onError
(
e
:
Exception
?)
{
model
.
resolutionList
.
onEach
{
Timber
.
d
(
"val ensure: ${it.resWidth} : ${it.resHeight}"
)
}
.
minBy
{
((
windowSize
.
x
-
it
.
resWidth
+
.
1f
).
absoluteValue
+
(
windowSize
.
y
-
it
.
resHeight
+
.
1f
).
absoluteValue
)
}
?.
let
{
Timber
.
d
(
"val: ${it.resWidth} : ${it.resHeight}"
)
picassoAsync
.
load
(
it
.
url
)
.
centerCrop
()
.
fit
()
.
into
(
photoPreview
)
}
}
})
}
}
}
}
}
private
fun
List
<
PhotoResolutionModel
>.
lowelest
()
=
private
fun
List
<
PhotoResolutionModel
>.
lowelest
()
=
this
.
minBy
{
it
.
resWidth
*
it
.
resHeight
}
this
.
minBy
{
it
.
resWidth
*
it
.
resHeight
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/photo/util/PhotoViewerAdapter.kt
deleted
100644 → 0
View file @
23fc8814
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
(
0
xCC000000
.
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
)
}
})
}
}
}
app/src/main/java/com/biganto/visual/roompark/util/view_utils/html/PicassoImageGetter.kt
deleted
100644 → 0
View file @
23fc8814
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment