nus-yam/ex-repair huggingface dataset:
Program: 62831
Project: 62831
Buggy source:
@Override public void onCreate(){
  super.onCreate();
  instance=this;
  mSettings=PreferenceManager.getDefaultSharedPreferences(this);
  String p=mSettings.getString("String_Node_Str","String_Node_Str");
  if (!p.equals("String_Node_Str")) {
    Locale locale;
    if (p.equals("String_Node_Str")) {
      locale=Locale.TRADITIONAL_CHINESE;
    }
 else     if (p.startsWith("String_Node_Str")) {
      locale=Locale.CHINA;
    }
 else     if (p.equals("String_Node_Str")) {
      locale=new Locale("String_Node_Str","String_Node_Str");
    }
 else     if (p.equals("String_Node_Str") || p.startsWith("String_Node_Str")) {
      locale=new Locale("String_Node_Str","String_Node_Str");
    }
 else {
      if (p.contains("String_Node_Str"))       p=p.substring(0,p.indexOf('-'));
      locale=new Locale(p);
    }
    Locale.setDefault(locale);
    Configuration config=new Configuration();
    config.locale=locale;
    getResources().updateConfiguration(config,getResources().getDisplayMetrics());
  }
  runBackground(new Runnable(){
    @Override public void run(){
      AudioUtil.prepareCacheFolder(instance);
      sTV=AndroidDevices.isAndroidTv() || !AndroidDevices.hasTsp();
      if (!VLCInstance.testCompatibleCPU(instance))       return;
      Dialog.setCallbacks(VLCInstance.get(),mDialogCallbacks);
      if (!AndroidDevices.hasTsp())       AndroidDevices.setRemoteControlReceiverEnabled(false);
    }
  }
);
}

Fixed version (ground truth):
@Override public void onCreate(){
  super.onCreate();
  instance=this;
  mSettings=PreferenceManager.getDefaultSharedPreferences(this);
  setLocale(this);
  runBackground(new Runnable(){
    @Override public void run(){
      AudioUtil.prepareCacheFolder(instance);
      sTV=AndroidDevices.isAndroidTv() || !AndroidDevices.hasTsp();
      if (!VLCInstance.testCompatibleCPU(instance))       return;
      Dialog.setCallbacks(VLCInstance.get(),mDialogCallbacks);
      if (!AndroidDevices.hasTsp())       AndroidDevices.setRemoteControlReceiverEnabled(false);
    }
  }
);
}
Program: 62832
Project: 62832
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  if (getActivity() instanceof AppCompatActivity)   ((AppCompatActivity)getActivity()).getSupportActionBar().setTitle("String_Node_Str" + BuildConfig.VERSION_NAME);
  View v=inflater.inflate(R.layout.about,container,false);
  View aboutMain=v.findViewById(R.id.about_main);
  WebView webView=(WebView)v.findViewById(R.id.webview);
  String revision=getString(R.string.build_revision);
  webView.loadData(Util.readAsset("String_Node_Str","String_Node_Str").replace("String_Node_Str",revision),"String_Node_Str","String_Node_Str");
  UiTools.fillAboutView(v);
  View[] lists=new View[]{aboutMain,webView};
  String[] titles=new String[]{getString(R.string.about),getString(R.string.licence)};
  mViewPager=(ViewPager)v.findViewById(R.id.pager);
  mViewPager.setOffscreenPageLimit(MODE_TOTAL - 1);
  mViewPager.setAdapter(new AudioPagerAdapter(lists,titles));
  mTabLayout=(TabLayout)v.findViewById(R.id.sliding_tabs);
  mTabLayout.setupWithViewPager(mViewPager);
  return v;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  if (getActivity() instanceof AppCompatActivity)   ((AppCompatActivity)getActivity()).getSupportActionBar().setTitle("String_Node_Str" + BuildConfig.VERSION_NAME);
  View v=inflater.inflate(R.layout.about,container,false);
  if (AndroidUtil.isNougatOrLater)   VLCApplication.setLocale(getContext());
  View aboutMain=v.findViewById(R.id.about_main);
  WebView webView=(WebView)v.findViewById(R.id.webview);
  String revision=getString(R.string.build_revision);
  webView.loadData(Util.readAsset("String_Node_Str","String_Node_Str").replace("String_Node_Str",revision),"String_Node_Str","String_Node_Str");
  UiTools.fillAboutView(v);
  View[] lists=new View[]{aboutMain,webView};
  String[] titles=new String[]{getString(R.string.about),getString(R.string.licence)};
  mViewPager=(ViewPager)v.findViewById(R.id.pager);
  mViewPager.setOffscreenPageLimit(MODE_TOTAL - 1);
  mViewPager.setAdapter(new AudioPagerAdapter(lists,titles));
  mTabLayout=(TabLayout)v.findViewById(R.id.sliding_tabs);
  mTabLayout.setupWithViewPager(mViewPager);
  return v;
}
Program: 62834
Project: 62834
Buggy source:
private void onPlaying(){
  mIsPlaying=true;
  stopLoading();
  updateOverlayPausePlay();
  updateNavStatus();
  if (!mService.getCurrentMediaWrapper().hasFlag(MediaWrapper.MEDIA_PAUSED))   mHandler.sendEmptyMessageDelayed(FADE_OUT,OVERLAY_TIMEOUT);
  setESTracks();
}

Fixed version (ground truth):
private void onPlaying(){
  mIsPlaying=true;
  stopLoading();
  updateOverlayPausePlay();
  updateNavStatus();
  if (!mService.getCurrentMediaWrapper().hasFlag(MediaWrapper.MEDIA_PAUSED))   mHandler.sendEmptyMessageDelayed(FADE_OUT,OVERLAY_TIMEOUT);
 else {
    mService.getCurrentMediaWrapper().removeFlags(MediaWrapper.MEDIA_PAUSED);
    mWasPaused=false;
  }
  setESTracks();
}
Program: 62835
Project: 62835
Buggy source:
@Override public void run(){
  mPlaylistAdapter.clear();
}

Fixed version (ground truth):
@Override public void run(){
  ArrayList<AudioBrowserListAdapter.ListItem> dbPlaylists=mMediaLibrary.getPlaylistDbItems();
  mPlaylistAdapter.addAllDBPlaylists(dbPlaylists);
  ArrayList<MediaWrapper> playlists=mMediaLibrary.getPlaylistFilesItems();
  mPlaylistAdapter.addAll(playlists,AudioBrowserListAdapter.TYPE_PLAYLISTS);
  mAdaptersToNotify.add(mPlaylistAdapter);
  if (mReadyToDisplay && !mDisplaying)   display();
}
Program: 62836
Project: 62836
Buggy source:
@Override public void onResume(){
  super.onResume();
  mMainActivity=(MainActivity)getActivity();
  mViewPager.addOnPageChangeListener(this);
  if (mMediaLibrary.isWorking())   mHandler.sendEmptyMessageDelayed(MSG_LOADING,300);
 else   if (mGenresAdapter.isEmpty() || mArtistsAdapter.isEmpty() || mAlbumsAdapter.isEmpty()|| mSongsAdapter.isEmpty())   updateLists();
 else {
    updateEmptyView(mViewPager.getCurrentItem());
  }
  mMediaLibrary.addUpdateHandler(mHandler);
  mMediaLibrary.setBrowser(this);
  final ListView current=(ListView)mLists.get(mViewPager.getCurrentItem());
  current.post(new Runnable(){
    @Override public void run(){
      mSwipeRefreshLayout.setEnabled(current.getFirstVisiblePosition() == 0);
    }
  }
);
  updatePlaylists();
}

Fixed version (ground truth):
@Override public void onResume(){
  super.onResume();
  mMainActivity=(MainActivity)getActivity();
  mViewPager.addOnPageChangeListener(this);
  if (mMediaLibrary.isWorking())   mHandler.sendEmptyMessageDelayed(MSG_LOADING,300);
 else   if (mGenresAdapter.isEmpty() || mArtistsAdapter.isEmpty() || mAlbumsAdapter.isEmpty()|| mSongsAdapter.isEmpty())   updateLists();
 else {
    updateEmptyView(mViewPager.getCurrentItem());
    updatePlaylists();
  }
  mMediaLibrary.addUpdateHandler(mHandler);
  mMediaLibrary.setBrowser(this);
  final ListView current=(ListView)mLists.get(mViewPager.getCurrentItem());
  current.post(new Runnable(){
    @Override public void run(){
      mSwipeRefreshLayout.setEnabled(current.getFirstVisiblePosition() == 0);
    }
  }
);
}
Program: 62837
Project: 62837
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mAdapter=new AudioBrowserListAdapter(getActivity(),AudioBrowserListAdapter.ITEM_WITHOUT_COVER);
  mAdapter.addAll(MediaLibrary.getInstance().getPlaylistDbItems());
  mTracks=getArguments().getParcelableArrayList(KEY_TRACKS);
  mNewTrack=getArguments().getParcelableArrayList(KEY_NEW_TRACKS);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mAdapter=new AudioBrowserListAdapter(getActivity(),AudioBrowserListAdapter.ITEM_WITHOUT_COVER);
  mAdapter.addAllDBPlaylists(MediaLibrary.getInstance().getPlaylistDbItems());
  mTracks=getArguments().getParcelableArrayList(KEY_TRACKS);
  mNewTrack=getArguments().getParcelableArrayList(KEY_NEW_TRACKS);
}
Program: 62838
Project: 62838
Buggy source:
public void changeSpeed(float delta){
  float rate=Math.round((mService.getRate() + delta) * 100f) / 100f;
  if (rate < 0.25f || rate > 4f)   return;
  mService.setRate(rate);
  mInfo.setText(getString(R.string.spu_delay) + "String_Node_Str" + rate+ "String_Node_Str");
  if (mPlaybackSetting == DelayState.OFF) {
    mPlaybackSetting=DelayState.SPEED;
    initPlaybackSettingInfo();
  }
}

Fixed version (ground truth):
public void changeSpeed(float delta){
  float rate=Math.round((mService.getRate() + delta) * 100f) / 100f;
  if (rate < 0.25f || rate > 4f)   return;
  mService.setRate(rate);
  mInfo.setText(getString(R.string.playback_speed) + "String_Node_Str" + rate+ "String_Node_Str");
  if (mPlaybackSetting == DelayState.OFF) {
    mPlaybackSetting=DelayState.SPEED;
    initPlaybackSettingInfo();
  }
}
Program: 62839
Project: 62839
Buggy source:
private void handleHardwareAccelerationError(){
  mHardwareAccelerationError=true;
  if (mSwitchingView)   return;
  Toast.makeText(this,R.string.hardware_acceleration_error,Toast.LENGTH_LONG).show();
  final boolean wasPaused=!mService.isPlaying();
  final long oldTime=mService.getTime();
  mService.stop();
  if (!isFinishing()) {
    final MediaWrapper mw=new MediaWrapper(mUri);
    if (wasPaused)     mw.addFlags(MediaWrapper.MEDIA_PAUSED);
    mw.addFlags(MediaWrapper.MEDIA_NO_HWACCEL);
    mw.addFlags(MediaWrapper.MEDIA_VIDEO);
    mService.load(mw);
    if (oldTime > 0)     seek(oldTime);
  }
}

Fixed version (ground truth):
private void handleHardwareAccelerationError(){
  mHardwareAccelerationError=true;
  if (mSwitchingView)   return;
  Toast.makeText(this,R.string.hardware_acceleration_error,Toast.LENGTH_LONG).show();
  final boolean wasPaused=!mService.isPlaying();
  final long oldTime=mService.getTime();
  int position=mService.getCurrentMediaPosition();
  List<MediaWrapper> list=new ArrayList<>(mService.getMedias());
  final MediaWrapper mw=list.get(position);
  mService.stop();
  if (!isFinishing()) {
    if (wasPaused)     mw.addFlags(MediaWrapper.MEDIA_PAUSED);
    mw.addFlags(MediaWrapper.MEDIA_NO_HWACCEL);
    mw.addFlags(MediaWrapper.MEDIA_VIDEO);
    mService.load(list,position);
    if (oldTime > 0)     seek(oldTime);
  }
}
Program: 62840
Project: 62840
Buggy source:
private void handleHardwareAccelerationError(){
  mHardwareAccelerationError=true;
  if (mSwitchingView)   return;
  Toast.makeText(this,R.string.hardware_acceleration_error,Toast.LENGTH_LONG).show();
  mService.removeCallback(this);
  mService.stop();
  if (!isFinishing())   loadMedia();
}

Fixed version (ground truth):
private void handleHardwareAccelerationError(){
  mHardwareAccelerationError=true;
  if (mSwitchingView)   return;
  Toast.makeText(this,R.string.hardware_acceleration_error,Toast.LENGTH_LONG).show();
  final boolean wasPaused=!mService.isPlaying();
  final long oldTime=mService.getTime();
  mService.stop();
  if (!isFinishing()) {
    final MediaWrapper mw=new MediaWrapper(mUri);
    if (wasPaused)     mw.addFlags(MediaWrapper.MEDIA_PAUSED);
    mw.addFlags(MediaWrapper.MEDIA_NO_HWACCEL);
    mw.addFlags(MediaWrapper.MEDIA_VIDEO);
    mService.load(mw);
    if (oldTime > 0)     seek(oldTime);
  }
}
Program: 62841
Project: 62841
Buggy source:
private void fadeOutInfo(){
  if (mInfo.getVisibility() == View.VISIBLE)   mInfo.startAnimation(AnimationUtils.loadAnimation(VideoPlayerActivity.this,android.R.anim.fade_out));
  mInfo.setVisibility(View.INVISIBLE);
  if (mPresentation == null) {
    if (mVerticalBar.getVisibility() == View.VISIBLE)     mVerticalBar.startAnimation(AnimationUtils.loadAnimation(VideoPlayerActivity.this,android.R.anim.fade_out));
    mVerticalBar.setVisibility(View.INVISIBLE);
  }
}

Fixed version (ground truth):
private void fadeOutInfo(){
  if (mInfo.getVisibility() == View.VISIBLE)   mInfo.startAnimation(AnimationUtils.loadAnimation(VideoPlayerActivity.this,android.R.anim.fade_out));
  mInfo.setVisibility(View.INVISIBLE);
  if (mPresentation == null) {
    if (mVerticalBar.getVisibility() == View.VISIBLE) {
      mVerticalBar.startAnimation(AnimationUtils.loadAnimation(VideoPlayerActivity.this,android.R.anim.fade_out));
      mVerticalBar.setVisibility(View.INVISIBLE);
    }
  }
}
Program: 62844
Project: 62844
Buggy source:
public static String[] getStorageDirectories(){
  String[] dirs=null;
  BufferedReader bufReader=null;
  try {
    bufReader=new BufferedReader(new FileReader("String_Node_Str"));
    ArrayList<String> list=new ArrayList<String>();
    list.add(Environment.getExternalStorageDirectory().getPath());
    String line;
    while ((line=bufReader.readLine()) != null) {
      if (line.contains("String_Node_Str") || line.contains("String_Node_Str") || line.contains("String_Node_Str")|| line.contains("String_Node_Str")) {
        StringTokenizer tokens=new StringTokenizer(line,"String_Node_Str");
        String s=tokens.nextToken();
        s=tokens.nextToken();
        if (list.contains(s))         continue;
        if (line.contains("String_Node_Str")) {
          if (!line.startsWith("String_Node_Str") && !line.startsWith("String_Node_Str") && !s.startsWith("String_Node_Str")&& !s.startsWith("String_Node_Str")&& !s.startsWith("String_Node_Str")&& !s.startsWith("String_Node_Str")) {
            list.add(s);
          }
        }
      }
    }
    dirs=new String[list.size()];
    for (int i=0; i < list.size(); i++) {
      dirs[i]=list.get(i);
    }
  }
 catch (  FileNotFoundException e) {
  }
catch (  IOException e) {
  }
 finally {
    if (bufReader != null) {
      try {
        bufReader.close();
      }
 catch (      IOException e) {
      }
    }
  }
  return dirs;
}

Fixed version (ground truth):
public static String[] getStorageDirectories(){
  String[] dirs=null;
  BufferedReader bufReader=null;
  try {
    bufReader=new BufferedReader(new FileReader("String_Node_Str"));
    ArrayList<String> list=new ArrayList<String>();
    list.add(Environment.getExternalStorageDirectory().getPath());
    String line;
    while ((line=bufReader.readLine()) != null) {
      if (line.contains("String_Node_Str") || line.contains("String_Node_Str") || line.contains("String_Node_Str")|| line.contains("String_Node_Str")|| line.contains("String_Node_Str")) {
        StringTokenizer tokens=new StringTokenizer(line,"String_Node_Str");
        String s=tokens.nextToken();
        s=tokens.nextToken();
        if (list.contains(s))         continue;
        if (line.contains("String_Node_Str")) {
          if (!line.startsWith("String_Node_Str") && !line.startsWith("String_Node_Str") && !s.startsWith("String_Node_Str")&& !s.startsWith("String_Node_Str")&& !s.startsWith("String_Node_Str")&& !s.startsWith("String_Node_Str")) {
            list.add(s);
          }
        }
      }
    }
    dirs=new String[list.size()];
    for (int i=0; i < list.size(); i++) {
      dirs[i]=list.get(i);
    }
  }
 catch (  FileNotFoundException e) {
  }
catch (  IOException e) {
  }
 finally {
    if (bufReader != null) {
      try {
        bufReader.close();
      }
 catch (      IOException e) {
      }
    }
  }
  return dirs;
}
Program: 62846
Project: 62846
Buggy source:
private static void insertInto(ArrayList<MediaGroup> groups,Media media){
  for (  MediaGroup mediaGroup : groups) {
    CharSequence group=mediaGroup.getTitle();
    CharSequence item=media.getTitle();
    int commonLength=0;
    int minLength=Math.min(group.length(),item.length());
    while (commonLength < minLength && group.charAt(commonLength) == item.charAt(commonLength))     ++commonLength;
    if (commonLength == group.length())     mediaGroup.add(media);
 else     if (commonLength > 0 && commonLength < group.length() && commonLength > MIN_GROUP_LENGTH)     mediaGroup.merge(media,group.subSequence(0,commonLength).toString());
 else     continue;
    return;
  }
  groups.add(new MediaGroup(media));
}

Fixed version (ground truth):
private static void insertInto(ArrayList<MediaGroup> groups,Media media){
  for (  MediaGroup mediaGroup : groups) {
    CharSequence group=mediaGroup.getTitle();
    CharSequence item=media.getTitle();
    int commonLength=0;
    int minLength=Math.min(group.length(),item.length());
    while (commonLength < minLength && group.charAt(commonLength) == item.charAt(commonLength))     ++commonLength;
    if (commonLength == group.length() && mediaGroup.size() > 0)     mediaGroup.add(media);
 else     if (commonLength > 0 && (commonLength < group.length() || mediaGroup.size() == 0) && commonLength > MIN_GROUP_LENGTH)     mediaGroup.merge(media,group.subSequence(0,commonLength).toString());
 else     continue;
    return;
  }
  groups.add(new MediaGroup(media));
}
Program: 62847
Project: 62847
Buggy source:
@Override protected void onListItemClick(ListView l,View v,int position,long id){
  File file=mAdapter.getItem(position);
  if (file.getPath() == BrowserAdapter.ADD_ITEM_PATH) {
    AlertDialog.Builder b=new AlertDialog.Builder(this);
    final EditText input=new EditText(this);
    input.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    b.setTitle(R.string.add_custom_path);
    b.setMessage(R.string.add_custom_path_description);
    b.setView(input);
    b.setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface x,      int y){
        return;
      }
    }
);
    b.setPositiveButton(R.string.ok,new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        Util.addCustomDirectory(input.getText().toString());
        refresh();
      }
    }
);
    b.show();
    return;
  }
  File[] files=file.listFiles(new DirFilter());
  if (files != null && files.length > 0) {
    int index=l.getFirstVisiblePosition();
    int top=l.getChildAt(0).getTop();
    mScrollStates.push(new ScrollState(index,top));
    openDir(file);
  }
 else {
    Util.toaster(this,R.string.nosubdirectory);
  }
}

Fixed version (ground truth):
@Override protected void onListItemClick(ListView l,View v,int position,long id){
  File file=mAdapter.getItem(position);
  if (file.getPath().equals(BrowserAdapter.ADD_ITEM_PATH)) {
    AlertDialog.Builder b=new AlertDialog.Builder(this);
    final EditText input=new EditText(this);
    input.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    b.setTitle(R.string.add_custom_path);
    b.setMessage(R.string.add_custom_path_description);
    b.setView(input);
    b.setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface x,      int y){
        return;
      }
    }
);
    b.setPositiveButton(R.string.ok,new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        Util.addCustomDirectory(input.getText().toString());
        refresh();
      }
    }
);
    b.show();
    return;
  }
  File[] files=file.listFiles(new DirFilter());
  if (files != null && files.length > 0) {
    int index=l.getFirstVisiblePosition();
    int top=l.getChildAt(0).getTop();
    mScrollStates.push(new ScrollState(index,top));
    openDir(file);
  }
 else {
    Util.toaster(this,R.string.nosubdirectory);
  }
}
Program: 62848
Project: 62848
Buggy source:
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void showAdvanceFunction(View v){
  if (!Util.isHoneycombOrLater()) {
    registerForContextMenu(v);
    openContextMenu(v);
    return;
  }
  PopupMenu popupMenu=new PopupMenu(this,v);
  popupMenu.getMenuInflater().inflate(R.menu.player_overflow,popupMenu.getMenu());
  popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){
    @Override public boolean onMenuItemClick(    MenuItem item){
      return handleContextItemSelected(item);
    }
  }
);
  popupMenu.show();
}

Fixed version (ground truth):
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void showAdvanceFunction(View v){
  if (!Util.isHoneycombOrLater()) {
    registerForContextMenu(v);
    openContextMenu(v);
    return;
  }
  PopupMenu popupMenu=new PopupMenu(VLCApplication.getAppContext(),v);
  popupMenu.getMenuInflater().inflate(R.menu.player_overflow,popupMenu.getMenu());
  popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){
    @Override public boolean onMenuItemClick(    MenuItem item){
      return handleContextItemSelected(item);
    }
  }
);
  popupMenu.show();
}
Program: 62850
Project: 62850
Buggy source:
@Override public void onScrollStarted(){
  showOverlay(OVERLAY_INFINITE);
}

Fixed version (ground truth):
@Override public void onScrollStarted(){
  showOverlay(OVERLAY_INFINITE);
  setTracksAndSubtitles();
}
Program: 62854
Project: 62854
Buggy source:
@Override protected void onResume(){
  mAudioController.addAudioPlayer(mAudioPlayer);
  AudioServiceController.getInstance().bindAudioService(this);
  SharedPreferences sharedPrefs=getSharedPreferences("String_Node_Str",MODE_PRIVATE);
  mCurrentViewTab=sharedPrefs.getInt("String_Node_Str",VIDEO_TAB);
  mMediaLibraryActive=sharedPrefs.getBoolean("String_Node_Str",true);
  if (!mMediaLibraryActive)   showDirectoryView();
 else   if (mCurrentViewTab == AUDIO_TAB)   showAudioTab();
 else   showVideoTab();
  super.onResume();
}

Fixed version (ground truth):
@Override protected void onResume(){
  mAudioController.addAudioPlayer(mAudioPlayer);
  AudioServiceController.getInstance().bindAudioService(this);
  SharedPreferences sharedPrefs=getSharedPreferences("String_Node_Str",MODE_PRIVATE);
  mCurrentViewTab=sharedPrefs.getInt("String_Node_Str",VIDEO_TAB);
  mMediaLibraryActive=sharedPrefs.getBoolean("String_Node_Str",true);
  if (!mMediaLibraryActive)   showDirectoryView();
 else   if (getIntent().hasExtra(AudioService.START_FROM_NOTIFICATION) || mCurrentViewTab == AUDIO_TAB)   showAudioTab();
 else   showVideoTab();
  super.onResume();
}
Program: 62855
Project: 62855
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mAudioController=AudioServiceController.getInstance();
  mMediaLibrary=MediaLibrary.getInstance(getActivity());
  mMediaLibrary.addUpdateHandler(mHandler);
  mSongsAdapter=new AudioListAdapter(getActivity());
  setListAdapter(mSongsAdapter);
  mHandler.sendEmptyMessageDelayed(MediaLibrary.MEDIA_ITEMS_UPDATED,250);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mAudioController=AudioServiceController.getInstance();
  mMediaLibrary=MediaLibrary.getInstance(getActivity());
  mMediaLibrary.addUpdateHandler(mHandler);
  mSongsAdapter=new AudioListAdapter(getActivity());
  setListAdapter(mSongsAdapter);
}
Program: 62856
Project: 62856
Buggy source:
private void updateList(){
  final Bundle b=getArguments();
  String name=b.getString(EXTRA_NAME);
  String name2=b.getString(EXTRA_NAME2);
  int mode=b.getInt(EXTRA_MODE,0);
  List<Media> audioList;
  List<String> itemList;
  String currentItem=null;
  int currentIndex=-1;
  if (name == null || mode == AudioBrowserFragment.MODE_SONG) {
    mTitle.setText(R.string.songs);
    itemList=AudioServiceController.getInstance().getItems();
    currentItem=AudioServiceController.getInstance().getItem();
    audioList=MediaLibrary.getInstance(getActivity()).getMediaItems(itemList);
  }
 else {
    mTitle.setText(name2 != null ? name2 : name);
    audioList=MediaLibrary.getInstance(getActivity()).getAudioItems(name,name2,mode);
  }
  mSongsAdapter.clear();
switch (mSortBy) {
case SORT_BY_LENGTH:
    Collections.sort(audioList,byLength);
  break;
case SORT_BY_TITLE:
default :
Collections.sort(audioList,byMRL);
break;
}
if (mSortReverse) {
Collections.reverse(audioList);
}
for (int i=0; i < audioList.size(); i++) {
Media media=audioList.get(i);
if (currentItem != null && currentItem.equals(media.getLocation())) currentIndex=i;
mSongsAdapter.add(media);
}
mSongsAdapter.setCurrentIndex(currentIndex);
try {
getListView().setSelection(currentIndex);
}
 catch (IllegalStateException e) {
}
mSongsAdapter.notifyDataSetChanged();
}

Fixed version (ground truth):
private void updateList(){
  final Bundle b=getArguments();
  String name=b.getString(EXTRA_NAME);
  String name2=b.getString(EXTRA_NAME2);
  int mode=b.getInt(EXTRA_MODE,0);
  List<Media> audioList;
  List<String> itemList;
  String currentItem=null;
  int currentIndex=-1;
  if (name == null || mode == AudioBrowserFragment.MODE_SONG) {
    mTitle.setText(R.string.songs);
    itemList=AudioServiceController.getInstance().getItems();
    currentItem=AudioServiceController.getInstance().getItem();
    audioList=MediaLibrary.getInstance(getActivity()).getMediaItems(itemList);
  }
 else {
    mTitle.setText(name2 != null ? name2 : name);
    audioList=MediaLibrary.getInstance(getActivity()).getAudioItems(name,name2,mode);
  }
  mSongsAdapter.clear();
switch (mSortBy) {
case SORT_BY_LENGTH:
    Collections.sort(audioList,byLength);
  break;
case SORT_BY_TITLE:
default :
Collections.sort(audioList,byMRL);
break;
}
if (mSortReverse) {
Collections.reverse(audioList);
}
for (int i=0; i < audioList.size(); i++) {
Media media=audioList.get(i);
if (currentItem != null && currentItem.equals(media.getLocation())) currentIndex=i;
mSongsAdapter.add(media);
}
mSongsAdapter.setCurrentIndex(currentIndex);
getListView().setSelection(currentIndex);
mSongsAdapter.notifyDataSetChanged();
}
Program: 62857
Project: 62857
Buggy source:
/** 
 * Return true if there is a video track in the file
 */
private native long getLengthFromFile(int instance,String filePath);

Fixed version (ground truth):
/** 
 * Return the length of the stream, in milliseconds
 */
private native long getLengthFromFile(int instance,String filePath);
Program: 62858
Project: 62858
Buggy source:
private void init(){
  LayoutInflater layoutInflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View mMiniPlayerView=layoutInflater.inflate(R.layout.audio_player_mini,this,false);
  addView(mMiniPlayerView);
  mCover=(ImageView)findViewById(R.id.cover);
  mTitle=(TextView)findViewById(R.id.title);
  mArtist=(TextView)findViewById(R.id.artist);
  mPlayPause=(ImageButton)findViewById(R.id.play_pause);
  mForward=(ImageButton)findViewById(R.id.forward);
  mBackward=(ImageButton)findViewById(R.id.backward);
  mPlayPause.setOnClickListener(onMediaControlClickListener);
  mForward.setOnClickListener(onMediaControlClickListener);
  mBackward.setOnClickListener(onMediaControlClickListener);
  mSeekbar=(SeekBar)findViewById(R.id.timeline);
  this.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View view){
      Intent intent=new Intent(getContext(),AudioPlayerActivity.class);
      getContext().startActivity(intent);
    }
  }
);
  this.setOnLongClickListener(new OnLongClickListener(){
    @Override public boolean onLongClick(    View arg0){
      showContextMenu();
      return true;
    }
  }
);
}

Fixed version (ground truth):
private void init(){
  LayoutInflater layoutInflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View mMiniPlayerView=layoutInflater.inflate(R.layout.audio_player_mini,this,false);
  addView(mMiniPlayerView);
  mCover=(ImageView)findViewById(R.id.cover);
  mTitle=(TextView)findViewById(R.id.title);
  mArtist=(TextView)findViewById(R.id.artist);
  mPlayPause=(ImageButton)findViewById(R.id.play_pause);
  mForward=(ImageButton)findViewById(R.id.forward);
  mBackward=(ImageButton)findViewById(R.id.backward);
  mPlayPause.setOnClickListener(onMediaControlClickListener);
  mForward.setOnClickListener(onMediaControlClickListener);
  mBackward.setOnClickListener(onMediaControlClickListener);
  mSeekbar=(SeekBar)findViewById(R.id.timeline);
  lastTitle="String_Node_Str";
  this.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View view){
      Intent intent=new Intent(getContext(),AudioPlayerActivity.class);
      getContext().startActivity(intent);
    }
  }
);
  this.setOnLongClickListener(new OnLongClickListener(){
    @Override public boolean onLongClick(    View arg0){
      showContextMenu();
      return true;
    }
  }
);
}
Program: 62859
Project: 62859
Buggy source:
public void update(){
  if (mAudioPlayerControl != null) {
    if (mAudioPlayerControl.hasMedia()) {
      this.setVisibility(LinearLayout.VISIBLE);
    }
 else {
      this.setVisibility(LinearLayout.GONE);
      return;
    }
    Bitmap cover=mAudioPlayerControl.getCover();
    if (cover != null) {
      mCover.setVisibility(ImageView.VISIBLE);
      mCover.setImageBitmap(cover);
    }
 else {
      mCover.setVisibility(ImageView.GONE);
    }
    mTitle.setText(mAudioPlayerControl.getTitle());
    mArtist.setText(mAudioPlayerControl.getArtist());
    if (mAudioPlayerControl.isPlaying()) {
      mPlayPause.setImageResource(R.drawable.ic_pause);
    }
 else {
      mPlayPause.setImageResource(R.drawable.ic_play);
    }
    if (mAudioPlayerControl.hasNext())     mForward.setVisibility(ImageButton.VISIBLE);
 else     mForward.setVisibility(ImageButton.INVISIBLE);
    if (mAudioPlayerControl.hasPrevious())     mBackward.setVisibility(ImageButton.VISIBLE);
 else     mBackward.setVisibility(ImageButton.INVISIBLE);
    int time=(int)mAudioPlayerControl.getTime();
    int length=(int)mAudioPlayerControl.getLength();
    mSeekbar.setMax(length);
    mSeekbar.setProgress(time);
  }
}

Fixed version (ground truth):
public void update(){
  if (mAudioPlayerControl != null) {
    if (mAudioPlayerControl.hasMedia()) {
      this.setVisibility(LinearLayout.VISIBLE);
    }
 else {
      this.setVisibility(LinearLayout.GONE);
      return;
    }
    if (!mAudioPlayerControl.getTitle().equals(lastTitle)) {
      Bitmap cover=mAudioPlayerControl.getCover();
      if (cover != null) {
        mCover.setVisibility(ImageView.VISIBLE);
        mCover.setImageBitmap(cover);
      }
 else {
        mCover.setVisibility(ImageView.GONE);
      }
    }
    lastTitle=mAudioPlayerControl.getTitle();
    mTitle.setText(lastTitle);
    mArtist.setText(mAudioPlayerControl.getArtist());
    if (mAudioPlayerControl.isPlaying()) {
      mPlayPause.setImageResource(R.drawable.ic_pause);
    }
 else {
      mPlayPause.setImageResource(R.drawable.ic_play);
    }
    if (mAudioPlayerControl.hasNext())     mForward.setVisibility(ImageButton.VISIBLE);
 else     mForward.setVisibility(ImageButton.INVISIBLE);
    if (mAudioPlayerControl.hasPrevious())     mBackward.setVisibility(ImageButton.VISIBLE);
 else     mBackward.setVisibility(ImageButton.INVISIBLE);
    int time=(int)mAudioPlayerControl.getTime();
    int length=(int)mAudioPlayerControl.getLength();
    mSeekbar.setMax(length);
    mSeekbar.setProgress(time);
  }
}
Program: 62860
Project: 62860
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.search);
  mResultAdapter=new SearchResultAdapter(this,android.R.layout.simple_list_item_1);
  mSearchText=(EditText)findViewById(R.id.search_text);
  mSearchText.setOnEditorActionListener(searchTextListener);
  mSearchText.addTextChangedListener(searchTextWatcher);
  final Intent queryIntent=getIntent();
  final String queryAction=queryIntent.getAction();
  if (Intent.ACTION_SEARCH.equals(queryAction)) {
    String query=queryIntent.getStringExtra(SearchManager.QUERY);
    mSearchText.setText(query);
    mSearchText.setSelection(query.length());
  }
 else {
    InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(mSearchText,InputMethodManager.RESULT_SHOWN);
  }
  mSearchText.requestFocus();
  showSearchHistory();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.search);
  mResultAdapter=new SearchResultAdapter(this,android.R.layout.simple_list_item_1);
  mSearchText=(EditText)findViewById(R.id.search_text);
  mSearchText.setOnEditorActionListener(searchTextListener);
  mSearchText.addTextChangedListener(searchTextWatcher);
  final Intent queryIntent=getIntent();
  final String queryAction=queryIntent.getAction();
  if (Intent.ACTION_SEARCH.equals(queryAction)) {
    String query=queryIntent.getStringExtra(SearchManager.QUERY);
    mSearchText.setText(query);
    mSearchText.setSelection(query.length());
  }
 else {
    InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(mSearchText,InputMethodManager.RESULT_SHOWN);
    showSearchHistory();
  }
  mSearchText.requestFocus();
}
Program: 62861
Project: 62861
Buggy source:
private void search(CharSequence key,int type){
  mResultAdapter.clear();
  String[] keys=key.toString().split("String_Node_Str");
  ArrayList<MediaItem> allItems=MediaLibraryActivity.getInstance().mItemList;
  int results=0;
  for (int i=0; i < allItems.size(); i++) {
    MediaItem item=allItems.get(i);
    if (type != MediaItem.TYPE_ALL && type != item.getType())     continue;
    Log.d(TAG,keys[0]);
    boolean add=true;
    String name=item.getName().toLowerCase();
    String path=item.getPath().toLowerCase();
    for (int k=0; k < keys.length; k++) {
      Log.d(TAG,keys[k]);
      if (!(name.contains(keys[k].toLowerCase()) || path.contains(keys[k].toLowerCase()))) {
        add=false;
        break;
      }
    }
    if (add) {
      mResultAdapter.add(item);
      results++;
    }
  }
  mResultAdapter.sort();
  setListAdapter(mResultAdapter);
  String headerText=getString(R.string.search_found_results,results);
  showListHeader(headerText);
}

Fixed version (ground truth):
private void search(CharSequence key,int type){
  mResultAdapter.clear();
  String[] keys=key.toString().split("String_Node_Str");
  ArrayList<MediaItem> allItems=MediaLibraryActivity.getInstance().mItemList;
  int results=0;
  for (int i=0; i < allItems.size(); i++) {
    MediaItem item=allItems.get(i);
    if (type != MediaItem.TYPE_ALL && type != item.getType())     continue;
    boolean add=true;
    String name=item.getName().toLowerCase();
    String path=item.getPath().toLowerCase();
    for (int k=0; k < keys.length; k++) {
      if (!(name.contains(keys[k].toLowerCase()) || path.contains(keys[k].toLowerCase()))) {
        add=false;
        break;
      }
    }
    if (add) {
      mResultAdapter.add(item);
      results++;
    }
  }
  mResultAdapter.sort();
  String headerText=getString(R.string.search_found_results,results);
  showListHeader(headerText);
  setListAdapter(mResultAdapter);
}
Program: 62862
Project: 62862
Buggy source:
/** 
 * Handle onClick form menu buttons
 */
@Override public boolean onOptionsItemSelected(MenuItem item){
  Intent intent;
switch (item.getItemId()) {
case R.id.search_clear_history:
    DatabaseManager db=DatabaseManager.getInstance();
  db.clearSearchhistory();
showSearchHistory();
}
return super.onOptionsItemSelected(item);
}

Fixed version (ground truth):
/** 
 * Handle onClick form menu buttons
 */
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.search_clear_history:
    DatabaseManager db=DatabaseManager.getInstance();
  db.clearSearchhistory();
if (mHistoryAdapter == getListAdapter()) showSearchHistory();
}
return super.onOptionsItemSelected(item);
}
Program: 62863
Project: 62863
Buggy source:
public synchronized void updateMediaItem(String path,mediaColumn col,Object object){
  ContentValues values=new ContentValues();
switch (col) {
case MEDIA_THUMBNAIL:
    Bitmap thumbnail=(Bitmap)object;
  ByteArrayOutputStream out=new ByteArrayOutputStream();
thumbnail.compress(Bitmap.CompressFormat.PNG,100,out);
values.put(MEDIA_THUMBNAIL,out.toByteArray());
break;
default :
return;
}
mDb.update(MEDIA_TABLE_NAME,values,MEDIA_PATH + "String_Node_Str" + path+ "String_Node_Str",null);
}

Fixed version (ground truth):
public synchronized void updateMediaItem(String path,mediaColumn col,Object object){
  ContentValues values=new ContentValues();
switch (col) {
case MEDIA_THUMBNAIL:
    Bitmap thumbnail=(Bitmap)object;
  ByteArrayOutputStream out=new ByteArrayOutputStream();
thumbnail.compress(Bitmap.CompressFormat.PNG,100,out);
values.put(MEDIA_THUMBNAIL,out.toByteArray());
break;
default :
return;
}
mDb.update(MEDIA_TABLE_NAME,values,MEDIA_PATH + "String_Node_Str",new String[]{path});
}
Program: 62864
Project: 62864
Buggy source:
public synchronized boolean mediaDirExists(String path){
  String query="String_Node_Str" + DIR_ROW_PATH + "String_Node_Str"+ DIR_TABLE_NAME+ "String_Node_Str"+ DIR_ROW_PATH+ "String_Node_Str";
  Cursor cursor=mDb.rawQuery(query,new String[]{path});
  boolean exists=cursor.moveToFirst();
  cursor.close();
  return exists;
}

Fixed version (ground truth):
public synchronized boolean mediaDirExists(String path){
  Cursor cursor=mDb.query(DIR_TABLE_NAME,new String[]{DIR_ROW_PATH},DIR_ROW_PATH + "String_Node_Str",new String[]{path},null,null,null);
  boolean exists=cursor.moveToFirst();
  cursor.close();
  return exists;
}
Program: 62865
Project: 62865
Buggy source:
/** 
 * Delete directory from directories table
 * @param path
 */
public synchronized void removeMediaDir(String path){
  mDb.delete(DIR_TABLE_NAME,DIR_ROW_PATH + "String_Node_Str" + path+ "String_Node_Str",null);
}

Fixed version (ground truth):
/** 
 * Delete directory from directories table
 * @param path
 */
public synchronized void removeMediaDir(String path){
  mDb.delete(DIR_TABLE_NAME,DIR_ROW_PATH + "String_Node_Str",new String[]{path});
}
Program: 62866
Project: 62866
Buggy source:
/** 
 * Check if the item already in the database
 * @param path of the item (primary key)
 * @return 
 */
public synchronized boolean mediaItemExists(String path){
  Cursor cursor=mDb.query(MEDIA_TABLE_NAME,new String[]{DIR_ROW_PATH},MEDIA_PATH + "String_Node_Str" + path+ "String_Node_Str",null,null,null,null);
  cursor.close();
  return cursor.moveToFirst();
}

Fixed version (ground truth):
/** 
 * Check if the item already in the database
 * @param path of the item (primary key)
 * @return 
 */
public synchronized boolean mediaItemExists(String path){
  Cursor cursor=mDb.query(MEDIA_TABLE_NAME,new String[]{DIR_ROW_PATH},MEDIA_PATH + "String_Node_Str",new String[]{path},null,null,null);
  cursor.close();
  return cursor.moveToFirst();
}
Program: 62867
Project: 62867
Buggy source:
public synchronized MediaItem getMediaItem(String path){
  Cursor cursor;
  MediaItem item=null;
  Bitmap thumbnail=null;
  byte[] blob;
  cursor=mDb.query(MEDIA_TABLE_NAME,new String[]{MEDIA_NAME,MEDIA_PATH,MEDIA_TIME,MEDIA_LENGTH,MEDIA_TYPE,MEDIA_WIDTH,MEDIA_HEIGHT,MEDIA_THUMBNAIL},MEDIA_PATH + "String_Node_Str" + path+ "String_Node_Str",null,null,null,null);
  if (cursor.moveToFirst()) {
    blob=cursor.getBlob(7);
    if (blob != null) {
      thumbnail=BitmapFactory.decodeByteArray(blob,0,blob.length);
    }
    item=new MediaItem(cursor.getString(0),new File(cursor.getString(1)),cursor.getLong(2),cursor.getLong(3),cursor.getString(4),cursor.getInt(5),cursor.getInt(6),thumbnail);
  }
  return item;
}

Fixed version (ground truth):
public synchronized MediaItem getMediaItem(String path){
  Cursor cursor;
  MediaItem item=null;
  Bitmap thumbnail=null;
  byte[] blob;
  cursor=mDb.query(MEDIA_TABLE_NAME,new String[]{MEDIA_NAME,MEDIA_PATH,MEDIA_TIME,MEDIA_LENGTH,MEDIA_TYPE,MEDIA_WIDTH,MEDIA_HEIGHT,MEDIA_THUMBNAIL},MEDIA_PATH + "String_Node_Str",new String[]{path},null,null,null);
  if (cursor.moveToFirst()) {
    blob=cursor.getBlob(7);
    if (blob != null) {
      thumbnail=BitmapFactory.decodeByteArray(blob,0,blob.length);
    }
    item=new MediaItem(cursor.getString(0),new File(cursor.getString(1)),cursor.getLong(2),cursor.getLong(3),cursor.getString(4),cursor.getInt(5),cursor.getInt(6),thumbnail);
  }
  return item;
}
Program: 62868
Project: 62868
Buggy source:
public synchronized void removeMediaItem(String path){
  mDb.delete(MEDIA_TABLE_NAME,MEDIA_PATH + "String_Node_Str" + path+ "String_Node_Str",null);
}

Fixed version (ground truth):
public synchronized void removeMediaItem(String path){
  mDb.delete(MEDIA_TABLE_NAME,MEDIA_PATH + "String_Node_Str",new String[]{path});
}
Program: 62869
Project: 62869
Buggy source:
@Provides static NewsAdapter providesNewsAdapter(Context context){
  return new NewsAdapter(context);
}

Fixed version (ground truth):
@Provides static NewsAdapter providesNewsAdapter(){
  return new NewsAdapter(App.getAppContext());
}
Program: 62870
Project: 62870
Buggy source:
public NewsAdapter(Context context){
  mContext=context;
}

Fixed version (ground truth):
@Inject public NewsAdapter(Context context){
  mContext=context;
}
Program: 62871
Project: 62871
Buggy source:
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent,int viewType){
  View view=LayoutInflater.from(mContext).inflate(R.layout.item_news,parent,false);
  return new NewsViewHolder(view);
}

Fixed version (ground truth):
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent,int viewType){
  View view=LayoutInflater.from(App.getAppContext()).inflate(R.layout.item_news,parent,false);
  return new NewsViewHolder(view);
}
Program: 62872
Project: 62872
Buggy source:
@Override protected void initView(View view){
  mNewsAdapter=new NewsAdapter(getActivity());
  topicRecyclerView.setAdapter(mNewsAdapter);
  topicRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
  topicRefreshLayout.addEasyEvent(new EasyRefreshLayout.EasyEvent(){
    @Override public void onLoadMore(){
      topicRefreshLayout.loadMoreComplete();
    }
    @Override public void onRefreshing(){
      topicRefreshLayout.refreshComplete();
    }
  }
);
}

Fixed version (ground truth):
@Override protected void initView(View view){
  topicRecyclerView.setAdapter(mNewsAdapter);
  topicRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
  topicRefreshLayout.addEasyEvent(new EasyRefreshLayout.EasyEvent(){
    @Override public void onLoadMore(){
      topicRefreshLayout.loadMoreComplete();
    }
    @Override public void onRefreshing(){
      topicRefreshLayout.refreshComplete();
    }
  }
);
}
Program: 62873
Project: 62873
Buggy source:
/** 
 * if js invoke the java async ,that the result will be returned by execute a script in the bridge since this method may be invoked not in the main thread ,we send a message using the   {@link Handler} and resolve it in main thread
 * @param callbackId uniqueId which match to an callback function in js
 * @param parameters value that will be pass to js
 */
private void dispatchResult(String callbackId,String parameters){
  if (bridgeWebView == null || bridgeWebView.get() == null) {
    return;
  }
  final String callBackScript=String.format(CALLBACK_FUNCTION,bridgeName,callbackId,parameters);
}

Fixed version (ground truth):
/** 
 * if js invoke the java async ,that the result will be returned by execute a script in the bridge since this method may be invoked not in the main thread ,we send a message using the   {@link Handler} and resolve it in main thread
 * @param callbackId uniqueId which match to an callback function in js
 * @param parameters value that will be pass to js
 */
private void dispatchResult(String callbackId,String parameters){
  if (bridgeWebView == null || bridgeWebView.get() == null) {
    return;
  }
  final String callBackScript=String.format(CALLBACK_FUNCTION,bridgeName,callbackId,parameters);
  executeScriptInMain(callBackScript);
}
Program: 62874
Project: 62874
Buggy source:
private static void scheduleNotification(Context context,NotificationDetails notificationDetails,Boolean updateScheduledNotificationsCache){
  Notification notification=createNotification(context,notificationDetails);
  Intent notificationIntent=new Intent(context,ScheduledNotificationReceiver.class);
  notificationIntent.putExtra(NOTIFICATION_ID,notificationDetails.id);
  notificationIntent.putExtra(NOTIFICATION,notification);
  PendingIntent pendingIntent=PendingIntent.getBroadcast(context,notificationDetails.id,notificationIntent,PendingIntent.FLAG_CANCEL_CURRENT);
  AlarmManager alarmManager=getAlarmManager(context);
  alarmManager.set(AlarmManager.RTC_WAKEUP,notificationDetails.millisecondsSinceEpoch,pendingIntent);
  if (updateScheduledNotificationsCache) {
    ArrayList<NotificationDetails> scheduledNotifications=loadScheduledNotifications(context);
    scheduledNotifications.add(notificationDetails);
    saveScheduledNotifications(context,scheduledNotifications);
  }
}

Fixed version (ground truth):
private static void scheduleNotification(Context context,NotificationDetails notificationDetails,Boolean updateScheduledNotificationsCache){
  setIconResourceId(context,notificationDetails);
  Gson gson=buildGson();
  String notificationDetailsJson=gson.toJson(notificationDetails);
  Intent notificationIntent=new Intent(context,ScheduledNotificationReceiver.class);
  notificationIntent.putExtra(NOTIFICATION_DETAILS,notificationDetailsJson);
  PendingIntent pendingIntent=PendingIntent.getBroadcast(context,notificationDetails.id,notificationIntent,PendingIntent.FLAG_CANCEL_CURRENT);
  AlarmManager alarmManager=getAlarmManager(context);
  alarmManager.set(AlarmManager.RTC_WAKEUP,notificationDetails.millisecondsSinceEpoch,pendingIntent);
  if (updateScheduledNotificationsCache) {
    ArrayList<NotificationDetails> scheduledNotifications=loadScheduledNotifications(context);
    scheduledNotifications.add(notificationDetails);
    saveScheduledNotifications(context,scheduledNotifications);
  }
}
Program: 62875
Project: 62875
Buggy source:
private static void saveScheduledNotifications(Context context,ArrayList<NotificationDetails> scheduledNotifications){
  Gson gson=getGsonBuilder();
  String json=gson.toJson(scheduledNotifications);
  SharedPreferences sharedPreferences=context.getSharedPreferences(SCHEDULED_NOTIFICATIONS,Context.MODE_PRIVATE);
  SharedPreferences.Editor editor=sharedPreferences.edit();
  editor.putString(SCHEDULED_NOTIFICATIONS,json);
  editor.commit();
}

Fixed version (ground truth):
private static void saveScheduledNotifications(Context context,ArrayList<NotificationDetails> scheduledNotifications){
  Gson gson=buildGson();
  String json=gson.toJson(scheduledNotifications);
  SharedPreferences sharedPreferences=context.getSharedPreferences(SCHEDULED_NOTIFICATIONS,Context.MODE_PRIVATE);
  SharedPreferences.Editor editor=sharedPreferences.edit();
  editor.putString(SCHEDULED_NOTIFICATIONS,json);
  editor.commit();
}
Program: 62876
Project: 62876
Buggy source:
private static ArrayList<NotificationDetails> loadScheduledNotifications(Context context){
  ArrayList<NotificationDetails> scheduledNotifications=new ArrayList<>();
  SharedPreferences sharedPreferences=context.getSharedPreferences(SCHEDULED_NOTIFICATIONS,Context.MODE_PRIVATE);
  String json=sharedPreferences.getString(SCHEDULED_NOTIFICATIONS,null);
  if (json != null) {
    Gson gson=getGsonBuilder();
    Type type=new TypeToken<ArrayList<NotificationDetails>>(){
    }
.getType();
    scheduledNotifications=gson.fromJson(json,type);
  }
  return scheduledNotifications;
}

Fixed version (ground truth):
private static ArrayList<NotificationDetails> loadScheduledNotifications(Context context){
  ArrayList<NotificationDetails> scheduledNotifications=new ArrayList<>();
  SharedPreferences sharedPreferences=context.getSharedPreferences(SCHEDULED_NOTIFICATIONS,Context.MODE_PRIVATE);
  String json=sharedPreferences.getString(SCHEDULED_NOTIFICATIONS,null);
  if (json != null) {
    Gson gson=buildGson();
    Type type=new TypeToken<ArrayList<NotificationDetails>>(){
    }
.getType();
    scheduledNotifications=gson.fromJson(json,type);
  }
  return scheduledNotifications;
}