Program: 15083
Project: 15083
Buggy source:
public void refreshMediaFromServer(int offset,final boolean auto){
  if (WordPress.getCurrentBlog() == null)   return;
  if (offset == 0 || !mIsRefreshing) {
    mIsRefreshing=true;
    mListener.onMediaItemListDownloadStart();
    mGridAdapter.setRefreshing(true);
    List<Object> apiArgs=new ArrayList<Object>();
    apiArgs.add(WordPress.getCurrentBlog());
    Callback callback=new Callback(){
      @Override public void onSuccess(      int count){
        MediaGridAdapter adapter=(MediaGridAdapter)mGridView.getAdapter();
        mHasRetrievedAllMedia=(count == 0);
        adapter.setHasRetrieviedAll(mHasRetrievedAllMedia);
        mIsRefreshing=false;
        if (MediaGridFragment.this.isVisible()) {
          refreshSpinnerAdapter();
          setFilter(mFilter);
          if (!auto)           mGridView.post(new Runnable(){
            @Override public void run(){
              mGridView.setSelection(0);
            }
          }
);
        }
        mListener.onMediaItemListDownloaded();
        mGridAdapter.setRefreshing(false);
      }
      @Override public void onFailure(){
        mIsRefreshing=false;
        mListener.onMediaItemListDownloaded();
        mGridAdapter.setRefreshing(false);
      }
    }
;
    ApiHelper.SyncMediaLibraryTask getMediaTask=new ApiHelper.SyncMediaLibraryTask(offset,mFilter,callback);
    getMediaTask.execute(apiArgs);
  }
}

Fixed version (ground truth):
public void refreshMediaFromServer(int offset,final boolean auto){
  if (WordPress.getCurrentBlog() == null)   return;
  if (offset == 0 || !mIsRefreshing) {
    if (offset == mOldMediaSyncOffset) {
      offset=0;
    }
    mOldMediaSyncOffset=offset;
    mIsRefreshing=true;
    mListener.onMediaItemListDownloadStart();
    mGridAdapter.setRefreshing(true);
    List<Object> apiArgs=new ArrayList<Object>();
    apiArgs.add(WordPress.getCurrentBlog());
    Callback callback=new Callback(){
      @Override public void onSuccess(      int count){
        MediaGridAdapter adapter=(MediaGridAdapter)mGridView.getAdapter();
        mHasRetrievedAllMedia=(count == 0);
        adapter.setHasRetrieviedAll(mHasRetrievedAllMedia);
        mIsRefreshing=false;
        if (getActivity() != null && MediaGridFragment.this.isVisible()) {
          getActivity().runOnUiThread(new Runnable(){
            @Override public void run(){
              refreshSpinnerAdapter();
              setFilter(mFilter);
              if (!auto)               mGridView.setSelection(0);
              mListener.onMediaItemListDownloaded();
              mGridAdapter.setRefreshing(false);
            }
          }
);
        }
      }
      @Override public void onFailure(      int errorCode){
        if (errorCode == SyncMediaLibraryTask.NO_UPLOAD_FILES_CAP) {
          Toast.makeText(getActivity(),"String_Node_Str",Toast.LENGTH_SHORT).show();
          MediaGridAdapter adapter=(MediaGridAdapter)mGridView.getAdapter();
          mHasRetrievedAllMedia=true;
          adapter.setHasRetrieviedAll(mHasRetrievedAllMedia);
        }
        if (getActivity() != null && MediaGridFragment.this.isVisible()) {
          getActivity().runOnUiThread(new Runnable(){
            @Override public void run(){
              mIsRefreshing=false;
              mListener.onMediaItemListDownloaded();
              mGridAdapter.setRefreshing(false);
            }
          }
);
        }
      }
    }
;
    ApiHelper.SyncMediaLibraryTask getMediaTask=new ApiHelper.SyncMediaLibraryTask(offset,mFilter,callback);
    getMediaTask.execute(apiArgs);
  }
}