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
b715e5e9
Commit
b715e5e9
authored
Dec 16, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize picasso loader
parent
c03a1a85
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
31 deletions
+38
-31
ScreenController.kt
...l/roompark/presentation/screen/albums/ScreenController.kt
+31
-30
AlbumListAdapter.kt
...mpark/presentation/screen/albums/util/AlbumListAdapter.kt
+7
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenController.kt
View file @
b715e5e9
...
@@ -55,6 +55,35 @@ class AlbumsScreenController :
...
@@ -55,6 +55,35 @@ class AlbumsScreenController :
val
photosBackgroundTarget
=
object
:
com
.
squareup
.
picasso
.
Target
{
override
fun
onPrepareLoad
(
placeHolderDrawable
:
Drawable
?)
{
Timber
.
d
(
"View measures: 1 - "
+
"${nestedScrollView.width} "
+
"/ ${nestedScrollView.height} "
+
"/ ${nestedScrollView.measuredWidth} "
+
"/${nestedScrollView.measuredHeight}"
)
nestedScrollView
.
background
=
placeHolderDrawable
}
override
fun
onBitmapFailed
(
e
:
Exception
?,
errorDrawable
:
Drawable
?)
{
Timber
.
e
(
e
)
}
override
fun
onBitmapLoaded
(
bitmap
:
Bitmap
?,
from
:
Picasso
.
LoadedFrom
?)
{
Timber
.
d
(
"View measures: 2 - "
+
"${nestedScrollView.width} "
+
"/ ${nestedScrollView.height} "
+
"/ ${nestedScrollView.measuredWidth} "
+
"/${nestedScrollView.measuredHeight}"
)
val
croppedBtimpa
=
bitmap
?.
scaleCenterCrop
(
nestedScrollView
)
nestedScrollView
.
background
=
BitmapDrawable
(
activity
?.
resources
,
croppedBtimpa
)
}
}
private
fun
bindRecycler
()
{
private
fun
bindRecycler
()
{
...
@@ -141,39 +170,11 @@ class AlbumsScreenController :
...
@@ -141,39 +170,11 @@ class AlbumsScreenController :
Timber
.
d
(
"URL TO LOAD BG $urlToLoadBg"
)
Timber
.
d
(
"URL TO LOAD BG $urlToLoadBg"
)
urlToLoadBg
.
let
{
urlToLoadBg
.
let
{
Picasso
.
get
()
Picasso
.
Builder
(
activity
!!
).
build
()
.
load
(
it
)
.
load
(
it
)
.
transform
(
BlurTransformation
(
activity
,
13
,
2
))
.
transform
(
BlurTransformation
(
activity
,
13
,
2
))
.
transform
(
ColorFilterTransformation
(
0
xCC000000
.
toInt
()))
.
transform
(
ColorFilterTransformation
(
0
xCC000000
.
toInt
()))
.
into
(
object
:
com
.
squareup
.
picasso
.
Target
{
.
into
(
photosBackgroundTarget
)
override
fun
onPrepareLoad
(
placeHolderDrawable
:
Drawable
?)
{
Timber
.
d
(
"View measures: 1 - "
+
"${nestedScrollView.width} "
+
"/ ${nestedScrollView.height} "
+
"/ ${nestedScrollView.measuredWidth} "
+
"/${nestedScrollView.measuredHeight}"
)
nestedScrollView
.
background
=
placeHolderDrawable
}
override
fun
onBitmapFailed
(
e
:
Exception
?,
errorDrawable
:
Drawable
?)
{
Timber
.
e
(
e
)
}
override
fun
onBitmapLoaded
(
bitmap
:
Bitmap
?,
from
:
Picasso
.
LoadedFrom
?)
{
Timber
.
d
(
"View measures: 2 - "
+
"${nestedScrollView.width} "
+
"/ ${nestedScrollView.height} "
+
"/ ${nestedScrollView.measuredWidth} "
+
"/${nestedScrollView.measuredHeight}"
)
val
croppedBtimpa
=
bitmap
?.
scaleCenterCrop
(
nestedScrollView
)
nestedScrollView
.
background
=
BitmapDrawable
(
activity
?.
resources
,
croppedBtimpa
)
}
})
}
}
}
}
catch
(
e
:
java
.
lang
.
Exception
){
Timber
.
e
(
e
)}
catch
(
e
:
java
.
lang
.
Exception
){
Timber
.
e
(
e
)}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/util/AlbumListAdapter.kt
View file @
b715e5e9
...
@@ -5,6 +5,7 @@ import androidx.recyclerview.widget.RecyclerView
...
@@ -5,6 +5,7 @@ import androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.StaggeredGridLayoutManager
import
androidx.recyclerview.widget.StaggeredGridLayoutManager
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
...
@@ -13,6 +14,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewH
...
@@ -13,6 +14,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewH
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
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.
...
@@ -51,6 +53,10 @@ class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() {
...
@@ -51,6 +53,10 @@ 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
)
{
...
@@ -58,7 +64,7 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
...
@@ -58,7 +64,7 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
override
fun
onViewBound
(
model
:
PhotoModel
)
{
override
fun
onViewBound
(
model
:
PhotoModel
)
{
model
.
resolutionList
.
lowelest
()
?.
let
{
model
.
resolutionList
.
lowelest
()
?.
let
{
Picasso
.
get
()
picoAbuilder
.
load
(
it
.
url
)
.
load
(
it
.
url
)
.
centerCrop
()
.
centerCrop
()
.
fit
()
.
fit
()
...
...
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