time calculation in jumble
This commit is contained in:
parent
d5971cf24a
commit
9cbaf5148e
|
@ -4,9 +4,7 @@
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<compositeConfiguration>
|
<option name="testRunner" value="PLATFORM" />
|
||||||
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
|
||||||
</compositeConfiguration>
|
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
@ -16,7 +14,6 @@
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
<option name="testRunner" value="PLATFORM" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
package com.example.alzapp;
|
package com.example.alzapp;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Bundle;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.Chronometer;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.zip.Inflater;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.zip.Inflater.*;
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
/*******
|
/*******
|
||||||
Created on: 21/01/2020
|
Created on: 21/01/2020
|
||||||
|
@ -25,7 +23,7 @@ import java.util.zip.Inflater.*;
|
||||||
********/
|
********/
|
||||||
|
|
||||||
|
|
||||||
public class JumbleActivity extends AppCompatActivity implements View.OnClickListener{
|
public class JumbleActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private TextView wordTv;
|
private TextView wordTv;
|
||||||
private EditText wordEnteredTv;
|
private EditText wordEnteredTv;
|
||||||
|
@ -33,6 +31,14 @@ public class JumbleActivity extends AppCompatActivity implements View.OnClickLis
|
||||||
private String wordToFind;
|
private String wordToFind;
|
||||||
private int score = 0;
|
private int score = 0;
|
||||||
private TextView score_dis;
|
private TextView score_dis;
|
||||||
|
private TextView timer;
|
||||||
|
private Chronometer chronometer;
|
||||||
|
private long pauseOffset;
|
||||||
|
private boolean running;
|
||||||
|
private Button pauser;
|
||||||
|
private Button resumer;
|
||||||
|
private long elapsedMillis;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -40,21 +46,22 @@ public class JumbleActivity extends AppCompatActivity implements View.OnClickLis
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
score_dis = (TextView) findViewById(R.id.score);
|
pauser = findViewById(R.id.pause);
|
||||||
wordTv = (TextView) findViewById(R.id.wordTv);
|
resumer = findViewById(R.id.resume);
|
||||||
wordEnteredTv = (EditText) findViewById(R.id.wordEnteredTv);
|
timer = findViewById(R.id.time);
|
||||||
validate = (Button) findViewById(R.id.validate);
|
score_dis = findViewById(R.id.score);
|
||||||
validate.setOnClickListener(this);
|
wordTv = findViewById(R.id.wordTv);
|
||||||
newGame = (Button) findViewById(R.id.newGame);
|
wordEnteredTv =findViewById(R.id.wordEnteredTv);
|
||||||
|
validate = findViewById(R.id.validate);
|
||||||
|
newGame = findViewById(R.id.newGame);
|
||||||
newGame.setOnClickListener(new View.OnClickListener() {
|
newGame.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
reset();
|
newGame();
|
||||||
score_dis.setText("Score : " + score);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
newGame();
|
|
||||||
|
|
||||||
Button back = (Button) findViewById(R.id.back);
|
Button back = (Button) findViewById(R.id.back);
|
||||||
|
|
||||||
|
@ -65,21 +72,51 @@ public class JumbleActivity extends AppCompatActivity implements View.OnClickLis
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
validate.setOnClickListener(new View.OnClickListener() {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View v) {
|
||||||
if (view == validate) {
|
|
||||||
|
|
||||||
validate();
|
validate();
|
||||||
} else if (view == newGame) {
|
}
|
||||||
score = 0;
|
});
|
||||||
|
|
||||||
|
chronometer = findViewById(R.id.chronometer);
|
||||||
|
chronometer.setFormat("Time: %s");
|
||||||
|
chronometer.setBase(SystemClock.elapsedRealtime());
|
||||||
newGame();
|
newGame();
|
||||||
|
chronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
|
||||||
|
@Override
|
||||||
|
public void onChronometerTick(Chronometer chronometer) {
|
||||||
|
if (score == 15) {
|
||||||
|
elapsedMillis = SystemClock.elapsedRealtime() - chronometer.getBase();
|
||||||
|
long minutes = TimeUnit.MILLISECONDS.toMinutes(elapsedMillis);
|
||||||
|
long seconds = TimeUnit.MILLISECONDS.toSeconds(elapsedMillis);
|
||||||
|
timer.setText("time : " + minutes + ":" + seconds);
|
||||||
|
|
||||||
|
Intent intent = new Intent(JumbleActivity.this,QuickPlayMenu.class);
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pauser.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
pauseChronometer();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
resumer.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
startChronometer();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void validate() {
|
private void validate() {
|
||||||
String w = wordEnteredTv.getText().toString();
|
String w = wordEnteredTv.getText().toString();
|
||||||
|
@ -102,7 +139,7 @@ public class JumbleActivity extends AppCompatActivity implements View.OnClickLis
|
||||||
String wordShuffled = Jumble.shuffleWord(wordToFind);
|
String wordShuffled = Jumble.shuffleWord(wordToFind);
|
||||||
wordTv.setText(wordShuffled);
|
wordTv.setText(wordShuffled);
|
||||||
wordEnteredTv.setText("");
|
wordEnteredTv.setText("");
|
||||||
|
startChronometer();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -110,13 +147,39 @@ public class JumbleActivity extends AppCompatActivity implements View.OnClickLis
|
||||||
|
|
||||||
score = 0;
|
score = 0;
|
||||||
newGame();
|
newGame();
|
||||||
|
resetChronometer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void startChronometer() {
|
||||||
|
if (!running) {
|
||||||
|
chronometer.setBase(SystemClock.elapsedRealtime() - pauseOffset);
|
||||||
|
chronometer.start();
|
||||||
|
running = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pauseChronometer() {
|
||||||
|
if (running) {
|
||||||
|
chronometer.stop();
|
||||||
|
pauseOffset = SystemClock.elapsedRealtime() - chronometer.getBase();
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetChronometer() {
|
||||||
|
chronometer.setBase(SystemClock.elapsedRealtime());
|
||||||
|
pauseOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.example.alzapp;
|
package com.example.alzapp;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.Chronometer;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
/*******
|
/*******
|
||||||
Created on: 21/01/2020
|
Created on: 21/01/2020
|
||||||
|
@ -21,6 +23,10 @@ public class QuickPlayMenu extends AppCompatActivity {
|
||||||
private Button tilematch;
|
private Button tilematch;
|
||||||
private Button game3;
|
private Button game3;
|
||||||
private Button game4;
|
private Button game4;
|
||||||
|
private Chronometer chronometer;
|
||||||
|
private long pauseOffset;
|
||||||
|
private boolean running;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -59,5 +65,12 @@ public class QuickPlayMenu extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public void startChronometer(View v) {
|
||||||
|
if (!running) {
|
||||||
|
chronometer.setBase(SystemClock.elapsedRealtime() - pauseOffset);
|
||||||
|
chronometer.start();
|
||||||
|
running = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,11 @@ import android.widget.RadioButton;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.volley.RequestQueue;
|
import com.android.volley.RequestQueue;
|
||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
import com.android.volley.toolbox.Volley;
|
import com.android.volley.toolbox.Volley;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -131,10 +128,8 @@ public class registration extends AppCompatActivity {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// get selected radio button from radioGroup
|
|
||||||
int selectedId = radioSexGroup.getCheckedRadioButtonId();
|
|
||||||
|
|
||||||
//find the radiobutton by returned id
|
int selectedId = radioSexGroup.getCheckedRadioButtonId();
|
||||||
radioSexButton = findViewById(selectedId);
|
radioSexButton = findViewById(selectedId);
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -1,12 +1,15 @@
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout 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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/bg_gradient2"
|
android:background="@drawable/bg_gradient2"
|
||||||
tools:context=".MainActivity" >
|
tools:context=".MainActivity"
|
||||||
|
|
||||||
|
>
|
||||||
|
|
||||||
|
<include layout="@layout/backbutton" />
|
||||||
|
|
||||||
<include layout="@layout/backbutton"
|
|
||||||
/>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wordTv"
|
android:id="@+id/wordTv"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -44,7 +47,8 @@
|
||||||
android:layout_below="@id/validate"
|
android:layout_below="@id/validate"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="25dp"
|
||||||
android:text="New Game" />
|
android:text="New Game"
|
||||||
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/score"
|
android:id="@+id/score"
|
||||||
|
@ -53,6 +57,43 @@
|
||||||
android:layout_below="@+id/newGame"
|
android:layout_below="@+id/newGame"
|
||||||
|
|
||||||
android:textSize="50dp" />
|
android:textSize="50dp" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/time"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/score"
|
||||||
|
android:textSize="50dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Chronometer
|
||||||
|
android:id="@+id/chronometer"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginLeft="290dp"
|
||||||
|
android:layout_marginTop="500dp"
|
||||||
|
android:textSize="30sp"
|
||||||
|
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@id/chronometer"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginBottom="-59dp"
|
||||||
|
android:text = "pause"
|
||||||
|
android:id="@+id/pause"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/resume"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@id/pause"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginBottom="-60dp"
|
||||||
|
android:text="resume" />
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -67,7 +67,9 @@
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/textView"
|
app:layout_constraintTop_toBottomOf="@+id/textView"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible"
|
||||||
|
|
||||||
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/game3"
|
android:id="@+id/game3"
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
|
||||||
<include layout="@layout/backbutton"
|
<include layout="@layout/backbutton" />
|
||||||
/>
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView"
|
android:id="@+id/textView"
|
||||||
|
|
|
@ -7,7 +7,7 @@ buildscript {
|
||||||
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.5.3'
|
classpath 'com.android.tools.build:gradle:3.6.1'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#Fri Jan 17 15:08:17 IST 2020
|
#Sat Mar 21 17:07:16 IST 2020
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
||||||
|
|
Loading…
Reference in New Issue