Program: 38620
Project: 38620
Buggy source:
@Override public void onCreate(Bundle data,Bundle restoreState){
  super.onCreate(data,restoreState);
  mActionBar=mActivity.getGalleryActionBar();
  mSelectionManager=new SelectionManager(mActivity,false);
  mMenuExecutor=new MenuExecutor(mActivity,mSelectionManager);
  mPhotoView=new PhotoView(mActivity);
  mPhotoView.setListener(this);
  mRootPane.addComponent(mPhotoView);
  mApplication=(GalleryApp)((Activity)mActivity).getApplication();
  mOrientationManager=mActivity.getOrientationManager();
  mOrientationManager.addListener(this);
  mActivity.getGLRoot().setOrientationSource(mOrientationManager);
  mSetPathString=data.getString(KEY_MEDIA_SET_PATH);
  mOriginalSetPathString=mSetPathString;
  mNfcAdapter=NfcAdapter.getDefaultAdapter(mActivity.getAndroidContext());
  String itemPathString=data.getString(KEY_MEDIA_ITEM_PATH);
  Path itemPath=itemPathString != null ? Path.fromString(data.getString(KEY_MEDIA_ITEM_PATH)) : null;
  mTreatBackAsUp=data.getBoolean(KEY_TREAT_BACK_AS_UP,false);
  mStartInFilmstrip=data.getBoolean(KEY_START_IN_FILMSTRIP,false);
  mStartedFromAlbumPage=data.getInt(KEY_ALBUMPAGE_TRANSITION,MSG_ALBUMPAGE_NONE) == MSG_ALBUMPAGE_STARTED;
  setGridButtonVisibility(!mStartedFromAlbumPage);
  if (mSetPathString != null) {
    mAppBridge=(AppBridge)data.getParcelable(KEY_APP_BRIDGE);
    if (mAppBridge != null) {
      mFlags|=FLAG_HIDE_ACTION_BAR | FLAG_HIDE_STATUS_BAR;
      mShowBars=false;
      mAppBridge.setServer(this);
      mOrientationManager.lockOrientation();
      int id=SnailSource.newId();
      Path screenNailSetPath=SnailSource.getSetPath(id);
      Path screenNailItemPath=SnailSource.getItemPath(id);
      mScreenNailSet=(SnailAlbum)mActivity.getDataManager().getMediaObject(screenNailSetPath);
      mScreenNailItem=(SnailItem)mActivity.getDataManager().getMediaObject(screenNailItemPath);
      mScreenNailItem.setScreenNail(mAppBridge.attachScreenNail());
      if (SecureSource.isSecurePath(mSetPathString)) {
        mSecureAlbum=(SecureAlbum)mActivity.getDataManager().getMediaSet(mSetPathString);
        mFlags|=FLAG_SHOW_WHEN_LOCKED;
      }
      mSetPathString="String_Node_Str" + screenNailSetPath + "String_Node_Str"+ mSetPathString+ "String_Node_Str";
      itemPath=screenNailItemPath;
    }
    MediaSet originalSet=mActivity.getDataManager().getMediaSet(mSetPathString);
    mSelectionManager.setSourceMediaSet(originalSet);
    mSetPathString="String_Node_Str" + mSetPathString + "String_Node_Str";
    mMediaSet=(FilterDeleteSet)mActivity.getDataManager().getMediaSet(mSetPathString);
    mCurrentIndex=data.getInt(KEY_INDEX_HINT,0);
    if (mMediaSet == null) {
      Log.w(TAG,"String_Node_Str" + mSetPathString);
    }
    if (itemPath == null) {
      itemPath=mMediaSet.getMediaItem(mCurrentIndex,1).get(0).getPath();
    }
    PhotoDataAdapter pda=new PhotoDataAdapter(mActivity,mPhotoView,mMediaSet,itemPath,mCurrentIndex,mAppBridge == null ? -1 : 0,mAppBridge == null ? false : mAppBridge.isPanorama(),mAppBridge == null ? false : mAppBridge.isStaticCamera());
    mModel=pda;
    mPhotoView.setModel(mModel);
    pda.setDataListener(new PhotoDataAdapter.DataListener(){
      @Override public void onPhotoChanged(      int index,      Path item){
        mCurrentIndex=index;
        if (item != null) {
          MediaItem photo=mModel.getMediaItem(0);
          if (photo != null)           updateCurrentPhoto(photo);
        }
        updateBars();
      }
      @Override public void onLoadingFinished(){
        if (!mModel.isEmpty()) {
          MediaItem photo=mModel.getMediaItem(0);
          if (photo != null)           updateCurrentPhoto(photo);
        }
 else         if (mIsActive) {
          if (mMediaSet.getNumberOfDeletions() == 0) {
            mActivity.getStateManager().finishState(PhotoPage.this);
          }
        }
      }
      @Override public void onLoadingStarted(){
      }
    }
);
  }
 else {
    MediaItem mediaItem=(MediaItem)mActivity.getDataManager().getMediaObject(itemPath);
    mModel=new SinglePhotoDataAdapter(mActivity,mPhotoView,mediaItem);
    mPhotoView.setModel(mModel);
    updateCurrentPhoto(mediaItem);
  }
  mHandler=new SynchronizedHandler(mActivity.getGLRoot()){
    @Override public void handleMessage(    Message message){
switch (message.what) {
case MSG_HIDE_BARS:
{
          hideBars();
          break;
        }
case MSG_REFRESH_GRID_BUTTON:
{
        setGridButtonVisibility(mPhotoView.getFilmMode());
        break;
      }
case MSG_REFRESH_EDIT_BUTTON:
{
      refreshEditButton();
      break;
    }
case MSG_LOCK_ORIENTATION:
{
    mOrientationManager.lockOrientation();
    break;
  }
case MSG_UNLOCK_ORIENTATION:
{
  mOrientationManager.unlockOrientation();
  break;
}
case MSG_ON_FULL_SCREEN_CHANGED:
{
mAppBridge.onFullScreenChanged(message.arg1 == 1);
break;
}
case MSG_UPDATE_ACTION_BAR:
{
updateBars();
break;
}
case MSG_WANT_BARS:
{
wantBars();
break;
}
case MSG_UNFREEZE_GLROOT:
{
mActivity.getGLRoot().unfreeze();
break;
}
default :
throw new AssertionError(message.what);
}
}
}
;
mPhotoView.setFilmMode(mStartInFilmstrip);
setupEditButton();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle data,Bundle restoreState){
  super.onCreate(data,restoreState);
  mActionBar=mActivity.getGalleryActionBar();
  mSelectionManager=new SelectionManager(mActivity,false);
  mMenuExecutor=new MenuExecutor(mActivity,mSelectionManager);
  mPhotoView=new PhotoView(mActivity);
  mPhotoView.setListener(this);
  mRootPane.addComponent(mPhotoView);
  mApplication=(GalleryApp)((Activity)mActivity).getApplication();
  mOrientationManager=mActivity.getOrientationManager();
  mOrientationManager.addListener(this);
  mActivity.getGLRoot().setOrientationSource(mOrientationManager);
  mHandler=new SynchronizedHandler(mActivity.getGLRoot()){
    @Override public void handleMessage(    Message message){
switch (message.what) {
case MSG_HIDE_BARS:
{
          hideBars();
          break;
        }
case MSG_REFRESH_GRID_BUTTON:
{
        setGridButtonVisibility(mPhotoView.getFilmMode());
        break;
      }
case MSG_REFRESH_EDIT_BUTTON:
{
      refreshEditButton();
      break;
    }
case MSG_LOCK_ORIENTATION:
{
    mOrientationManager.lockOrientation();
    break;
  }
case MSG_UNLOCK_ORIENTATION:
{
  mOrientationManager.unlockOrientation();
  break;
}
case MSG_ON_FULL_SCREEN_CHANGED:
{
mAppBridge.onFullScreenChanged(message.arg1 == 1);
break;
}
case MSG_UPDATE_ACTION_BAR:
{
updateBars();
break;
}
case MSG_WANT_BARS:
{
wantBars();
break;
}
case MSG_UNFREEZE_GLROOT:
{
mActivity.getGLRoot().unfreeze();
break;
}
default :
throw new AssertionError(message.what);
}
}
}
;
mSetPathString=data.getString(KEY_MEDIA_SET_PATH);
mOriginalSetPathString=mSetPathString;
mNfcAdapter=NfcAdapter.getDefaultAdapter(mActivity.getAndroidContext());
String itemPathString=data.getString(KEY_MEDIA_ITEM_PATH);
Path itemPath=itemPathString != null ? Path.fromString(data.getString(KEY_MEDIA_ITEM_PATH)) : null;
mTreatBackAsUp=data.getBoolean(KEY_TREAT_BACK_AS_UP,false);
mStartInFilmstrip=data.getBoolean(KEY_START_IN_FILMSTRIP,false);
mStartedFromAlbumPage=data.getInt(KEY_ALBUMPAGE_TRANSITION,MSG_ALBUMPAGE_NONE) == MSG_ALBUMPAGE_STARTED;
setGridButtonVisibility(!mStartedFromAlbumPage);
if (mSetPathString != null) {
mAppBridge=(AppBridge)data.getParcelable(KEY_APP_BRIDGE);
if (mAppBridge != null) {
mFlags|=FLAG_HIDE_ACTION_BAR | FLAG_HIDE_STATUS_BAR;
mShowBars=false;
mAppBridge.setServer(this);
mOrientationManager.lockOrientation();
int id=SnailSource.newId();
Path screenNailSetPath=SnailSource.getSetPath(id);
Path screenNailItemPath=SnailSource.getItemPath(id);
mScreenNailSet=(SnailAlbum)mActivity.getDataManager().getMediaObject(screenNailSetPath);
mScreenNailItem=(SnailItem)mActivity.getDataManager().getMediaObject(screenNailItemPath);
mScreenNailItem.setScreenNail(mAppBridge.attachScreenNail());
if (SecureSource.isSecurePath(mSetPathString)) {
mSecureAlbum=(SecureAlbum)mActivity.getDataManager().getMediaSet(mSetPathString);
mFlags|=FLAG_SHOW_WHEN_LOCKED;
}
mSetPathString="String_Node_Str" + screenNailSetPath + "String_Node_Str"+ mSetPathString+ "String_Node_Str";
itemPath=screenNailItemPath;
}
MediaSet originalSet=mActivity.getDataManager().getMediaSet(mSetPathString);
mSelectionManager.setSourceMediaSet(originalSet);
mSetPathString="String_Node_Str" + mSetPathString + "String_Node_Str";
mMediaSet=(FilterDeleteSet)mActivity.getDataManager().getMediaSet(mSetPathString);
mCurrentIndex=data.getInt(KEY_INDEX_HINT,0);
if (mMediaSet == null) {
Log.w(TAG,"String_Node_Str" + mSetPathString);
}
if (itemPath == null) {
mMediaSet.reload();
if (mMediaSet.getMediaItemCount() > 0) {
itemPath=mMediaSet.getMediaItem(mCurrentIndex,1).get(0).getPath();
}
 else {
return;
}
}
PhotoDataAdapter pda=new PhotoDataAdapter(mActivity,mPhotoView,mMediaSet,itemPath,mCurrentIndex,mAppBridge == null ? -1 : 0,mAppBridge == null ? false : mAppBridge.isPanorama(),mAppBridge == null ? false : mAppBridge.isStaticCamera());
mModel=pda;
mPhotoView.setModel(mModel);
pda.setDataListener(new PhotoDataAdapter.DataListener(){
@Override public void onPhotoChanged(int index,Path item){
mCurrentIndex=index;
if (item != null) {
MediaItem photo=mModel.getMediaItem(0);
if (photo != null) updateCurrentPhoto(photo);
}
updateBars();
}
@Override public void onLoadingFinished(){
if (!mModel.isEmpty()) {
MediaItem photo=mModel.getMediaItem(0);
if (photo != null) updateCurrentPhoto(photo);
}
 else if (mIsActive) {
if (mMediaSet.getNumberOfDeletions() == 0) {
mActivity.getStateManager().finishState(PhotoPage.this);
}
}
}
@Override public void onLoadingStarted(){
}
}
);
}
 else {
MediaItem mediaItem=(MediaItem)mActivity.getDataManager().getMediaObject(itemPath);
mModel=new SinglePhotoDataAdapter(mActivity,mPhotoView,mediaItem);
mPhotoView.setModel(mModel);
updateCurrentPhoto(mediaItem);
}
mPhotoView.setFilmMode(mStartInFilmstrip);
setupEditButton();
}