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
3695a419
Commit
3695a419
authored
Mar 18, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common drawing bubblie pin
parent
b22a6d40
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
278 additions
and
3 deletions
+278
-3
gradle.xml
.idea/gradle.xml
+1
-0
PhotoPreviewSlider.kt
...ark/presentation/screen/albums/util/PhotoPreviewSlider.kt
+95
-0
Renderer.kt
...sual/roompark/presentation/screen/albums/util/Renderer.kt
+179
-0
ScreenController.kt
...al/roompark/presentation/screen/photo/ScreenController.kt
+1
-1
photo_view_screen.xml
app/src/main/res/layout/photo_view_screen.xml
+1
-1
dependencies.gradle
dependencies.gradle
+1
-1
No files found.
.idea/gradle.xml
View file @
3695a419
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"GradleMigrationSettings"
migrationVersion=
"1"
/>
<component
name=
"GradleSettings"
>
<option
name=
"linkedExternalProjectsSettings"
>
<GradleProjectSettings>
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/util/PhotoPreviewSlider.kt
0 → 100644
View file @
3695a419
package
com.biganto.visual.roompark.presentation.screen.albums.util
import
android.content.Context
import
android.graphics.Rect
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
val
actualRect
=
Rect
()
fun
setUpView
(
view
:
RecyclerView
)
{
recyclerView
=
view
recyclerView
?.
setOnScrollChangeListener
{
v
,
scrollX
,
scrollY
,
oldScrollX
,
oldScrollY
->
val
child
=
recyclerView
?.
getChildAt
(
actualPosition
)
child
?.
getDrawingRect
(
actualRect
)
actualRect
.
let
{
texThread
?.
setCenter
(
it
.
centerX
())
}
}
}
fun
onCurrentItemChanged
(
newPosition
:
Int
){
actualPosition
=
newPosition
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 @
3695a419
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.tan
/**
* Created by Vladislav Bogdashkin on 18.07.2019.
*/
private
const
val
CONST_SLEEP_THRESHOLD
=
8L
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
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
isDirty
=
true
}
private
var
scrollScaleFactor
=
1f
private
var
touchOffset
=
0f
private
var
scrollOffset
=
0f
private
var
isDragging
=
false
private
var
slidePosition
=
0f
private
var
dragKoef
=
1f
fun
setSlidePosition
(
newPosition
:
Float
){
slidePosition
=
newPosition
isDirty
=
true
}
private
var
decayFraction
=
0f
private
fun
timerDecay
(
mills
:
Long
){
isDirty
=
true
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
val
dirty
=
animateBorders
()
if
(!
isDirty
)
isDirty
=
dirty
}
private
fun
animateBorders
():
Boolean
{
if
(
isDragging
&&
dragKoef
>
0
){
dragKoef
=
dragKoef
.
smoothLerp
(-
dragKoef
,.
12f
)
if
(
dragKoef
<.
1f
)
dragKoef
=
0f
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
{
return
this
+
fraction
*
(
delta
)
}
fun
setSize
(
w
:
Int
,
h
:
Int
){
width
=
w
height
=
h
}
private
val
pinColor
:
Int
by
lazy
{
return
@lazy
context
.
resources
.
getColor
(
R
.
color
.
colorOpacityBackground
)
}
private
val
trianglePath
:
Path
get
()
{
val
p
=
Path
()
p
.
fillType
=
Path
.
FillType
.
EVEN_ODD
p
.
moveTo
(
centerX
.
toFloat
(),
height
.
toFloat
())
p
.
lineTo
(
centerX
.
toFloat
()
+
height
*
tan
(
Math
.
toRadians
(
60.0
)).
toFloat
(),
height
.
toFloat
())
p
.
lineTo
(
centerX
.
toFloat
()
-
height
*
tan
(
Math
.
toRadians
(
60.0
)).
toFloat
(),
height
.
toFloat
())
p
.
lineTo
(
centerX
.
toFloat
(),
height
.
toFloat
())
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
.
TRANSPARENT
)
c
.
drawPath
(
trianglePath
,
trianglePaint
)
timerDecay
(
SLEEP_THRESHOLD
)
surf
.
unlockCanvasAndPost
(
c
)
surf
.
release
()
// isDirty = false
}
Timber
.
w
(
"STOPPED; $isStopped"
)
Timber
.
w
(
"STOPPED; $isDirty"
)
isDirty
=
false
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/photo/ScreenController.kt
View file @
3695a419
...
...
@@ -14,7 +14,7 @@ import com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.dialogs.ChooseResolutionDialogController
import
com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import
com.biganto.visual.roompark.presentation.screen.
photo
.util.PhotoPreviewSlider
import
com.biganto.visual.roompark.presentation.screen.
albums
.util.PhotoPreviewSlider
import
com.biganto.visual.roompark.presentation.screen.photo.util.PhotosAdapter
import
com.bluelinelabs.conductor.RouterTransaction
import
com.google.android.material.textview.MaterialTextView
...
...
app/src/main/res/layout/photo_view_screen.xml
View file @
3695a419
...
...
@@ -75,7 +75,7 @@
app:layout_constraintVertical_bias=
"0.0"
app:srcCompat=
"@drawable/iic_full_view"
/>
<com.biganto.visual.roompark.presentation.screen.
photo
.util.PhotoPreviewSlider
<com.biganto.visual.roompark.presentation.screen.
albums
.util.PhotoPreviewSlider
android:id=
"@+id/photosPreviewSlider"
android:layout_width=
"0dp"
android:layout_height=
"48dp"
...
...
dependencies.gradle
View file @
3695a419
...
...
@@ -2,7 +2,7 @@ ext {
$APPLICATION_ID
=
"com.biganto.visual.roompark"
targetSdkVersion_RoomPark
=
28
minSdkVersion_RoomPark
=
2
1
minSdkVersion_RoomPark
=
2
3
compileSdkVersion_RoomPark
=
28
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