Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
baby-monitoring-android-app
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
R24-145
baby-monitoring-android-app
Commits
52101e08
Commit
52101e08
authored
Sep 07, 2024
by
Ishankha K.C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit baby screen and api connect
parent
efb2ae08
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
7 deletions
+107
-7
app/src/main/java/com/kaluwa/enterprises/babycare/activities/BabyDashboardActivity.java
...nterprises/babycare/activities/BabyDashboardActivity.java
+59
-1
app/src/main/java/com/kaluwa/enterprises/babycare/dialogs/EditBabyDialog.java
...m/kaluwa/enterprises/babycare/dialogs/EditBabyDialog.java
+4
-3
app/src/main/java/com/kaluwa/enterprises/babycare/service/BabyApiService.java
...m/kaluwa/enterprises/babycare/service/BabyApiService.java
+5
-0
app/src/main/java/com/kaluwa/enterprises/babycare/utils/Utils.java
...ain/java/com/kaluwa/enterprises/babycare/utils/Utils.java
+2
-2
app/src/main/res/layout/edit_baby_view_layout.xml
app/src/main/res/layout/edit_baby_view_layout.xml
+37
-1
No files found.
app/src/main/java/com/kaluwa/enterprises/babycare/activities/BabyDashboardActivity.java
View file @
52101e08
...
...
@@ -37,6 +37,7 @@ import com.kaluwa.enterprises.babycare.R;
import
com.kaluwa.enterprises.babycare.adapter.BabyDashboardAdapter
;
import
com.kaluwa.enterprises.babycare.config.ApiConfig
;
import
com.kaluwa.enterprises.babycare.dialogs.AddBabyDialog
;
import
com.kaluwa.enterprises.babycare.dialogs.EditBabyDialog
;
import
com.kaluwa.enterprises.babycare.dto.BabyDto
;
import
com.kaluwa.enterprises.babycare.dto.responseDto.AuthenticationDto
;
import
com.kaluwa.enterprises.babycare.error.ErrorDto
;
...
...
@@ -51,7 +52,7 @@ import retrofit2.Call;
import
retrofit2.Callback
;
import
retrofit2.Response
;
public
class
BabyDashboardActivity
extends
AppCompatActivity
implements
AddBabyDialog
.
BabyDialogInterface
{
public
class
BabyDashboardActivity
extends
AppCompatActivity
implements
AddBabyDialog
.
BabyDialogInterface
,
EditBabyDialog
.
EditBabyDialogInterface
{
private
final
static
String
TAG
=
"BabyDashboardActivity"
;
private
SwipeRefreshLayout
swipeContainer
;
...
...
@@ -299,6 +300,63 @@ public class BabyDashboardActivity extends AppCompatActivity implements AddBabyD
// make dropdowns
}
@Override
public
void
parseValuesForEdit
(
BabyDto
baby
,
AlertDialog
dialog
,
View
overlay
,
SpinKitView
progressbar
)
{
baby
.
setUserId
(
authDto
.
getUserId
());
Button
positiveBtn
=
dialog
.
getButton
(
DialogInterface
.
BUTTON_POSITIVE
);
Button
negativeBtn
=
dialog
.
getButton
(
DialogInterface
.
BUTTON_NEGATIVE
);
loader
(
overlay
,
progressbar
,
true
);
positiveBtn
.
setEnabled
(
false
);
negativeBtn
.
setEnabled
(
false
);
Call
<
BabyDto
>
call
=
babyApiService
.
updateBaby
(
baby
.
getBabyId
(),
baby
);
call
.
enqueue
(
new
Callback
<
BabyDto
>()
{
@Override
public
void
onResponse
(
Call
<
BabyDto
>
call
,
Response
<
BabyDto
>
response
)
{
if
(
response
.
isSuccessful
())
{
loadData
();
Toast
.
makeText
(
BabyDashboardActivity
.
this
,
"Baby Details were successfully updated."
,
Toast
.
LENGTH_LONG
).
show
();
dialog
.
dismiss
();
loader
(
overlay
,
progressbar
,
false
);
}
else
{
try
{
Gson
gson
=
new
Gson
();
assert
response
.
errorBody
()
!=
null
;
String
errorBodyString
=
response
.
errorBody
().
string
();
// Check if the error body is in JSON format
if
(
errorBodyString
.
startsWith
(
"{"
))
{
ErrorDto
errorDto
=
gson
.
fromJson
(
errorBodyString
,
ErrorDto
.
class
);
Toast
.
makeText
(
BabyDashboardActivity
.
this
,
errorDto
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
}
else
{
// If the error body is not in JSON format, display a generic error message
Log
.
e
(
TAG
,
errorBodyString
);
Toast
.
makeText
(
BabyDashboardActivity
.
this
,
"An unexpected error occurred"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"else-error: "
+
e
.
getMessage
());
Toast
.
makeText
(
BabyDashboardActivity
.
this
,
e
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
}
positiveBtn
.
setEnabled
(
true
);
negativeBtn
.
setEnabled
(
true
);
loader
(
overlay
,
progressbar
,
false
);
}
}
@Override
public
void
onFailure
(
Call
<
BabyDto
>
call
,
Throwable
throwable
)
{
Toast
.
makeText
(
BabyDashboardActivity
.
this
,
throwable
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
positiveBtn
.
setEnabled
(
true
);
negativeBtn
.
setEnabled
(
true
);
loader
(
overlay
,
progressbar
,
false
);
}
});
// TODO
// make photo selector
// make dropdowns
}
void
noContentCall
()
{
if
(
babyDtoList
.
isEmpty
())
{
tvNoContent
.
setVisibility
(
View
.
VISIBLE
);
...
...
app/src/main/java/com/kaluwa/enterprises/babycare/dialogs/EditBabyDialog.java
View file @
52101e08
...
...
@@ -147,13 +147,14 @@ public class EditBabyDialog extends AppCompatDialogFragment {
private
void
applyBabyDto
(
AlertDialog
dialog
)
{
babyDto
=
validateObjects
();
if
(
babyDto
.
isSys_validated
())
{
babyDialogInterface
.
parseValues
(
babyDto
,
dialog
,
overlay
,
progressbar
);
babyDialogInterface
.
parseValues
ForEdit
(
babyDto
,
dialog
,
overlay
,
progressbar
);
}
}
@SuppressLint
(
"NewApi"
)
private
BabyDto
validateObjects
()
{
BabyDto
baby
=
new
BabyDto
();
baby
.
setBabyId
(
babyDto
.
getBabyId
());
baby
.
setSys_validated
(
false
);
String
firstname
,
lastname
,
dob
,
sex
,
weight
,
height
,
bType
,
eyeColor
,
hairColor
,
allergies
,
medicalConditions
,
medications
,
vaccinateRecs
,
docName
,
docContact
,
healthInsuInfo
,
firstSmile
,
firstTooth
,
firstWord
,
firstStep
,
favFoods
,
disFoods
,
pEmergeConName
,
pEmergeRelationship
,
pEmergeContact
,
sEmergeConName
,
sEmergeRelationship
,
sEmergeContact
,
notes
;
...
...
@@ -249,7 +250,7 @@ public class EditBabyDialog extends AppCompatDialogFragment {
@Override
public
void
onAttach
(
@NonNull
Context
context
)
{
super
.
onAttach
(
context
);
//
babyDialogInterface = (EditBabyDialogInterface) context;
babyDialogInterface
=
(
EditBabyDialogInterface
)
context
;
}
private
void
findViews
(
View
view
)
{
...
...
@@ -297,6 +298,6 @@ public class EditBabyDialog extends AppCompatDialogFragment {
}
public
interface
EditBabyDialogInterface
{
void
parseValues
(
BabyDto
dto
,
AlertDialog
dialog
,
View
overlay
,
SpinKitView
progressbar
);
void
parseValues
ForEdit
(
BabyDto
dto
,
AlertDialog
dialog
,
View
overlay
,
SpinKitView
progressbar
);
}
}
app/src/main/java/com/kaluwa/enterprises/babycare/service/BabyApiService.java
View file @
52101e08
...
...
@@ -8,6 +8,8 @@ import retrofit2.Call;
import
retrofit2.http.Body
;
import
retrofit2.http.GET
;
import
retrofit2.http.POST
;
import
retrofit2.http.PUT
;
import
retrofit2.http.Path
;
public
interface
BabyApiService
{
...
...
@@ -17,4 +19,7 @@ public interface BabyApiService {
@POST
(
"baby"
)
Call
<
BabyDto
>
addBaby
(
@Body
BabyDto
baby
);
@PUT
(
"baby/{babyId}"
)
Call
<
BabyDto
>
updateBaby
(
@Path
(
"babyId"
)
Long
babyId
,
@Body
BabyDto
baby
);
}
app/src/main/java/com/kaluwa/enterprises/babycare/utils/Utils.java
View file @
52101e08
...
...
@@ -234,8 +234,8 @@ public class Utils {
.
parseCaseInsensitive
().
parseLenient
()
// .appendPattern("[d/M/yyyy]")
// .appendPattern("[dd MMM yyyy]")
.
appendPattern
(
"[dd/MM/yyyy]"
)
;
// .appendPattern("[dd/M/yyyy
]");
.
appendPattern
(
"[dd/MM/yyyy]"
)
.
appendPattern
(
"[yyyy-MM-dd
]"
);
return
builder
.
toFormatter
(
Locale
.
ENGLISH
);
}
...
...
app/src/main/res/layout/edit_baby_view_layout.xml
View file @
52101e08
...
...
@@ -22,7 +22,7 @@
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Ba
sic Information
"
android:text=
"Ba
by's Picture
"
android:textColor=
"@color/purple"
android:textStyle=
"bold"
android:fontFamily=
"@font/jeju_gothic_regular"
...
...
@@ -33,6 +33,42 @@
android:layout_height=
"1dp"
android:background=
"@color/dark_purple"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:layout_marginTop=
"4dp"
android:background=
"@drawable/borders"
android:padding=
"8dp"
>
<ImageButton
android:id=
"@+id/ebv_ib_photo"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:maxHeight=
"200dp"
android:src=
"@drawable/ic_add_32"
android:adjustViewBounds=
"true"
android:scaleType=
"centerInside"
android:layout_gravity=
"center"
android:contentDescription=
"baby_uploaded_photo"
/>
</LinearLayout>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Basic Information"
android:textColor=
"@color/purple"
android:textStyle=
"bold"
android:fontFamily=
"@font/jeju_gothic_regular"
android:textSize=
"18sp"
android:paddingTop=
"12dp"
/>
<View
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:background=
"@color/dark_purple"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
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