Skip to content

Commit

Permalink
Merge pull request #32 from learning-layers/integration
Browse files Browse the repository at this point in the history
Release v1.0.5.
  • Loading branch information
lnikkila committed Feb 4, 2015
2 parents 009bd4e + afeeb84 commit f402c1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe;

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

Expand Down Expand Up @@ -65,9 +66,6 @@ public class BrowserActivity extends ActionBarActivity {
// been recorded.
private VideoCreatorService.VideoBuilder videoBuilder;

// URI to the file to which the video should be written.
private Uri videoFile;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -215,7 +213,13 @@ private void recordVideo() {
App.locationManager.startLocationUpdates();

videoBuilder = VideoCreatorService.build();
videoFile = Uri.fromFile(VideoCreatorService.getStorageVideoFile(videoBuilder));

File videoFile = VideoCreatorService.getStorageVideoFile(videoBuilder);

// Some camera apps (looking at you, Samsung) don't return any data if the EXTRA_OUTPUT
// flag is set. The storage file is a good fallback in case the camera app doesn't give us
// a URI.
videoBuilder.setVideoUri(Uri.fromFile(videoFile));

Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

Expand Down Expand Up @@ -248,22 +252,16 @@ private void chooseVideo() {
}

private void createVideo(@Nullable Intent resultData) {
final Uri contentUri;

// Some camera apps (looking at you, Samsung) don't return any data if the EXTRA_OUTPUT
// flag is set. If this is the case, let's just pass in the URI in EXTRA_OUTPUT.
if (resultData == null) {
contentUri = videoFile;
} else {
contentUri = resultData.getData();
// Data might not be there, in which case a fallback has been set in #recordVideo().
if (resultData != null) {
videoBuilder.setVideoUri(resultData.getData());
}

GenreDialogFragment fragment = new GenreDialogFragment();

fragment.setCallback(new GenreDialogFragment.Callback() {
@Override
public void onGenreSelected(String genre) {
videoBuilder.setVideoUri(contentUri);
videoBuilder.setGenre(genre);
videoBuilder.create(BrowserActivity.this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public final class AnnotationRenderer extends TrackRenderer implements Runnable
private final List<Annotation> annotations = new ArrayList<>();

/**
* List of rendered annotations. Recycled to avoid creating new lists with each render.
* List of rendered annotations. Recycled to avoid creating new lists with each render. This
* should only be used in #renderAnnotations().
*/
private final List<Annotation> renderList = new ArrayList<>();

Expand Down Expand Up @@ -83,6 +84,7 @@ public void setAnnotations(List<Annotation> annotations) {
this.annotations.addAll(annotations);
}

// Re-render annotations due to the change
clearAnnotations();
renderAnnotations(previousPosition, false);
}
Expand Down Expand Up @@ -111,8 +113,9 @@ private int renderAnnotations(long position, boolean isContinuous) {
return 0;
}

// Shallow copying the render list avoids concurrency issues without creating a new list
// when there are no annotations to render.
// If renderList was passed to the main thread, by the time it was executed, it might have
// been already cleared. Shallow copying it here avoids concurrency issues without creating
// new lists when there are no annotations to render.
final List<Annotation> internalRenderList = new ArrayList<>(renderList);

mainHandler.post(new Runnable() {
Expand Down Expand Up @@ -163,7 +166,7 @@ public void run() {
}

/**
* Pauses for the specified duration.
* Pauses for the given duration.
*/
private void startPause(final int duration) {
isPaused = true;
Expand All @@ -181,7 +184,7 @@ public void run() {
}

/**
* Stops a pause if one is going on.
* Stops a pause if in effect.
*/
private void stopPause() {
if (isPaused) {
Expand Down Expand Up @@ -268,8 +271,6 @@ protected void onStarted() throws ExoPlaybackException {
protected void onReleased() throws ExoPlaybackException {
stopPause();

strategies.clear();

synchronized (annotations) {
annotations.clear();
}
Expand Down

0 comments on commit f402c1c

Please sign in to comment.