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
a451139d
Commit
a451139d
authored
2 years ago
by
FurWaz
Browse files
Options
Downloads
Patches
Plain Diff
Moved some popups to their own class
parent
d2ab52b0
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/Popups/BuildingPopup.java
+105
-0
105 additions, 0 deletions
Sources/app/src/main/java/Popups/BuildingPopup.java
Sources/app/src/main/java/Popups/RoomPopup.java
+92
-0
92 additions, 0 deletions
Sources/app/src/main/java/Popups/RoomPopup.java
with
197 additions
and
0 deletions
Sources/app/src/main/java/Popups/BuildingPopup.java
0 → 100644
+
105
−
0
View file @
a451139d
package
Popups
;
import
android.content.Context
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
androidx.appcompat.app.AlertDialog
;
import
com.furwaz.roomview.R
;
import
Common.BuildingManager
;
import
Common.Callback
;
public
class
BuildingPopup
{
public
static
final
int
MODE_NEW
=
1
;
public
static
final
int
MODE_EDIT
=
2
;
AlertDialog
dialog
=
null
;
TextView
b_err
=
null
;
EditText
b_name
=
null
;
Button
validate_btn
=
null
;
Button
cancel_btn
=
null
;
TextView
popup_title
=
null
;
public
BuildingPopup
(
Context
context
,
Callback
onCreate
,
Callback
onCancel
,
Callback
onValidate
,
int
mode
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
context
);
dialog
=
builder
.
create
();
LayoutInflater
factory
=
LayoutInflater
.
from
(
context
);
View
popup
=
factory
.
inflate
(
R
.
layout
.
add_building_popup
,
null
);
dialog
.
setView
(
popup
);
dialog
.
setOnShowListener
(
dialogInterface
->
{
b_err
=
popup
.
findViewById
(
R
.
id
.
building_input_error_msg
);
b_name
=
popup
.
findViewById
(
R
.
id
.
input_building_name
);
validate_btn
=
popup
.
findViewById
(
R
.
id
.
btn_validate_building
);
cancel_btn
=
popup
.
findViewById
(
R
.
id
.
btn_cancel_building
);
popup_title
=
popup
.
findViewById
(
R
.
id
.
building_popup_title
);
onCreate
.
call
(
this
);
String
title
=
context
.
getResources
().
getString
(
(
mode
==
MODE_EDIT
)?
R
.
string
.
edit_building
:
R
.
string
.
new_building
);
String
btn_text
=
context
.
getResources
().
getString
(
(
mode
==
MODE_EDIT
)?
R
.
string
.
edit
:
R
.
string
.
create
);
popup_title
.
setText
(
title
);
validate_btn
.
setText
(
btn_text
);
validate_btn
.
setEnabled
(
false
);
b_err
.
setText
(
""
);
b_name
.
addTextChangedListener
(
new
TextWatcher
()
{
public
void
beforeTextChanged
(
CharSequence
charSequence
,
int
i
,
int
i1
,
int
i2
)
{}
public
void
onTextChanged
(
CharSequence
charSequence
,
int
i
,
int
i1
,
int
i2
)
{}
public
void
afterTextChanged
(
Editable
editable
)
{
validate_btn
.
setEnabled
(
false
);
b_err
.
setText
(
""
);
String
input
=
editable
.
toString
();
if
(
input
.
length
()
==
0
)
{
b_err
.
setText
(
context
.
getResources
().
getString
(
R
.
string
.
specify_building_name
));
return
;
}
if
(
BuildingManager
.
getBuilding
(
input
)
!=
null
)
{
b_err
.
setText
(
context
.
getResources
().
getString
(
R
.
string
.
building_exists
));
return
;
}
if
(
input
.
contains
(
"/"
))
{
b_err
.
setText
(
context
.
getResources
().
getString
(
R
.
string
.
building_invalid
));
return
;
}
// everything is correct, display the button
validate_btn
.
setEnabled
(
true
);
}
});
cancel_btn
.
setOnClickListener
(
view
->
onCancel
.
call
(
this
));
validate_btn
.
setOnClickListener
(
view
->
onValidate
.
call
(
this
));
});
}
public
void
show
()
{
dialog
.
show
();
}
public
void
dismiss
()
{
dialog
.
dismiss
();
}
public
Button
getCancel_btn
()
{
return
cancel_btn
;
}
public
Button
getValidate_btn
()
{
return
validate_btn
;
}
public
EditText
getInput
()
{
return
b_name
;
}
public
TextView
getTitle
()
{
return
popup_title
;
}
}
This diff is collapsed.
Click to expand it.
Sources/app/src/main/java/Popups/RoomPopup.java
0 → 100644
+
92
−
0
View file @
a451139d
package
Popups
;
import
android.content.Context
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
androidx.appcompat.app.AlertDialog
;
import
com.furwaz.roomview.BuildingActivity
;
import
com.furwaz.roomview.R
;
import
Common.Callback
;
import
Structures.BuildingInfo
;
import
Structures.RoomInfo
;
public
class
RoomPopup
{
public
static
final
int
MODE_NEW
=
1
;
public
static
final
int
MODE_EDIT
=
2
;
AlertDialog
dialog
=
null
;
TextView
r_err
=
null
;
EditText
r_name
=
null
;
Button
validate_btn
=
null
;
Button
cancel_btn
=
null
;
TextView
room_title
=
null
;
public
RoomPopup
(
Context
context
,
BuildingInfo
building
,
Callback
onCreate
,
Callback
onCancel
,
Callback
onValidate
,
int
mode
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
context
);
dialog
=
builder
.
create
();
LayoutInflater
factory
=
LayoutInflater
.
from
(
context
);
View
popup
=
factory
.
inflate
(
R
.
layout
.
add_room_popup
,
null
);
dialog
.
setView
(
popup
);
dialog
.
setOnShowListener
(
dialogInterface
->
{
r_err
=
popup
.
findViewById
(
R
.
id
.
room_input_error_msg
);
r_name
=
popup
.
findViewById
(
R
.
id
.
input_room_name
);
validate_btn
=
popup
.
findViewById
(
R
.
id
.
btn_validate_room
);
cancel_btn
=
popup
.
findViewById
(
R
.
id
.
btn_cancel_room
);
room_title
=
popup
.
findViewById
(
R
.
id
.
room_popup_title
);
onCreate
.
call
(
this
);
String
title
=
context
.
getResources
().
getString
(
(
mode
==
MODE_EDIT
)?
R
.
string
.
edit_room
:
R
.
string
.
new_room
);
String
btn_text
=
context
.
getResources
().
getString
(
(
mode
==
MODE_EDIT
)?
R
.
string
.
edit
:
R
.
string
.
create
);
room_title
.
setText
(
title
);
validate_btn
.
setText
(
btn_text
);
validate_btn
.
setEnabled
(
false
);
r_err
.
setText
(
""
);
r_name
.
addTextChangedListener
(
new
TextWatcher
()
{
public
void
beforeTextChanged
(
CharSequence
charSequence
,
int
i
,
int
i1
,
int
i2
)
{}
public
void
onTextChanged
(
CharSequence
charSequence
,
int
i
,
int
i1
,
int
i2
)
{}
public
void
afterTextChanged
(
Editable
editable
)
{
validate_btn
.
setEnabled
(
false
);
r_err
.
setText
(
""
);
String
input
=
editable
.
toString
();
if
(
input
.
length
()
==
0
)
{
r_err
.
setText
(
context
.
getResources
().
getString
(
R
.
string
.
specify_room_name
));
return
;
}
if
(
building
.
getRoom
(
input
)
!=
null
)
{
r_err
.
setText
(
context
.
getResources
().
getString
(
R
.
string
.
room_exists
));
return
;
}
// everything is correct, display the button
validate_btn
.
setEnabled
(
true
);
}
});
cancel_btn
.
setOnClickListener
(
view
->
onCancel
.
call
(
this
));
validate_btn
.
setOnClickListener
(
view
->
onValidate
.
call
(
this
));
});
dialog
.
show
();
}
public
void
dismiss
()
{
dialog
.
dismiss
();
}
public
EditText
getInput
()
{
return
r_name
;
}
public
void
show
()
{
dialog
.
show
();
}
}
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