Skip to content

Commit

Permalink
You can now change the sentence you want to start at. Resolves #3.
Browse files Browse the repository at this point in the history
  • Loading branch information
chickendude committed Jun 10, 2018
1 parent 8198011 commit 7405f76
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

private void setStartingSentence() {
course.setStartingSentenceForAllSchedules(realm, curSentence);
getActivity().onBackPressed();
}

Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/ch/ralena/natibo/object/Course.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class Course extends RealmObject {
private int pauseMillis;
private RealmList<Day> pastDays = new RealmList<>();
private RealmList<Schedule> schedules = new RealmList<>(); // the different pieces that make up the study routine for each day
private RealmList<Sentence> sentencesSeen = new RealmList<>(); // keep track of which sentences have been seen and which haven't

// --- getters and setters ---

Expand Down Expand Up @@ -148,6 +149,15 @@ public RealmList<Schedule> getSchedules() {

// --- helper methods ---

public void setStartingSentenceForAllSchedules(Realm realm, Sentence sentence) {
// remember, the sentence index starts at 1, not 0!
realm.executeTransaction(r -> {
for (Schedule schedule : schedules) {
schedule.setSentenceIndex(sentence.getIndex() - 1);
}
});
}

public void addReps(int reps) {
numReps += reps;
}
Expand Down Expand Up @@ -206,6 +216,7 @@ public void prepareNextDay(Realm realm) {
private RealmList<Sentence> getSentences(int index, int numSentences, RealmList<Pack> packs) {
RealmList<Sentence> sentences = new RealmList<>();

// go through each pack
for (Pack pack : packs) {
RealmList<Sentence> packSentences = pack.getSentences();
if (index >= pack.getSentences().size())
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_sentence_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"/>

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
Expand Down

1 comment on commit 7405f76

@chickendude
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit should say "Resolves #12", not 3.

Please sign in to comment.