Skip to content

Commit

Permalink
issue 701 - crash on questions having video prompts upon swiping back…
Browse files Browse the repository at this point in the history
…ward...
  • Loading branch information
mitchellsundt committed Oct 10, 2012
1 parent 5366d0d commit fc69ad9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.odk.collect.android"
android:versionCode="1016"
android:versionCode="1017"
android:versionName="1.2.1" >
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Expand Down
40 changes: 28 additions & 12 deletions src/org/odk/collect/android/activities/FormEntryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1015,12 +1015,11 @@ public void showView(View next, AnimationType from) {
mStaleView = mCurrentView;
mCurrentView = next;
mRelativeLayout.addView(mCurrentView, lp);

mAnimationCompletionSet = 0;

if (mStaleView != null) {
// start OutAnimation for transition...
mStaleView.startAnimation(mOutAnimation);
// and remove the old view (MUST occur after start of animation!!!)
mRelativeLayout.removeView(mStaleView);
}
// start InAnimation for transition...
mCurrentView.startAnimation(mInAnimation);
Expand Down Expand Up @@ -1622,23 +1621,40 @@ protected void onDestroy() {

}

private int mAnimationCompletionSet = 0;

private void afterAllAnimations() {

if ( mStaleView != null ) {
// and remove the old view (MUST occur after start of animation!!!)
mRelativeLayout.removeView(mStaleView);
if ( mStaleView instanceof ODKView ) {
// http://code.google.com/p/android/issues/detail?id=8488
((ODKView) mStaleView).recycleDrawables();
}
mStaleView = null;
}

if (mCurrentView instanceof ODKView) {
((ODKView) mCurrentView).setFocus(this);
}
mBeenSwiped = false;
}

@Override
public void onAnimationEnd(Animation animation) {
Log.i(t, "onAnimationEnd " + ((animation == mInAnimation) ? "in" : ((animation == mOutAnimation) ? "out" : "other")));
if ( mInAnimation == animation) {
if (mCurrentView instanceof ODKView) {
((ODKView) mCurrentView).setFocus(this);
}
mBeenSwiped = false;
mAnimationCompletionSet |= 1;
} else if ( mOutAnimation == animation ) {
if ( mStaleView != null && mStaleView instanceof ODKView ) {
// http://code.google.com/p/android/issues/detail?id=8488
((ODKView) mStaleView).recycleDrawables();
}
mStaleView = null;
mAnimationCompletionSet |= 2;
} else {
Log.e(t, "Unexpected animation");
}

if ( mAnimationCompletionSet == 3 ) {
this.afterAllAnimations();
}
}


Expand Down
6 changes: 5 additions & 1 deletion src/org/odk/collect/android/views/MediaLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.util.Log;
Expand Down Expand Up @@ -143,7 +144,10 @@ public void setAVT(FormIndex index, String selectionDesignator, TextView text, S
if (videoURI != null) {
// An video file is specified
mVideoButton = new ImageButton(getContext());
mVideoButton.setImageResource(android.R.drawable.ic_media_play);
Bitmap b =
BitmapFactory.decodeResource(getContext().getResources(),
android.R.drawable.ic_media_play);
mVideoButton.setImageBitmap(b);
mVideoButton.setOnClickListener(new OnClickListener() {

@Override
Expand Down

0 comments on commit fc69ad9

Please sign in to comment.