Fix crashes in android remote.
Several objects become invalid after ending show prematurely. Data transmission may be flawed, don't rely on valid base64 etc. Change-Id: I9bb6929b9cd6b3183948662b472f92e2fa67a7e6
This commit is contained in:
@@ -95,7 +95,8 @@ public class PresentationActivity extends SherlockFragmentActivity {
|
||||
Intent aIntent = new Intent(this, SelectorActivity.class);
|
||||
aIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(aIntent);
|
||||
mCommunicationService.disconnect();
|
||||
if ( mCommunicationService != null )
|
||||
mCommunicationService.disconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -542,4 +543,4 @@ public class PresentationActivity extends SherlockFragmentActivity {
|
||||
}
|
||||
};
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -119,13 +119,15 @@ public class PresentationFragment extends SherlockFragment {
|
||||
if (mNewCoverflowHeight != 0) {
|
||||
ThumbnailAdapter aAdapter = (ThumbnailAdapter) mTopView
|
||||
.getAdapter();
|
||||
aAdapter.setHeight(mNewCoverflowHeight);
|
||||
mTopView.setImageHeight(mNewCoverflowHeight);
|
||||
aAdapter.setWidth(mNewCoverflowWidth);
|
||||
mTopView.setImageWidth(mNewCoverflowWidth);
|
||||
if ( aAdapter != null ) {
|
||||
aAdapter.setHeight(mNewCoverflowHeight);
|
||||
mTopView.setImageHeight(mNewCoverflowHeight);
|
||||
aAdapter.setWidth(mNewCoverflowWidth);
|
||||
mTopView.setImageWidth(mNewCoverflowWidth);
|
||||
|
||||
// We need to update the view now
|
||||
aAdapter.notifyDataSetChanged();
|
||||
// We need to update the view now
|
||||
aAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
IntentFilter aFilter = new IntentFilter(
|
||||
|
@@ -83,16 +83,20 @@ public class Receiver {
|
||||
} else if (aInstruction.equals("slide_preview")) {
|
||||
int aSlideNumber = Integer.parseInt(aCommand.get(1));
|
||||
String aImageString = aCommand.get(2);
|
||||
byte[] aImage = Base64.decode(aImageString, Base64.DEFAULT);
|
||||
try {
|
||||
byte[] aImage = Base64.decode(aImageString, Base64.DEFAULT);
|
||||
|
||||
// Store image internally
|
||||
mSlideShow.putImage(aSlideNumber, aImage);
|
||||
// Store image internally
|
||||
mSlideShow.putImage(aSlideNumber, aImage);
|
||||
|
||||
Intent aIntent = new Intent(
|
||||
CommunicationService.MSG_SLIDE_PREVIEW);
|
||||
aIntent.putExtra("slide_number", aSlideNumber);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(
|
||||
aIntent);
|
||||
Intent aIntent = new Intent(
|
||||
CommunicationService.MSG_SLIDE_PREVIEW);
|
||||
aIntent.putExtra("slide_number", aSlideNumber);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(
|
||||
aIntent);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Bad data - tough luck
|
||||
}
|
||||
} else if (aInstruction.equals("slide_notes")) {
|
||||
int aSlideNumber = Integer.parseInt(aCommand.get(1));
|
||||
String aNotes = new String();
|
||||
@@ -114,4 +118,4 @@ public class Receiver {
|
||||
|
||||
}
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -54,7 +54,12 @@ public class SlideShow {
|
||||
return BitmapFactory.decodeResource(mContext.getResources(),
|
||||
R.drawable.image_loading);
|
||||
}
|
||||
return BitmapFactory.decodeByteArray(aImage, 0, aImage.length);
|
||||
Bitmap aBitmap = BitmapFactory.decodeByteArray(aImage, 0, aImage.length);
|
||||
if (aBitmap == null) {
|
||||
return BitmapFactory.decodeResource(mContext.getResources(),
|
||||
R.drawable.image_loading);
|
||||
}
|
||||
return aBitmap;
|
||||
}
|
||||
|
||||
protected void putNotes(int aSlide, String aNotes) {
|
||||
@@ -178,4 +183,4 @@ public class SlideShow {
|
||||
}
|
||||
}
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
Reference in New Issue
Block a user