From 6a57bc4d42652b644b965c410b759ef2fd8f1369 Mon Sep 17 00:00:00 2001 From: Srujan Jha Date: Fri, 6 Mar 2015 19:02:27 +0530 Subject: [PATCH 1/3] "Unfortunately Stopped" issue fixed There was a small issue. On pressing the "Next" button, while the last Flash Card is on display, was making the app to stop unfortunately. This issue has been fixed. --- .../src/com/buildmlearnstore/activities/FlashActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/FlashActivity.java b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/FlashActivity.java index 641dd46..4794b06 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/FlashActivity.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/FlashActivity.java @@ -106,7 +106,7 @@ public void onClick(View v) { @Override public void onClick(View v) { - if (iQuestionIndex < mCardList.size()) { + if (iQuestionIndex < mCardList.size()-1) { isFlipped = false; iQuestionIndex++; questionView.setVisibility(View.VISIBLE); @@ -115,6 +115,7 @@ public void onClick(View v) { populateQuestion(iQuestionIndex); } else { + finish(); /*Intent myIntent = new Intent(FlashActivity.this, ScoreActivity.class); startActivity(myIntent); From 1fceec19e15078fdfa60e023f7752d62d85e0fe8 Mon Sep 17 00:00:00 2001 From: Srujan Jha Date: Fri, 6 Mar 2015 23:42:01 +0530 Subject: [PATCH 2/3] Spellings-Template: There was an issue with restarting a Spellings Puzzle, and also the scorecard. ScoreActivity was meant only for Quiz and not for Spellings puzzle. It was not able to handle the scores of Spellings puzzle. The issue was fixed. Now ScoreActivity can handle scores from both Quiz and Spellings Puzzle. Also, there was an issue with restarting the Spellings Puzzle, the scores start accumulating and also the index of the question was not set to '0' while restarting the puzzle. --- .../activities/QuestionActivity.java | 1 + .../activities/ScoreActivity.java | 53 +++++++++++++++---- .../activities/SpellingActivity.java | 3 +- .../model/SpellingsModel.java | 7 ++- 4 files changed, 51 insertions(+), 13 deletions(-) diff --git a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/QuestionActivity.java b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/QuestionActivity.java index 83c3359..6edcb31 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/QuestionActivity.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/QuestionActivity.java @@ -146,6 +146,7 @@ public void onClick(View arg0) { reInitialize(); Intent myIntent = new Intent(arg0.getContext(), ScoreActivity.class); + myIntent.putExtra("Activity",0);// 0: Quiz Template and 1: Spellings Template startActivity(myIntent); finish(); } diff --git a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ScoreActivity.java b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ScoreActivity.java index c1ccebe..b37e606 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ScoreActivity.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ScoreActivity.java @@ -37,45 +37,76 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE import com.actionbarsherlock.app.SherlockActivity; import com.buildmlearnstore.model.QuizModel; +import com.buildmlearnstore.model.SpellingsModel; public class ScoreActivity extends SherlockActivity { private QuizModel mQuizModel; + private SpellingsModel mSpellingsModel; private TextView mTv_correct, mTv_wrong, mTv_unanswered; - + private int activity=0;// 0: Quiz Template and 1: Spellings Template /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.score_view); - mQuizModel = QuizModel.getInstance(); + Intent intent=getIntent(); + activity=intent.getIntExtra("Activity",0); + System.out.println("#"+activity+"#"); + if(activity==1) + mSpellingsModel=SpellingsModel.getInstance(); + else + mQuizModel = QuizModel.getInstance(); mTv_correct = (TextView) findViewById(R.id.tv_correct); mTv_wrong = (TextView) findViewById(R.id.tv_wrong); mTv_unanswered = (TextView) findViewById(R.id.tv_unanswered); - mTv_correct.setText("Total Correct: " + mQuizModel.getTotalCorrect()); - mTv_wrong.setText("Total Wrong: " + mQuizModel.getTotalWrong()); - int unanswered = mQuizModel.getQueAnsList().size() - - mQuizModel.getTotalCorrect() - mQuizModel.getTotalWrong(); - mTv_unanswered.setText("Unanswered: " + unanswered); - + if(activity==1) + { + mTv_correct.setText("Total Correct: " + mSpellingsModel.getTotalCorrect()); + mTv_wrong.setText("Total Wrong: " + mSpellingsModel.getTotalWrong()); + int unanswered = mSpellingsModel.getSpellingsList().size() + - mSpellingsModel.getTotalCorrect() - mSpellingsModel.getTotalWrong(); + mTv_unanswered.setText("Unanswered: " + unanswered); + } + else + { + mTv_correct.setText("Total Correct: " + mQuizModel.getTotalCorrect()); + mTv_wrong.setText("Total Wrong: " + mQuizModel.getTotalWrong()); + int unanswered = mQuizModel.getQueAnsList().size() + - mQuizModel.getTotalCorrect() - mQuizModel.getTotalWrong(); + mTv_unanswered.setText("Unanswered: " + unanswered); + } Button startAgainButton = (Button) findViewById(R.id.start_again_button); startAgainButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { - Intent myIntent = new Intent(arg0.getContext(), - QuestionActivity.class); + if(activity==1) + { + Intent myIntent = new Intent(arg0.getContext(), + SpellingActivity.class); startActivityForResult(myIntent, 0); + mSpellingsModel.clearInstance(); finish(); + } + else + { + Intent myIntent = new Intent(arg0.getContext(), + QuestionActivity.class); + startActivityForResult(myIntent, 0); + mQuizModel.clearInstance(); + finish(); + } } }); - Button quitButton = (Button) findViewById(R.id.quit_button); quitButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // android.os.Process.killProcess(android.os.Process.myPid()); + mSpellingsModel.clearInstance(); + mQuizModel.clearInstance(); finish(); } }); diff --git a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/SpellingActivity.java b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/SpellingActivity.java index 78ff221..c5be094 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/SpellingActivity.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/SpellingActivity.java @@ -55,7 +55,7 @@ public class SpellingActivity extends SherlockActivity implements TextToSpeech.OnInitListener { private TextToSpeech textToSpeech; private ArrayList mWordList; - private int count; + private int count=0; private AlertDialog mAlert; private TextView mTv_WordNumber; private Button mBtn_Spell, mBtn_Skip; @@ -101,6 +101,7 @@ public void click(View view) { mBtn_Spell.setTextColor(Color.WHITE); } else { Intent resultIntent = new Intent(this, ScoreActivity.class); + resultIntent.putExtra("Activity",1);// 0: Quiz Template and 1: Spellings Template startActivity(resultIntent); finish(); diff --git a/source/BuildmLearnStore/src/com/buildmlearnstore/model/SpellingsModel.java b/source/BuildmLearnStore/src/com/buildmlearnstore/model/SpellingsModel.java index 16a4627..bd817e5 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/model/SpellingsModel.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/model/SpellingsModel.java @@ -11,7 +11,12 @@ public class SpellingsModel { public static SpellingsModel mSpellingsModel; - + public static void clearInstance() + { + mSpellingsModel.totalCorrect=0; + mSpellingsModel.totalWrong=0; + mSpellingsModel.activeCount=0; + } public static SpellingsModel getInstance() { if(mSpellingsModel==null) From b368e3c3302d8fab3409c572f9de19408d85e02a Mon Sep 17 00:00:00 2001 From: Srujan Jha Date: Fri, 6 Mar 2015 23:50:21 +0530 Subject: [PATCH 3/3] Revert "Spellings-Template: There was an issue with restarting a Spellings Puzzle, and also the scorecard." This reverts commit 1fceec19e15078fdfa60e023f7752d62d85e0fe8. --- .../activities/QuestionActivity.java | 1 - .../activities/ScoreActivity.java | 53 ++++--------------- .../activities/SpellingActivity.java | 3 +- .../model/SpellingsModel.java | 7 +-- 4 files changed, 13 insertions(+), 51 deletions(-) diff --git a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/QuestionActivity.java b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/QuestionActivity.java index 6edcb31..83c3359 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/QuestionActivity.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/QuestionActivity.java @@ -146,7 +146,6 @@ public void onClick(View arg0) { reInitialize(); Intent myIntent = new Intent(arg0.getContext(), ScoreActivity.class); - myIntent.putExtra("Activity",0);// 0: Quiz Template and 1: Spellings Template startActivity(myIntent); finish(); } diff --git a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ScoreActivity.java b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ScoreActivity.java index b37e606..c1ccebe 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ScoreActivity.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ScoreActivity.java @@ -37,76 +37,45 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE import com.actionbarsherlock.app.SherlockActivity; import com.buildmlearnstore.model.QuizModel; -import com.buildmlearnstore.model.SpellingsModel; public class ScoreActivity extends SherlockActivity { private QuizModel mQuizModel; - private SpellingsModel mSpellingsModel; private TextView mTv_correct, mTv_wrong, mTv_unanswered; - private int activity=0;// 0: Quiz Template and 1: Spellings Template + /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.score_view); - Intent intent=getIntent(); - activity=intent.getIntExtra("Activity",0); - System.out.println("#"+activity+"#"); - if(activity==1) - mSpellingsModel=SpellingsModel.getInstance(); - else - mQuizModel = QuizModel.getInstance(); + mQuizModel = QuizModel.getInstance(); mTv_correct = (TextView) findViewById(R.id.tv_correct); mTv_wrong = (TextView) findViewById(R.id.tv_wrong); mTv_unanswered = (TextView) findViewById(R.id.tv_unanswered); - if(activity==1) - { - mTv_correct.setText("Total Correct: " + mSpellingsModel.getTotalCorrect()); - mTv_wrong.setText("Total Wrong: " + mSpellingsModel.getTotalWrong()); - int unanswered = mSpellingsModel.getSpellingsList().size() - - mSpellingsModel.getTotalCorrect() - mSpellingsModel.getTotalWrong(); - mTv_unanswered.setText("Unanswered: " + unanswered); - } - else - { - mTv_correct.setText("Total Correct: " + mQuizModel.getTotalCorrect()); - mTv_wrong.setText("Total Wrong: " + mQuizModel.getTotalWrong()); - int unanswered = mQuizModel.getQueAnsList().size() - - mQuizModel.getTotalCorrect() - mQuizModel.getTotalWrong(); - mTv_unanswered.setText("Unanswered: " + unanswered); - } + mTv_correct.setText("Total Correct: " + mQuizModel.getTotalCorrect()); + mTv_wrong.setText("Total Wrong: " + mQuizModel.getTotalWrong()); + int unanswered = mQuizModel.getQueAnsList().size() + - mQuizModel.getTotalCorrect() - mQuizModel.getTotalWrong(); + mTv_unanswered.setText("Unanswered: " + unanswered); + Button startAgainButton = (Button) findViewById(R.id.start_again_button); startAgainButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { - if(activity==1) - { - Intent myIntent = new Intent(arg0.getContext(), - SpellingActivity.class); + Intent myIntent = new Intent(arg0.getContext(), + QuestionActivity.class); startActivityForResult(myIntent, 0); - mSpellingsModel.clearInstance(); finish(); - } - else - { - Intent myIntent = new Intent(arg0.getContext(), - QuestionActivity.class); - startActivityForResult(myIntent, 0); - mQuizModel.clearInstance(); - finish(); - } } }); + Button quitButton = (Button) findViewById(R.id.quit_button); quitButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // android.os.Process.killProcess(android.os.Process.myPid()); - mSpellingsModel.clearInstance(); - mQuizModel.clearInstance(); finish(); } }); diff --git a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/SpellingActivity.java b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/SpellingActivity.java index c5be094..78ff221 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/SpellingActivity.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/SpellingActivity.java @@ -55,7 +55,7 @@ public class SpellingActivity extends SherlockActivity implements TextToSpeech.OnInitListener { private TextToSpeech textToSpeech; private ArrayList mWordList; - private int count=0; + private int count; private AlertDialog mAlert; private TextView mTv_WordNumber; private Button mBtn_Spell, mBtn_Skip; @@ -101,7 +101,6 @@ public void click(View view) { mBtn_Spell.setTextColor(Color.WHITE); } else { Intent resultIntent = new Intent(this, ScoreActivity.class); - resultIntent.putExtra("Activity",1);// 0: Quiz Template and 1: Spellings Template startActivity(resultIntent); finish(); diff --git a/source/BuildmLearnStore/src/com/buildmlearnstore/model/SpellingsModel.java b/source/BuildmLearnStore/src/com/buildmlearnstore/model/SpellingsModel.java index bd817e5..16a4627 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/model/SpellingsModel.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/model/SpellingsModel.java @@ -11,12 +11,7 @@ public class SpellingsModel { public static SpellingsModel mSpellingsModel; - public static void clearInstance() - { - mSpellingsModel.totalCorrect=0; - mSpellingsModel.totalWrong=0; - mSpellingsModel.activeCount=0; - } + public static SpellingsModel getInstance() { if(mSpellingsModel==null)