nus-yam/ex-repair huggingface dataset:
Program: 110030
Project: 110030
Buggy source:
public static void doAddVideosTo(final Activity activity,final Object user,final OnPostExecuteListener listener,final long plid,final long[] vids,final boolean move){
  DiagAsyncTask.Worker worker=new DiagAsyncTask.Worker(){
    @Override public void onPostExecute(    DiagAsyncTask task,    Err result){
      listener.onPostExecute(result,user);
    }
    @Override public Err doBackgroundWork(    DiagAsyncTask task){
      DB db=DB.get();
      db.beginTransaction();
      try {
        for (        long mid : vids) {
          DB.Err err=db.insertVideoToPlaylist(plid,mid);
          if (DB.Err.NO_ERR != err) {
            if (DB.Err.DUPLICATED != err)             return Err.DB_DUPLICATED;
 else             if (1 == vids.length && !move)             return Err.map(err);
          }
          if (move) {
            if (UiUtils.isUserPlaylist(plid))             db.deleteVideoFrom(plid,mid);
 else             db.deleteVideoExcept(plid,mid);
          }
        }
        db.setTransactionSuccessful();
      }
  finally {
        db.endTransaction();
      }
      return Err.NO_ERR;
    }
  }
;
  new DiagAsyncTask(activity,worker,DiagAsyncTask.Style.SPIN,move ? R.string.moving : R.string.adding).run();
}

Fixed version (ground truth):
public static void doAddVideosTo(final Activity activity,final Object user,final OnPostExecuteListener listener,final long dstPlid,final long srcPlid,final long[] vids,final boolean move){
  DiagAsyncTask.Worker worker=new DiagAsyncTask.Worker(){
    @Override public void onPostExecute(    DiagAsyncTask task,    Err result){
      listener.onPostExecute(result,user);
    }
    @Override public Err doBackgroundWork(    DiagAsyncTask task){
      DB db=DB.get();
      db.beginTransaction();
      try {
        for (        long mid : vids) {
          DB.Err err=db.insertVideoToPlaylist(dstPlid,mid);
          if (DB.Err.NO_ERR != err) {
            if (DB.Err.DUPLICATED != err)             return Err.DB_DUPLICATED;
 else             if (1 == vids.length && !move)             return Err.map(err);
          }
          if (move) {
            if (UiUtils.isUserPlaylist(srcPlid))             db.deleteVideoFrom(srcPlid,mid);
 else             db.deleteVideoExcept(dstPlid,mid);
          }
        }
        db.setTransactionSuccessful();
      }
  finally {
        db.endTransaction();
      }
      return Err.NO_ERR;
    }
  }
;
  new DiagAsyncTask(activity,worker,DiagAsyncTask.Style.SPIN,move ? R.string.moving : R.string.adding).run();
}
Program: 110031
Project: 110031
Buggy source:
@Override public void onPlaylist(long plid,Object user){
  doAddVideosTo(activity,user,listener,plid,vids,move);
}

Fixed version (ground truth):
@Override public void onPlaylist(long plid,Object user){
  doAddVideosTo(activity,user,listener,plid,srcPlid,vids,move);
}
Program: 110032
Project: 110032
Buggy source:
public static void addVideosTo(final Activity activity,final Object user,final OnPostExecuteListener listener,final long plidExcluded,final long[] vids,final boolean move){
  UiUtils.OnPlaylistSelectedListener action=new UiUtils.OnPlaylistSelectedListener(){
    @Override public void onPlaylist(    long plid,    Object user){
      doAddVideosTo(activity,user,listener,plid,vids,move);
    }
    @Override public void onUserMenu(    int pos,    Object user){
    }
  }
;
  UiUtils.buildSelectPlaylistDialog(DB.get(),activity,move ? R.string.move_to : R.string.add_to,null,action,plidExcluded,null).show();
}

Fixed version (ground truth):
public static void addVideosTo(final Activity activity,final Object user,final OnPostExecuteListener listener,final long plid,final long[] vids,final boolean move){
  final long srcPlid=UiUtils.isUserPlaylist(plid) ? plid : DB.INVALID_PLAYLIST_ID;
  UiUtils.OnPlaylistSelectedListener action=new UiUtils.OnPlaylistSelectedListener(){
    @Override public void onPlaylist(    long plid,    Object user){
      doAddVideosTo(activity,user,listener,plid,srcPlid,vids,move);
    }
    @Override public void onUserMenu(    int pos,    Object user){
    }
  }
;
  UiUtils.buildSelectPlaylistDialog(DB.get(),activity,move ? R.string.move_to : R.string.add_to,null,action,srcPlid,null).show();
}
Program: 110033
Project: 110033
Buggy source:
void removeVideo(String ytvid){
  int nextIdx=mVlm.findVideoExcept(mVlm.getActiveVideoIndex(),ytvid);
  if (nextIdx < 0)   stopPlay(StopState.DONE);
 else   startAt(nextIdx);
  mVlm.removeVideo(ytvid);
}

Fixed version (ground truth):
void removeVideo(String ytvid){
  int avi=mVlm.getActiveVideoIndex();
  avi=mVlm.findVideoExcept(avi,ytvid);
  if (mVlm.isValidVideoIndex(avi)) {
    startAt(avi);
    mVlm.removeVideo(ytvid);
  }
 else {
    mVlm.removeVideo(ytvid);
    stopPlay(StopState.DONE);
  }
}
Program: 110034
Project: 110034
Buggy source:
public final boolean cancel(final boolean interrupt){
  mCancelled.set(true);
  if (mCancelled.get() || State.READY == mState.get() || State.TERMINATED == mState.get())   return false;
  mOwner.post(new Runnable(){
    @Override public void run(){
      onCancel();
      if (interrupt)       mThread.interrupt();
    }
  }
);
  return true;
}

Fixed version (ground truth):
public final boolean cancel(final boolean interrupt){
  if (mCancelled.getAndSet(true) || State.READY == mState.get() || State.TERMINATED == mState.get())   return false;
  mOwner.post(new Runnable(){
    @Override public void run(){
      onCancel();
      if (interrupt)       mThread.interrupt();
    }
  }
);
  return true;
}
Program: 110035
Project: 110035
Buggy source:
public final void cancel(final boolean interrupt){
  mCancelled.set(true);
  mOwner.post(new Runnable(){
    @Override public void run(){
      onCancel();
      if (interrupt)       mThread.interrupt();
    }
  }
);
}

Fixed version (ground truth):
public final boolean cancel(final boolean interrupt){
  mCancelled.set(true);
  if (mCancelled.get() || State.READY == mState.get() || State.TERMINATED == mState.get())   return false;
  mOwner.post(new Runnable(){
    @Override public void run(){
      onCancel();
      if (interrupt)       mThread.interrupt();
    }
  }
);
  return true;
}
Program: 110036
Project: 110036
Buggy source:
public final boolean isCancelled(){
  eAssert(isCurrentOwnerThread());
  return mCancelled.get();
}

Fixed version (ground truth):
public final boolean isCancelled(){
  return mCancelled.get();
}
Program: 110037
Project: 110037
Buggy source:
private void bgRun(){
  if (mCancelled.get())   return;
  mState.set(State.RUNNING);
  final R r=doAsyncTask();
  mState.set(State.DONE);
  if (mCancelled.get())   mOwner.post(new Runnable(){
    @Override public void run(){
      onCancelled();
    }
  }
);
 else   mOwner.post(new Runnable(){
    @Override public void run(){
      onPostRun(r);
    }
  }
);
}

Fixed version (ground truth):
private void bgRun(){
  if (mCancelled.get())   return;
  mState.set(State.RUNNING);
  R r=null;
  try {
    r=doAsyncTask();
  }
  finally {
    mState.set(State.DONE);
    if (mCancelled.get())     mOwner.post(new Runnable(){
      @Override public void run(){
        onCancelled();
        mState.set(State.TERMINATED);
      }
    }
);
 else {
      final R result=r;
      mOwner.post(new Runnable(){
        @Override public void run(){
          onPostRun(result);
          mState.set(State.TERMINATED);
        }
      }
);
    }
  }
}
Program: 110038
Project: 110038
Buggy source:
@Override public void onCancelled(){
  mDialog.dismiss();
  if (null != mWorker)   mWorker.onCancelled(this);
}

Fixed version (ground truth):
@Override public void onCancelled(){
  if (null != mWorker)   mWorker.onCancelled(this);
  mDialog.dismiss();
}
Program: 110039
Project: 110039
Buggy source:
@Override public void onClick(DialogInterface dialogI,int which){
  if (!mCancelable)   return;
  mUserCancelled=true;
  mDialog.setMessage(mContext.getResources().getText(R.string.msg_wait_cancel));
  if (null != mWorker)   mWorker.onCancel(this);
  super.cancel(mInterruptOnCancel);
}

Fixed version (ground truth):
@Override public void onClick(DialogInterface dialogI,int which){
  eAssert(mCancelable);
  mUserCancelled=true;
  mDialog.setMessage(mContext.getResources().getText(R.string.msg_wait_cancel));
  if (null != mWorker)   mWorker.onCancel(this);
  super.cancel(mInterruptOnCancel);
}
Program: 110040
Project: 110040
Buggy source:
@Override public void onDismiss(DialogInterface dialog){
}

Fixed version (ground truth):
@Override public void onDismiss(DialogInterface dialogI){
  if (null != mOnDismissListener)   mOnDismissListener.onDismiss(dialogI);
}
Program: 110041
Project: 110041
Buggy source:
@Override protected void onPreRun(){
  mDialog=new ProgressDialog(mContext);
  mDialog.setMessage(mContext.getResources().getText(mMsgid));
  mDialog.setProgressStyle(mStyle.getStyle());
  mDialog.setMax(100);
  mDialog.setCanceledOnTouchOutside(false);
  if (mCancelable)   mDialog.setButton(mContext.getResources().getText(R.string.cancel),this);
 else   mDialog.setCancelable(false);
  mDialog.setOnDismissListener(this);
  mDialog.show();
}

Fixed version (ground truth):
@Override protected void onPreRun(){
  mDialog=new ProgressDialog(mContext);
  mDialog.setMessage(mContext.getResources().getText(mMsgid));
  mDialog.setProgressStyle(mStyle.getStyle());
  mDialog.setMax(100);
  mDialog.setCancelable(false);
  mDialog.setOnKeyListener(new DialogInterface.OnKeyListener(){
    @Override public boolean onKey(    DialogInterface dialog,    int keyCode,    KeyEvent event){
      if (KeyEvent.KEYCODE_SEARCH == keyCode && 0 == event.getRepeatCount()) {
        return true;
      }
      return false;
    }
  }
);
  if (mCancelable)   mDialog.setButton(mContext.getResources().getText(R.string.cancel),this);
  mDialog.setOnDismissListener(this);
  mDialog.show();
}
Program: 110042
Project: 110042
Buggy source:
DiagAsyncTask(Context context,Worker listener,Style style,int msgid){
  this(context,listener,style,msgid,true,true);
}

Fixed version (ground truth):
public DiagAsyncTask(Context context,Worker listener,Style style,int msgid){
  this(context,listener,style,msgid,false,true);
}
Program: 110043
Project: 110043
Buggy source:
@Override protected void onPostRun(Err result){
  mDialog.dismiss();
  if (mUserCancelled)   return;
  if (null != mWorker)   mWorker.onPostExecute(this,result);
}

Fixed version (ground truth):
@Override protected void onPostRun(Err result){
  if (!mUserCancelled && null != mWorker)   mWorker.onPostExecute(this,result);
  mDialog.dismiss();
}
Program: 110044
Project: 110044
Buggy source:
@Override public void searchDone(YTSearchHelper helper,YTSearchHelper.SearchArg arg,YTFeed.Result result,Err err){
  if (!handleSearchResult(helper,arg,result,err))   return;
  mDbHelper=new DBHelper();
  mDbHelper.setCheckExistDoneReceiver(this);
  mDbHelper.open();
  mDbHelper.checkExistAsync(new DBHelper.CheckExistArg(arg,(YTVideoFeed.Entry[])result.entries));
}

Fixed version (ground truth):
@Override public void searchDone(YTSearchHelper helper,YTSearchHelper.SearchArg arg,YTFeed.Result result,Err err){
  if (!handleSearchResult(helper,arg,result,err))   return;
  mDbHelper.close();
  mDbHelper=new DBHelper();
  mDbHelper.setCheckExistDoneReceiver(this);
  mDbHelper.open();
  mDbHelper.checkExistAsync(new DBHelper.CheckExistArg(arg,(YTVideoFeed.Entry[])result.entries));
}
Program: 110045
Project: 110045
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MSG_WHAT_CHECK_EXIST:
    handleCheckExist((CheckExistArg)msg.obj);
  break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (closed)   return;
switch (msg.what) {
case MSG_WHAT_CLOSE:
    closed=true;
  ((HandlerThread)getLooper().getThread()).quit();
break;
case MSG_WHAT_CHECK_EXIST:
handleCheckExist((CheckExistArg)msg.obj);
break;
}
}
Program: 110046
Project: 110046
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MSG_WHAT_DOWNLOAD:
    handleDownload((DnArg)msg.obj);
  break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (closed)   return;
switch (msg.what) {
case MSG_WHAT_CLOSE:
    closed=true;
  if (null != loader)   loader.close();
((HandlerThread)getLooper().getThread()).quit();
break;
case MSG_WHAT_DOWNLOAD:
handleDownload((DnArg)msg.obj);
break;
}
}
Program: 110047
Project: 110047
Buggy source:
@Override public void run(){
  LoadThumbnailReturn r=doLoadThumbnail(arg);
  sendLoadThumbnailDone(arg,r.bm,r.err);
  Message doneMsg=BGHandler.this.obtainMessage(MSG_WHAT_LOAD_THUMBNAIL_DONE,this);
  BGHandler.this.sendMessage(doneMsg);
}

Fixed version (ground truth):
@Override public void run(){
  LoadThumbnailReturn r=doLoadThumbnail(arg);
  sendLoadThumbnailDone(arg,r.bm,r.err);
  Message doneMsg=BGHandler.this.obtainMessage(MSG_WHAT_LOAD_THUMBNAIL_DONE,this);
  sendMessage(doneMsg);
}
Program: 110048
Project: 110048
Buggy source:
@Override public void handleMessage(final Message msg){
switch (msg.what) {
case MSG_WHAT_SEARCH:
{
      SearchArg arg=(SearchArg)msg.obj;
      SearchReturn r=doSearch(arg);
      sendFeedDone(arg,r.r,r.err);
    }
  break;
case MSG_WHAT_LOAD_THUMBNAIL:
{
  final LoadThumbnailArg arg=(LoadThumbnailArg)msg.obj;
  if (activeLoadThumbnaill.size() < Policy.YTSEARCH_MAX_LOAD_THUMBNAIL_THREAD) {
    Thread thd=new Thread(){
      @Override public void run(){
        LoadThumbnailReturn r=doLoadThumbnail(arg);
        sendLoadThumbnailDone(arg,r.bm,r.err);
        Message doneMsg=BGHandler.this.obtainMessage(MSG_WHAT_LOAD_THUMBNAIL_DONE,this);
        BGHandler.this.sendMessage(doneMsg);
      }
    }
;
    thd.setPriority(Thread.MIN_PRIORITY);
    thd.start();
    activeLoadThumbnaill.add(thd);
  }
 else {
    Message retryMsg=BGHandler.this.obtainMessage(MSG_WHAT_LOAD_THUMBNAIL,arg);
    BGHandler.this.sendMessageDelayed(retryMsg,Policy.YTSEARCH_LOAD_THUMBNAIL_INTERVAL);
  }
}
break;
case MSG_WHAT_LOAD_THUMBNAIL_DONE:
activeLoadThumbnaill.remove(msg.obj);
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(final Message msg){
  if (closed)   return;
switch (msg.what) {
case MSG_WHAT_CLOSE:
{
      closed=true;
      Iterator<Thread> iter=activeLoadThumbnaill.iterator();
      while (iter.hasNext())       iter.next().interrupt();
      activeLoadThumbnaill.clear();
      ((HandlerThread)getLooper().getThread()).quit();
    }
  break;
case MSG_WHAT_SEARCH:
{
  SearchArg arg=(SearchArg)msg.obj;
  SearchReturn r=doSearch(arg);
  sendFeedDone(arg,r.r,r.err);
}
break;
case MSG_WHAT_LOAD_THUMBNAIL:
{
final LoadThumbnailArg arg=(LoadThumbnailArg)msg.obj;
if (activeLoadThumbnaill.size() < Policy.YTSEARCH_MAX_LOAD_THUMBNAIL_THREAD) {
Thread thd=new Thread(){
  @Override public void run(){
    LoadThumbnailReturn r=doLoadThumbnail(arg);
    sendLoadThumbnailDone(arg,r.bm,r.err);
    Message doneMsg=BGHandler.this.obtainMessage(MSG_WHAT_LOAD_THUMBNAIL_DONE,this);
    sendMessage(doneMsg);
  }
}
;
thd.setPriority(Thread.MIN_PRIORITY);
thd.start();
activeLoadThumbnaill.add(thd);
}
 else {
Message retryMsg=BGHandler.this.obtainMessage(MSG_WHAT_LOAD_THUMBNAIL,arg);
sendMessageDelayed(retryMsg,Policy.YTSEARCH_LOAD_THUMBNAIL_INTERVAL);
}
}
break;
case MSG_WHAT_LOAD_THUMBNAIL_DONE:
activeLoadThumbnaill.remove(msg.obj);
break;
}
}
Program: 110049
Project: 110049
Buggy source:
public static void init(){
  IntentFilter filter=new IntentFilter();
  filter.addAction(Intent.ACTION_SCREEN_OFF);
  filter.addAction(Intent.ACTION_SCREEN_ON);
  ScreenMonitor rcvr=new ScreenMonitor();
  Utils.getAppContext().registerReceiver(rcvr,filter);
}

Fixed version (ground truth):
public static void init(){
  IntentFilter filter=new IntentFilter();
  filter.addAction(Intent.ACTION_SCREEN_ON);
  ScreenMonitor rcvr=new ScreenMonitor();
  Utils.getAppContext().registerReceiver(rcvr,filter);
}
Program: 110050
Project: 110050
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
  setContentView(R.layout.lockscreen);
  findViewById(R.id.close).setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      finish();
    }
  }
);
  mMp.addVideosStateListener(this,this);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mForeground=getIntent().getBooleanExtra(INTENT_KEY_APP_FOREGROUND,false);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
  setContentView(R.layout.lockscreen);
  findViewById(R.id.close).setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      close();
    }
  }
);
  mMp.addVideosStateListener(this,this);
}
Program: 110051
Project: 110051
Buggy source:
@Override public void onClick(View v){
  finish();
}

Fixed version (ground truth):
@Override public void onClick(View v){
  close();
}
Program: 110052
Project: 110052
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  Intent i=new Intent(Utils.getAppContext(),LockScreenActivity.class);
  i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
  if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
    i.putExtra(INTENT_KEY_SCREEN,false);
  }
 else   if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
    i.putExtra(INTENT_KEY_SCREEN,true);
    if (Utils.isPrefLockScreen() && YTPlayer.get().hasActiveVideo())     context.startActivity(i);
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  Intent i=new Intent(Utils.getAppContext(),LockScreenActivity.class);
  i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
  if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
    i.putExtra(INTENT_KEY_APP_FOREGROUND,Utils.isAppForeground());
    if (Utils.isPrefLockScreen() && YTPlayer.get().hasActiveVideo())     context.startActivity(i);
  }
}
Program: 110053
Project: 110053
Buggy source:
@Override public void onStopped(StopState state){
  finish();
}

Fixed version (ground truth):
@Override public void onStopped(StopState state){
  close();
}
Program: 110054
Project: 110054
Buggy source:
@Override public void onBackPressed(){
  super.onBackPressed();
}

Fixed version (ground truth):
@Override public void onBackPressed(){
  close();
  super.onBackPressed();
}
Program: 110055
Project: 110055
Buggy source:
@Override protected void onPause(){
  mMp.unsetController(this);
  super.onPause();
  mDb.registerToPlaylistTableWatcher(this);
}

Fixed version (ground truth):
@Override protected void onPause(){
  mMp.unsetController(this);
  mDb.registerToPlaylistTableWatcher(this);
  super.onPause();
}
Program: 110056
Project: 110056
Buggy source:
@Override protected void onDestroy(){
  super.onDestroy();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  mDb.unregisterToPlaylistTableWatcher(this);
  super.onDestroy();
}
Program: 110057
Project: 110057
Buggy source:
@Override protected void onResume(){
  super.onResume();
  ViewGroup playerv=(ViewGroup)findViewById(R.id.player);
  mMp.setController(this,playerv,(ViewGroup)findViewById(R.id.list_drawer),null,mMp.getVideoToolButton());
  if (mMp.hasActiveVideo())   playerv.setVisibility(View.VISIBLE);
 else   playerv.setVisibility(View.GONE);
  if (mDb.isRegisteredToPlaylistTableWatcher(this) && mDb.isPlaylistTableUpdated(this))   getAdapter().reloadCursorAsync();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  ViewGroup playerv=(ViewGroup)findViewById(R.id.player);
  mMp.setController(this,playerv,(ViewGroup)findViewById(R.id.list_drawer),null,mMp.getVideoToolButton());
  if (mMp.hasActiveVideo())   playerv.setVisibility(View.VISIBLE);
 else   playerv.setVisibility(View.GONE);
  if (mDb.isRegisteredToPlaylistTableWatcher(this)) {
    if (mDb.isPlaylistTableUpdated(this))     getAdapter().reloadCursorAsync();
    mDb.unregisterToPlaylistTableWatcher(this);
  }
}
Program: 110058
Project: 110058
Buggy source:
protected void stopLoadingLookAndFeel(){
  View listv=findViewById(R.id.list);
  View loadingv=findViewById(R.id.loading);
  ImageView iv=(ImageView)loadingv.findViewById(R.id.loading_img);
  if (null != iv.getAnimation()) {
    iv.getAnimation().cancel();
    iv.getAnimation().reset();
  }
  loadingv.setVisibility(View.GONE);
  listv.setVisibility(View.VISIBLE);
}

Fixed version (ground truth):
protected void stopLoadingLookAndFeel(){
  View loadingv=findViewById(R.id.loading);
  if (View.VISIBLE != loadingv.getVisibility()) {
    eAssert(View.VISIBLE == mListv.getVisibility());
    return;
  }
  ImageView iv=(ImageView)loadingv.findViewById(R.id.loading_img);
  if (null != iv.getAnimation()) {
    iv.getAnimation().cancel();
    iv.getAnimation().reset();
  }
  loadingv.setVisibility(View.GONE);
  mListv.setVisibility(View.VISIBLE);
}
Program: 110059
Project: 110059
Buggy source:
protected void showLoadingLookAndFeel(){
  View listv=findViewById(R.id.list);
  View loadingv=findViewById(R.id.loading);
  ImageView iv=(ImageView)loadingv.findViewById(R.id.loading_img);
  TextView tv=(TextView)loadingv.findViewById(R.id.loading_msg);
  tv.setText(R.string.loading);
  loadingv.setVisibility(View.VISIBLE);
  listv.setVisibility(View.GONE);
  iv.startAnimation(AnimationUtils.loadAnimation(YTSearchActivity.this,R.anim.rotate));
}

Fixed version (ground truth):
protected void showLoadingLookAndFeel(){
  View loadingv=findViewById(R.id.loading);
  if (View.VISIBLE == loadingv.getVisibility()) {
    eAssert(View.VISIBLE != mListv.getVisibility());
    return;
  }
  ImageView iv=(ImageView)loadingv.findViewById(R.id.loading_img);
  TextView tv=(TextView)loadingv.findViewById(R.id.loading_msg);
  tv.setText(R.string.loading);
  loadingv.setVisibility(View.VISIBLE);
  mListv.setVisibility(View.GONE);
  iv.startAnimation(AnimationUtils.loadAnimation(YTSearchActivity.this,R.anim.rotate));
}
Program: 110060
Project: 110060
Buggy source:
@Override protected void onPause(){
  super.onPause();
}

Fixed version (ground truth):
@Override protected void onPause(){
  mDb.registerToVideoTableWatcher(this);
  super.onPause();
}
Program: 110061
Project: 110061
Buggy source:
private void onContextMenuVideosOfThisAuthor(final int position){
  loadFirstPage(YTSearchHelper.SearchType.VID_AUTHOR,getAdapter().getItemAuthor(position),getAdapter().getItemAuthor(position));
}

Fixed version (ground truth):
private void onContextMenuVideosOfThisAuthor(final int position){
  Intent i=new Intent(this,YTVideoSearchActivity.class);
  i.putExtra(INTENT_KEY_SEARCH_TYPE,YTSearchHelper.SearchType.VID_AUTHOR.name());
  i.putExtra(INTENT_KEY_SEARCH_TEXT,getAdapter().getItemAuthor(position));
  i.putExtra(INTENT_KEY_SEARCH_TITLE,getAdapter().getItemAuthor(position));
  startActivity(i);
}
Program: 110062
Project: 110062
Buggy source:
@Override public void searchDone(YTSearchHelper helper,YTSearchHelper.SearchArg arg,YTFeed.Result result,Err err){
  if (!handleSearchResult(helper,arg,result,err))   return;
  mDbHelper.close();
  mDbHelper=new DBHelper();
  mDbHelper.setCheckExistDoneReceiver(this);
  mDbHelper.open();
  mDbHelper.checkExistAsync(new DBHelper.CheckExistArg(arg,(YTVideoFeed.Entry[])result.entries));
}

Fixed version (ground truth):
@Override public void searchDone(YTSearchHelper helper,YTSearchHelper.SearchArg arg,YTFeed.Result result,Err err){
  if (!handleSearchResult(helper,arg,result,err))   return;
  checkDupAsync(arg,(YTVideoFeed.Entry[])result.entries);
}
Program: 110063
Project: 110063
Buggy source:
@Override protected void onDestroy(){
  mDbHelper.close();
  super.onDestroy();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  mDbHelper.close();
  mDb.unregisterToVideoTableWatcher(this);
  super.onDestroy();
}
Program: 110064
Project: 110064
Buggy source:
/** 
 * @return 0 for success, otherwise error message id.
 */
private int addToPlaylist(final long plid,final int pos,final int volume){
  eAssert(plid >= 0);
  Bitmap bm=getAdapter().getItemThumbnail(pos);
  if (null == bm) {
    return R.string.msg_no_thumbnail;
  }
  final YTVideoFeed.Entry entry=(YTVideoFeed.Entry)getAdapter().getItem(pos);
  int playtm=0;
  try {
    playtm=Integer.parseInt(entry.media.playTime);
  }
 catch (  NumberFormatException ex) {
    return R.string.msg_unknown_format;
  }
  Err err=mDb.insertVideoToPlaylist(plid,entry.media.title,entry.media.description,entry.media.videoId,playtm,Utils.compressBitmap(bm),volume);
  if (Err.NO_ERR != err) {
    if (Err.DB_DUPLICATED == err)     return R.string.msg_existing_muisc;
 else     return err.getMessage();
  }
  runOnUiThread(new Runnable(){
    @Override public void run(){
      getAdapter().markEntryExist(pos);
    }
  }
);
  return 0;
}

Fixed version (ground truth):
/** 
 * @return 0 for success, otherwise error message id.
 */
private int addToPlaylist(final long plid,final int pos,final int volume){
  eAssert(plid >= 0);
  Bitmap bm=getAdapter().getItemThumbnail(pos);
  if (null == bm) {
    return R.string.msg_no_thumbnail;
  }
  final YTVideoFeed.Entry entry=(YTVideoFeed.Entry)getAdapter().getItem(pos);
  int playtm=0;
  try {
    playtm=Integer.parseInt(entry.media.playTime);
  }
 catch (  NumberFormatException ex) {
    return R.string.msg_unknown_format;
  }
  Err err=mDb.insertVideoToPlaylist(plid,entry.media.title,entry.media.description,entry.media.videoId,playtm,Utils.compressBitmap(bm),volume);
  if (Err.NO_ERR != err) {
    if (Err.DB_DUPLICATED == err)     return R.string.msg_existing_muisc;
 else     return err.getMessage();
  }
  runOnUiThread(new Runnable(){
    @Override public void run(){
      getAdapter().markEntryExist(pos,true);
    }
  }
);
  return 0;
}
Program: 110065
Project: 110065
Buggy source:
@Override protected void onResume(){
  super.onResume();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  if (mDb.isRegisteredToVideoTableWatcher(this)) {
    if (mDb.isVideoTableUpdated(this)) {
      showLoadingLookAndFeel();
      checkDupAsync(null,(YTVideoFeed.Entry[])getAdapter().getEntries());
    }
    mDb.unregisterToVideoTableWatcher(this);
  }
}
Program: 110066
Project: 110066
Buggy source:
public void markEntryExist(int pos){
  YTFeed.Entry e=mEntries[pos];
  e.uflag=Utils.bitSet(e.uflag,FENT_EXIST_DUP,MENT_EXIST);
  setToExist(mItemViews[pos]);
}

Fixed version (ground truth):
public void markEntryExist(int pos,boolean exist){
  YTFeed.Entry e=mEntries[pos];
  long olduflag=e.uflag;
  e.uflag=Utils.bitSet(e.uflag,exist ? FENT_EXIST_DUP : FENT_EXIST_NEW,MENT_EXIST);
  if (olduflag != e.uflag)   setToExist(mItemViews[pos]);
}
Program: 110067
Project: 110067
Buggy source:
public static String getFeedUrlByUser(String user,int start,int maxCount){
  return "String_Node_Str" + Uri.encode(user,null) + "String_Node_Str";
}

Fixed version (ground truth):
public static String getFeedUrlByUser(String user,int start,int maxCount){
  return "String_Node_Str" + Uri.encode(user,null) + "String_Node_Str"+ "String_Node_Str"+ start+ "String_Node_Str"+ maxCount;
}
Program: 110068
Project: 110068
Buggy source:
private void storePlayerState(){
  if (null == mMp)   return;
  int storedPos=0;
  int storedVol=Policy.DEFAULT_VIDEO_VOLUME;
  if (mVlm.hasActiveVideo()) {
    Long vol=(Long)mDb.getVideoInfo(mVlm.getActiveVideo().videoId,DB.ColVideo.VOLUME);
    if (null != vol)     storedVol=vol.intValue();
  }
  if (haveStoredPlayerState()) {
    storedPos=mStoredPState.pos;
    storedVol=mStoredPState.vol;
  }
  clearStoredPlayerState();
  mStoredPState=new PlayerState();
  mStoredPState.mpState=mpGetState();
  mStoredPState.vidobj=mVlm.getActiveVideo();
switch (mpGetState()) {
case STARTED:
case PAUSED:
    mStoredPState.pos=mpGetCurrentPosition();
  mStoredPState.vol=mpGetVolume();
break;
default :
mStoredPState.pos=storedPos;
mStoredPState.vol=storedVol;
}
}

Fixed version (ground truth):
private void storePlayerState(){
  if (null == mMp)   return;
  int storedPos=0;
  int storedVol=Policy.DEFAULT_VIDEO_VOLUME;
  if (mVlm.hasActiveVideo()) {
    Long vol=(Long)mDb.getVideoInfo(mVlm.getActiveVideo().videoId,DB.ColVideo.VOLUME);
    if (null != vol)     storedVol=vol.intValue();
  }
  if (haveStoredPlayerState()) {
    storedPos=mStoredPState.pos;
    storedVol=mStoredPState.vol;
  }
  clearStoredPlayerState();
  mStoredPState=new PlayerState();
  mStoredPState.mpState=mpGetState();
  mStoredPState.vidobj=mVlm.getActiveVideo();
switch (mpGetState()) {
case STARTED:
case PAUSED:
case PREPARED_AUDIO:
case PREPARED:
    mStoredPState.pos=mpGetCurrentPosition();
  mStoredPState.vol=mpGetVolume();
break;
default :
mStoredPState.pos=storedPos;
mStoredPState.vol=storedVol;
}
}
Program: 110069
Project: 110069
Buggy source:
private boolean isStoredPlayerStatePaused(){
  return MPState.PAUSED == mStoredPState.mpState;
}

Fixed version (ground truth):
private boolean isStoredPlayerStatePaused(){
switch (mStoredPState.mpState) {
case PAUSED:
case PREPARED_AUDIO:
case PREPARED:
    return true;
}
return false;
}
Program: 110070
Project: 110070
Buggy source:
private void fitVideoSurfaceToScreen(boolean statusBarShown){
  SurfaceHolder holder=mSurfv.getHolder();
  int vw=mMp.getVideoWidth();
  int vh=mMp.getVideoHeight();
  if (0 >= vw || 0 >= vh)   return;
  int sw, sh;
  if (statusBarShown) {
    sw=Utils.getVisibleFrameWidth(this);
    sh=Utils.getVisibleFrameHeight(this);
  }
 else {
    sw=((WindowManager)Utils.getAppContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
    sh=((WindowManager)Utils.getAppContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight();
  }
  if (sw < sh) {
    int tmp=sw;
    sw=sh;
    sh=tmp;
  }
  int[] sz=new int[2];
  Utils.fitFixedRatio(sw,sh,vw,vh,sz);
  holder.setFixedSize(sz[0],sz[1]);
  ViewGroup.LayoutParams lp=mSurfv.getLayoutParams();
  lp.width=sz[0];
  lp.height=sz[1];
  mSurfv.setLayoutParams(lp);
  mSurfv.requestLayout();
}

Fixed version (ground truth):
private void fitVideoSurfaceToScreen(boolean statusBarShown){
  SurfaceHolder holder=mSurfv.getHolder();
  int vw=mMp.getVideoWidth();
  int vh=mMp.getVideoHeight();
  if (0 >= vw || 0 >= vh)   return;
  int sw=Utils.getVisibleFrameWidth(this);
  int sh=Utils.getVisibleFrameHeight(this);
  if (statusBarShown)   sh-=mStatusBarHeight;
  if (sw < sh) {
    int tmp=sw;
    sw=sh;
    sh=tmp;
  }
  int[] sz=new int[2];
  Utils.fitFixedRatio(sw,sh,vw,vh,sz);
  holder.setFixedSize(sz[0],sz[1]);
  ViewGroup.LayoutParams lp=mSurfv.getLayoutParams();
  lp.width=sz[0];
  lp.height=sz[1];
  mSurfv.setLayoutParams(lp);
  mSurfv.requestLayout();
}
Program: 110071
Project: 110071
Buggy source:
public static int getVisibleFrameHeight(Activity activity){
  Rect rect=new Rect();
  Window window=activity.getWindow();
  window.getDecorView().getWindowVisibleDisplayFrame(rect);
  return rect.bottom - rect.top;
}

Fixed version (ground truth):
public static int getVisibleFrameHeight(Activity activity){
  Rect rect=new Rect();
  Window window=activity.getWindow();
  window.getDecorView().getWindowVisibleDisplayFrame(rect);
  return rect.bottom;
}
Program: 110072
Project: 110072
Buggy source:
private int mpGetCurrentPosition(){
  if (null == mMp)   return 0;
switch (mpGetState()) {
case IDLE:
case INITIALIZED:
case PREPARED_AUDIO:
case PREPARED:
case STARTED:
case PAUSED:
case STOPPED:
case PLAYBACK_COMPLETED:
    return mMp.getCurrentPosition();
}
logI("String_Node_Str" + mpGetState().name() + "String_Node_Str");
return 0;
}

Fixed version (ground truth):
private int mpGetCurrentPosition(){
  if (null == mMp)   return 0;
switch (mpGetState()) {
case PREPARED_AUDIO:
case PREPARED:
case STARTED:
case PAUSED:
case STOPPED:
case PLAYBACK_COMPLETED:
    return mMp.getCurrentPosition();
}
logI("String_Node_Str" + mpGetState().name() + "String_Node_Str");
return 0;
}
Program: 110073
Project: 110073
Buggy source:
private void addCheckedMusicsToPlaylist(final long plid){
  final YTVideoSearchAdapter adpr=getAdapter();
  final int[] checkedItems=adpr.getCheckedItemPositions();
  for (  int i : checkedItems) {
    if (null == adpr.getItemThumbnail(i)) {
      UiUtils.showTextToast(this,R.string.msg_no_all_thumbnail);
      return;
    }
  }
  DiagAsyncTask.Worker worker=new DiagAsyncTask.Worker(){
    private int failedCnt=0;
    @Override public void onPostExecute(    DiagAsyncTask task,    Err result){
      adpr.cleanItemCheck();
      if (failedCnt > 0) {
        CharSequence msg=getResources().getText(R.string.msg_fails_to_add);
        UiUtils.showTextToast(YTVideoSearchActivity.this,msg + "String_Node_Str" + failedCnt);
      }
    }
    @Override public void onCancel(    DiagAsyncTask task){
    }
    @Override public Err doBackgroundWork(    DiagAsyncTask task,    Object... objs){
      mDb.beginTransaction();
      try {
        for (        int i : checkedItems) {
          int r=addToPlaylist(plid,i,adpr.getItemVolume(i));
          if (0 != r && R.string.msg_existing_muisc != r)           failedCnt++;
        }
        mDb.setTransactionSuccessful();
      }
  finally {
        mDb.endTransaction();
      }
      return Err.NO_ERR;
    }
  }
;
  new DiagAsyncTask(YTVideoSearchActivity.this,worker,DiagAsyncTask.Style.SPIN,R.string.adding,false).execute();
}

Fixed version (ground truth):
private void addCheckedMusicsToPlaylist(final long plid){
  final YTVideoSearchAdapter adpr=getAdapter();
  final int[] checkedItems=adpr.getCheckedItemPositions();
  final int[] itemVolumes=new int[checkedItems.length];
  for (int i=0; i < checkedItems.length; i++) {
    int pos=checkedItems[i];
    if (null == adpr.getItemThumbnail(pos)) {
      UiUtils.showTextToast(this,R.string.msg_no_all_thumbnail);
      return;
    }
    itemVolumes[i]=adpr.getItemVolume(pos);
  }
  DiagAsyncTask.Worker worker=new DiagAsyncTask.Worker(){
    private int failedCnt=0;
    @Override public void onPostExecute(    DiagAsyncTask task,    Err result){
      adpr.cleanItemCheck();
      if (failedCnt > 0) {
        CharSequence msg=getResources().getText(R.string.msg_fails_to_add);
        UiUtils.showTextToast(YTVideoSearchActivity.this,msg + "String_Node_Str" + failedCnt);
      }
    }
    @Override public void onCancel(    DiagAsyncTask task){
    }
    @Override public Err doBackgroundWork(    DiagAsyncTask task,    Object... objs){
      mDb.beginTransaction();
      try {
        for (int i=0; i < checkedItems.length; i++) {
          int pos=checkedItems[i];
          int r=addToPlaylist(plid,pos,itemVolumes[i]);
          if (0 != r && R.string.msg_existing_muisc != r)           failedCnt++;
        }
        mDb.setTransactionSuccessful();
      }
  finally {
        mDb.endTransaction();
      }
      return Err.NO_ERR;
    }
  }
;
  new DiagAsyncTask(this,worker,DiagAsyncTask.Style.SPIN,R.string.adding,false).execute();
}
Program: 110074
Project: 110074
Buggy source:
@Override public Err doBackgroundWork(DiagAsyncTask task,Object... objs){
  mDb.beginTransaction();
  try {
    for (    int i : checkedItems) {
      int r=addToPlaylist(plid,i,adpr.getItemVolume(i));
      if (0 != r && R.string.msg_existing_muisc != r)       failedCnt++;
    }
    mDb.setTransactionSuccessful();
  }
  finally {
    mDb.endTransaction();
  }
  return Err.NO_ERR;
}

Fixed version (ground truth):
@Override public Err doBackgroundWork(DiagAsyncTask task,Object... objs){
  mDb.beginTransaction();
  try {
    for (int i=0; i < checkedItems.length; i++) {
      int pos=checkedItems[i];
      int r=addToPlaylist(plid,pos,itemVolumes[i]);
      if (0 != r && R.string.msg_existing_muisc != r)       failedCnt++;
    }
    mDb.setTransactionSuccessful();
  }
  finally {
    mDb.endTransaction();
  }
  return Err.NO_ERR;
}
Program: 110075
Project: 110075
Buggy source:
@Override public void onClick(DialogInterface dialog,int which){
  eAssert(which >= 0);
  dialog.dismiss();
  if (userMenus.length > which) {
    action.onUserMenu(which,user);
  }
 else   if (userMenus.length == which) {
    UiUtils.EditTextAction edAction=new UiUtils.EditTextAction(){
      @Override public void prepare(      Dialog dialog,      EditText edit){
      }
      @Override public void onOk(      Dialog dialog,      EditText edit){
        String title=edit.getText().toString();
        if (db.containsPlaylist(title)) {
          UiUtils.showTextToast(context,R.string.msg_existing_playlist);
          return;
        }
        long plid=db.insertPlaylist(title,"String_Node_Str");
        if (plid < 0) {
          UiUtils.showTextToast(context,R.string.err_db_unknown);
          return;
        }
        action.onPlaylist(plid,user);
      }
    }
;
    AlertDialog diag=UiUtils.buildOneLineEditTextDialog(context,R.string.enter_playlist_title,R.string.enter_playlist_title,edAction);
    diag.show();
  }
 else   action.onPlaylist(ids[which],user);
}

Fixed version (ground truth):
@Override public void onClick(DialogInterface dialog,int which){
  eAssert(which >= 0);
  dialog.dismiss();
  if (userMenus.length > which) {
    action.onUserMenu(which,user);
  }
 else   if (userMenus.length == which) {
    UiUtils.EditTextAction edAction=new UiUtils.EditTextAction(){
      @Override public void prepare(      Dialog dialog,      EditText edit){
      }
      @Override public void onOk(      Dialog dialog,      EditText edit){
        String title=edit.getText().toString();
        if (db.containsPlaylist(title)) {
          UiUtils.showTextToast(context,R.string.msg_existing_playlist);
          return;
        }
        long plid=db.insertPlaylist(title,"String_Node_Str");
        if (plid < 0) {
          UiUtils.showTextToast(context,R.string.err_db_unknown);
          return;
        }
        action.onPlaylist(plid,user);
      }
    }
;
    UiUtils.buildOneLineEditTextDialog(context,R.string.enter_playlist_title,R.string.enter_playlist_title,edAction).show();
  }
 else   action.onPlaylist(ids[which],user);
}
Program: 110077
Project: 110077
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.videoplayer);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  mSurfv=(SurfaceView)findViewById(R.id.surface);
  mMp.setSurfaceHolder(mSurfv.getHolder());
  findViewById(R.id.touch_ground).setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      ViewGroup playerv=(ViewGroup)findViewById(R.id.player);
      if (View.GONE == playerv.getVisibility())       showController();
 else       hideController();
    }
  }
);
  mMp.addPlayerStateListener(this,this);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.videoplayer);
  mSurfv=(SurfaceView)findViewById(R.id.surface);
  mMp.setSurfaceHolder(mSurfv.getHolder());
  findViewById(R.id.touch_ground).setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      ViewGroup playerv=(ViewGroup)findViewById(R.id.player);
      if (View.GONE == playerv.getVisibility())       showController();
 else       hideController();
    }
  }
);
  if (mMp.hasActiveVideo())   getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  mMp.addPlayerStateListener(this,this);
  mMp.addVideosStateListener(this,this);
}
Program: 110078
Project: 110078
Buggy source:
@Override protected void onDestroy(){
  mMp.unsetSurfaceHolder(mSurfv.getHolder());
  mMp.removePlayerStateListener(this);
  super.onDestroy();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  mMp.unsetSurfaceHolder(mSurfv.getHolder());
  mMp.removePlayerStateListener(this);
  mMp.removeVideosStateListener(this);
  super.onDestroy();
}
Program: 110079
Project: 110079
Buggy source:
@Override public void onStateChanged(YTPlayer.MPState from,YTPlayer.MPState to){
switch (to) {
case IDLE:
    showLoadingSpinProgress();
  break;
case STOPPED:
case STARTED:
case PAUSED:
hideLoadingSpinProgress();
}
}

Fixed version (ground truth):
@Override public void onStateChanged(YTPlayer.MPState from,YTPlayer.MPState to){
switch (to) {
case IDLE:
    showLoadingSpinProgress();
  break;
case PREPARED:
case STOPPED:
case ERROR:
hideLoadingSpinProgress();
break;
}
}
Program: 110080
Project: 110080
Buggy source:
private File getCachedVideo(String ytvid){
  return new File(Policy.APPDATA_CACHEDIR + ytvid + "String_Node_Str");
}

Fixed version (ground truth):
private static File getCachedVideo(String ytvid){
  return new File(getCachedVideoFilePath(ytvid,Utils.getPrefQuality()));
}
Program: 110081
Project: 110081
Buggy source:
private void cleanCache(boolean allClear){
  if (!mVlm.hasActiveVideo())   return;
  HashSet<String> skipSet=new HashSet<String>();
  if (!allClear) {
    skipSet.add(sCacheDir.getAbsolutePath());
    skipSet.add(getCachedVideo(mVlm.getActiveVideo().videoId).getAbsolutePath());
    Video nextVid=mVlm.getNextVideo();
    if (null != nextVid)     skipSet.add(getCachedVideo(nextVid.videoId).getAbsolutePath());
  }
  Utils.removeFileRecursive(sCacheDir,skipSet);
}

Fixed version (ground truth):
private void cleanCache(boolean allClear){
  if (!mVlm.hasActiveVideo())   return;
  HashSet<String> skipSet=new HashSet<String>();
  if (!allClear) {
    skipSet.add(sCacheDir.getAbsolutePath());
    for (    Utils.PrefQuality pq : Utils.PrefQuality.values()) {
      skipSet.add(new File(getCachedVideoFilePath(mVlm.getActiveVideo().videoId,pq)).getAbsolutePath());
      Video nextVid=mVlm.getNextVideo();
      if (null != nextVid)       skipSet.add(new File(getCachedVideoFilePath(nextVid.videoId,pq)).getAbsolutePath());
    }
  }
  Utils.removeFileRecursive(sCacheDir,skipSet);
}
Program: 110082
Project: 110082
Buggy source:
private void prepareCachedVideo(File cachedVid){
  logI("String_Node_Str" + cachedVid.getAbsolutePath());
  try {
    mpSetDataSource(cachedVid.getAbsolutePath());
    mpSetVideoSurface(mSurfHolder);
  }
 catch (  IOException e) {
    cleanCache(true);
    logW("String_Node_Str" + e.getMessage());
    mStartVideoRecovery.executeRecoveryStart(mVlm.getActiveVideo());
  }
  mpPrepareAsync();
  prepareNext();
}

Fixed version (ground truth):
private void prepareCachedVideo(File cachedVid){
  logI("String_Node_Str" + cachedVid.getAbsolutePath());
  try {
    mpSetDataSource(cachedVid.getAbsolutePath());
  }
 catch (  IOException e) {
    cleanCache(true);
    logW("String_Node_Str" + e.getMessage());
    mStartVideoRecovery.executeRecoveryStart(mVlm.getActiveVideo());
    return;
  }
  final MediaPlayer mp=mpGet();
  Utils.getUiHandler().post(new Runnable(){
    private int retry=20;
    @Override public void run(){
      if (mp != mpGet())       return;
      if (retry < 0) {
        logW("String_Node_Str");
        mpStop();
        return;
      }
      if (null == mSurfHolder || isSurfaceReady()) {
        mpSetVideoSurface(mSurfHolder);
        mpPrepareAsync();
      }
 else {
        --retry;
        Utils.getUiHandler().postDelayed(this,100);
      }
    }
  }
);
  prepareNext();
}
Program: 110083
Project: 110083
Buggy source:
@Override protected void onDestroy(){
  mMp.unsetController(this);
  super.onDestroy();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  super.onDestroy();
}
Program: 110084
Project: 110084
Buggy source:
@Override protected void onPause(){
  mMp.unsetController(this);
  super.onPause();
}

Fixed version (ground truth):
@Override protected void onPause(){
  mMp.backupPlayerState();
  mMp.unsetController(this);
  super.onPause();
}
Program: 110085
Project: 110085
Buggy source:
private void storePlayerState(){
  if (null == mMp)   return;
  clearStoredPlayerState();
switch (mpGetState()) {
case STARTED:
case PAUSED:
    mStoredPState=new PlayerState();
  mStoredPState.pos=mpGetCurrentPosition();
mStoredPState.vol=mpGetVolume();
mStoredPState.mpState=mpGetState();
break;
}
}

Fixed version (ground truth):
private void storePlayerState(){
  if (null == mMp)   return;
  clearStoredPlayerState();
switch (mpGetState()) {
case STARTED:
case PAUSED:
    mStoredPState=new PlayerState();
  mStoredPState.vidobj=mVlm.getActiveVideo();
mStoredPState.pos=mpGetCurrentPosition();
mStoredPState.vol=mpGetVolume();
mStoredPState.mpState=mpGetState();
break;
}
}
Program: 110086
Project: 110086
Buggy source:
private void setVideoSurface(SurfaceView surfv){
  if (null == surfv)   return;
  SurfaceHolder holder=(null == surfv) ? null : surfv.getHolder();
  mpSetVideoSurface(holder);
  int vw=mpGetVideoWidth();
  int vh=mpGetVideoHeight();
  if (0 >= vw || 0 >= vh)   return;
  int sw=((WindowManager)Utils.getAppContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
  int sh=((WindowManager)Utils.getAppContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight();
  int[] sz=new int[2];
  Utils.fitFixedRatio(sw,sh,vw,vh,sz);
  ViewGroup.LayoutParams lp=surfv.getLayoutParams();
  lp.width=sz[0];
  lp.height=sz[1];
  surfv.setLayoutParams(lp);
  surfv.requestLayout();
}

Fixed version (ground truth):
private void setVideoSurface(SurfaceView surfv){
  if (null == surfv)   return;
  SurfaceHolder holder=(null == surfv) ? null : surfv.getHolder();
  int vw=mpGetVideoWidth();
  int vh=mpGetVideoHeight();
  if (0 >= vw || 0 >= vh)   return;
  int sw=((WindowManager)Utils.getAppContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
  int sh=((WindowManager)Utils.getAppContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight();
  int[] sz=new int[2];
  Utils.fitFixedRatio(sw,sh,vw,vh,sz);
  ViewGroup.LayoutParams lp=surfv.getLayoutParams();
  lp.width=sz[0];
  lp.height=sz[1];
  surfv.setLayoutParams(lp);
  surfv.requestLayout();
  mpSetVideoSurface(holder);
}
Program: 110087
Project: 110087
Buggy source:
private void restorePlayerState(){
  if (!haveStoredPlayerState())   return;
  mpSeekTo(mStoredPState.pos);
  mpSetVolume(mStoredPState.vol);
  clearStoredPlayerState();
}

Fixed version (ground truth):
private void restorePlayerState(){
  if (!haveStoredPlayerState())   return;
  if (mVlm.getActiveVideo() == mStoredPState.vidobj) {
    mpSeekTo(mStoredPState.pos);
    mpSetVolume(mStoredPState.vol);
  }
  clearStoredPlayerState();
}
Program: 110088
Project: 110088
Buggy source:
@Override public void onClick(View v){
  if (!mMp.hasActiveVideo() || null == mVActivity)   return;
  mMp.prepareTransitionMPMode();
  mVActivity.startActivity(new Intent(mVActivity,VideoPlayerActivity.class));
}

Fixed version (ground truth):
@Override public void onClick(View v){
  if (!mMp.hasActiveVideo() || null == mVActivity)   return;
  mMp.backupPlayerState();
  mVActivity.startActivity(new Intent(mVActivity,VideoPlayerActivity.class));
}
Program: 110091
Project: 110091
Buggy source:
private void pvConfigureTitle(TextView titlev,YTPlayer.MPState from,YTPlayer.MPState to){
  if (null == titlev)   return;
  CharSequence videoTitle="String_Node_Str";
  if (mMp.hasActiveVideo())   videoTitle=mMp.getActiveVideo().title;
switch (to) {
case BUFFERING:
{
      eAssert(null != videoTitle);
      pvSetTitle(titlev,"String_Node_Str" + mRes.getText(R.string.buffering) + "String_Node_Str"+ videoTitle);
    }
  break;
case PREPARED:
case PAUSED:
case STARTED:
eAssert(null != videoTitle);
if (null != videoTitle) pvSetTitle(titlev,videoTitle);
break;
case ERROR:
pvSetTitle(titlev,mRes.getText(R.string.msg_ytplayer_err));
break;
default :
if (Utils.isValidValue(videoTitle)) pvSetTitle(titlev,"String_Node_Str" + mRes.getText(R.string.preparing) + "String_Node_Str"+ videoTitle);
 else pvSetTitle(titlev,mRes.getText(R.string.msg_preparing_mplayer));
}
}

Fixed version (ground truth):
private void pvConfigureTitle(TextView titlev,YTPlayer.MPState from,YTPlayer.MPState to){
  if (null == titlev)   return;
  CharSequence videoTitle="String_Node_Str";
  if (mMp.hasActiveVideo())   videoTitle=mMp.getActiveVideo().title;
switch (to) {
case BUFFERING:
{
      eAssert(null != videoTitle);
      pvSetTitle(titlev,"String_Node_Str" + mRes.getText(R.string.buffering) + "String_Node_Str"+ videoTitle);
    }
  break;
case PREPARED:
case PAUSED:
case STARTED:
eAssert(null != videoTitle);
if (null != videoTitle) pvSetTitle(titlev,videoTitle);
break;
case ERROR:
pvSetTitle(titlev,mRes.getText(R.string.msg_ytplayer_err));
break;
default :
if (Utils.isValidValue(videoTitle)) pvSetTitle(titlev,"String_Node_Str" + mRes.getText(R.string.preparing) + "String_Node_Str"+ videoTitle);
 else pvSetTitle(titlev,"String_Node_Str");
}
}