Skip to content

Commit

Permalink
Merge pull request #363 from jogrimst/master
Browse files Browse the repository at this point in the history
#362 Select number after hearing pronunciation
  • Loading branch information
literacyapp authored Jan 29, 2017
2 parents b2b00e5 + 3459e5d commit 37e9933
Show file tree
Hide file tree
Showing 8 changed files with 396 additions and 63 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdkVersion 21
targetSdkVersion 23
versionCode 1004001
versionName "1.4.1-SNAPSHOT"
versionName "1.4.1"

// jackOptions {
// enabled true
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
<activity
android:name=".content.task.SelectLetterActivity"
android:screenOrientation="fullSensor" />
<activity
android:name=".content.task.SelectNumberActivity"
android:screenOrientation="fullSensor" />
<activity
android:name=".content.task.StarActivity"
android:screenOrientation="fullSensor" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
import org.literacyapp.LiteracyApplication;
import org.literacyapp.R;
import org.literacyapp.dao.AudioDao;
import org.literacyapp.dao.JoinVideosWithLettersDao;
import org.literacyapp.dao.LetterDao;
import org.literacyapp.dao.VideoDao;
import org.literacyapp.model.content.Letter;
import org.literacyapp.model.content.multimedia.Audio;
import org.literacyapp.util.MediaPlayerHelper;
Expand All @@ -35,8 +33,6 @@ public class LetterGraphemeActivity extends AppCompatActivity {

private LetterDao letterDao;
private AudioDao audioDao;
private VideoDao videoDao;
private JoinVideosWithLettersDao joinVideosWithLettersDao;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -52,8 +48,6 @@ protected void onCreate(Bundle savedInstanceState) {
LiteracyApplication literacyApplication = (LiteracyApplication) getApplicationContext();
letterDao = literacyApplication.getDaoSession().getLetterDao();
audioDao = literacyApplication.getDaoSession().getAudioDao();
videoDao = literacyApplication.getDaoSession().getVideoDao();
joinVideosWithLettersDao = literacyApplication.getDaoSession().getJoinVideosWithLettersDao();
}

@Override
Expand Down Expand Up @@ -89,29 +83,6 @@ public void onClick(View view) {
public void onClick(View view) {
Log.i(getClass().getName(), "onClick");

// // Look up video(s) containing letter
// List<Video> videosContainingLetter = new ArrayList<Video>();
// List<JoinVideosWithLetters> joinVideosWithLettersList = joinVideosWithLettersDao.queryBuilder()
// .where(JoinVideosWithLettersDao.Properties.LetterId.eq(letter.getId()))
// .list();
// Log.d(getClass().getName(), "joinVideosWithLettersList.size(): " + joinVideosWithLettersList.size());
// if (!joinVideosWithLettersList.isEmpty()) {
// for (JoinVideosWithLetters joinVideosWithLetters : joinVideosWithLettersList) {
// Video video = videoDao.load(joinVideosWithLetters.getVideoId());
// Log.d(getClass().getName(), "Adding video with id " + video.getId());
// videosContainingLetter.add(video);
// }
// }
// Log.d(getClass().getName(), "videosContainingLetter.size(): " + videosContainingLetter.size());
// if (!videosContainingLetter.isEmpty()) {
// // Redirect to video(s)
// Intent intent = new Intent(getApplicationContext(), VideoActivity.class);
// int randomIndex = (int) (Math.random() * videosContainingLetter.size());
// Video video = videosContainingLetter.get(randomIndex); // TODO: iterate all videos
// intent.putExtra(VideoActivity.EXTRA_KEY_VIDEO_ID, video.getId());
// startActivity(intent);
// }

Intent intent = new Intent(getApplicationContext(), SelectLetterActivity.class);
intent.putExtra("letter", letter.getText());
startActivity(intent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,14 @@
import org.literacyapp.LiteracyApplication;
import org.literacyapp.R;
import org.literacyapp.dao.AudioDao;
import org.literacyapp.dao.JoinVideosWithNumbersDao;
import org.literacyapp.dao.NumberDao;
import org.literacyapp.dao.VideoDao;
import org.literacyapp.model.content.Number;
import org.literacyapp.model.content.multimedia.Audio;
import org.literacyapp.model.content.multimedia.JoinVideosWithNumbers;
import org.literacyapp.model.content.multimedia.Video;
import org.literacyapp.util.MediaPlayerHelper;
import org.literacyapp.util.MultimediaHelper;
import org.literacyapp.util.TtsHelper;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class NumberGraphemeActivity extends AppCompatActivity {

Expand All @@ -39,8 +33,6 @@ public class NumberGraphemeActivity extends AppCompatActivity {

private NumberDao numberDao;
private AudioDao audioDao;
private VideoDao videoDao;
private JoinVideosWithNumbersDao joinVideosWithNumbersDao;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -56,8 +48,6 @@ protected void onCreate(Bundle savedInstanceState) {
LiteracyApplication literacyApplication = (LiteracyApplication) getApplicationContext();
numberDao = literacyApplication.getDaoSession().getNumberDao();
audioDao = literacyApplication.getDaoSession().getAudioDao();
videoDao = literacyApplication.getDaoSession().getVideoDao();
joinVideosWithNumbersDao = literacyApplication.getDaoSession().getJoinVideosWithNumbersDao();
}

@Override
Expand Down Expand Up @@ -93,28 +83,9 @@ public void onClick(View view) {
public void onClick(View view) {
Log.i(getClass().getName(), "onClick");

// Look up video(s) containing number
List<Video> videosContainingNumber = new ArrayList<Video>();
List<JoinVideosWithNumbers> joinVideosWithNumbersList = joinVideosWithNumbersDao.queryBuilder()
.where(JoinVideosWithNumbersDao.Properties.NumberId.eq(number.getId()))
.list();
Log.d(getClass().getName(), "joinVideosWithNumbersList.size(): " + joinVideosWithNumbersList.size());
if (!joinVideosWithNumbersList.isEmpty()) {
for (JoinVideosWithNumbers joinVideosWithNumbers : joinVideosWithNumbersList) {
Video video = videoDao.load(joinVideosWithNumbers.getVideoId());
Log.d(getClass().getName(), "Adding video with id " + video.getId());
videosContainingNumber.add(video);
}
}
Log.d(getClass().getName(), "videosContainingNumber.size(): " + videosContainingNumber.size());
if (!videosContainingNumber.isEmpty()) {
// Redirect to video(s)
Intent intent = new Intent(getApplicationContext(), VideoActivity.class);
int randomIndex = (int) (Math.random() * videosContainingNumber.size());
Video video = videosContainingNumber.get(randomIndex); // TODO: iterate all videos
intent.putExtra(VideoActivity.EXTRA_KEY_VIDEO_ID, video.getId());
startActivity(intent);
}
Intent intent = new Intent(getApplicationContext(), SelectNumberActivity.class);
intent.putExtra("number", number.getValue());
startActivity(intent);

finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ public void onClick(View view) {
Video video = videosContainingLetter.get(randomIndex); // TODO: iterate all videos
intent.putExtra(VideoActivity.EXTRA_KEY_VIDEO_ID, video.getId());
startActivity(intent);
} else {
Intent loadingIntent = new Intent(getApplicationContext(), LoadingActivity.class);
startActivity(loadingIntent);
}

finish();
Expand Down
Loading

0 comments on commit 37e9933

Please sign in to comment.