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
adfcf8c4
Commit
adfcf8c4
authored
Mar 10, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some fixes
parent
6340a573
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
5 deletions
+60
-5
PhotoViewAdapter.kt
...ompark/presentation/screen/photo/util/PhotoViewAdapter.kt
+60
-5
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/photo/util/PhotoViewAdapter.kt
View file @
adfcf8c4
package
com.biganto.visual.roompark.presentation.screen.photo.util
package
com.biganto.visual.roompark.presentation.screen.photo.util
import
android.content.Context
import
android.graphics.Point
import
android.view.View
import
android.view.View
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.base.RoomParkApplication
...
@@ -11,6 +14,8 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewH
...
@@ -11,6 +14,8 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewH
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
/**
/**
* Created by Vladislav Bogdashkin on 16.10.2019.
* Created by Vladislav Bogdashkin on 16.10.2019.
...
@@ -36,26 +41,76 @@ class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() {
...
@@ -36,26 +41,76 @@ class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() {
class
PhotosViewHolder
(
itemView
:
View
)
:
CommonViewHolder
<
PhotoModel
>(
itemView
)
{
class
PhotosViewHolder
(
itemView
:
View
)
:
CommonViewHolder
<
PhotoModel
>(
itemView
)
{
@BindView
(
R
.
id
.
photo_view
)
lateinit
var
photoPreview
:
PhotoView
@BindView
(
R
.
id
.
photo_view
)
lateinit
var
photoPreview
:
PhotoView
@BindView
(
R
.
id
.
photo_description
)
lateinit
var
description
:
MaterialTextView
@BindView
(
R
.
id
.
photo_description
)
lateinit
var
description
:
MaterialTextView
private
val
picassoAsync
by
lazy
{
private
val
picassoAsync
by
lazy
{
return
@lazy
RoomParkApplication
.
component
.
providePicassoAsync
()
return
@lazy
RoomParkApplication
.
component
.
providePicassoAsync
()
}
}
private
val
windowSize
by
lazy
{
val
pSize
:
Point
=
Point
()
(
itemView
.
context
.
getSystemService
(
Context
.
WINDOW_SERVICE
)
as
WindowManager
)
.
defaultDisplay
.
getSize
(
pSize
)
pSize
}
override
fun
onViewBound
(
model
:
PhotoModel
)
{
override
fun
onViewBound
(
model
:
PhotoModel
)
{
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
.
lowelest
()
?.
let
{
picassoAsync
picassoAsync
.
load
(
it
.
url
)
.
load
(
it
.
url
)
.
centerCrop
()
.
centerCrop
()
.
fit
()
.
fit
()
.
into
(
photoPreview
)
.
into
(
photoPreview
,
object
:
Callback
,
com
.
squareup
.
picasso
.
Callback
{
}}
override
fun
onSuccess
()
{
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
{
photo
->
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
()
=
...
...
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