diff --git a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ContentListActivity.java b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ContentListActivity.java index 7702943..e1e94ff 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ContentListActivity.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/activities/ContentListActivity.java @@ -64,7 +64,7 @@ public void onItemClick(AdapterView parent, View view, int position, switch (option) { case 0: - fileName = "info/" + mFileNameList.get(position); + fileName = "info/" + mFileNameList.get(position)+".txt"; break; case 1: @@ -73,11 +73,11 @@ public void onItemClick(AdapterView parent, View view, int position, break; case 2: - fileName = "quiz/" + mFileNameList.get(position); + fileName = "quiz/" + mFileNameList.get(position)+".txt"; break; case 3: - fileName = "spellings/" + mFileNameList.get(position); + fileName = "spellings/" + mFileNameList.get(position)+".txt"; break; } 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); 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/QuizModel.java b/source/BuildmLearnStore/src/com/buildmlearnstore/model/QuizModel.java index 1a8ecbd..47f804e 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/model/QuizModel.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/model/QuizModel.java @@ -11,7 +11,13 @@ public class QuizModel { public static QuizModel mQuizModel; - + public static void clearInstance() + { + if(mQuizModel!=null) { + mQuizModel.totalCorrect = 0; + mQuizModel.totalWrong = 0; + } + } public static QuizModel getInstance() { if(mQuizModel==null) 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) diff --git a/source/BuildmLearnStore/src/com/buildmlearnstore/utils/Utility.java b/source/BuildmLearnStore/src/com/buildmlearnstore/utils/Utility.java index 3ba15a0..d421135 100644 --- a/source/BuildmLearnStore/src/com/buildmlearnstore/utils/Utility.java +++ b/source/BuildmLearnStore/src/com/buildmlearnstore/utils/Utility.java @@ -36,7 +36,9 @@ public static ArrayList listFiles(Context context, String dirFrom) { if (fileList != null) { for (int i = 0; i < fileList.length; i++) { Log.d("", fileList[i]); - mFileList.add(fileList[i]); + if(fileList[i].endsWith(".txt"))mFileList.add(fileList[i].substring(0,fileList[i].length()-4)); + else + mFileList.add(fileList[i]); } } } catch (IOException e) {