Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
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
68531f19
Commit
68531f19
authored
Mar 18, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/bubble' into develop
parents
b22a6d40
8e88c2e9
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
295 additions
and
14 deletions
+295
-14
gradle.xml
.idea/gradle.xml
+1
-0
ScreenController.kt
...l/roompark/presentation/screen/albums/ScreenController.kt
+24
-13
BubbleSlider.kt
.../roompark/presentation/screen/albums/util/BubbleSlider.kt
+92
-0
Renderer.kt
...sual/roompark/presentation/screen/albums/util/Renderer.kt
+164
-0
albums_screen.xml
app/src/main/res/layout/albums_screen.xml
+13
-0
dependencies.gradle
dependencies.gradle
+1
-1
No files found.
.idea/gradle.xml
View file @
68531f19
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"GradleMigrationSettings"
migrationVersion=
"1"
/>
<component
name=
"GradleSettings"
>
<component
name=
"GradleSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<GradleProjectSettings>
<GradleProjectSettings>
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenController.kt
View file @
68531f19
...
@@ -18,6 +18,7 @@ import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
...
@@ -18,6 +18,7 @@ import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import
com.biganto.visual.roompark.domain.model.PhotoModel
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.albums.util.BubbleSlider
import
com.biganto.visual.roompark.presentation.screen.photo.PhotoScreenController
import
com.biganto.visual.roompark.presentation.screen.photo.PhotoScreenController
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
...
@@ -63,6 +64,8 @@ class AlbumsScreenController :
...
@@ -63,6 +64,8 @@ class AlbumsScreenController :
@BindView
(
R
.
id
.
header_album_title
)
@BindView
(
R
.
id
.
header_album_title
)
lateinit
var
currentAlbomTitle
:
MaterialTextView
lateinit
var
currentAlbomTitle
:
MaterialTextView
@BindView
(
R
.
id
.
bubble_slider
)
lateinit
var
bubble
:
BubbleSlider
//
//
...
@@ -96,6 +99,10 @@ class AlbumsScreenController :
...
@@ -96,6 +99,10 @@ class AlbumsScreenController :
,
resources
?.
getDimensionPixelSize
(
R
.
dimen
.
ceil_grid_padding
))
,
resources
?.
getDimensionPixelSize
(
R
.
dimen
.
ceil_grid_padding
))
)
)
bubble
.
setUpView
(
headersRecyclerView
)
albumsRecyclerView
.
isNestedScrollingEnabled
=
false
albumsRecyclerView
.
isNestedScrollingEnabled
=
false
albumsRecyclerView
.
layoutManager
=
albumsRecyclerView
.
layoutManager
=
LinearLayoutManager
(
activity
,
RecyclerView
.
VERTICAL
,
false
)
LinearLayoutManager
(
activity
,
RecyclerView
.
VERTICAL
,
false
)
...
@@ -164,10 +171,11 @@ class AlbumsScreenController :
...
@@ -164,10 +171,11 @@ 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
{
...
@@ -180,8 +188,10 @@ class AlbumsScreenController :
...
@@ -180,8 +188,10 @@ 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
...
@@ -206,10 +216,11 @@ class AlbumsScreenController :
...
@@ -206,10 +216,11 @@ 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
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/util/BubbleSlider.kt
0 → 100644
View file @
68531f19
package
com.biganto.visual.roompark.presentation.screen.albums.util
import
android.content.Context
import
android.graphics.SurfaceTexture
import
android.util.AttributeSet
import
android.view.TextureView
import
androidx.recyclerview.widget.RecyclerView
import
timber.log.Timber
/**
* Created by Vladislav Bogdashkin on 22.12.2019.
*/
class
BubbleSlider
@JvmOverloads
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?
=
null
,
defStyleAttr
:
Int
=
0
)
:
TextureView
(
context
,
attrs
,
defStyleAttr
)
,
TextureView
.
SurfaceTextureListener
{
private
var
texThread
:
RendererThread
?=
null
private
var
recyclerView
:
RecyclerView
?
=
null
private
var
actualPosition
=
-
1
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
)
{
recyclerView
=
view
recyclerView
?.
setOnScrollChangeListener
{
v
,
scrollX
,
scrollY
,
oldScrollX
,
oldScrollY
->
invalidatePosition
()
}
}
fun
onCurrentItemChanged
(
newPosition
:
Int
){
actualPosition
=
newPosition
invalidatePosition
()
texThread
?.
setIndex
(
actualPosition
)
}
fun
processSliding
(
_position
:
Float
){
texThread
?.
setSlidePosition
(
_position
)
}
init
{
surfaceTextureListener
=
this
}
override
fun
onSizeChanged
(
w
:
Int
,
h
:
Int
,
oldw
:
Int
,
oldh
:
Int
)
{
Timber
.
d
(
"On Size Chagned"
)
super
.
onSizeChanged
(
w
,
h
,
oldw
,
oldh
)
}
override
fun
onSurfaceTextureSizeChanged
(
surface
:
SurfaceTexture
?,
width
:
Int
,
height
:
Int
)
{
print
(
" onSurfaceTextureSizeChanged"
)
texThread
?.
setSize
(
width
,
height
)
//Ignored
}
override
fun
onSurfaceTextureUpdated
(
surface
:
SurfaceTexture
?)
{
print
(
" onSurfaceTextureUpdated"
)
//Ignored
}
override
fun
onSurfaceTextureDestroyed
(
surface
:
SurfaceTexture
?):
Boolean
{
texThread
?.
isStopped
=
true
return
true
}
override
fun
onSurfaceTextureAvailable
(
surface
:
SurfaceTexture
?,
width
:
Int
,
height
:
Int
)
{
Timber
.
d
(
"avaliable surf: $surface"
)
surface
?.
let
{
if
(
texThread
?.
isAlive
==
true
)
return
texThread
=
RendererThread
(
context
,
it
)
texThread
?.
setSize
(
width
,
height
)
texThread
?.
start
()
}
}
override
fun
onDetachedFromWindow
()
{
super
.
onDetachedFromWindow
()
texThread
?.
isStopped
=
true
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/util/Renderer.kt
0 → 100644
View file @
68531f19
package
com.biganto.visual.roompark.presentation.screen.albums.util
import
android.content.Context
import
android.graphics.*
import
android.view.Surface
import
com.biganto.visual.roompark.R
import
timber.log.Timber
import
kotlin.math.absoluteValue
import
kotlin.math.tan
/**
* Created by Vladislav Bogdashkin on 18.07.2019.
*/
private
const
val
CONST_SLEEP_THRESHOLD
=
6L
private
const
val
CONST_HEIGHT_MARGIN_BORDER_PX
=
8
private
const
val
CONST_DECAY_TIMER
=
500L
class
RendererThread
(
val
context
:
Context
,
val
surface
:
SurfaceTexture
)
:
Thread
(){
private
val
dens
:
Float
by
lazy
{
context
.
resources
.
displayMetrics
.
density
}
private
val
SLEEP_THRESHOLD
get
()
=
CONST_SLEEP_THRESHOLD
private
val
HEIGHT_MARGIN_BORDER_PX
get
()
=
(
CONST_HEIGHT_MARGIN_BORDER_PX
*
dens
).
int
private
val
DECAY_TIMER
get
()
=
CONST_DECAY_TIMER
private
var
isDirty
=
true
var
isStopped
=
false
private
var
width
=
0
private
var
height
=
0
private
var
centerX
=
0
private
var
destCenterX
=
0
private
var
holdIndex
=
0
get
()
=
if
(
isDragging
)
field
else
currentIndex
private
var
currentIndex
:
Int
=
0
set
(
value
)
{
Timber
.
w
(
"currentIndex to: $value"
);
field
=
value
}
fun
setIndex
(
index
:
Int
){
if
(!
isDragging
)
holdIndex
=
index
currentIndex
=
index
isDirty
=
true
}
private
val
Float
.
int
:
Int
get
()
{
return
this
.
toInt
()}
fun
setCenter
(
centerX
:
Int
){
this
.
centerX
=
centerX
Timber
.
w
(
"CENTER IS: $centerX"
)
isDirty
=
true
}
private
var
isDragging
=
false
private
var
slidePosition
=
0f
fun
setSlidePosition
(
newPosition
:
Float
){
slidePosition
=
newPosition
isDirty
=
true
}
private
var
decayFraction
=
0f
private
fun
timerDecay
(
mills
:
Long
){
isDirty
=
true
decayFraction
+=
mills
if
(
decayFraction
>
DECAY_TIMER
)
isDirty
=
false
val
dirty
=
centerSmooth
()
if
(!
isDirty
)
isDirty
=
dirty
}
private
fun
centerSmooth
():
Boolean
{
centerX
=
centerX
.
smoothLerp
(
destCenterX
-
centerX
,
decayFraction
/
DECAY_TIMER
)
Timber
.
w
(
"CENTER visa verse: $centerX -> $destCenterX"
)
return
(
centerX
-
destCenterX
).
absoluteValue
>
1
}
private
fun
Float
.
smoothLerp
(
delta
:
Float
,
fraction
:
Float
=.
4f
):
Float
{
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
){
width
=
w
height
=
h
}
private
val
pinColor
:
Int
by
lazy
{
context
.
resources
.
getColor
(
R
.
color
.
colorOpacityBackground
,
context
.
theme
)
}
private
val
trianglePath
:
Path
get
()
{
val
p
=
Path
()
p
.
fillType
=
Path
.
FillType
.
EVEN_ODD
p
.
moveTo
(
centerX
.
toFloat
(),
0f
)
p
.
lineTo
(
centerX
.
toFloat
()
+
height
*
tan
(
Math
.
toRadians
(
45.0
)).
toFloat
(),
height
.
toFloat
())
p
.
lineTo
(
centerX
.
toFloat
()
-
height
*
tan
(
Math
.
toRadians
(
45.0
)).
toFloat
(),
height
.
toFloat
())
p
.
lineTo
(
centerX
.
toFloat
(),
0f
)
p
.
close
()
return
p
}
private
val
trianglePaint
:
Paint
by
lazy
{
val
p
=
Paint
()
p
.
color
=
pinColor
p
.
style
=
Paint
.
Style
.
FILL_AND_STROKE
p
.
isAntiAlias
=
true
p
}
override
fun
run
()
{
super
.
run
()
Timber
.
w
(
"isStopped: $isStopped"
)
Timber
.
w
(
"isDirty: $isDirty"
)
isDirty
=
true
while
(!
isStopped
)
{
while
(!
isDirty
)
sleep
(
SLEEP_THRESHOLD
)
// in real life this sleep is more complicated
isDirty
=
false
val
surf
=
Surface
(
surface
)
val
dRect
=
Rect
(
0
,
0
,
width
,
height
)
val
c
=
surf
.
lockCanvas
(
dRect
)
c
.
drawColor
(
Color
.
WHITE
)
c
.
drawPath
(
trianglePath
,
trianglePaint
)
// c.drawRect(Rect(centerX - 30,height,centerX+30,0),trianglePaint)
// timerDecay(SLEEP_THRESHOLD)
surf
.
unlockCanvasAndPost
(
c
)
surf
.
release
()
// isDirty = false
}
Timber
.
w
(
"STOPPED; $isStopped"
)
Timber
.
w
(
"STOPPED; $isDirty"
)
isDirty
=
false
}
}
app/src/main/res/layout/albums_screen.xml
View file @
68531f19
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/container"
android:id=
"@+id/container"
android:background=
"@color/colorPrimary"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
...
@@ -19,6 +20,18 @@
...
@@ -19,6 +20,18 @@
tools:itemCount=
"1"
tools:itemCount=
"1"
tools:listitem=
"@layout/album_header_preview_viewholder"
/>
tools:listitem=
"@layout/album_header_preview_viewholder"
/>
<com.biganto.visual.roompark.presentation.screen.albums.util.BubbleSlider
android:id=
"@+id/bubble_slider"
android:layout_width=
"match_parent"
android:layout_height=
"16dp"
android:orientation=
"horizontal"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/headers_recycler_view"
/>
<androidx.core.widget.NestedScrollView
<androidx.core.widget.NestedScrollView
android:id=
"@+id/photo_albums_container"
android:id=
"@+id/photo_albums_container"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
...
dependencies.gradle
View file @
68531f19
...
@@ -2,7 +2,7 @@ ext {
...
@@ -2,7 +2,7 @@ ext {
$APPLICATION_ID
=
"com.biganto.visual.roompark"
$APPLICATION_ID
=
"com.biganto.visual.roompark"
targetSdkVersion_RoomPark
=
28
targetSdkVersion_RoomPark
=
28
minSdkVersion_RoomPark
=
2
1
minSdkVersion_RoomPark
=
2
3
compileSdkVersion_RoomPark
=
28
compileSdkVersion_RoomPark
=
28
VERSION_CODE
=
1
VERSION_CODE
=
1
...
...
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