Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RoomView
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOISIL Paul
RoomView
Commits
2906195c
Commit
2906195c
authored
2 years ago
by
FurWaz
Browse files
Options
Downloads
Patches
Plain Diff
Added pathviews preview when visiting
parent
4a37a4dc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/app/src/main/java/Views/ClickDetector.java
+44
-0
44 additions, 0 deletions
Sources/app/src/main/java/Views/ClickDetector.java
Sources/app/src/main/java/com/furwaz/roomview/ZoneView.java
+5
-1
5 additions, 1 deletion
Sources/app/src/main/java/com/furwaz/roomview/ZoneView.java
with
49 additions
and
1 deletion
Sources/app/src/main/java/Views/ClickDetector.java
+
44
−
0
View file @
2906195c
...
...
@@ -2,16 +2,24 @@ package Views;
import
android.content.Context
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Paint
;
import
android.graphics.RectF
;
import
android.util.AttributeSet
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.widget.Toast
;
import
com.furwaz.roomview.R
;
import
Common.Callback
;
import
Common.Coord
;
import
Structures.PathView
;
import
Structures.PhotoInfo
;
public
class
ClickDetector
extends
View
{
Callback
cb
=
null
;
PhotoInfo
photo
=
null
;
// set the on touch callback function
protected
void
init
()
{
...
...
@@ -35,6 +43,11 @@ public class ClickDetector extends View {
this
.
cb
=
c
;
}
public
void
setPhoto
(
PhotoInfo
p
)
{
this
.
photo
=
p
;
this
.
invalidate
();
}
// on touch, if the touch is valid (only one finger, and the action is up), call the callback function with the touch coordinates
protected
boolean
touchListener
(
View
v
,
MotionEvent
ev
)
{
if
(
ev
.
getPointerCount
()
!=
1
)
return
true
;
...
...
@@ -47,5 +60,36 @@ public class ClickDetector extends View {
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
super
.
onDraw
(
canvas
);
if
(
photo
==
null
)
return
;
for
(
PathView
p
:
photo
.
getPathViews
())
{
drawDoorZone
(
canvas
,
p
.
getRect
(),
p
.
getPath
().
getName
()
);
}
}
// draw one pathview on the canvas
protected
void
drawDoorZone
(
Canvas
c
,
RectF
rect
,
String
name
)
{
Paint
p
=
new
Paint
();
int
width
=
getWidth
();
int
height
=
getHeight
();
RectF
r
=
new
RectF
(
rect
.
left
*
width
,
rect
.
top
*
height
,
rect
.
right
*
width
,
rect
.
bottom
*
height
);
p
.
setColor
(
Color
.
parseColor
(
"#60f8fafc"
));
c
.
drawRect
(
r
.
left
,
r
.
top
,
r
.
right
,
r
.
bottom
,
p
);
p
.
setColor
(
getResources
().
getColor
(
R
.
color
.
slate_50
,
getContext
().
getTheme
()));
p
.
setTextSize
(
36
);
p
.
setTextAlign
(
Paint
.
Align
.
CENTER
);
c
.
drawText
(
name
,
(
r
.
left
+
r
.
right
)
/
2
,
(
r
.
top
+
r
.
bottom
)
/
2
,
p
);
}
}
This diff is collapsed.
Click to expand it.
Sources/app/src/main/java/com/furwaz/roomview/ZoneView.java
+
5
−
1
View file @
2906195c
...
...
@@ -48,6 +48,7 @@ public class ZoneView extends AppCompatActivity {
PhotoInfo
photo
=
null
;
Orientation
orient
=
Orientation
.
NORTH
;
ClickDetector
bitmap_zone
=
null
;
// return the string corresponding to the orientation
protected
String
stringifyOrientation
(
Orientation
orient
)
{
...
...
@@ -135,7 +136,7 @@ public class ZoneView extends AppCompatActivity {
});
// set the photo zone click listener (for pathviews click, to move)
ClickDetector
bitmap_zone
=
findViewById
(
R
.
id
.
bitmap_zone
);
if
(
bitmap_zone
==
null
)
bitmap_zone
=
findViewById
(
R
.
id
.
bitmap_zone
);
bitmap_zone
.
setOnClickCallback
(
param
->
{
Coord
c
=
(
Coord
)
param
;
this
.
onClickAt
(
c
);
...
...
@@ -155,6 +156,7 @@ public class ZoneView extends AppCompatActivity {
TextView
tv_orient
=
findViewById
(
R
.
id
.
orient_text
);
TextView
tv_room
=
findViewById
(
R
.
id
.
room_name
);
TextView
tv_zone
=
findViewById
(
R
.
id
.
zone_name
);
if
(
bitmap_zone
==
null
)
bitmap_zone
=
findViewById
(
R
.
id
.
bitmap_zone
);
tv_orient
.
setText
(
getResources
().
getString
(
R
.
string
.
orientation
)+
": "
+
stringifyOrientation
(
this
.
orient
));
tv_room
.
setText
(
room
==
null
?
""
:
room
.
getName
());
...
...
@@ -182,6 +184,8 @@ public class ZoneView extends AppCompatActivity {
return
;
}
bitmap_zone
.
setPhoto
(
photo
);
// if the photo has not been taken yet, display an error message
Bitmap
bm
=
photo
.
getBitmap
();
if
(
bm
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment