Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
Research-Project
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
Jayakody J.A.D.K.A - IT19114040
Research-Project
Commits
adf9eff9
Commit
adf9eff9
authored
May 08, 2022
by
Anuththara18
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Analysing factors added- Sustained Attention
parent
18dc766f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
122 additions
and
832 deletions
+122
-832
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+0
-8
app/src/main/java/com/anuththara18/attentionassessment/sustained/SA1CompleteScreen.java
...ra18/attentionassessment/sustained/SA1CompleteScreen.java
+12
-10
app/src/main/java/com/anuththara18/attentionassessment/sustained/SA2CompleteScreen.java
...ra18/attentionassessment/sustained/SA2CompleteScreen.java
+0
-343
app/src/main/java/com/anuththara18/attentionassessment/sustained/Sustained.java
...anuththara18/attentionassessment/sustained/Sustained.java
+73
-1
app/src/main/java/com/anuththara18/attentionassessment/sustained/SustainedAttentionGame1.java
...ttentionassessment/sustained/SustainedAttentionGame1.java
+37
-7
app/src/main/java/com/anuththara18/attentionassessment/sustained/SustainedAttentionGame2.java
...ttentionassessment/sustained/SustainedAttentionGame2.java
+0
-392
app/src/main/res/layout/activity_sustained_attention_game2.xml
...rc/main/res/layout/activity_sustained_attention_game2.xml
+0
-71
No files found.
app/src/main/AndroidManifest.xml
View file @
adf9eff9
...
@@ -97,18 +97,10 @@
...
@@ -97,18 +97,10 @@
android:name=
".sustained.SA1CompleteScreen"
android:name=
".sustained.SA1CompleteScreen"
android:screenOrientation=
"portrait"
android:screenOrientation=
"portrait"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
/>
android:theme=
"@style/Theme.AppCompat.NoActionBar"
/>
<activity
android:name=
".sustained.SA2CompleteScreen"
android:screenOrientation=
"portrait"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
/>
<activity
<activity
android:name=
".selective.SelectiveACompleteScreen"
android:name=
".selective.SelectiveACompleteScreen"
android:screenOrientation=
"portrait"
android:screenOrientation=
"portrait"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
/>
android:theme=
"@style/Theme.AppCompat.NoActionBar"
/>
<activity
android:name=
".sustained.SustainedAttentionGame2"
android:screenOrientation=
"portrait"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
/>
<activity
<activity
android:name=
".CompleteScreen2"
android:name=
".CompleteScreen2"
android:screenOrientation=
"portrait"
android:screenOrientation=
"portrait"
...
...
app/src/main/java/com/anuththara18/attentionassessment/sustained/SA1CompleteScreen.java
View file @
adf9eff9
...
@@ -156,12 +156,16 @@ public class SA1CompleteScreen extends AppCompatActivity {
...
@@ -156,12 +156,16 @@ public class SA1CompleteScreen extends AppCompatActivity {
dataList
.
add
(
new
Sustained
(
dataList
.
add
(
new
Sustained
(
cursorEmployees
.
getInt
(
0
),
cursorEmployees
.
getInt
(
0
),
cursorEmployees
.
getInt
(
1
),
cursorEmployees
.
getInt
(
1
),
cursorEmployees
.
get
Int
(
2
),
cursorEmployees
.
get
String
(
2
),
cursorEmployees
.
get
Int
(
3
),
cursorEmployees
.
get
String
(
3
),
cursorEmployees
.
get
Int
(
4
),
cursorEmployees
.
get
String
(
4
),
cursorEmployees
.
getInt
(
5
),
cursorEmployees
.
getInt
(
5
),
cursorEmployees
.
getInt
(
6
),
cursorEmployees
.
getInt
(
6
),
cursorEmployees
.
getInt
(
7
)
cursorEmployees
.
getInt
(
7
),
cursorEmployees
.
getInt
(
8
),
cursorEmployees
.
getInt
(
9
),
cursorEmployees
.
getInt
(
10
),
cursorEmployees
.
getString
(
11
)
));
));
}
while
(
cursorEmployees
.
moveToNext
());
}
while
(
cursorEmployees
.
moveToNext
());
}
}
...
@@ -190,18 +194,16 @@ public class SA1CompleteScreen extends AppCompatActivity {
...
@@ -190,18 +194,16 @@ public class SA1CompleteScreen extends AppCompatActivity {
data
.
add
(
new
String
[]{
String
.
valueOf
(
gameData
.
getId
()),
data
.
add
(
new
String
[]{
String
.
valueOf
(
gameData
.
getId
()),
String
.
valueOf
(
String
.
valueOf
(
gameData
.
getChildID
()).
charAt
(
0
)),
String
.
valueOf
(
String
.
valueOf
(
gameData
.
getChildID
()).
charAt
(
0
)),
String
.
valueOf
(
String
.
valueOf
(
gameData
.
getChildID
()).
charAt
(
1
)),
String
.
valueOf
(
String
.
valueOf
(
gameData
.
getChildID
()).
charAt
(
1
)),
String
.
valueOf
(
gameData
.
getColour
()),
String
.
valueOf
(
SustainedAttentionGame1
.
stimulus
),
String
.
valueOf
(
gameData
.
getStimulus
()),
String
.
valueOf
(
SustainedAttentionGame1
.
colour
),
String
.
valueOf
(
gameData
.
getSequence_of_responses
()),
String
.
valueOf
(
"null"
),
String
.
valueOf
(
gameData
.
getTotalCorrectResponses
()),
String
.
valueOf
(
gameData
.
getTotalCorrectResponses
()),
String
.
valueOf
(
gameData
.
getNoOfCorrectResponses
()),
String
.
valueOf
(
gameData
.
getNoOfCorrectResponses
()),
String
.
valueOf
(
gameData
.
getNoOfCommissionErrors
()),
String
.
valueOf
(
gameData
.
getNoOfCommissionErrors
()),
String
.
valueOf
(
gameData
.
getNoOfOmmissionErrors
()),
String
.
valueOf
(
gameData
.
getNoOfOmmissionErrors
()),
String
.
valueOf
(
gameData
.
getMeanReactionTime
()),
String
.
valueOf
(
gameData
.
getMeanReactionTime
()),
String
.
valueOf
(
gameData
.
getTotalDuration
()),
String
.
valueOf
(
gameData
.
getTotalDuration
()),
String
.
valueOf
(
ParentDetailsActivity
.
diagnosis
)
String
.
valueOf
(
gameData
.
getDiagnosis
()
)
});
});
}
}
...
...
app/src/main/java/com/anuththara18/attentionassessment/sustained/SA2CompleteScreen.java
deleted
100644 → 0
View file @
18dc766f
package
com.anuththara18.attentionassessment.sustained
;
import
android.content.ActivityNotFoundException
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Canvas
;
import
android.graphics.Paint
;
import
android.graphics.Typeface
;
import
android.graphics.pdf.PdfDocument
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.ImageView
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.core.app.ActivityCompat
;
import
androidx.core.content.ContextCompat
;
import
androidx.core.content.FileProvider
;
import
com.anuththara18.attentionassessment.BuildConfig
;
import
com.anuththara18.attentionassessment.R
;
import
com.anuththara18.attentionassessment.age.AgeActivity
;
import
com.anuththara18.attentionassessment.gender.GenderActivity
;
import
com.anuththara18.attentionassessment.home.NavigationDrawerActivity
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
android
.
Manifest
.
permission
.
MANAGE_EXTERNAL_STORAGE
;
import
static
android
.
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
;
import
static
android
.
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
;
public
class
SA2CompleteScreen
extends
AppCompatActivity
{
ImageView
complete
;
List
<
Sustained
>
dataList
;
SQLiteDatabase
mDatabase
;
// declaring width and height
// for our PDF file.
int
pageHeight
=
1120
;
int
pagewidth
=
792
;
// creating a bitmap variable
// for storing our images
Bitmap
bmp
,
scaledbmp
;
// constant code for runtime permissions
private
static
final
int
PERMISSION_REQUEST_CODE
=
200
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
Build
.
VERSION
.
SDK_INT
<
16
)
{
getWindow
().
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
,
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
);
}
View
decorView
=
getWindow
().
getDecorView
();
int
uiOptions
=
View
.
SYSTEM_UI_FLAG_FULLSCREEN
;
decorView
.
setSystemUiVisibility
(
uiOptions
);
setContentView
(
R
.
layout
.
activity_complete_screen2
);
complete
=
findViewById
(
R
.
id
.
complete
);
complete
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Intent
intent
=
new
Intent
(
getApplicationContext
(),
NavigationDrawerActivity
.
class
);
finish
();
startActivity
(
intent
);
}
});
dataList
=
new
ArrayList
<>();
//opening the database
mDatabase
=
openOrCreateDatabase
(
SustainedAttentionGame2
.
DATABASE_NAME
,
MODE_PRIVATE
,
null
);
/*******************************************************************************************/
// initializing our variables.
bmp
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
sustained2
);
scaledbmp
=
Bitmap
.
createScaledBitmap
(
bmp
,
140
,
140
,
false
);
// below code is used for
// checking our permissions.
if
(
checkPermission
())
{
//Toast.makeText(this, "Permission Granted", Toast.LENGTH_SHORT).show();
}
else
{
requestPermission
();
}
/*******************************************************************************************/
//this part will display the data in the list
//we used rawQuery(sql, selectionargs) for fetching all the employees
Cursor
cursorEmployees
=
mDatabase
.
rawQuery
(
"SELECT * FROM sustainedAttention2"
,
null
);
//if the cursor has some data
if
(
cursorEmployees
.
moveToFirst
())
{
//looping through all the records
do
{
//pushing each record in the employee list
dataList
.
add
(
new
Sustained
(
cursorEmployees
.
getInt
(
0
),
cursorEmployees
.
getInt
(
1
),
cursorEmployees
.
getInt
(
2
),
cursorEmployees
.
getInt
(
3
),
cursorEmployees
.
getInt
(
4
),
cursorEmployees
.
getInt
(
5
),
cursorEmployees
.
getInt
(
6
),
cursorEmployees
.
getInt
(
7
)
));
}
while
(
cursorEmployees
.
moveToNext
());
}
//closing the cursor
cursorEmployees
.
close
();
/*******************************************************************************************/
// generate our PDF file.
// creating an object variable
// for our PDF document.
PdfDocument
pdfDocument
=
new
PdfDocument
();
// two variables for paint "paint" is used
// for drawing shapes and we will use "title"
// for adding text in our PDF file.
Paint
paint
=
new
Paint
();
Paint
title
=
new
Paint
();
// we are adding page info to our PDF file
// in which we will be passing our pageWidth,
// pageHeight and number of pages and after that
// we are calling it to create our PDF.
PdfDocument
.
PageInfo
mypageInfo
=
new
PdfDocument
.
PageInfo
.
Builder
(
pagewidth
,
pageHeight
,
1
).
create
();
// below line is used for setting
// start page for our PDF file.
PdfDocument
.
Page
myPage
=
pdfDocument
.
startPage
(
mypageInfo
);
// creating a variable for canvas
// from our page of PDF.
Canvas
canvas
=
myPage
.
getCanvas
();
// below line is used to draw our image on our PDF file.
// the first parameter of our drawbitmap method is
// our bitmap
// second parameter is position from left
// third parameter is position from top and last
// one is our variable for paint.
canvas
.
drawBitmap
(
scaledbmp
,
56
,
40
,
paint
);
// below line is used for adding typeface for
// our text which we will be adding in our PDF file.
title
.
setTypeface
(
Typeface
.
create
(
Typeface
.
DEFAULT
,
Typeface
.
BOLD
));
// below line is used for setting text size
// which we will be displaying in our PDF file.
title
.
setTextSize
(
20
);
// below line is sued for setting color
// of our text inside our PDF file.
title
.
setColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
orange
));
// below line is used to draw text in our PDF file.
// the first parameter is our text, second parameter
// is position from start, third parameter is position from top
// and then we are passing our variable of paint which is title.
canvas
.
drawText
(
"Sustained Attention 2"
,
250
,
80
,
title
);
title
.
setTypeface
(
Typeface
.
defaultFromStyle
(
Typeface
.
NORMAL
));
title
.
setColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
black
));
title
.
setTextSize
(
15
);
canvas
.
drawText
(
"Age : "
+
AgeActivity
.
age
,
150
,
250
,
title
);
String
gender
;
if
(
GenderActivity
.
gender
==
0
)
{
gender
=
"Male"
;
}
else
{
gender
=
"Female"
;
}
canvas
.
drawText
(
"Gender: "
+
gender
,
150
,
300
,
title
);
/*
canvas.drawText("Child Name: " + gender, 150, 350, title);
canvas.drawText("Parent Name: " + gender, 150, 400, title);
canvas.drawText("Contact No: " + gender, 150, 450, title);
canvas.drawText("Email: " + gender, 150, 500, title);
*/
// similarly we are creating another text and in this
// we are aligning this text to center of our PDF file.
title
.
setTypeface
(
Typeface
.
defaultFromStyle
(
Typeface
.
NORMAL
));
title
.
setColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
black
));
title
.
setTextSize
(
15
);
// below line is used for setting
// our text to center of PDF.
//title.setTextAlign(Paint.Align.CENTER);
int
space
=
0
;
// Printing elements one by one
for
(
int
i
=
0
;
i
<
dataList
.
size
();
i
++)
{
//getting employee of the specified position
Sustained
data
=
dataList
.
get
(
i
);
Log
.
d
(
"********************************"
,
"ID : "
+
String
.
valueOf
(
data
.
getId
())
+
", \t"
+
"C: "
+
String
.
valueOf
(
data
.
getChildID
())
+
", \t"
+
"TCR: "
+
String
.
valueOf
(
data
.
getTotalCorrectResponses
())
+
", \t"
+
"CR: "
+
String
.
valueOf
(
data
.
getNoOfCorrectResponses
())
+
", \t"
+
"CE: "
+
String
.
valueOf
(
data
.
getNoOfCommissionErrors
())
+
", \t"
+
"OE: "
+
String
.
valueOf
(
data
.
getNoOfOmmissionErrors
())
+
", \t"
+
"MRT: "
+
String
.
valueOf
(
data
.
getMeanReactionTime
())
+
", \t"
+
"TD: "
+
String
.
valueOf
(
data
.
getTotalDuration
())
);
canvas
.
drawText
(
"ID : "
+
String
.
valueOf
(
data
.
getId
())
+
", \t"
+
"C: "
+
String
.
valueOf
(
data
.
getChildID
())
+
", \t"
+
"TCR: "
+
String
.
valueOf
(
data
.
getTotalCorrectResponses
())
+
", \t"
+
"CR: "
+
String
.
valueOf
(
data
.
getNoOfCorrectResponses
())
+
", \t"
+
"CE: "
+
String
.
valueOf
(
data
.
getNoOfCommissionErrors
())
+
", \t"
+
"OE: "
+
String
.
valueOf
(
data
.
getNoOfOmmissionErrors
())
+
", \t"
+
"MRT: "
+
String
.
valueOf
(
data
.
getMeanReactionTime
())
+
", \t"
+
"TD: "
+
String
.
valueOf
(
data
.
getTotalDuration
())
+
" "
,
150
,
350
+
space
,
title
);
space
=
space
+
50
;
}
// after adding all attributes to our
// PDF file we will be finishing our page.
pdfDocument
.
finishPage
(
myPage
);
// below line is used to set the name of
// our PDF file and its path.
File
file
=
new
File
(
Environment
.
getExternalStorageDirectory
(),
"SustainedAttention2.pdf"
);
try
{
// after creating a file name we will
// write our PDF file to that location.
pdfDocument
.
writeTo
(
new
FileOutputStream
(
file
));
/*
// Uri path = Uri.fromFile(file);
Uri path = FileProvider.getUriForFile(SA2CompleteScreen.this, BuildConfig.APPLICATION_ID + ".provider", file);
Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
pdfIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
pdfIntent.setDataAndType(path, "application/pdf");
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try{
startActivity(pdfIntent);
}catch(ActivityNotFoundException e){
Toast.makeText(getApplicationContext(), "No Application available to view PDF", Toast.LENGTH_SHORT).show();
}
*/
// below line is to print toast message
// on completion of PDF generation.
Toast
.
makeText
(
getApplicationContext
(),
"PDF file generated successfully."
,
Toast
.
LENGTH_LONG
).
show
();
}
catch
(
IOException
e
)
{
// below line is used
// to handle error
e
.
printStackTrace
();
}
// after storing our pdf to that
// location we are closing our PDF file.
pdfDocument
.
close
();
}
/**************************************************************************************************/
private
boolean
checkPermission
()
{
// checking of permissions.
int
permission1
=
ContextCompat
.
checkSelfPermission
(
getApplicationContext
(),
WRITE_EXTERNAL_STORAGE
);
int
permission2
=
ContextCompat
.
checkSelfPermission
(
getApplicationContext
(),
READ_EXTERNAL_STORAGE
);
int
permission3
=
ContextCompat
.
checkSelfPermission
(
getApplicationContext
(),
MANAGE_EXTERNAL_STORAGE
);
return
permission1
==
PackageManager
.
PERMISSION_GRANTED
&&
permission2
==
PackageManager
.
PERMISSION_GRANTED
&&
permission3
==
PackageManager
.
PERMISSION_GRANTED
;
}
/**************************************************************************************************/
private
void
requestPermission
()
{
// requesting permissions if not provided.
ActivityCompat
.
requestPermissions
(
this
,
new
String
[]{
WRITE_EXTERNAL_STORAGE
,
READ_EXTERNAL_STORAGE
,
MANAGE_EXTERNAL_STORAGE
},
PERMISSION_REQUEST_CODE
);
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
if
(
requestCode
==
PERMISSION_REQUEST_CODE
)
{
if
(
grantResults
.
length
>
0
)
{
/*
Intent intent = new Intent();
intent.setAction(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
Uri uri = Uri.fromParts("package", this.getPackageName(), null);
intent.setData(uri);
startActivity(intent);
*/
// after requesting permissions we are showing
// users a toast message of permission granted.
boolean
writeStorage
=
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
;
boolean
readStorage
=
grantResults
[
1
]
==
PackageManager
.
PERMISSION_GRANTED
;
if
(
writeStorage
&&
readStorage
)
{
//Toast.makeText(this, "Permission Granted..", Toast.LENGTH_SHORT).show();
}
else
{
Toast
.
makeText
(
this
,
"Permission Denied."
,
Toast
.
LENGTH_SHORT
).
show
();
finish
();
}
}
}
}
/**************************************************************************************************/
}
app/src/main/java/com/anuththara18/attentionassessment/sustained/Sustained.java
View file @
adf9eff9
...
@@ -4,56 +4,128 @@ public class Sustained {
...
@@ -4,56 +4,128 @@ public class Sustained {
private
int
id
;
private
int
id
;
private
int
childID
;
private
int
childID
;
private
String
colour
;
private
String
stimulus
;
private
String
sequence_of_responses
;
private
int
totalCorrectResponses
;
private
int
totalCorrectResponses
;
private
int
noOfCorrectResponses
;
private
int
noOfCorrectResponses
;
private
int
noOfCommissionErrors
;
private
int
noOfCommissionErrors
;
private
int
noOfOmmissionErrors
;
private
int
noOfOmmissionErrors
;
private
int
meanReactionTime
;
private
int
meanReactionTime
;
private
int
totalDuration
;
private
int
totalDuration
;
private
String
diagnosis
;
public
Sustained
(
int
id
,
int
childID
,
int
totalCorrectResponses
,
int
noOfCorrectResponses
,
int
noOfCommissionErrors
,
int
noOfOmmissionErrors
,
int
meanReactionTime
,
int
totalDuration
)
{
public
Sustained
(
int
id
,
int
childID
,
String
colour
,
String
stimulus
,
String
sequence_of_responses
,
int
totalCorrectResponses
,
int
noOfCorrectResponses
,
int
noOfCommissionErrors
,
int
noOfOmmissionErrors
,
int
meanReactionTime
,
int
totalDuration
,
String
diagnosis
)
{
this
.
id
=
id
;
this
.
id
=
id
;
this
.
childID
=
childID
;
this
.
childID
=
childID
;
this
.
colour
=
colour
;
this
.
stimulus
=
stimulus
;
this
.
sequence_of_responses
=
sequence_of_responses
;
this
.
totalCorrectResponses
=
totalCorrectResponses
;
this
.
totalCorrectResponses
=
totalCorrectResponses
;
this
.
noOfCorrectResponses
=
noOfCorrectResponses
;
this
.
noOfCorrectResponses
=
noOfCorrectResponses
;
this
.
noOfCommissionErrors
=
noOfCommissionErrors
;
this
.
noOfCommissionErrors
=
noOfCommissionErrors
;
this
.
noOfOmmissionErrors
=
noOfOmmissionErrors
;
this
.
noOfOmmissionErrors
=
noOfOmmissionErrors
;
this
.
meanReactionTime
=
meanReactionTime
;
this
.
meanReactionTime
=
meanReactionTime
;
this
.
totalDuration
=
totalDuration
;
this
.
totalDuration
=
totalDuration
;
this
.
diagnosis
=
diagnosis
;
}
}
public
int
getId
()
{
public
int
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
int
getChildID
()
{
public
int
getChildID
()
{
return
childID
;
return
childID
;
}
}
public
void
setChildID
(
int
childID
)
{
this
.
childID
=
childID
;
}
public
String
getColour
()
{
return
colour
;
}
public
void
setColour
(
String
colour
)
{
this
.
colour
=
colour
;
}
public
String
getStimulus
()
{
return
stimulus
;
}
public
void
setStimulus
(
String
stimulus
)
{
this
.
stimulus
=
stimulus
;
}
public
String
getSequence_of_responses
()
{
return
sequence_of_responses
;
}
public
void
setSequence_of_responses
(
String
sequence_of_responses
)
{
this
.
sequence_of_responses
=
sequence_of_responses
;
}
public
int
getTotalCorrectResponses
()
{
public
int
getTotalCorrectResponses
()
{
return
totalCorrectResponses
;
return
totalCorrectResponses
;
}
}
public
void
setTotalCorrectResponses
(
int
totalCorrectResponses
)
{
this
.
totalCorrectResponses
=
totalCorrectResponses
;
}
public
int
getNoOfCorrectResponses
()
{
public
int
getNoOfCorrectResponses
()
{
return
noOfCorrectResponses
;
return
noOfCorrectResponses
;
}
}
public
void
setNoOfCorrectResponses
(
int
noOfCorrectResponses
)
{
this
.
noOfCorrectResponses
=
noOfCorrectResponses
;
}
public
int
getNoOfCommissionErrors
()
{
public
int
getNoOfCommissionErrors
()
{
return
noOfCommissionErrors
;
return
noOfCommissionErrors
;
}
}
public
void
setNoOfCommissionErrors
(
int
noOfCommissionErrors
)
{
this
.
noOfCommissionErrors
=
noOfCommissionErrors
;
}
public
int
getNoOfOmmissionErrors
()
{
public
int
getNoOfOmmissionErrors
()
{
return
noOfOmmissionErrors
;
return
noOfOmmissionErrors
;
}
}
public
void
setNoOfOmmissionErrors
(
int
noOfOmmissionErrors
)
{
this
.
noOfOmmissionErrors
=
noOfOmmissionErrors
;
}
public
int
getMeanReactionTime
()
{
public
int
getMeanReactionTime
()
{
return
meanReactionTime
;
return
meanReactionTime
;
}
}
public
void
setMeanReactionTime
(
int
meanReactionTime
)
{
this
.
meanReactionTime
=
meanReactionTime
;
}
public
int
getTotalDuration
()
{
public
int
getTotalDuration
()
{
return
totalDuration
;
return
totalDuration
;
}
}
public
void
setTotalDuration
(
int
totalDuration
)
{
this
.
totalDuration
=
totalDuration
;
}
public
String
getDiagnosis
()
{
return
diagnosis
;
}
public
void
setDiagnosis
(
String
diagnosis
)
{
this
.
diagnosis
=
diagnosis
;
}
/*
/*
CREATE TABLE sustainedAttention (
CREATE TABLE sustainedAttention (
id int NOT NULL AUTO_INCREMENT,
id int NOT NULL AUTO_INCREMENT,
...
...
app/src/main/java/com/anuththara18/attentionassessment/sustained/SustainedAttentionGame1.java
View file @
adf9eff9
...
@@ -15,6 +15,8 @@ import android.util.Log;
...
@@ -15,6 +15,8 @@ import android.util.Log;
import
android.view.MotionEvent
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.ImageButton
;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.TextView
;
...
@@ -24,6 +26,7 @@ import com.anuththara18.attentionassessment.R;
...
@@ -24,6 +26,7 @@ import com.anuththara18.attentionassessment.R;
import
com.anuththara18.attentionassessment.age.AgeActivity
;
import
com.anuththara18.attentionassessment.age.AgeActivity
;
import
com.anuththara18.attentionassessment.db.Api
;
import
com.anuththara18.attentionassessment.db.Api
;
import
com.anuththara18.attentionassessment.db.RequestHandler
;
import
com.anuththara18.attentionassessment.db.RequestHandler
;
import
com.anuththara18.attentionassessment.details.ParentDetailsActivity
;
import
com.anuththara18.attentionassessment.gender.GenderActivity
;
import
com.anuththara18.attentionassessment.gender.GenderActivity
;
import
com.anuththara18.attentionassessment.home.NavigationDrawerActivity
;
import
com.anuththara18.attentionassessment.home.NavigationDrawerActivity
;
import
com.anuththara18.attentionassessment.language.LanguageSetter
;
import
com.anuththara18.attentionassessment.language.LanguageSetter
;
...
@@ -31,6 +34,7 @@ import com.anuththara18.attentionassessment.language.LanguageSetter;
...
@@ -31,6 +34,7 @@ import com.anuththara18.attentionassessment.language.LanguageSetter;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Random
;
import
java.util.Random
;
...
@@ -55,6 +59,9 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -55,6 +59,9 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
};
1000
,
4500
,
2500
,
5000
,
2000
,
3500
,
6000
,
1500
,
3000
,
5500
,
4000
,
};
public
static
ArrayList
<
String
>
sequence_of_responses
;
int
missed
=
0
;
/*
/*
Integer[] image = { R.drawable.red_bird_gif,
Integer[] image = { R.drawable.red_bird_gif,
R.drawable.blue_bird_gif,
R.drawable.blue_bird_gif,
...
@@ -67,7 +74,7 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -67,7 +74,7 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
int
correctImage
,
clickedImage
;
int
correctImage
,
clickedImage
;
public
static
String
stimulus
,
colour
,
sequence_of_responses
=
""
;
public
static
String
stimulus
,
colour
;
Random
random
=
new
Random
();
Random
random
=
new
Random
();
...
@@ -113,6 +120,8 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -113,6 +120,8 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
mp
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
sustained
);
mp
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
sustained
);
mp
.
start
();
mp
.
start
();
sequence_of_responses
=
new
ArrayList
<>();
mp
.
setOnCompletionListener
(
new
MediaPlayer
.
OnCompletionListener
()
{
mp
.
setOnCompletionListener
(
new
MediaPlayer
.
OnCompletionListener
()
{
@Override
@Override
...
@@ -177,6 +186,11 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -177,6 +186,11 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
colour
=
"pink"
;
colour
=
"pink"
;
}
}
if
(
missed
==
0
)
{
sequence_of_responses
.
add
(
"M"
);
Log
.
d
(
"%%%%%%%%%%%%%%%%%%"
,
String
.
valueOf
(
sequence_of_responses
));
}
//gifImageView.setImageResource(image[randomImage]);
//gifImageView.setImageResource(image[randomImage]);
//clickedImage = image[randomImage];
//clickedImage = image[randomImage];
updateInterval
=
isi
[
j
];
updateInterval
=
isi
[
j
];
...
@@ -210,6 +224,8 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -210,6 +224,8 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
clickedImage
=
R
.
drawable
.
woody_bird
;
clickedImage
=
R
.
drawable
.
woody_bird
;
}
}
missed
=
0
;
bird
.
setVisibility
(
View
.
VISIBLE
);
bird
.
setVisibility
(
View
.
VISIBLE
);
bird
.
setEnabled
(
true
);
bird
.
setEnabled
(
true
);
gifImageView
.
setVisibility
(
View
.
INVISIBLE
);
gifImageView
.
setVisibility
(
View
.
INVISIBLE
);
...
@@ -239,7 +255,7 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -239,7 +255,7 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
Log
.
d
(
"commissionErrors"
,
String
.
valueOf
(
noOfCommissionErrors
));
Log
.
d
(
"commissionErrors"
,
String
.
valueOf
(
noOfCommissionErrors
));
Log
.
d
(
"meanReactionTime"
,
String
.
valueOf
(
meanReactionTime
));
Log
.
d
(
"meanReactionTime"
,
String
.
valueOf
(
meanReactionTime
));
Log
.
d
(
"duration"
,
String
.
valueOf
(
seconds
));
Log
.
d
(
"duration"
,
String
.
valueOf
(
seconds
));
saveDataToOnlineDB
();
//
saveDataToOnlineDB();
createTable
();
createTable
();
saveDataToLocalDB
();
saveDataToLocalDB
();
Intent
intent
=
new
Intent
(
getApplicationContext
(),
SA1CompleteScreen
.
class
);
Intent
intent
=
new
Intent
(
getApplicationContext
(),
SA1CompleteScreen
.
class
);
...
@@ -267,6 +283,8 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -267,6 +283,8 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
red_btn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
red_btn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
Animation
animZoomOut
=
AnimationUtils
.
loadAnimation
(
getApplicationContext
(),
R
.
anim
.
blink
);
red_btn
.
startAnimation
(
animZoomOut
);
long
gameEnd
=
System
.
currentTimeMillis
();
long
gameEnd
=
System
.
currentTimeMillis
();
seconds
=
(
gameEnd
-
gameStart
);
seconds
=
(
gameEnd
-
gameStart
);
if
(
noOfCorrectResponses
==
0
)
{
if
(
noOfCorrectResponses
==
0
)
{
...
@@ -284,7 +302,10 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -284,7 +302,10 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
Log
.
d
(
"commissionErrors"
,
String
.
valueOf
(
noOfCommissionErrors
));
Log
.
d
(
"commissionErrors"
,
String
.
valueOf
(
noOfCommissionErrors
));
Log
.
d
(
"meanReactionTime"
,
String
.
valueOf
(
meanReactionTime
));
Log
.
d
(
"meanReactionTime"
,
String
.
valueOf
(
meanReactionTime
));
Log
.
d
(
"duration"
,
String
.
valueOf
(
seconds
));
Log
.
d
(
"duration"
,
String
.
valueOf
(
seconds
));
saveDataToOnlineDB
();
sequence_of_responses
.
remove
(
0
);
Log
.
d
(
"responses"
,
String
.
valueOf
(
sequence_of_responses
));
//saveDataToOnlineDB();
createTable
();
createTable
();
saveDataToLocalDB
();
saveDataToLocalDB
();
Intent
intent
=
new
Intent
(
getApplicationContext
(),
SA1CompleteScreen
.
class
);
Intent
intent
=
new
Intent
(
getApplicationContext
(),
SA1CompleteScreen
.
class
);
...
@@ -297,6 +318,8 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -297,6 +318,8 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
bird
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
bird
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
Animation
animZoomOut
=
AnimationUtils
.
loadAnimation
(
getApplicationContext
(),
R
.
anim
.
blink
);
bird
.
startAnimation
(
animZoomOut
);
clickedTime
=
System
.
currentTimeMillis
();
clickedTime
=
System
.
currentTimeMillis
();
reactionTime
=
(
clickedTime
-
startTime
);
reactionTime
=
(
clickedTime
-
startTime
);
mp2
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
button_click
);
mp2
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
button_click
);
...
@@ -305,6 +328,9 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -305,6 +328,9 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
totalReactionTime
=
(
long
)
(
totalReactionTime
+
reactionTime
);
totalReactionTime
=
(
long
)
(
totalReactionTime
+
reactionTime
);
Log
.
d
(
"correct "
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
Log
.
d
(
"correct "
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
noOfCorrectResponses
++;
noOfCorrectResponses
++;
missed
=
1
;
sequence_of_responses
.
add
(
"C"
);
Log
.
d
(
"%%%%%%%%%%%%%%%%%%"
,
String
.
valueOf
(
sequence_of_responses
));
bird
.
setEnabled
(
false
);
bird
.
setEnabled
(
false
);
}
}
else
{
else
{
...
@@ -465,12 +491,16 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -465,12 +491,16 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
"CREATE TABLE IF NOT EXISTS sustainedAttention (\n"
+
"CREATE TABLE IF NOT EXISTS sustainedAttention (\n"
+
" id INTEGER PRIMARY KEY AUTOINCREMENT,\n"
+
" id INTEGER PRIMARY KEY AUTOINCREMENT,\n"
+
" childID int NOT NULL,\n"
+
" childID int NOT NULL,\n"
+
" colour int NOT NULL,\n"
+
" stimulus int NOT NULL,\n"
+
" sequence_of_responses String NOT NULL,\n"
+
" totalCorrectResponses int NOT NULL,\n"
+
" totalCorrectResponses int NOT NULL,\n"
+
" noOfCorrectResponses int NOT NULL,\n"
+
" noOfCorrectResponses int NOT NULL,\n"
+
" noOfCommissionErrors int NOT NULL,\n"
+
" noOfCommissionErrors int NOT NULL,\n"
+
" noOfOmmissionErrors int NOT NULL,\n"
+
" noOfOmmissionErrors int NOT NULL,\n"
+
" meanReactionTime int NOT NULL,\n"
+
" meanReactionTime int NOT NULL,\n"
+
" totalDuration int NOT NULL\n"
+
" totalDuration int NOT NULL,\n"
+
" diagnosis int NOT NULL\n"
+
");"
");"
);
);
}
}
...
@@ -489,11 +519,11 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
...
@@ -489,11 +519,11 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
int
total_duration
=
(
int
)
seconds
;
int
total_duration
=
(
int
)
seconds
;
String
insertSQL
=
"INSERT INTO sustainedAttention \n"
+
String
insertSQL
=
"INSERT INTO sustainedAttention \n"
+
"(childID,
totalCorrectResponses, noOfCorrectResponses, noOfCommissionErrors, noOfOmmissionErrors, meanReactionTime, totalDuration
)\n"
+
"(childID,
colour, stimulus, sequence_of_responses, totalCorrectResponses, noOfCorrectResponses, noOfCommissionErrors, noOfOmmissionErrors, meanReactionTime, totalDuration, diagnosis
)\n"
+
"VALUES \n"
+
"VALUES \n"
+
"(?, ?, ?, ?, ?, ?, ?);"
;
"(?, ?, ?, ?, ?, ?, ?
, ?, ?, ?, ?
);"
;
mDatabase
.
execSQL
(
insertSQL
,
new
Integer
[]{
child_ID
,
total_correct_responses
,
no_of_correct_responses
,
no_of_ommission_errors
,
no_of_commission_errors
,
mean_reaction_time
,
total_duration
});
mDatabase
.
execSQL
(
insertSQL
,
new
Object
[]{
child_ID
,
colour
,
stimulus
,
sequence_of_responses
,
total_correct_responses
,
no_of_correct_responses
,
no_of_ommission_errors
,
no_of_commission_errors
,
mean_reaction_time
,
total_duration
,
ParentDetailsActivity
.
diagnosis
});
//Toast.makeText(this, "Data Added Successfully", Toast.LENGTH_SHORT).show();
//Toast.makeText(this, "Data Added Successfully", Toast.LENGTH_SHORT).show();
...
...
app/src/main/java/com/anuththara18/attentionassessment/sustained/SustainedAttentionGame2.java
deleted
100644 → 0
View file @
18dc766f
package
com.anuththara18.attentionassessment.sustained
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.graphics.PorterDuff
;
import
android.media.MediaPlayer
;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.appcompat.app.AlertDialog
;
import
androidx.appcompat.app.AppCompatActivity
;
import
com.anuththara18.attentionassessment.CompleteScreen2
;
import
com.anuththara18.attentionassessment.R
;
import
com.anuththara18.attentionassessment.age.AgeActivity
;
import
com.anuththara18.attentionassessment.db.Api
;
import
com.anuththara18.attentionassessment.db.RequestHandler
;
import
com.anuththara18.attentionassessment.gender.GenderActivity
;
import
com.anuththara18.attentionassessment.home.NavigationDrawerActivity
;
import
com.anuththara18.attentionassessment.language.LanguageSetter
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.util.HashMap
;
import
java.util.Random
;
public
class
SustainedAttentionGame2
extends
AppCompatActivity
{
private
static
final
int
CODE_GET_REQUEST
=
1024
;
private
static
final
int
CODE_POST_REQUEST
=
1025
;
public
static
final
String
DATABASE_NAME
=
"sustainedAttention2"
;
SQLiteDatabase
mDatabase
;
ImageButton
red_btn
;
ImageView
bird
,
cross_btn
;
TextView
textView
;
// isi = 10 - 60 secs
Integer
[]
isi
=
{
10000
,
45000
,
25000
,
50000
,
20000
,
35000
,
60000
,
15000
,
30000
,
55000
,
40000
,
10000
,
45000
,
25000
,
50000
,
20000
,
35000
,
60000
,
15000
,
30000
,
55000
,
40000
,
10000
,
15000
,
10000
,
15000
};
/*Integer[] isi = { 1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000,
1000, 4500, 2500, 5000, 2000, 3500, 6000, 1500, 3000, 5500, 4000,
1000, 1500, 1000, 1500 };*/
Integer
[]
image
=
{
R
.
drawable
.
red_bird_gif
,
R
.
drawable
.
blue_bird_gif
,
R
.
drawable
.
green_bird_gif
,
R
.
drawable
.
black_bird_gif
};
int
correctImage
,
clickedImage
;
Random
random
=
new
Random
();
int
randomImage
=
0
;
int
i
=
1
;
int
j
=
0
;
int
duration
=
0
;
private
long
startTime
,
clickedTime
=
0
;
float
reactionTime
;
int
totalCorrectResponses
=
0
;
int
noOfCorrectResponses
=
0
;
int
noOfCommissionErrors
=
0
;
int
noOfOmmissionErrors
=
0
;
long
totalReactionTime
=
0
;
int
meanReactionTime
=
0
;
MediaPlayer
mp
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
Build
.
VERSION
.
SDK_INT
<
16
)
{
getWindow
().
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
,
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
);
}
View
decorView
=
getWindow
().
getDecorView
();
int
uiOptions
=
View
.
SYSTEM_UI_FLAG_FULLSCREEN
;
decorView
.
setSystemUiVisibility
(
uiOptions
);
setContentView
(
R
.
layout
.
activity_sustained_attention_game2
);
bird
=
findViewById
(
R
.
id
.
bird
);
red_btn
=
(
ImageButton
)
findViewById
(
R
.
id
.
red_btn
);
cross_btn
=
(
ImageView
)
findViewById
(
R
.
id
.
cross_btn
);
textView
=
(
TextView
)
findViewById
(
R
.
id
.
textView
);
textView
.
setText
(
LanguageSetter
.
getresources
().
getString
(
R
.
string
.
susg1
));
mp
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
divided
);
mp
.
start
();
mp
.
setOnCompletionListener
(
new
MediaPlayer
.
OnCompletionListener
()
{
@Override
public
void
onCompletion
(
MediaPlayer
mp
)
{
Log
.
d
(
"#############"
,
"restart"
);
mp
.
start
();
}
});
long
gameStart
=
System
.
currentTimeMillis
();
//creating a database
mDatabase
=
openOrCreateDatabase
(
DATABASE_NAME
,
MODE_PRIVATE
,
null
);
new
Runnable
()
{
int
updateInterval
;
@Override
public
void
run
()
{
if
(
i
<=
51
)
{
// tot duration - 14.5 mins = 870000
//385000 , 770000, (50000)
if
(
i
%
2
!=
0
||
totalCorrectResponses
>
25
)
{
randomImage
=
random
.
nextInt
(
4
);
bird
.
setVisibility
(
View
.
INVISIBLE
);
//gifImageView.setImageResource(image[randomImage]);
clickedImage
=
image
[
randomImage
];
updateInterval
=
isi
[
j
];
Log
.
d
(
"radomTimer"
,
String
.
valueOf
(
i
+
" "
+
updateInterval
));
bird
.
postDelayed
(
this
,
updateInterval
);
duration
=
duration
+
updateInterval
;
i
++;
j
++;
}
// appearance - 0.5s * 25 times
else
if
(
totalCorrectResponses
<=
25
)
{
Log
.
d
(
"radomTimer"
,
String
.
valueOf
(
i
+
" 2000"
));
bird
.
setVisibility
(
View
.
VISIBLE
);
startTime
=
System
.
currentTimeMillis
();
clickedImage
=
R
.
drawable
.
blue_bird
;
bird
.
postDelayed
(
this
,
2000
);
totalCorrectResponses
++;
duration
=
duration
+
2000
;
i
++;
}
}
else
{
long
gameEnd
=
System
.
currentTimeMillis
();
long
seconds
=
(
gameEnd
-
gameStart
)
/
1000
;
meanReactionTime
=
(
int
)
Math
.
ceil
(
totalReactionTime
/
noOfCorrectResponses
);
// ms
Log
.
d
(
"****************************************************"
,
"****************************************************"
);
Log
.
d
(
"Game Time"
,
String
.
valueOf
(
seconds
));
Log
.
d
(
"total"
,
String
.
valueOf
(
totalCorrectResponses
));
Log
.
d
(
"correctResponses"
,
String
.
valueOf
(
noOfCorrectResponses
));
noOfOmmissionErrors
=
totalCorrectResponses
-
noOfCorrectResponses
;
Log
.
d
(
"omissionErrors"
,
String
.
valueOf
(
totalCorrectResponses
-
noOfCorrectResponses
));
Log
.
d
(
"commissionErrors"
,
String
.
valueOf
(
noOfCommissionErrors
));
Log
.
d
(
"meanReactionTime"
,
String
.
valueOf
(
meanReactionTime
));
Log
.
d
(
"duration"
,
String
.
valueOf
(
duration
));
saveDataToOnlineDB
();
createTable
();
saveDataToLocalDB
();
Intent
intent
=
new
Intent
(
getApplicationContext
(),
SA2CompleteScreen
.
class
);
finish
();
mp
.
pause
();
startActivity
(
intent
);
}
}
}.
run
();
correctImage
=
R
.
drawable
.
blue_bird
;
red_btn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
clickedTime
=
System
.
currentTimeMillis
();
reactionTime
=
(
clickedTime
-
startTime
);
if
(
correctImage
==
clickedImage
)
{
totalReactionTime
=
(
long
)
(
totalReactionTime
+
reactionTime
);
Log
.
d
(
"correct "
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
noOfCorrectResponses
++;
}
else
if
(
reactionTime
<
4000
)
{
totalReactionTime
=
(
long
)
(
totalReactionTime
+
reactionTime
);
Log
.
d
(
"correct "
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
noOfCorrectResponses
++;
}
else
{
noOfCommissionErrors
++;
Log
.
d
(
"wrong"
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
}
}
});
cross_btn
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
@Override
public
boolean
onTouch
(
View
view
,
MotionEvent
motionEvent
)
{
switch
(
motionEvent
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
{
cross_btn
.
getBackground
().
setColorFilter
(
0x77000000
,
PorterDuff
.
Mode
.
SRC_ATOP
);
view
.
invalidate
();
break
;
}
case
MotionEvent
.
ACTION_UP
:
alert
();
mp
.
pause
();
case
MotionEvent
.
ACTION_CANCEL
:
{
cross_btn
.
getBackground
().
clearColorFilter
();
view
.
invalidate
();
break
;
}
}
return
true
;
}
});
}
/*************************************************************************************************/
@Override
public
void
onBackPressed
()
{
super
.
onBackPressed
();
mp
.
pause
();
}
/*************************************************************************************************/
private
void
alert
()
{
AlertDialog
.
Builder
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
this
);
alertDialogBuilder
.
setMessage
(
"Do you really want to quit the game?"
);
alertDialogBuilder
.
setPositiveButton
(
"yes"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
arg0
,
int
arg1
)
{
Intent
intent
=
new
Intent
(
getApplicationContext
(),
NavigationDrawerActivity
.
class
);
finish
();
startActivity
(
intent
);
//Toast.makeText(FocusedAttentionGame1.this,"You clicked yes button",Toast.LENGTH_LONG).show();
}
});
alertDialogBuilder
.
setNegativeButton
(
"No"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
//finish();
}
});
AlertDialog
alertDialog
=
alertDialogBuilder
.
create
();
alertDialog
.
show
();
}
/*************************************************************************************************/
private
void
saveDataToOnlineDB
()
{
String
child
=
String
.
valueOf
(
GenderActivity
.
gender
)
+
String
.
valueOf
(
AgeActivity
.
age
)
+
"9"
;
int
child_ID
=
Integer
.
parseInt
(
child
);
int
total_correct_responses
=
totalCorrectResponses
;
int
no_of_correct_responses
=
noOfCorrectResponses
;
int
no_of_ommission_errors
=
noOfOmmissionErrors
;
int
no_of_commission_errors
=
noOfCommissionErrors
;
int
mean_reaction_time
=
(
int
)
meanReactionTime
;
int
total_duration
=
duration
;
HashMap
<
String
,
Integer
>
params
=
new
HashMap
<>();
params
.
put
(
"childID"
,
child_ID
);
params
.
put
(
"totalCorrectResponses"
,
total_correct_responses
);
params
.
put
(
"noOfCorrectResponses"
,
no_of_correct_responses
);
params
.
put
(
"noOfCommissionErrors"
,
no_of_commission_errors
);
params
.
put
(
"noOfOmmissionErrors"
,
no_of_ommission_errors
);
params
.
put
(
"meanReactionTime"
,
mean_reaction_time
);
params
.
put
(
"totalDuration"
,
total_duration
);
//Calling the create hero API
PerformNetworkRequest
request
=
new
PerformNetworkRequest
(
Api
.
URL_SUSTAINED_ATTENTION
,
params
,
CODE_POST_REQUEST
);
request
.
execute
();
}
/*************************************************************************************************/
//inner class to perform network request extending an AsyncTask
private
class
PerformNetworkRequest
extends
AsyncTask
<
Void
,
Void
,
String
>
{
//the url where we need to send the request
String
url
;
//the parameters
HashMap
<
String
,
Integer
>
params
;
//the request code to define whether it is a GET or POST
int
requestCode
;
//constructor to initialize values
PerformNetworkRequest
(
String
url
,
HashMap
<
String
,
Integer
>
params
,
int
requestCode
)
{
this
.
url
=
url
;
this
.
params
=
params
;
this
.
requestCode
=
requestCode
;
}
//when the task started displaying a progressbar
@Override
protected
void
onPreExecute
()
{
super
.
onPreExecute
();
}
//this method will give the response from the request
@Override
protected
void
onPostExecute
(
String
s
)
{
super
.
onPostExecute
(
s
);
try
{
JSONObject
object
=
new
JSONObject
(
s
);
if
(!
object
.
getBoolean
(
"error"
))
{
Toast
.
makeText
(
getApplicationContext
(),
object
.
getString
(
"message"
),
Toast
.
LENGTH_SHORT
).
show
();
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
//the network operation will be performed in background
@Override
protected
String
doInBackground
(
Void
...
voids
)
{
RequestHandler
requestHandler
=
new
RequestHandler
();
if
(
requestCode
==
CODE_POST_REQUEST
)
return
requestHandler
.
sendPostRequest
(
url
,
params
);
if
(
requestCode
==
CODE_GET_REQUEST
)
return
requestHandler
.
sendGetRequest
(
url
);
return
null
;
}
}
/*************************************************************************************************/
private
void
createTable
()
{
mDatabase
.
execSQL
(
"CREATE TABLE IF NOT EXISTS sustainedAttention (\n"
+
" id INTEGER PRIMARY KEY AUTOINCREMENT,\n"
+
" childID int NOT NULL,\n"
+
" totalCorrectResponses int NOT NULL,\n"
+
" noOfCorrectResponses int NOT NULL,\n"
+
" noOfCommissionErrors int NOT NULL,\n"
+
" noOfOmmissionErrors int NOT NULL,\n"
+
" meanReactionTime int NOT NULL,\n"
+
" totalDuration int NOT NULL\n"
+
");"
);
}
/*************************************************************************************************/
private
void
saveDataToLocalDB
()
{
String
child
=
String
.
valueOf
(
GenderActivity
.
gender
)
+
String
.
valueOf
(
AgeActivity
.
age
);
int
child_ID
=
Integer
.
parseInt
(
child
);
int
total_correct_responses
=
totalCorrectResponses
;
int
no_of_correct_responses
=
noOfCorrectResponses
;
int
no_of_ommission_errors
=
noOfOmmissionErrors
;
int
no_of_commission_errors
=
noOfCommissionErrors
;
int
mean_reaction_time
=
(
int
)
meanReactionTime
;
int
total_duration
=
duration
;
String
insertSQL
=
"INSERT INTO sustainedAttention \n"
+
"(childID, totalCorrectResponses, noOfCorrectResponses, noOfCommissionErrors, noOfOmmissionErrors, meanReactionTime, totalDuration)\n"
+
"VALUES \n"
+
"(?, ?, ?, ?, ?, ?, ?);"
;
mDatabase
.
execSQL
(
insertSQL
,
new
Integer
[]{
child_ID
,
total_correct_responses
,
no_of_correct_responses
,
no_of_ommission_errors
,
no_of_commission_errors
,
mean_reaction_time
,
total_duration
});
Toast
.
makeText
(
this
,
"Data Added Successfully"
,
Toast
.
LENGTH_SHORT
).
show
();
}
/*************************************************************************************************/
}
\ No newline at end of file
app/src/main/res/layout/activity_sustained_attention_game2.xml
deleted
100644 → 0
View file @
18dc766f
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/bg4"
tools:context=
".sustained.SustainedAttentionGame2"
>
<ImageButton
android:id=
"@+id/cross_btn"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_marginStart=
"9dp"
android:layout_marginTop=
"14dp"
android:background=
"@drawable/cross_button"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<ImageButton
android:id=
"@+id/help_btn"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_marginTop=
"14dp"
android:layout_marginEnd=
"9dp"
android:background=
"@drawable/question_button"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/textView"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"50dp"
android:layout_marginTop=
"95dp"
android:layout_marginEnd=
"50dp"
android:fontFamily=
"@font/poppins_bold"
android:text=
"@string/susg1"
android:textAlignment=
"center"
android:textColor=
"@color/black"
android:textSize=
"24dp"
android:textStyle=
"bold"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<ImageView
android:id=
"@+id/bird"
android:layout_width=
"200dp"
android:layout_height=
"200dp"
android:src=
"@drawable/blue_bird"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.497"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.615"
/>
<ImageButton
android:id=
"@+id/red_btn"
android:layout_width=
"150dp"
android:layout_height=
"150dp"
android:layout_marginBottom=
"-20dp"
android:background=
"@drawable/red_btn"
android:elevation=
"80dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toStartOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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