Skip to content

Commit

Permalink
Maybe fixed Andrew's Unable to submit answer bug
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfinke committed Mar 12, 2014
1 parent f2f61e8 commit a3422f4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ca/unbc/cpsc472/mynextphone/QuestionActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public void onSaveInstanceState(Bundle outState){
}
}

public void onDestroy() {
super.onDestroy();
qMan.recycle();
}

/**
* This method grabs a brand new Question from our storage.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ public HashSet<Fact> getFactsLeadingToResult(int resultId) throws Exception{
int i = cursor.getInt(cursor.getColumnIndex(factColumns[0]));
facts.add(this.getFactForFactId(i, 1));
}while(cursor.moveToNext());
cursor.close();

while(facts.addAll(this.getFactIdsLeadingToFactId(facts)));
return facts;
Expand Down
6 changes: 6 additions & 0 deletions src/ca/unbc/cpsc472/mynextphone/models/QuestionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ private InferenceEngine getEngine() throws Exception {
return engine;
}

public void recycle() {
helper.close();
}

/**
* Generates a random question to display in this QuestionActivity.
*
Expand Down Expand Up @@ -143,6 +147,8 @@ public void restoreState(Bundle savedState) {
// Fetch the facts from the db for their ids
facts.add(helper.getFactForFactId(workingMemIds[i], workingMemFlags[i] ? 1 : 0));
}
getEngine().addFactsToMem(facts);
getEngine().updateMem();
}
catch(Exception ex) {
Log.e(this.getClass().getName(), "Unable to restore working mem from saved state");
Expand Down

0 comments on commit a3422f4

Please sign in to comment.