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
Show 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 {
SQLiteDatabase
mDatabase
;
ImageView
imageView1
,
imageView2
,
cross_btn
;
ImageButton
red_btn_left
,
red_btn_right
;
//
ImageButton red_btn_left, red_btn_right;
TextView
textView
;
Random
random
=
new
Random
();
...
...
@@ -100,8 +100,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
imageView1
=
findViewById
(
R
.
id
.
imageView1
);
imageView2
=
findViewById
(
R
.
id
.
imageView2
);
red_btn_left
=
findViewById
(
R
.
id
.
red_btn_left
);
red_btn_right
=
findViewById
(
R
.
id
.
red_btn_right
);
//
red_btn_left = findViewById(R.id.red_btn_left);
//
red_btn_right = findViewById(R.id.red_btn_right);
textView
=
findViewById
(
R
.
id
.
textView
);
cross_btn
=
(
ImageView
)
findViewById
(
R
.
id
.
cross_btn
);
...
...
@@ -148,14 +148,15 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
if
(
side
.
equals
(
"left"
))
{
radomImage
=
random
.
nextInt
(
4
);
imageView2
.
setVisibility
(
View
.
INVISIBLE
);
//imageView2.setVisibility(View.INVISIBLE);
imageView2
.
setImageResource
(
0
);
imageView1
.
setVisibility
(
View
.
VISIBLE
);
if
(
leftcount
>
3
){
leftcount
=
0
;
}
imageView1
.
setImageResource
(
left_images
[
leftcount
]);
red_btn_left
.
setEnabled
(
true
);
red_btn_right
.
setEnabled
(
true
);
imageView1
.
setEnabled
(
true
);
imageView2
.
setEnabled
(
true
);
leftcount
++;
startTime
=
System
.
currentTimeMillis
();
clickedSide
=
"left"
;
...
...
@@ -168,14 +169,15 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
// appearance - 1s * 20 times
else
{
radomImage
=
random
.
nextInt
(
4
);
imageView1
.
setVisibility
(
View
.
INVISIBLE
);
//imageView1.setVisibility(View.INVISIBLE);
imageView1
.
setImageResource
(
0
);
imageView2
.
setVisibility
(
View
.
VISIBLE
);
if
(
rightcount
>
3
){
rightcount
=
0
;
}
imageView2
.
setImageResource
(
right_images
[
rightcount
]);
red_btn_left
.
setEnabled
(
true
);
red_btn_right
.
setEnabled
(
true
);
imageView1
.
setEnabled
(
true
);
imageView2
.
setEnabled
(
true
);
rightcount
++;
startTime
=
System
.
currentTimeMillis
();
clickedSide
=
"right"
;
...
...
@@ -217,78 +219,48 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
}
}.
run
();
red_btn_left
.
setOnTouchListener
(
new
View
.
OnTouch
Listener
()
{
imageView1
.
setOnClickListener
(
new
View
.
OnClick
Listener
()
{
@Override
public
boolean
onTouch
(
View
view
,
MotionEvent
motionEvent
)
{
switch
(
motionEvent
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
{
red_btn_left
.
getBackground
().
setColorFilter
(
0x77000000
,
PorterDuff
.
Mode
.
SRC_ATOP
);
view
.
invalidate
();
public
void
onClick
(
View
view
)
{
mp2
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
button_click
);
mp2
.
start
();
break
;
}
case
MotionEvent
.
ACTION_UP
:
// Your action here on button click
clickedTime
=
System
.
currentTimeMillis
();
reactionTime
=
(
clickedTime
-
startTime
);
if
(
clickedSide
.
equals
(
"left"
))
{
totalReactionTime
=
totalReactionTime
+
reactionTime
;
Log
.
d
(
"correct "
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
noOfCorrectResponses
++;
red_btn_left
.
setEnabled
(
false
);
imageView1
.
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
public
boolean
onTouch
(
View
view
,
MotionEvent
motionEvent
)
{
switch
(
motionEvent
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
{
red_btn_right
.
getBackground
().
setColorFilter
(
0x77000000
,
PorterDuff
.
Mode
.
SRC_ATOP
);
view
.
invalidate
();
public
void
onClick
(
View
view
)
{
mp3
=
MediaPlayer
.
create
(
getApplicationContext
(),
R
.
raw
.
button_click
);
mp3
.
start
();
break
;
}
case
MotionEvent
.
ACTION_UP
:
// Your action here on button click
clickedTime
=
System
.
currentTimeMillis
();
reactionTime
=
(
clickedTime
-
startTime
);
if
(
clickedSide
.
equals
(
"right"
))
{
totalReactionTime
=
totalReactionTime
+
reactionTime
;
Log
.
d
(
"correct "
,
startTime
+
" "
+
clickedTime
+
" "
+
reactionTime
);
noOfCorrectResponses
++;
red_btn_right
.
setEnabled
(
false
);
imageView2
.
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
()
{
@Override
public
boolean
onTouch
(
View
view
,
MotionEvent
motionEvent
)
{
...
...
app/src/main/res/layout/activity_alternating_attention_game1.xml
View file @
1974bd94
...
...
@@ -73,6 +73,7 @@
app:layout_constraintStart_toEndOf=
"@+id/imageView6"
app:layout_constraintTop_toTopOf=
"parent"
/>
<!--
<ImageButton
android:id="@+id/red_btn_right"
android:layout_width="150dp"
...
...
@@ -95,4 +96,6 @@
app:layout_constraintBottom_toBottomOf="parent"
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