Skip to content

Commit fc69ad9

Browse files
committed
issue 701 - crash on questions having video prompts upon swiping backward...
1 parent 5366d0d commit fc69ad9

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
-->
1111
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
1212
package="org.odk.collect.android"
13-
android:versionCode="1016"
13+
android:versionCode="1017"
1414
android:versionName="1.2.1" >
1515
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
1616
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

src/org/odk/collect/android/activities/FormEntryActivity.java

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,12 +1015,11 @@ public void showView(View next, AnimationType from) {
10151015
mStaleView = mCurrentView;
10161016
mCurrentView = next;
10171017
mRelativeLayout.addView(mCurrentView, lp);
1018-
1018+
mAnimationCompletionSet = 0;
1019+
10191020
if (mStaleView != null) {
10201021
// start OutAnimation for transition...
10211022
mStaleView.startAnimation(mOutAnimation);
1022-
// and remove the old view (MUST occur after start of animation!!!)
1023-
mRelativeLayout.removeView(mStaleView);
10241023
}
10251024
// start InAnimation for transition...
10261025
mCurrentView.startAnimation(mInAnimation);
@@ -1622,23 +1621,40 @@ protected void onDestroy() {
16221621

16231622
}
16241623

1624+
private int mAnimationCompletionSet = 0;
1625+
1626+
private void afterAllAnimations() {
1627+
1628+
if ( mStaleView != null ) {
1629+
// and remove the old view (MUST occur after start of animation!!!)
1630+
mRelativeLayout.removeView(mStaleView);
1631+
if ( mStaleView instanceof ODKView ) {
1632+
// http://code.google.com/p/android/issues/detail?id=8488
1633+
((ODKView) mStaleView).recycleDrawables();
1634+
}
1635+
mStaleView = null;
1636+
}
1637+
1638+
if (mCurrentView instanceof ODKView) {
1639+
((ODKView) mCurrentView).setFocus(this);
1640+
}
1641+
mBeenSwiped = false;
1642+
}
1643+
16251644
@Override
16261645
public void onAnimationEnd(Animation animation) {
16271646
Log.i(t, "onAnimationEnd " + ((animation == mInAnimation) ? "in" : ((animation == mOutAnimation) ? "out" : "other")));
16281647
if ( mInAnimation == animation) {
1629-
if (mCurrentView instanceof ODKView) {
1630-
((ODKView) mCurrentView).setFocus(this);
1631-
}
1632-
mBeenSwiped = false;
1648+
mAnimationCompletionSet |= 1;
16331649
} else if ( mOutAnimation == animation ) {
1634-
if ( mStaleView != null && mStaleView instanceof ODKView ) {
1635-
// http://code.google.com/p/android/issues/detail?id=8488
1636-
((ODKView) mStaleView).recycleDrawables();
1637-
}
1638-
mStaleView = null;
1650+
mAnimationCompletionSet |= 2;
16391651
} else {
16401652
Log.e(t, "Unexpected animation");
16411653
}
1654+
1655+
if ( mAnimationCompletionSet == 3 ) {
1656+
this.afterAllAnimations();
1657+
}
16421658
}
16431659

16441660

src/org/odk/collect/android/views/MediaLayout.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import android.content.Context;
3030
import android.content.Intent;
3131
import android.graphics.Bitmap;
32+
import android.graphics.BitmapFactory;
3233
import android.graphics.Color;
3334
import android.net.Uri;
3435
import android.util.Log;
@@ -143,7 +144,10 @@ public void setAVT(FormIndex index, String selectionDesignator, TextView text, S
143144
if (videoURI != null) {
144145
// An video file is specified
145146
mVideoButton = new ImageButton(getContext());
146-
mVideoButton.setImageResource(android.R.drawable.ic_media_play);
147+
Bitmap b =
148+
BitmapFactory.decodeResource(getContext().getResources(),
149+
android.R.drawable.ic_media_play);
150+
mVideoButton.setImageBitmap(b);
147151
mVideoButton.setOnClickListener(new OnClickListener() {
148152

149153
@Override

0 commit comments

Comments
 (0)