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
d72a59a7
Commit
d72a59a7
authored
Dec 24, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
photo loads with preview
parent
69b6e42f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
13 deletions
+58
-13
raw2entity.kt
...anto/visual/roompark/data/repository/mapper/raw2entity.kt
+1
-1
albums.kt
...n/java/com/biganto/visual/roompark/domain/model/albums.kt
+4
-2
ScreenController.kt
...al/roompark/presentation/screen/photo/ScreenController.kt
+1
-1
PhotoViewerAdapter.kt
...park/presentation/screen/photo/util/PhotoViewerAdapter.kt
+49
-6
ext.kt
...n/java/com/biganto/visual/roompark/util/extensions/ext.kt
+3
-3
No files found.
app/src/main/java/com/biganto/visual/roompark/data/repository/mapper/raw2entity.kt
View file @
d72a59a7
...
...
@@ -93,7 +93,7 @@ fun fromRaw(raw:ResolutionRaw) =
//fun fromRaw(raw: List<FeedRaw>):List<FeedEntity> = List(raw.
s
ize) { index-> fromRaw(raw[index]) }
//fun fromRaw(raw: List<FeedRaw>):List<FeedEntity> = List(raw.
displayS
ize) { index-> fromRaw(raw[index]) }
fun
<
E
,
M
>
fromRawList
(
raw
:
List
<
E
>,
block
:(
E
)->
M
):
List
<
M
>
=
List
(
raw
.
size
)
{
index
->
block
(
raw
[
index
])
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/model/albums.kt
View file @
d72a59a7
...
...
@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.domain.model
import
com.biganto.visual.roompark.data.repository.db.requrey.model.GalleryPhotoEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ImageAlbumEntity
import
timber.log.Timber
import
java.util.*
/**
...
...
@@ -48,8 +49,9 @@ data class PhotoModel(
fun
optimalResolution
(
width
:
Int
,
height
:
Int
)
=
resolutionList
.
asSequence
()
.
filter
{
it
.
resWidth
>=
width
}
.
filter
{
it
.
resHeight
>=
height
}
.
filter
{
it
.
resWidth
>=
width
||
it
.
resWidth
>=
height
}
.
filter
{
it
.
resHeight
>=
height
||
it
.
resHeight
>=
width
}
.
onEach
{
Timber
.
d
(
"res filtered: ${it.resWidth} / ${it.resHeight}"
)
}
.
minBy
{
it
.
resHeight
*
it
.
resWidth
}
?:
resolutionList
.
maxBy
{
it
.
resHeight
*
it
.
resWidth
}
!!
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/photo/ScreenController.kt
View file @
d72a59a7
...
...
@@ -43,7 +43,7 @@ class PhotoScreenController :
private
fun
bindRecycler
()
{
photoViewPager
.
isNestedScrollingEnabled
=
false
photoViewPager
.
offscreenPageLimit
=
2
photoViewPager
.
adapter
=
PhotoViewerAdapter
()
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/photo/util/PhotoViewerAdapter.kt
View file @
d72a59a7
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
...
...
@@ -9,7 +14,12 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc
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
/**
...
...
@@ -34,20 +44,53 @@ class PhotoViewerViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemV
@BindView
(
R
.
id
.
photo_view
)
lateinit
var
photoView
:
PhotoView
@BindView
(
R
.
id
.
photo_description
)
lateinit
var
photoDesc
:
MaterialTextView
val
picassoAsync
:
Picasso
by
lazy
{
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
}
model
.
optimalResolution
(
photoView
.
width
,
photoView
.
height
).
let
{
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
)
// .transform(BlurTransformation(itemView.context,13,2))
.
into
(
photoView
)
.
into
(
_t
)
}
}
override
fun
onError
(
e
:
Exception
?)
{
Timber
.
e
(
e
)
}
})
}
}
}
app/src/main/java/com/biganto/visual/roompark/util/extensions/ext.kt
View file @
d72a59a7
...
...
@@ -67,12 +67,12 @@ fun Bitmap.scaleCenterCrop(viewHolder:View): Bitmap {
Timber
.
d
(
" left/top $xScale/$yScale"
)
// Now get the
s
ize of the source bitmap when scaled
// Now get the
displayS
ize of the source bitmap when scaled
val
scaledWidth
=
scale
*
sourceWidth
val
scaledHeight
=
scale
*
sourceHeight
// Let's find out the upper left coordinates if the scaled bitmap
// should be centered in the new
s
ize give by the parameters
// should be centered in the new
displayS
ize give by the parameters
val
left
=
(
viewHolder
.
measuredWidth
-
scaledWidth
)
/
2
val
top
=
(
viewHolder
.
measuredHeight
-
scaledHeight
)
/
2
...
...
@@ -82,7 +82,7 @@ fun Bitmap.scaleCenterCrop(viewHolder:View): Bitmap {
// be
val
targetRect
=
RectF
(
left
,
top
,
left
+
scaledWidth
,
top
+
scaledHeight
)
// Finally, we create a new bitmap of the specified
s
ize and draw our new,
// Finally, we create a new bitmap of the specified
displayS
ize and draw our new,
// scaled bitmap onto it.
val
dest
=
Bitmap
.
createBitmap
(
viewHolder
.
measuredWidth
,
viewHolder
.
measuredHeight
,
this
.
config
)
val
canvas
=
Canvas
(
dest
)
...
...
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