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
68d91859
Commit
68d91859
authored
Mar 07, 2022
by
Anuththara18
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing the image and the location in the focusd attention game
parent
db4713fb
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
189 additions
and
12 deletions
+189
-12
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+5
-4
app/src/main/java/com/anuththara18/attentionassessment/focused/FocusedAttentionGame1.java
...18/attentionassessment/focused/FocusedAttentionGame1.java
+126
-6
app/src/main/res/drawable-nodpi/baby_tiger.png
app/src/main/res/drawable-nodpi/baby_tiger.png
+0
-0
app/src/main/res/drawable-nodpi/baby_zebra.png
app/src/main/res/drawable-nodpi/baby_zebra.png
+0
-0
app/src/main/res/drawable-nodpi/cow.png
app/src/main/res/drawable-nodpi/cow.png
+0
-0
app/src/main/res/drawable-nodpi/dino.png
app/src/main/res/drawable-nodpi/dino.png
+0
-0
app/src/main/res/drawable-nodpi/dog.png
app/src/main/res/drawable-nodpi/dog.png
+0
-0
app/src/main/res/drawable-nodpi/elephant.png
app/src/main/res/drawable-nodpi/elephant.png
+0
-0
app/src/main/res/drawable-nodpi/giraffe.png
app/src/main/res/drawable-nodpi/giraffe.png
+0
-0
app/src/main/res/drawable-nodpi/horse.png
app/src/main/res/drawable-nodpi/horse.png
+0
-0
app/src/main/res/drawable-nodpi/lion.png
app/src/main/res/drawable-nodpi/lion.png
+0
-0
app/src/main/res/drawable-nodpi/pig.png
app/src/main/res/drawable-nodpi/pig.png
+0
-0
app/src/main/res/layout/activity_focused_attention_game1.xml
app/src/main/res/layout/activity_focused_attention_game1.xml
+58
-2
No files found.
app/src/main/AndroidManifest.xml
View file @
68d91859
...
...
@@ -140,6 +140,11 @@
android:name=
".focused.FocusedAttentionGame1"
android:screenOrientation=
"landscape"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
".loginregistration.RegistrationActivity"
...
...
@@ -171,11 +176,7 @@
android:name=
".splashscreen.SplashActivity"
android:screenOrientation=
"landscape"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
...
...
app/src/main/java/com/anuththara18/attentionassessment/focused/FocusedAttentionGame1.java
View file @
68d91859
package
com.anuththara18.attentionassessment.focused
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AlertDialog
;
import
androidx.appcompat.app.AppCompatActivity
;
...
...
@@ -37,8 +39,14 @@ import com.anuththara18.attentionassessment.sustained.SustainedAttentionGame1;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.Set
;
public
class
FocusedAttentionGame1
extends
AppCompatActivity
{
...
...
@@ -50,6 +58,7 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
Random
random
=
new
Random
();
int
radomTimer
=
0
;
int
rand
=
0
;
int
i
=
1
;
private
long
startTime
,
clickedTime
=
0
;
...
...
@@ -63,7 +72,7 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
int
meanReactionTime
=
0
;
int
duration
=
0
;
ImageView
imageView
,
cross_btn
;
ImageView
imageView
,
cross_btn
,
imageView2
,
imageView3
,
imageView4
,
imageView5
,
imageView6
;
ImageButton
red_btn
;
TextView
textView
;
...
...
@@ -71,6 +80,9 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
Integer
[]
isi
=
{
3000
,
3500
,
4000
,
4500
,
5000
,
5500
,
6000
};
Integer
[]
images
=
{
R
.
drawable
.
monkey
,
R
.
drawable
.
baby_zebra
,
R
.
drawable
.
elephant
,
R
.
drawable
.
pig
,
R
.
drawable
.
giraffe
,
R
.
drawable
.
cow
,
R
.
drawable
.
horse
,
R
.
drawable
.
dino
,
R
.
drawable
.
lion
,
R
.
drawable
.
dog
};
MediaPlayer
mp
,
mp2
;
@Override
...
...
@@ -86,11 +98,16 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
setContentView
(
R
.
layout
.
activity_focused_attention_game1
);
imageView
=
(
ImageView
)
findViewById
(
R
.
id
.
imageView
);
imageView2
=
(
ImageView
)
findViewById
(
R
.
id
.
imageView2
);
imageView3
=
(
ImageView
)
findViewById
(
R
.
id
.
imageView3
);
imageView4
=
(
ImageView
)
findViewById
(
R
.
id
.
imageView4
);
imageView5
=
(
ImageView
)
findViewById
(
R
.
id
.
imageView5
);
imageView6
=
(
ImageView
)
findViewById
(
R
.
id
.
imageView6
);
cross_btn
=
(
ImageView
)
findViewById
(
R
.
id
.
cross_btn
);
red_btn
=
(
ImageButton
)
findViewById
(
R
.
id
.
red_btn
);
textView
=
(
TextView
)
findViewById
(
R
.
id
.
textView
);
textView
.
setText
(
LanguageSetter
.
getresources
().
getString
(
R
.
string
.
focg1
));
//
textView.setText(LanguageSetter.getresources().getString(R.string.focg1));
mp
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
focused
);
mp
.
start
();
...
...
@@ -100,6 +117,18 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
//creating a database
mDatabase
=
openOrCreateDatabase
(
DATABASE_NAME
,
MODE_PRIVATE
,
null
);
List
<
Integer
>
unpickedNumbers
=
new
ArrayList
<
Integer
>();
unpickedNumbers
.
add
(
0
);
unpickedNumbers
.
add
(
1
);
unpickedNumbers
.
add
(
2
);
unpickedNumbers
.
add
(
3
);
unpickedNumbers
.
add
(
4
);
unpickedNumbers
.
add
(
5
);
unpickedNumbers
.
add
(
6
);
unpickedNumbers
.
add
(
7
);
unpickedNumbers
.
add
(
8
);
unpickedNumbers
.
add
(
9
);
new
Runnable
()
{
int
updateInterval
;
...
...
@@ -109,8 +138,12 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
if
(
i
<=
41
)
{
// 41 times
if
(
i
%
2
!=
0
)
{
imageView
.
setVisibility
(
View
.
INVISIBLE
);
imageView2
.
setVisibility
(
View
.
INVISIBLE
);
imageView3
.
setVisibility
(
View
.
INVISIBLE
);
imageView4
.
setVisibility
(
View
.
INVISIBLE
);
imageView5
.
setVisibility
(
View
.
INVISIBLE
);
imageView6
.
setVisibility
(
View
.
INVISIBLE
);
clicked
=
"null"
;
red_btn
.
setEnabled
(
true
);
radomTimer
=
random
.
nextInt
(
5
);
...
...
@@ -122,10 +155,78 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
}
// appearance - 1s * 20 times
else
{
Log
.
d
(
"***************radomTimer******************"
,
String
.
valueOf
(
i
+
" 1000"
));
Log
.
d
(
"***************radomTimer******************"
,
String
.
valueOf
(
i
+
" 3000"
));
if
(
i
==
22
)
{
unpickedNumbers
.
add
(
0
);
unpickedNumbers
.
add
(
1
);
unpickedNumbers
.
add
(
2
);
unpickedNumbers
.
add
(
3
);
unpickedNumbers
.
add
(
4
);
unpickedNumbers
.
add
(
5
);
unpickedNumbers
.
add
(
6
);
unpickedNumbers
.
add
(
7
);
unpickedNumbers
.
add
(
8
);
unpickedNumbers
.
add
(
9
);
}
rand
=
getRandomElement
(
unpickedNumbers
);
if
(
i
==
2
||
i
==
14
||
i
==
26
||
i
==
38
)
{
imageView
.
setVisibility
(
View
.
VISIBLE
);
imageView2
.
setVisibility
(
View
.
INVISIBLE
);
imageView3
.
setVisibility
(
View
.
INVISIBLE
);
imageView4
.
setVisibility
(
View
.
INVISIBLE
);
imageView5
.
setVisibility
(
View
.
INVISIBLE
);
imageView6
.
setVisibility
(
View
.
INVISIBLE
);
imageView
.
setImageResource
(
images
[
rand
]);
}
else
if
(
i
==
4
||
i
==
16
||
i
==
28
||
i
==
40
)
{
imageView2
.
setVisibility
(
View
.
VISIBLE
);
imageView
.
setVisibility
(
View
.
INVISIBLE
);
imageView3
.
setVisibility
(
View
.
INVISIBLE
);
imageView4
.
setVisibility
(
View
.
INVISIBLE
);
imageView5
.
setVisibility
(
View
.
INVISIBLE
);
imageView6
.
setVisibility
(
View
.
INVISIBLE
);
imageView2
.
setImageResource
(
images
[
rand
]);
}
else
if
(
i
==
6
||
i
==
18
||
i
==
30
)
{
imageView3
.
setVisibility
(
View
.
VISIBLE
);
imageView2
.
setVisibility
(
View
.
INVISIBLE
);
imageView
.
setVisibility
(
View
.
INVISIBLE
);
imageView4
.
setVisibility
(
View
.
INVISIBLE
);
imageView5
.
setVisibility
(
View
.
INVISIBLE
);
imageView6
.
setVisibility
(
View
.
INVISIBLE
);
imageView3
.
setImageResource
(
images
[
rand
]);
}
else
if
(
i
==
8
||
i
==
20
||
i
==
32
)
{
imageView4
.
setVisibility
(
View
.
VISIBLE
);
imageView2
.
setVisibility
(
View
.
INVISIBLE
);
imageView3
.
setVisibility
(
View
.
INVISIBLE
);
imageView
.
setVisibility
(
View
.
INVISIBLE
);
imageView5
.
setVisibility
(
View
.
INVISIBLE
);
imageView6
.
setVisibility
(
View
.
INVISIBLE
);
imageView4
.
setImageResource
(
images
[
rand
]);
}
else
if
(
i
==
10
||
i
==
22
||
i
==
34
)
{
imageView5
.
setVisibility
(
View
.
VISIBLE
);
imageView2
.
setVisibility
(
View
.
INVISIBLE
);
imageView3
.
setVisibility
(
View
.
INVISIBLE
);
imageView4
.
setVisibility
(
View
.
INVISIBLE
);
imageView
.
setVisibility
(
View
.
INVISIBLE
);
imageView6
.
setVisibility
(
View
.
INVISIBLE
);
imageView5
.
setImageResource
(
images
[
rand
]);
}
else
if
(
i
==
12
||
i
==
24
||
i
==
36
)
{
imageView6
.
setVisibility
(
View
.
VISIBLE
);
imageView2
.
setVisibility
(
View
.
INVISIBLE
);
imageView3
.
setVisibility
(
View
.
INVISIBLE
);
imageView4
.
setVisibility
(
View
.
INVISIBLE
);
imageView5
.
setVisibility
(
View
.
INVISIBLE
);
imageView
.
setVisibility
(
View
.
INVISIBLE
);
imageView6
.
setImageResource
(
images
[
rand
]);
}
red_btn
.
setEnabled
(
true
);
imageView
.
setImageResource
(
R
.
drawable
.
monkey
);
clicked
=
"monkey"
;
startTime
=
System
.
currentTimeMillis
();
imageView
.
postDelayed
(
this
,
3000
);
...
...
@@ -225,6 +326,25 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
}
// Function select an element base on index
// and return an element
public
int
getRandomElement
(
List
<
Integer
>
list
)
{
Random
rand
=
new
Random
();
//int val = rand.nextInt(list.size());
int
val
=
list
.
get
(
rand
.
nextInt
(
list
.
size
()));
//list.remove("val");
Iterator
itr
=
list
.
iterator
();
while
(
itr
.
hasNext
())
{
int
data
=
(
Integer
)
itr
.
next
();
if
(
data
==
val
)
itr
.
remove
();
}
Log
.
d
(
"1111111111111111111111111"
,
val
+
"----"
+
list
);
return
val
;
}
/*************************************************************************************************/
@Override
...
...
app/src/main/res/drawable-nodpi/baby_tiger.png
0 → 100644
View file @
68d91859
173 KB
app/src/main/res/drawable-nodpi/baby_zebra.png
0 → 100644
View file @
68d91859
199 KB
app/src/main/res/drawable-nodpi/cow.png
0 → 100644
View file @
68d91859
164 KB
app/src/main/res/drawable-nodpi/dino.png
0 → 100644
View file @
68d91859
92 KB
app/src/main/res/drawable-nodpi/dog.png
0 → 100644
View file @
68d91859
136 KB
app/src/main/res/drawable-nodpi/elephant.png
0 → 100644
View file @
68d91859
156 KB
app/src/main/res/drawable-nodpi/giraffe.png
0 → 100644
View file @
68d91859
177 KB
app/src/main/res/drawable-nodpi/horse.png
0 → 100644
View file @
68d91859
148 KB
app/src/main/res/drawable-nodpi/lion.png
0 → 100644
View file @
68d91859
24.4 KB
app/src/main/res/drawable-nodpi/pig.png
0 → 100644
View file @
68d91859
61 KB
app/src/main/res/layout/activity_focused_attention_game1.xml
View file @
68d91859
...
...
@@ -46,10 +46,66 @@
android:id=
"@+id/imageView"
android:layout_width=
"200dp"
android:layout_height=
"200dp"
android:layout_marginBottom=
"50dp"
android:layout_marginBottom=
"48dp"
android:src=
"@drawable/monkey"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintHorizontal_bias=
"0.54"
app:layout_constraintStart_toStartOf=
"parent"
/>
<ImageView
android:id=
"@+id/imageView2"
android:layout_width=
"200dp"
android:layout_height=
"200dp"
android:layout_marginBottom=
"104dp"
android:src=
"@drawable/monkey"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.952"
app:layout_constraintStart_toStartOf=
"parent"
/>
<ImageView
android:id=
"@+id/imageView3"
android:layout_width=
"200dp"
android:layout_height=
"200dp"
android:layout_marginBottom=
"48dp"
android:src=
"@drawable/monkey"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.03"
app:layout_constraintStart_toStartOf=
"parent"
/>
<ImageView
android:id=
"@+id/imageView4"
android:layout_width=
"200dp"
android:layout_height=
"200dp"
android:layout_marginBottom=
"140dp"
android:src=
"@drawable/monkey"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.318"
app:layout_constraintStart_toStartOf=
"parent"
/>
<ImageView
android:id=
"@+id/imageView5"
android:layout_width=
"200dp"
android:layout_height=
"200dp"
android:layout_marginBottom=
"4dp"
android:src=
"@drawable/monkey"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.726"
app:layout_constraintStart_toStartOf=
"parent"
/>
<ImageView
android:id=
"@+id/imageView6"
android:layout_width=
"200dp"
android:layout_height=
"200dp"
android:layout_marginBottom=
"4dp"
android:src=
"@drawable/monkey"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.246"
app:layout_constraintStart_toStartOf=
"parent"
/>
<ImageButton
...
...
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