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
8d784c96
Commit
8d784c96
authored
Sep 19, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added to statusprogress view attributes and default behaviour
parent
b29f0f10
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
249 additions
and
39 deletions
+249
-39
StatusProgressCeil.kt
...ark/view_utils/status_progress_view/StatusProgressCeil.kt
+191
-14
activity_main.xml
app/src/main/res/layout/activity_main.xml
+3
-2
feed_read_header.xml
app/src/main/res/layout/feed_read_header.xml
+2
-2
progress_deal_state_pattern_view.xml
app/src/main/res/layout/progress_deal_state_pattern_view.xml
+34
-20
attrs.xml
app/src/main/res/values/attrs.xml
+19
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/view_utils/status_progress_view/StatusProgressCeil.kt
View file @
8d784c96
...
...
@@ -7,6 +7,7 @@ import android.graphics.Paint
import
android.graphics.PointF
import
android.util.AttributeSet
import
android.view.View
import
com.biganto.visual.roompark.R
/**
* Created by Vladislav Bogdashkin on 19.09.2019.
...
...
@@ -15,37 +16,140 @@ class StatusProgressCeil @JvmOverloads constructor(
context
:
Context
,
attrs
:
AttributeSet
?
=
null
,
defStyleAttr
:
Int
=
0
)
:
View
(
context
,
attrs
,
defStyleAttr
)
{
private
var
direction
:
StatusProgressDirection
=
StatusProgressDirection
.
HORIZONTAL
private
val
array
=
getContext
().
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
StatusProgressCeil
)
private
var
direction
:
StatusProgressDirection
=
StatusProgressDirection
.
fromInt
(
array
.
getInt
(
R
.
styleable
.
StatusProgressCeil_direction
,
1
))
private
var
animateState
:
StatusProgressAnimationState
=
StatusProgressAnimationState
.
fromInt
(
array
.
getInt
(
R
.
styleable
.
StatusProgressCeil_anim_state
,
1
))
private
val
hasStart
:
Boolean
=
array
.
getBoolean
(
R
.
styleable
.
StatusProgressCeil_hasStart
,
false
)
private
val
hasEnd
:
Boolean
=
array
.
getBoolean
(
R
.
styleable
.
StatusProgressCeil_hasEnd
,
false
)
private
val
isEnable
:
Boolean
=
array
.
getBoolean
(
R
.
styleable
.
StatusProgressCeil_isEnable
,
false
)
private
val
nextEnable
:
Boolean
=
array
.
getBoolean
(
R
.
styleable
.
StatusProgressCeil_nextEnable
,
false
)
val
animationTimeMills
:
Long
=
80L
var
lastAnimateStateChanged
:
Long
=
0L
val
ifAnimateEnd
:
Boolean
get
(){
return
(
System
.
currentTimeMillis
()-
lastAnimateStateChanged
)
>
animationTimeMills
}
private
val
fillEnableColor
:
Int
=
Color
.
WHITE
private
val
fillDisableColor
:
Int
=
Color
.
CYAN
private
val
enablePaint
:
Paint
=
Paint
()
get
(){
field
.
style
=
Paint
.
Style
.
STROKE
field
.
strokeWidth
=
3F
field
.
style
=
Paint
.
Style
.
FILL_AND_STROKE
field
.
color
=
fillEnableColor
return
field
}
private
val
disablePaint
:
Paint
=
Paint
()
get
(){
field
.
style
=
Paint
.
Style
.
STROKE
field
.
strokeWidth
=
3F
field
.
color
=
fillEnableColor
field
.
style
=
Paint
.
Style
.
FILL_AND_STROKE
field
.
color
=
fillDisableColor
return
field
}
private
val
prorgressHalfW
:
Float
get
()
{
return
when
(
direction
){
StatusProgressDirection
.
HORIZONTAL
->
measuredHeight
/
8f
StatusProgressDirection
.
VERTICAL
->
measuredWidth
/
8f
}}
private
val
enableRadius
:
Float
get
()
{
return
when
(
direction
){
StatusProgressDirection
.
HORIZONTAL
->
height
/
2f
StatusProgressDirection
.
VERTICAL
->
width
/
2f
StatusProgressDirection
.
HORIZONTAL
->
measuredHeight
/
4f
StatusProgressDirection
.
VERTICAL
->
measuredWidth
/
4f
}}
private
val
crossRadius
:
Float
get
()
{
return
when
(
direction
){
StatusProgressDirection
.
HORIZONTAL
->
measuredHeight
/
2.1f
StatusProgressDirection
.
VERTICAL
->
measuredWidth
/
2.1f
}}
private
val
disableRadius
:
Float
get
()
{
return
when
(
direction
){
StatusProgressDirection
.
HORIZONTAL
->
h
eight
/
2f
StatusProgressDirection
.
VERTICAL
->
w
idth
/
2f
StatusProgressDirection
.
HORIZONTAL
->
measuredH
eight
/
2f
StatusProgressDirection
.
VERTICAL
->
measuredW
idth
/
2f
}}
//region startProgressRect
private
val
progressStartLeft
:
Float
get
()
{
return
when
(
direction
)
{
StatusProgressDirection
.
HORIZONTAL
->
0f
StatusProgressDirection
.
VERTICAL
->
measuredWidth
/
2f
-
prorgressHalfW
}
}
private
val
progressStartTop
:
Float
get
()
{
return
when
(
direction
)
{
StatusProgressDirection
.
HORIZONTAL
->
measuredHeight
/
2f
-
prorgressHalfW
StatusProgressDirection
.
VERTICAL
->
0f
}
}
private
val
progressStartRight
:
Float
get
()
{
return
when
(
direction
)
{
StatusProgressDirection
.
HORIZONTAL
->
measuredWidth
/
2f
StatusProgressDirection
.
VERTICAL
->
measuredWidth
/
2f
+
prorgressHalfW
}
}
private
val
progressStartBottom
:
Float
get
()
{
return
when
(
direction
)
{
StatusProgressDirection
.
HORIZONTAL
->
measuredHeight
/
2f
+
prorgressHalfW
StatusProgressDirection
.
VERTICAL
->
measuredHeight
/
2f
}
}
//endregion
//region endProgressRect
private
val
progressEndLeft
:
Float
get
()
{
return
when
(
direction
)
{
StatusProgressDirection
.
HORIZONTAL
->
width
/
2f
StatusProgressDirection
.
VERTICAL
->
width
/
2f
-
prorgressHalfW
}
}
private
val
progressEndTop
:
Float
get
()
{
return
when
(
direction
)
{
StatusProgressDirection
.
HORIZONTAL
->
height
/
2f
-
prorgressHalfW
StatusProgressDirection
.
VERTICAL
->
height
/
2f
}
}
private
val
progressEndRight
:
Float
get
()
{
return
when
(
direction
)
{
StatusProgressDirection
.
HORIZONTAL
->
width
.
toFloat
()
StatusProgressDirection
.
VERTICAL
->
width
/
2f
+
prorgressHalfW
}
}
private
val
progressEndBottom
:
Float
get
()
{
return
when
(
direction
)
{
StatusProgressDirection
.
HORIZONTAL
->
height
/
2f
+
prorgressHalfW
StatusProgressDirection
.
VERTICAL
->
height
.
toFloat
()
}
}
//endregion
private
var
enableDisableCrossRadius
:
Int
=
0
private
val
centerStatus
:
PointF
get
()
{
...
...
@@ -61,15 +165,88 @@ class StatusProgressCeil @JvmOverloads constructor(
override
fun
onDraw
(
canvas
:
Canvas
?)
{
super
.
onDraw
(
canvas
)
canvas
?.
drawColor
(
Color
.
TRANSPARENT
)
when
(
animateState
){
StatusProgressAnimationState
.
ENABLE
->
drawEnable
(
canvas
)
StatusProgressAnimationState
.
DISABLE
->
drawDisable
(
canvas
)
StatusProgressAnimationState
.
TOENABLE
->
drawToEnable
(
canvas
)
StatusProgressAnimationState
.
TODISABLE
->
drawToDisable
(
canvas
)
}
}
fun
drawStartProgress
(
canvas
:
Canvas
?){
if
(
hasStart
)
canvas
?.
drawRect
(
progressStartLeft
,
progressStartTop
,
progressStartRight
,
progressStartBottom
,
enablePaint
)
}
fun
drawEndProgress
(
canvas
:
Canvas
?){
if
(
hasEnd
)
canvas
?.
drawRect
(
progressEndLeft
,
progressEndTop
,
progressEndRight
,
progressEndBottom
,
enablePaint
)
}
private
fun
drawEnable
(
canvas
:
Canvas
?){
drawStartProgress
(
canvas
)
drawEndProgress
(
canvas
)
canvas
?.
drawCircle
(
centerStatus
.
x
,
centerStatus
.
y
,
if
(
nextEnable
)
enableRadius
else
crossRadius
,
enablePaint
)
}
private
fun
drawDisable
(
canvas
:
Canvas
?){
drawStartProgress
(
canvas
)
drawEndProgress
(
canvas
)
canvas
?.
drawCircle
(
centerStatus
.
x
,
centerStatus
.
y
,
enableRadius
,
disablePaint
)
}
private
fun
drawToEnable
(
canvas
:
Canvas
?){
drawStartProgress
(
canvas
)
drawEndProgress
(
canvas
)
canvas
?.
drawCircle
(
centerStatus
.
x
,
centerStatus
.
y
,
enableRadius
,
enablePaint
)
}
private
fun
drawToDisable
(
canvas
:
Canvas
?){
drawStartProgress
(
canvas
)
drawEndProgress
(
canvas
)
canvas
?.
drawCircle
(
centerStatus
.
x
,
centerStatus
.
y
,
enableRadius
,
disablePaint
)
}
}
enum
class
StatusProgressDirection
{
HORIZONTAL
,
VERTICAL
enum
class
StatusProgressDirection
(
val
dir
:
Int
){
HORIZONTAL
(
1
),
VERTICAL
(
2
);
companion
object
{
fun
fromInt
(
value
:
Int
)
=
values
().
first
{
it
.
dir
==
value
}
}
}
enum
class
StatusProgressAnimationState
(
val
state
:
Int
){
ENABLE
(
1
),
DISABLE
(
2
),
TOENABLE
(
3
),
TODISABLE
(
4
);
companion
object
{
fun
fromInt
(
value
:
Int
)
=
StatusProgressAnimationState
.
values
().
first
{
it
.
state
==
value
}
}
}
app/src/main/res/layout/activity_main.xml
View file @
8d784c96
...
...
@@ -65,9 +65,10 @@
android:layout_height=
"match_parent"
app:layout_behavior=
"com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
>
<include
layout=
"@layout/authentication_screen"
<include
layout=
"@layout/progress_deal_state_pattern_view"
android:layout_width=
"match_parent"
android:layout_height=
"
match_parent"
/>
android:layout_height=
"
125dp"
/>
</FrameLayout>
...
...
app/src/main/res/layout/feed_read_header.xml
View file @
8d784c96
...
...
@@ -21,8 +21,8 @@
<ImageView
android:id=
"@+id/imageView4"
android:layout_width=
"125"
android:layout_height=
"125"
android:layout_width=
"125
dp
"
android:layout_height=
"125
dp
"
android:layout_marginStart=
"27dp"
android:layout_marginTop=
"44dp"
app:layout_constraintStart_toStartOf=
"parent"
...
...
app/src/main/res/layout/progress_deal_state_pattern_view.xml
View file @
8d784c96
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/sum"
android:layout_width=
"wrap_content"
android:layout_height=
"
6
4dp"
android:layout_height=
"
2
4dp"
android:background=
"@color/colorCheckListGradientEnd"
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
android:weightSum=
"3"
>
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width=
"66dp"
android:layout_height=
"match_parent"
android:scaleType=
"fitEnd"
app:direction=
"horizontal"
app:hasEnd=
"true"
app:hasStart=
"false"
app:isEnable=
"true"
app:nextEnable=
"true"
/>
<TextView
android:id=
"@+id/imageView7"
android:layout_width=
"58dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:background=
"@drawable/horizontal_patch"
android:scaleType=
"fitEnd"
/>
<TextView
android:id=
"@+id/imageView8"
android:layout_width=
"122dp"
android:layout_height=
"wrap_content"
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width=
"125dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:background=
"@drawable/horizontal_patch"
/>
android:scaleType=
"fitEnd"
app:direction=
"horizontal"
app:hasEnd=
"true"
app:hasStart=
"true"
app:isEnable=
"false"
app:nextEnable=
"false"
/>
<FrameLayout
android:id=
"@+id/imageView9"
android:layout_width=
"
wrap_content
"
android:layout_height=
"
wrap_cont
ent"
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width=
"
88dp
"
android:layout_height=
"
match_par
ent"
android:layout_weight=
"1"
android:background=
"@drawable/horizontal_patch"
android:scaleType=
"fitEnd"
/>
android:scaleType=
"fitEnd"
app:direction=
"horizontal"
app:hasEnd=
"false"
app:hasStart=
"true"
app:isEnable=
"true"
app:nextEnable=
"false"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/values/attrs.xml
View file @
8d784c96
...
...
@@ -3,4 +3,22 @@
<declare-styleable
name=
"RoundedImageView"
>
<attr
name=
"image_corner_radius"
format=
"dimension"
/>
</declare-styleable>
<declare-styleable
name=
"StatusProgressCeil"
>
<attr
name=
"hasStart"
format=
"boolean"
/>
<attr
name=
"hasEnd"
format=
"boolean"
/>
<attr
name=
"isEnable"
format=
"boolean"
/>
<attr
name=
"nextEnable"
format=
"boolean"
/>
<attr
name=
"direction"
>
<enum
name=
"horizontal"
value=
"1"
/>
<enum
name=
"vertical"
value=
"2"
/>
</attr>
<attr
name=
"anim_state"
>
<enum
name=
"enable"
value=
"1"
/>
<enum
name=
"disable"
value=
"2"
/>
<enum
name=
"toEnable"
value=
"3"
/>
<enum
name=
"toDisable"
value=
"4"
/>
</attr>
</declare-styleable>
</resources>
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