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
8e88c2e9
Commit
8e88c2e9
authored
Mar 18, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bubble smooth mooving;
bubble show correct position onn startup
parent
77d333ec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
62 deletions
+50
-62
ScreenController.kt
...l/roompark/presentation/screen/albums/ScreenController.kt
+19
-13
BubbleSlider.kt
.../roompark/presentation/screen/albums/util/BubbleSlider.kt
+7
-10
Renderer.kt
...sual/roompark/presentation/screen/albums/util/Renderer.kt
+23
-38
photo_view_screen.xml
app/src/main/res/layout/photo_view_screen.xml
+1
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenController.kt
View file @
8e88c2e9
...
@@ -99,6 +99,8 @@ class AlbumsScreenController :
...
@@ -99,6 +99,8 @@ class AlbumsScreenController :
,
resources
?.
getDimensionPixelSize
(
R
.
dimen
.
ceil_grid_padding
))
,
resources
?.
getDimensionPixelSize
(
R
.
dimen
.
ceil_grid_padding
))
)
)
bubble
.
setUpView
(
headersRecyclerView
)
bubble
.
setUpView
(
headersRecyclerView
)
albumsRecyclerView
.
isNestedScrollingEnabled
=
false
albumsRecyclerView
.
isNestedScrollingEnabled
=
false
...
@@ -169,11 +171,12 @@ class AlbumsScreenController :
...
@@ -169,11 +171,12 @@ class AlbumsScreenController :
viewState
.
list
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
viewState
.
list
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
)
)
headersRecyclerView
.
let
{
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
)
it
.
scrollToPosition
(
.
getItemPosition
(
viewState
.
selectedAlbumId
)
(
it
.
adapter
as
AlbumsHeaderAdapter
).
getItemPosition
(
viewState
.
selectedAlbumId
)
.
let
{
)
headersRecyclerView
.
smoothScrollToPosition
(
it
)
}
bubble
.
onCurrentItemChanged
(
it
)
}
viewState
.
list
.
first
{
it
.
albumId
==
viewState
.
selectedAlbumId
}.
let
{
viewState
.
list
.
first
{
it
.
albumId
==
viewState
.
selectedAlbumId
}.
let
{
currentAlbomTitle
.
text
=
it
.
title
currentAlbomTitle
.
text
=
it
.
title
...
@@ -185,9 +188,11 @@ class AlbumsScreenController :
...
@@ -185,9 +188,11 @@ class AlbumsScreenController :
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
HeaderAlbumChoosed
)
{
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
HeaderAlbumChoosed
)
{
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
)
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
)
.
getItemPosition
(
viewState
.
item
.
albumId
).
let
{
.
getItemPosition
(
viewState
.
item
.
albumId
)
headersRecyclerView
.
scrollToPosition
(
it
)
.
let
{
}
headersRecyclerView
.
smoothScrollToPosition
(
it
)
bubble
.
onCurrentItemChanged
(
it
)
}
currentAlbomTitle
.
text
=
viewState
.
item
.
title
currentAlbomTitle
.
text
=
viewState
.
item
.
title
activity
?.
let
{
ctx
->
activity
?.
let
{
ctx
->
...
@@ -211,11 +216,12 @@ class AlbumsScreenController :
...
@@ -211,11 +216,12 @@ class AlbumsScreenController :
viewState
.
restore
.
albumsPreview
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
viewState
.
restore
.
albumsPreview
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
)
)
headersRecyclerView
.
let
{
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
)
it
.
scrollToPosition
(
.
getItemPosition
(
viewState
.
restore
.
currentIndex
)
(
it
.
adapter
as
AlbumsHeaderAdapter
).
getItemPosition
(
viewState
.
restore
.
currentIndex
)
.
let
{
)
headersRecyclerView
.
smoothScrollToPosition
(
it
)
}
bubble
.
onCurrentItemChanged
(
it
)
}
viewState
.
restore
.
albumsPreview
.
first
{
it
.
albumId
==
viewState
.
restore
.
currentIndex
}
viewState
.
restore
.
albumsPreview
.
first
{
it
.
albumId
==
viewState
.
restore
.
currentIndex
}
.
let
{
.
let
{
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/util/BubbleSlider.kt
View file @
8e88c2e9
package
com.biganto.visual.roompark.presentation.screen.albums.util
package
com.biganto.visual.roompark.presentation.screen.albums.util
import
android.content.Context
import
android.content.Context
import
android.graphics.Rect
import
android.graphics.SurfaceTexture
import
android.graphics.SurfaceTexture
import
android.util.AttributeSet
import
android.util.AttributeSet
import
android.view.TextureView
import
android.view.TextureView
...
@@ -23,24 +22,22 @@ class BubbleSlider @JvmOverloads constructor(
...
@@ -23,24 +22,22 @@ class BubbleSlider @JvmOverloads constructor(
private
var
actualPosition
=
-
1
private
var
actualPosition
=
-
1
private
val
actualRect
=
Rect
()
private
fun
invalidatePosition
(){
val
child
=
recyclerView
?.
findViewHolderForAdapterPosition
(
actualPosition
)
if
(
child
==
null
)
texThread
?.
setCenter
(-
9999
)
else
texThread
?.
setCenter
(
child
.
itemView
.
x
.
toInt
()+
child
.
itemView
.
width
/
2
)
}
fun
setUpView
(
view
:
RecyclerView
)
{
fun
setUpView
(
view
:
RecyclerView
)
{
recyclerView
=
view
recyclerView
=
view
recyclerView
?.
setOnScrollChangeListener
{
v
,
scrollX
,
scrollY
,
oldScrollX
,
oldScrollY
->
recyclerView
?.
setOnScrollChangeListener
{
v
,
scrollX
,
scrollY
,
oldScrollX
,
oldScrollY
->
val
child
=
recyclerView
?.
getChildAt
(
actualPosition
)
invalidatePosition
()
child
?.
getDrawingRect
(
actualRect
)
actualRect
.
let
{
texThread
?.
setCenter
(
it
.
centerX
())
}
}
}
}
}
fun
onCurrentItemChanged
(
newPosition
:
Int
){
fun
onCurrentItemChanged
(
newPosition
:
Int
){
actualPosition
=
newPosition
actualPosition
=
newPosition
invalidatePosition
()
texThread
?.
setIndex
(
actualPosition
)
texThread
?.
setIndex
(
actualPosition
)
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/util/Renderer.kt
View file @
8e88c2e9
...
@@ -7,6 +7,7 @@ import android.graphics.*
...
@@ -7,6 +7,7 @@ import android.graphics.*
import
android.view.Surface
import
android.view.Surface
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.R
import
timber.log.Timber
import
timber.log.Timber
import
kotlin.math.absoluteValue
import
kotlin.math.tan
import
kotlin.math.tan
...
@@ -14,7 +15,7 @@ import kotlin.math.tan
...
@@ -14,7 +15,7 @@ import kotlin.math.tan
* Created by Vladislav Bogdashkin on 18.07.2019.
* Created by Vladislav Bogdashkin on 18.07.2019.
*/
*/
private
const
val
CONST_SLEEP_THRESHOLD
=
8
L
private
const
val
CONST_SLEEP_THRESHOLD
=
6
L
private
const
val
CONST_HEIGHT_MARGIN_BORDER_PX
=
8
private
const
val
CONST_HEIGHT_MARGIN_BORDER_PX
=
8
private
const
val
CONST_DECAY_TIMER
=
500L
private
const
val
CONST_DECAY_TIMER
=
500L
...
@@ -37,6 +38,7 @@ class RendererThread(val context: Context, val surface: SurfaceTexture)
...
@@ -37,6 +38,7 @@ class RendererThread(val context: Context, val surface: SurfaceTexture)
private
var
height
=
0
private
var
height
=
0
private
var
centerX
=
0
private
var
centerX
=
0
private
var
destCenterX
=
0
private
var
holdIndex
=
0
private
var
holdIndex
=
0
get
()
=
if
(
isDragging
)
field
get
()
=
if
(
isDragging
)
field
...
@@ -59,15 +61,12 @@ class RendererThread(val context: Context, val surface: SurfaceTexture)
...
@@ -59,15 +61,12 @@ class RendererThread(val context: Context, val surface: SurfaceTexture)
fun
setCenter
(
centerX
:
Int
){
fun
setCenter
(
centerX
:
Int
){
this
.
centerX
=
centerX
this
.
centerX
=
centerX
Timber
.
w
(
"CENTER IS: $centerX"
)
isDirty
=
true
isDirty
=
true
}
}
private
var
scrollScaleFactor
=
1f
private
var
touchOffset
=
0f
private
var
scrollOffset
=
0f
private
var
isDragging
=
false
private
var
isDragging
=
false
private
var
slidePosition
=
0f
private
var
slidePosition
=
0f
private
var
dragKoef
=
1f
fun
setSlidePosition
(
newPosition
:
Float
){
fun
setSlidePosition
(
newPosition
:
Float
){
slidePosition
=
newPosition
slidePosition
=
newPosition
...
@@ -79,57 +78,44 @@ class RendererThread(val context: Context, val surface: SurfaceTexture)
...
@@ -79,57 +78,44 @@ class RendererThread(val context: Context, val surface: SurfaceTexture)
private
fun
timerDecay
(
mills
:
Long
){
private
fun
timerDecay
(
mills
:
Long
){
isDirty
=
true
isDirty
=
true
decayFraction
+=
mills
decayFraction
+=
mills
animateBorders
()
scrollOffset
=
scrollOffset
.
smoothLerp
(
touchOffset
-
scrollOffset
,.
2f
)
if
(
touchOffset
>
0
&&
scrollOffset
>=
touchOffset
)
{
scrollOffset
=
touchOffset
isDirty
=
false
}
else
if
(
touchOffset
<
0
&&
scrollOffset
<=
touchOffset
)
{
scrollOffset
=
touchOffset
isDirty
=
false
}
if
(
decayFraction
>
DECAY_TIMER
)
isDirty
=
false
if
(
decayFraction
>
DECAY_TIMER
)
isDirty
=
false
val
dirty
=
animateBorders
()
val
dirty
=
centerSmooth
()
if
(!
isDirty
)
isDirty
=
dirty
if
(!
isDirty
)
isDirty
=
dirty
}
}
private
fun
animateBorders
():
Boolean
{
private
fun
centerSmooth
():
Boolean
{
if
(
isDragging
&&
dragKoef
>
0
){
centerX
=
centerX
.
smoothLerp
(
destCenterX
-
centerX
,
decayFraction
/
DECAY_TIMER
)
dragKoef
=
dragKoef
.
smoothLerp
(-
dragKoef
,.
12f
)
Timber
.
w
(
"CENTER visa verse: $centerX -> $destCenterX"
)
if
(
dragKoef
<.
1f
)
dragKoef
=
0f
return
(
centerX
-
destCenterX
).
absoluteValue
>
1
return
dragKoef
>
0
}
if
(!
isDragging
&&
dragKoef
<
1f
)
{
dragKoef
=
dragKoef
.
smoothLerp
(
1f
-
dragKoef
,.
03f
)
if
(
dragKoef
>.
99f
)
dragKoef
=
1f
return
dragKoef
<
1f
}
return
false
}
}
private
fun
Float
.
smoothLerp
(
delta
:
Float
,
fraction
:
Float
=.
4f
):
Float
{
private
fun
Float
.
smoothLerp
(
delta
:
Float
,
fraction
:
Float
=.
4f
):
Float
{
return
this
+
fraction
*
(
delta
)
return
this
+
fraction
*
(
delta
)
}
}
private
fun
Int
.
smoothLerp
(
delta
:
Int
,
fraction
:
Float
=.
4f
):
Int
{
return
(
this
+
fraction
*
(
delta
)).
int
}
fun
setSize
(
w
:
Int
,
h
:
Int
){
fun
setSize
(
w
:
Int
,
h
:
Int
){
width
=
w
width
=
w
height
=
h
height
=
h
}
}
private
val
pinColor
:
Int
by
lazy
{
private
val
pinColor
:
Int
by
lazy
{
return
@lazy
context
.
resources
.
getColor
(
R
.
color
.
colorOpacityBackground
)
context
.
resources
.
getColor
(
R
.
color
.
colorOpacityBackground
,
context
.
theme
)
}
}
private
val
trianglePath
:
Path
private
val
trianglePath
:
Path
get
()
{
get
()
{
val
p
=
Path
()
val
p
=
Path
()
p
.
fillType
=
Path
.
FillType
.
EVEN_ODD
p
.
fillType
=
Path
.
FillType
.
EVEN_ODD
p
.
moveTo
(
centerX
.
toFloat
(),
height
.
toFloat
()
)
p
.
moveTo
(
centerX
.
toFloat
(),
0f
)
p
.
lineTo
(
centerX
.
toFloat
()
+
height
*
tan
(
Math
.
toRadians
(
60
.0
)).
toFloat
(),
height
.
toFloat
())
p
.
lineTo
(
centerX
.
toFloat
()
+
height
*
tan
(
Math
.
toRadians
(
45
.0
)).
toFloat
(),
height
.
toFloat
())
p
.
lineTo
(
centerX
.
toFloat
()
-
height
*
tan
(
Math
.
toRadians
(
60
.0
)).
toFloat
(),
height
.
toFloat
())
p
.
lineTo
(
centerX
.
toFloat
()
-
height
*
tan
(
Math
.
toRadians
(
45
.0
)).
toFloat
(),
height
.
toFloat
())
p
.
lineTo
(
centerX
.
toFloat
(),
height
.
toFloat
()
)
p
.
lineTo
(
centerX
.
toFloat
(),
0f
)
p
.
close
()
p
.
close
()
return
p
return
p
}
}
...
@@ -161,11 +147,10 @@ class RendererThread(val context: Context, val surface: SurfaceTexture)
...
@@ -161,11 +147,10 @@ class RendererThread(val context: Context, val surface: SurfaceTexture)
,
height
,
height
)
)
val
c
=
surf
.
lockCanvas
(
dRect
)
val
c
=
surf
.
lockCanvas
(
dRect
)
c
.
drawColor
(
Color
.
TRANSPARENT
)
c
.
drawColor
(
Color
.
WHITE
)
c
.
drawPath
(
trianglePath
,
trianglePaint
)
c
.
drawPath
(
trianglePath
,
trianglePaint
)
timerDecay
(
SLEEP_THRESHOLD
)
// c.drawRect(Rect(centerX - 30,height,centerX+30,0),trianglePaint)
// timerDecay(SLEEP_THRESHOLD)
surf
.
unlockCanvasAndPost
(
c
)
surf
.
unlockCanvasAndPost
(
c
)
surf
.
release
()
surf
.
release
()
...
...
app/src/main/res/layout/photo_view_screen.xml
View file @
8e88c2e9
...
@@ -75,7 +75,7 @@
...
@@ -75,7 +75,7 @@
app:layout_constraintVertical_bias=
"0.0"
app:layout_constraintVertical_bias=
"0.0"
app:srcCompat=
"@drawable/iic_full_view"
/>
app:srcCompat=
"@drawable/iic_full_view"
/>
<com.biganto.visual.roompark.presentation.screen.
albums
.util.PhotoPreviewSlider
<com.biganto.visual.roompark.presentation.screen.
photo
.util.PhotoPreviewSlider
android:id=
"@+id/photosPreviewSlider"
android:id=
"@+id/photosPreviewSlider"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"48dp"
android:layout_height=
"48dp"
...
...
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