Commit cd564fd2 authored by Anuththara18's avatar Anuththara18

Bug Fixing, Adding sounds to button clicks

parent a3b78743
......@@ -45,7 +45,8 @@
<activity
android:name=".alternating.AlternatingAttentionGame1"
android:screenOrientation="landscape"
android:theme="@style/Theme.AppCompat.NoActionBar"></activity>
android:theme="@style/Theme.AppCompat.NoActionBar">
</activity>
<provider
android:name="androidx.core.content.FileProvider"
......@@ -58,9 +59,11 @@
</provider>
<activity
android:name=".selective.BirdChoosingActivity"
android:name=".sustained.BirdChoosingActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar" />
android:theme="@style/Theme.AppCompat.NoActionBar" >
</activity>
<activity
android:name=".dividedattention.DACompleteScreen"
android:screenOrientation="portrait"
......@@ -93,7 +96,6 @@
android:name=".CompleteScreen2"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar" >
</activity>
<activity
android:name=".CompleteScreen"
......@@ -104,19 +106,25 @@
<activity
android:name=".dividedattention.DividedAttentionGame1"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar" />
android:theme="@style/Theme.AppCompat.NoActionBar" >
</activity>
<activity
android:name=".sustained.SustainedAttentionGame1"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar" />
android:theme="@style/Theme.AppCompat.NoActionBar" >
</activity>
<activity
android:name=".focused.FocusedAttentionGame2"
android:screenOrientation="landscape"
android:theme="@style/Theme.AppCompat.NoActionBar" />
android:theme="@style/Theme.AppCompat.NoActionBar" >
</activity>
<activity
android:name=".map.Map2Activity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar" />
android:theme="@style/Theme.AppCompat.NoActionBar" >
</activity>
<activity
android:name=".map.Map1Activity"
android:screenOrientation="portrait"
......@@ -129,7 +137,8 @@
<activity
android:name=".focused.FocusedAttentionGame1"
android:screenOrientation="landscape"
android:theme="@style/Theme.AppCompat.NoActionBar" />
android:theme="@style/Theme.AppCompat.NoActionBar" >
</activity>
<activity
android:name=".loginregistration.RegistrationActivity"
android:screenOrientation="portrait"
......@@ -153,7 +162,9 @@
<activity
android:name=".selective.SelectiveAttentionGame1"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar" />
android:theme="@style/Theme.AppCompat.NoActionBar" >
</activity>
<activity
android:name=".splashscreen.SplashActivity"
android:screenOrientation="landscape"
......
......@@ -84,7 +84,7 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
//Integer[] sequence1 = { 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0};
MediaPlayer mp;
MediaPlayer mp, mp2, mp3;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -154,6 +154,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
leftcount = 0;
}
imageView1.setImageResource(left_images[leftcount]);
red_btn_left.setEnabled(true);
red_btn_right.setEnabled(true);
leftcount++;
startTime = System.currentTimeMillis();
clickedSide = "left";
......@@ -172,6 +174,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
rightcount = 0;
}
imageView2.setImageResource(right_images[rightcount]);
red_btn_left.setEnabled(true);
red_btn_right.setEnabled(true);
rightcount++;
startTime = System.currentTimeMillis();
clickedSide = "right";
......@@ -220,6 +224,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
case MotionEvent.ACTION_DOWN: {
red_btn_left.getBackground().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP);
view.invalidate();
mp2 = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp2.start();
break;
}
case MotionEvent.ACTION_UP:
......@@ -230,6 +236,7 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
totalReactionTime = totalReactionTime + reactionTime;
Log.d("correct " , startTime + " " + clickedTime + " " + reactionTime);
noOfCorrectResponses++;
red_btn_left.setEnabled(false);
}
else {
Log.d( "wrong" , startTime + " " + clickedTime + " " + reactionTime);
......@@ -253,6 +260,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
case MotionEvent.ACTION_DOWN: {
red_btn_right.getBackground().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP);
view.invalidate();
mp3 = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp3.start();
break;
}
case MotionEvent.ACTION_UP:
......@@ -263,6 +272,7 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
totalReactionTime = totalReactionTime + reactionTime;
Log.d("correct " , startTime + " " + clickedTime + " " + reactionTime);
noOfCorrectResponses++;
red_btn_right.setEnabled(false);
}
else {
Log.d( "wrong" , startTime + " " + clickedTime + " " + reactionTime);
......
......@@ -67,7 +67,7 @@ public class DividedAttentionGame1 extends AppCompatActivity {
R.color.green, R.color.pink, R.color.purple,
R.color.orange, R.color.teal};
MediaPlayer mp;
MediaPlayer mp, mp2;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -129,47 +129,59 @@ public class DividedAttentionGame1 extends AppCompatActivity {
if ( j.equals("0") || j.equals("8") || j.equals("16") || j.equals("24") || j.equals("32") || j.equals("40") ) {
sq2.setImageResource(image[0]);
red_btn.setEnabled(true);
sq2.setTag(image[0]);
}
else if ( j.equals("1") || j.equals("9") || j.equals("17") || j.equals("25") || j.equals("33") || j.equals("41") ) {
sq2.setImageResource(image[1]);
red_btn.setEnabled(true);
sq2.setTag(image[1]);
}
else if ( j.equals("2") || j.equals("10") || j.equals("18") || j.equals("26") || j.equals("34") || j.equals("42") ) {
sq2.setImageResource(image[2]);
red_btn.setEnabled(true);
sq2.setTag(image[2]);
}
else if ( j.equals("3") || j.equals("11") || j.equals("19") || j.equals("27") || j.equals("35") || j.equals("43") ) {
sq2.setImageResource(image[3]);
red_btn.setEnabled(true);
sq2.setTag(image[3]);
}
else if ( j.equals("4") || j.equals("12") || j.equals("20") || j.equals("28") || j.equals("36") || j.equals("44") ) {
sq2.setImageResource(image[4]);
red_btn.setEnabled(true);
sq2.setTag(image[4]);
}
else if ( j.equals("5") || j.equals("13") || j.equals("21") || j.equals("29") || j.equals("37") || j.equals("45") ) {
sq2.setImageResource(image[5]);
red_btn.setEnabled(true);
sq2.setTag(image[5]);
}
else if ( j.equals("6") || j.equals("14") || j.equals("22") || j.equals("30") || j.equals("38") || j.equals("46") ) {
sq2.setImageResource(image[6]);
red_btn.setEnabled(true);
sq2.setTag(image[6]);
}
else if ( j.equals("7") || j.equals("15") || j.equals("23") || j.equals("31") || j.equals("39") || j.equals("47") ) {
sq2.setImageResource(image[7]);
red_btn.setEnabled(true);
sq2.setTag(image[7]);
}
startTime = System.currentTimeMillis();
sq2.postDelayed(this, 3000);
sq2.postDelayed(this, 2000);
Log.d("int", String.valueOf(i));
duration = duration + 3000;
duration = duration + 2000;
i++;
}
else {
long gameEnd = System.currentTimeMillis();
long seconds = (gameEnd - gameStart) / 1000;
//meanReactionTime = totalReactionTime / noOfCorrectResponses;
meanReactionTime = totalReactionTime;
if ( noOfCorrectResponses == 0 ) {
meanReactionTime = 0;
}
else {
meanReactionTime = (int) Math.ceil(totalReactionTime / noOfCorrectResponses); // ms
}
Log.d("****************************************************", "****************************************************");
Log.d("Game Time", String.valueOf(seconds));
Log.d("total", String.valueOf(totalCorrectResponses));
......@@ -198,6 +210,8 @@ public class DividedAttentionGame1 extends AppCompatActivity {
case MotionEvent.ACTION_DOWN: {
red_btn.getBackground().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP);
view.invalidate();
mp2 = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp2.start();
break;
}
case MotionEvent.ACTION_UP:
......@@ -208,6 +222,7 @@ public class DividedAttentionGame1 extends AppCompatActivity {
totalReactionTime = totalReactionTime + reactionTime;
Log.d("correct " , startTime + " " + clickedTime + " " + reactionTime);
noOfCorrectResponses++;
red_btn.setEnabled(false);
}
else {
Log.d( "wrong" , startTime + " " + clickedTime + " " + reactionTime);
......
......@@ -67,9 +67,11 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
ImageButton red_btn;
TextView textView;
String clicked = "null";
Integer[] isi = { 3000, 3500, 4000, 4500, 5000, 5500, 6000 };
MediaPlayer mp;
MediaPlayer mp, mp2;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -109,6 +111,8 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
if ( i % 2 != 0 ) {
imageView.setVisibility(View.INVISIBLE);
clicked = "null";
red_btn.setEnabled(true);
radomTimer = random.nextInt(5);
updateInterval = isi[radomTimer];
imageView.postDelayed(this, updateInterval);
......@@ -120,11 +124,13 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
else {
Log.d("***************radomTimer******************", String.valueOf(i + " 1000" ));
imageView.setVisibility(View.VISIBLE);
red_btn.setEnabled(true);
imageView.setImageResource(R.drawable.monkey);
clicked = "monkey";
startTime = System.currentTimeMillis();
imageView.postDelayed(this, 1000);
imageView.postDelayed(this, 3000);
totalCorrectResponses++;
duration = duration + 1000;
duration = duration + 3000;
i++;
}
......@@ -164,19 +170,21 @@ public class FocusedAttentionGame1 extends AppCompatActivity {
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN: {
red_btn.getBackground().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP);
view.invalidate();
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 (reactionTime < 4000) {
if (clicked.equals("monkey")) {
totalReactionTime = totalReactionTime + reactionTime;
Log.d("correct " , startTime + " " + clickedTime + " " + reactionTime);
noOfCorrectResponses++;
red_btn.setEnabled(false);
}
else {
Log.d( "wrong" , startTime + " " + clickedTime + " " + reactionTime);
......
......@@ -17,10 +17,7 @@ import com.anuththara18.attentionassessment.alternating.AlternatingAttentionGame
import com.anuththara18.attentionassessment.dividedattention.DividedAttentionGame1;
import com.anuththara18.attentionassessment.focused.FocusedAttentionGame1;
import com.anuththara18.attentionassessment.map.Map2Activity;
import com.anuththara18.attentionassessment.selective.BirdChoosingActivity;
import com.anuththara18.attentionassessment.selective.SelectiveAttentionGame1;
import com.anuththara18.attentionassessment.sustained.SustainedAttentionGame1;
import com.anuththara18.attentionassessment.sustained.SustainedAttentionGame2;
import com.anuththara18.attentionassessment.sustained.BirdChoosingActivity;
@SuppressLint("ValidFragment")
......@@ -46,7 +43,7 @@ public class MainFragment extends Fragment {
selectiveAttention = view.findViewById(R.id.selectiveAttention);
dividedAttention = view.findViewById(R.id.dividedAttention);
sustainedAttention = view.findViewById(R.id.sustainedAttention);
alternatingAttention = view.findViewById(R.id.alternatingAttention);
//alternatingAttention = view.findViewById(R.id.alternatingAttention);
alternatingAttention2 = view.findViewById(R.id.alternatingAttention2);
final MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.button1);
......@@ -87,14 +84,6 @@ public class MainFragment extends Fragment {
}
});
alternatingAttention.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mp.start();
Intent intent = new Intent(getContext(), SustainedAttentionGame2.class);
startActivity(intent);
}
});
alternatingAttention2.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -109,6 +98,7 @@ public class MainFragment extends Fragment {
}
}
/*
public class FirstFragment extends Fragment {
......
package com.anuththara18.attentionassessment.home;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.Toast;
import com.anuththara18.attentionassessment.R;
import com.anuththara18.attentionassessment.consentform.ConsentFormActivity;
import com.google.android.material.navigation.NavigationView;
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 NavigationDrawerActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
//FOR DESIGN
......@@ -31,6 +40,9 @@ public class NavigationDrawerActivity extends AppCompatActivity implements Navig
//FOR DATAS
private static final int FRAGMENT_MAINDASHBOARD = 0;
// constant code for runtime permissions
private static final int PERMISSION_REQUEST_CODE = 200;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -44,6 +56,14 @@ public class NavigationDrawerActivity extends AppCompatActivity implements Navig
// Show First Fragment
this.showFirstFragment();
// below code is used for
// checking our permissions.
if (checkPermission()) {
//Toast.makeText(this, "Permission Granted", Toast.LENGTH_SHORT).show();
} else {
requestPermission();
}
}
@Override
......@@ -107,6 +127,8 @@ public class NavigationDrawerActivity extends AppCompatActivity implements Navig
return true;
}
/**************************************************************************************************/
private void logout() {
//closing activity
......@@ -117,9 +139,7 @@ public class NavigationDrawerActivity extends AppCompatActivity implements Navig
}
// ---------------------
// CONFIGURATION
// ---------------------
/**************************************************************************************************/
// Configure Toolbar
private void configureToolBar(){
......@@ -127,6 +147,8 @@ public class NavigationDrawerActivity extends AppCompatActivity implements Navig
setSupportActionBar(toolbar);
}
/**************************************************************************************************/
//Configure Drawer Layout
private void configureDrawerLayout(){
this.drawerLayout = (DrawerLayout) findViewById(R.id.activity_main_drawer_layout);
......@@ -135,15 +157,15 @@ public class NavigationDrawerActivity extends AppCompatActivity implements Navig
toggle.syncState();
}
/**************************************************************************************************/
//Configure NavigationView
private void configureNavigationView(){
this.navigationView = (NavigationView) findViewById(R.id.activity_main_nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
// ---------------------
// FRAGMENTS
// ---------------------
/**************************************************************************************************/
// Show first fragment when activity is created
private void showFirstFragment(){
......@@ -156,8 +178,9 @@ public class NavigationDrawerActivity extends AppCompatActivity implements Navig
}
}
// Show fragment according an Identifier
/**************************************************************************************************/
// Show fragment according an Identifier
private void showFragment(int fragmentIdentifier){
switch (fragmentIdentifier){
case FRAGMENT_MAINDASHBOARD :
......@@ -180,7 +203,7 @@ public class NavigationDrawerActivity extends AppCompatActivity implements Navig
}
}
// ---
/**************************************************************************************************/
// Create each fragment page and show it
......@@ -189,8 +212,7 @@ public class NavigationDrawerActivity extends AppCompatActivity implements Navig
this.startTransactionFragment(this.fragmentMainDashboard);
}
// ---
/**************************************************************************************************/
// Generic method that will replace and show a fragment inside the MainActivity Frame Layout
private void startTransactionFragment(Fragment fragment){
......@@ -199,4 +221,54 @@ public class NavigationDrawerActivity extends AppCompatActivity implements Navig
.replace(R.id.activity_main_frame_layout, fragment).commit();
}
}
/**************************************************************************************************/
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();
}
}
}
}
/**************************************************************************************************/
}
\ No newline at end of file
package com.anuththara18.attentionassessment.selective;
package com.anuththara18.attentionassessment.sustained;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
......@@ -9,14 +9,12 @@ import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.anuththara18.attentionassessment.R;
import com.anuththara18.attentionassessment.language.LanguageSetter;
import com.anuththara18.attentionassessment.sustained.SustainedAttentionGame1;
public class BirdChoosingActivity extends AppCompatActivity {
......@@ -50,7 +48,7 @@ public class BirdChoosingActivity extends AppCompatActivity {
l3 = findViewById(R.id.l3);
l4 = findViewById(R.id.l4);
textView8.setText(LanguageSetter.getresources().getString(R.string.birdselect));
//textView8.setText(LanguageSetter.getresources().getString(R.string.birdselect));
bird1.setOnClickListener(new View.OnClickListener() {
@Override
......
......@@ -7,25 +7,19 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.PorterDuff;
import android.graphics.drawable.AnimationDrawable;
import android.media.MediaPlayer;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.anuththara18.attentionassessment.CompleteScreen2;
import com.anuththara18.attentionassessment.R;
import com.anuththara18.attentionassessment.age.AgeActivity;
import com.anuththara18.attentionassessment.db.Api;
......@@ -33,14 +27,11 @@ 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 com.anuththara18.attentionassessment.selective.BirdChoosingActivity;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
public class SustainedAttentionGame1 extends AppCompatActivity {
......@@ -57,12 +48,12 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
// isi = 10 - 60 secs
Integer[] isi = { 10000, 45000, 25000, 50000, 20000, 35000, 60000, 15000, 30000, 55000, 40000,
/*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,
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 };*/
1000, 1500, 1000, 1500 };
Integer[] image = { R.drawable.red_bird_gif,
R.drawable.blue_bird_gif,
......@@ -88,7 +79,7 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
long totalReactionTime = 0;
int meanReactionTime = 0;
MediaPlayer mp;
MediaPlayer mp, mp2;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -134,6 +125,7 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
randomImage = random.nextInt(6);
bird.setVisibility(View.INVISIBLE);
gifImageView.setVisibility(View.VISIBLE);
red_btn.setEnabled(true);
gifImageView.setImageResource(image[randomImage]);
clickedImage = image[randomImage];
updateInterval = isi[j];
......@@ -145,7 +137,7 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
}
// appearance - 0.5s * 25 times
else if ( totalCorrectResponses <= 25 ) {
Log.d("radomTimer", String.valueOf(i + " 2000" ));
Log.d("radomTimer", String.valueOf(i + " 3000" ));
Log.d("******************************", "start 1");
if (BirdChoosingActivity.birdSelected == 1) {
......@@ -167,11 +159,12 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
}
bird.setVisibility(View.VISIBLE);
red_btn.setEnabled(true);
gifImageView.setVisibility(View.INVISIBLE);
startTime = System.currentTimeMillis();
gifImageView.postDelayed(this, 2000);
gifImageView.postDelayed(this, 3000);
totalCorrectResponses++;
duration = duration + 2000;
duration = duration + 3000;
i++;
}
......@@ -219,15 +212,13 @@ public class SustainedAttentionGame1 extends AppCompatActivity {
public void onClick(View view) {
clickedTime = System.currentTimeMillis();
reactionTime = ( clickedTime - startTime );
mp2 = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp2.start();
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++;
red_btn.setEnabled(false);
}
else {
noOfCommissionErrors++;
......
......@@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg5"
tools:context=".selective.BirdChoosingActivity">
tools:context=".sustained.BirdChoosingActivity">
<ImageButton
android:id="@+id/cross_btn"
......
......@@ -221,7 +221,7 @@
android:textSize="20dp"
android:layout_marginRight="15dp"
android:fontFamily="@font/aclonica"
android:text="Sustained Attention I"
android:text="Sustained Attention"
android:textStyle="bold"/>
<ImageView
......@@ -235,6 +235,8 @@
</androidx.cardview.widget.CardView>
<!--
<androidx.cardview.widget.CardView
android:id="@+id/alternatingAttention"
android:layout_height="200dp"
......@@ -290,6 +292,8 @@
</androidx.cardview.widget.CardView>
-->
<androidx.cardview.widget.CardView
android:id="@+id/alternatingAttention2"
android:layout_height="200dp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment