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
1974bd94
Commit
1974bd94
authored
Mar 22, 2022
by
Anuththara18
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alternating Attention - Removing Buttons
parent
7890ab2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
71 deletions
+46
-71
app/src/main/java/com/anuththara18/attentionassessment/alternating/AlternatingAttentionGame1.java
...tionassessment/alternating/AlternatingAttentionGame1.java
+43
-71
app/src/main/res/layout/activity_alternating_attention_game1.xml
.../main/res/layout/activity_alternating_attention_game1.xml
+3
-0
No files found.
app/src/main/java/com/anuththara18/attentionassessment/alternating/AlternatingAttentionGame1.java
View file @
1974bd94
...
@@ -44,7 +44,7 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
...
@@ -44,7 +44,7 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
SQLiteDatabase
mDatabase
;
SQLiteDatabase
mDatabase
;
ImageView
imageView1
,
imageView2
,
cross_btn
;
ImageView
imageView1
,
imageView2
,
cross_btn
;
ImageButton
red_btn_left
,
red_btn_right
;
//
ImageButton red_btn_left, red_btn_right;
TextView
textView
;
TextView
textView
;
Random
random
=
new
Random
();
Random
random
=
new
Random
();
...
@@ -100,8 +100,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
...
@@ -100,8 +100,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
imageView1
=
findViewById
(
R
.
id
.
imageView1
);
imageView1
=
findViewById
(
R
.
id
.
imageView1
);
imageView2
=
findViewById
(
R
.
id
.
imageView2
);
imageView2
=
findViewById
(
R
.
id
.
imageView2
);
red_btn_left
=
findViewById
(
R
.
id
.
red_btn_left
);
//
red_btn_left = findViewById(R.id.red_btn_left);
red_btn_right
=
findViewById
(
R
.
id
.
red_btn_right
);
//
red_btn_right = findViewById(R.id.red_btn_right);
textView
=
findViewById
(
R
.
id
.
textView
);
textView
=
findViewById
(
R
.
id
.
textView
);
cross_btn
=
(
ImageView
)
findViewById
(
R
.
id
.
cross_btn
);
cross_btn
=
(
ImageView
)
findViewById
(
R
.
id
.
cross_btn
);
...
@@ -148,14 +148,15 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
...
@@ -148,14 +148,15 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
if
(
side
.
equals
(
"left"
))
{
if
(
side
.
equals
(
"left"
))
{
radomImage
=
random
.
nextInt
(
4
);
radomImage
=
random
.
nextInt
(
4
);
imageView2
.
setVisibility
(
View
.
INVISIBLE
);
//imageView2.setVisibility(View.INVISIBLE);
imageView2
.
setImageResource
(
0
);
imageView1
.
setVisibility
(
View
.
VISIBLE
);
imageView1
.
setVisibility
(
View
.
VISIBLE
);
if
(
leftcount
>
3
){
if
(
leftcount
>
3
){
leftcount
=
0
;
leftcount
=
0
;
}
}
imageView1
.
setImageResource
(
left_images
[
leftcount
]);
imageView1
.
setImageResource
(
left_images
[
leftcount
]);
red_btn_left
.
setEnabled
(
true
);
imageView1
.
setEnabled
(
true
);
red_btn_right
.
setEnabled
(
true
);
imageView2
.
setEnabled
(
true
);
leftcount
++;
leftcount
++;
startTime
=
System
.
currentTimeMillis
();
startTime
=
System
.
currentTimeMillis
();
clickedSide
=
"left"
;
clickedSide
=
"left"
;
...
@@ -168,14 +169,15 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
...
@@ -168,14 +169,15 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
// appearance - 1s * 20 times
// appearance - 1s * 20 times
else
{
else
{
radomImage
=
random
.
nextInt
(
4
);
radomImage
=
random
.
nextInt
(
4
);
imageView1
.
setVisibility
(
View
.
INVISIBLE
);
//imageView1.setVisibility(View.INVISIBLE);
imageView1
.
setImageResource
(
0
);
imageView2
.
setVisibility
(
View
.
VISIBLE
);
imageView2
.
setVisibility
(
View
.
VISIBLE
);
if
(
rightcount
>
3
){
if
(
rightcount
>
3
){
rightcount
=
0
;
rightcount
=
0
;
}
}
imageView2
.
setImageResource
(
right_images
[
rightcount
]);
imageView2
.
setImageResource
(
right_images
[
rightcount
]);
red_btn_left
.
setEnabled
(
true
);
imageView1
.
setEnabled
(
true
);
red_btn_right
.
setEnabled
(
true
);
imageView2
.
setEnabled
(
true
);
rightcount
++;
rightcount
++;
startTime
=
System
.
currentTimeMillis
();
startTime
=
System
.
currentTimeMillis
();
clickedSide
=
"right"
;
clickedSide
=
"right"
;
...
@@ -217,78 +219,48 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
...
@@ -217,78 +219,48 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
}
}
}.
run
();
}.
run
();
red_btn_left
.
setOnTouchListener
(
new
View
.
OnTouch
Listener
()
{
imageView1
.
setOnClickListener
(
new
View
.
OnClick
Listener
()
{
@Override
@Override
public
boolean
onTouch
(
View
view
,
MotionEvent
motionEvent
)
{
public
void
onClick
(
View
view
)
{
switch
(
motionEvent
.
getAction
())
{
mp2
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
button_click
);
case
MotionEvent
.
ACTION_DOWN
:
{
mp2
.
start
();
red_btn_left
.
getBackground
().
setColorFilter
(
0x77000000
,
PorterDuff
.
Mode
.
SRC_ATOP
);
clickedTime
=
System
.
currentTimeMillis
();
view
.
invalidate
();
reactionTime
=
(
clickedTime
-
startTime
);
mp2
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
button_click
);
if
(
clickedSide
.
equals
(
"left"
))
{
mp2
.
start
();
totalReactionTime
=
totalReactionTime
+
reactionTime
;
break
;
Log
.
d
(
"correct "
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
}
noOfCorrectResponses
++;
case
MotionEvent
.
ACTION_UP
:
imageView1
.
setEnabled
(
false
);
// Your action here on button click
}
clickedTime
=
System
.
currentTimeMillis
();
else
{
reactionTime
=
(
clickedTime
-
startTime
);
Log
.
d
(
"wrong"
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
if
(
clickedSide
.
equals
(
"left"
))
{
noOfCommissionErrors
++;
totalReactionTime
=
totalReactionTime
+
reactionTime
;
Log
.
d
(
"correct "
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
noOfCorrectResponses
++;
red_btn_left
.
setEnabled
(
false
);
}
else
{
Log
.
d
(
"wrong"
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
noOfCommissionErrors
++;
}
case
MotionEvent
.
ACTION_CANCEL
:
{
red_btn_left
.
getBackground
().
clearColorFilter
();
view
.
invalidate
();
break
;
}
}
}
return
true
;
}
}
});
});
red_btn_right
.
setOnTouchListener
(
new
View
.
OnTouch
Listener
()
{
imageView2
.
setOnClickListener
(
new
View
.
OnClick
Listener
()
{
@Override
@Override
public
boolean
onTouch
(
View
view
,
MotionEvent
motionEvent
)
{
public
void
onClick
(
View
view
)
{
switch
(
motionEvent
.
getAction
())
{
mp3
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
button_click
);
case
MotionEvent
.
ACTION_DOWN
:
{
mp3
.
start
();
red_btn_right
.
getBackground
().
setColorFilter
(
0x77000000
,
PorterDuff
.
Mode
.
SRC_ATOP
);
clickedTime
=
System
.
currentTimeMillis
();
view
.
invalidate
();
reactionTime
=
(
clickedTime
-
startTime
);
mp3
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
button_click
);
if
(
clickedSide
.
equals
(
"right"
))
{
mp3
.
start
();
totalReactionTime
=
totalReactionTime
+
reactionTime
;
break
;
Log
.
d
(
"correct "
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
}
noOfCorrectResponses
++;
case
MotionEvent
.
ACTION_UP
:
imageView2
.
setEnabled
(
false
);
// Your action here on button click
}
clickedTime
=
System
.
currentTimeMillis
();
else
{
reactionTime
=
(
clickedTime
-
startTime
);
Log
.
d
(
"wrong"
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
if
(
clickedSide
.
equals
(
"right"
))
{
noOfCommissionErrors
++;
totalReactionTime
=
totalReactionTime
+
reactionTime
;
Log
.
d
(
"correct "
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
noOfCorrectResponses
++;
red_btn_right
.
setEnabled
(
false
);
}
else
{
Log
.
d
(
"wrong"
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
noOfCommissionErrors
++;
}
case
MotionEvent
.
ACTION_CANCEL
:
{
red_btn_right
.
getBackground
().
clearColorFilter
();
view
.
invalidate
();
break
;
}
}
}
return
true
;
}
}
});
});
cross_btn
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
cross_btn
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
@Override
@Override
public
boolean
onTouch
(
View
view
,
MotionEvent
motionEvent
)
{
public
boolean
onTouch
(
View
view
,
MotionEvent
motionEvent
)
{
...
...
app/src/main/res/layout/activity_alternating_attention_game1.xml
View file @
1974bd94
...
@@ -73,6 +73,7 @@
...
@@ -73,6 +73,7 @@
app:layout_constraintStart_toEndOf=
"@+id/imageView6"
app:layout_constraintStart_toEndOf=
"@+id/imageView6"
app:layout_constraintTop_toTopOf=
"parent"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<!--
<ImageButton
<ImageButton
android:id="@+id/red_btn_right"
android:id="@+id/red_btn_right"
android:layout_width="150dp"
android:layout_width="150dp"
...
@@ -95,4 +96,6 @@
...
@@ -95,4 +96,6 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent" />
-->
</androidx.constraintlayout.widget.ConstraintLayout>
</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