Program: 164504
Project: 164504
Buggy source:
@Override public void handleMessage(Message msg){
  if (isRemoving() || getActivity().isFinishing()) {
    LogUtil.w(TAG,"String_Node_Str");
    return;
  }
  mRefreshLayout.setRefreshing(false);
switch (msg.what) {
case MESSAGE_ACTION_COMPLETE:
    List<ImgurBaseObject> gallery=(List<ImgurBaseObject>)msg.obj;
  if (getAdapter() == null) {
    setUpGridTop();
    setAdapter(new GalleryAdapter(getActivity(),SetUniqueList.decorate(gallery)));
  }
 else {
    getAdapter().addItems(gallery);
  }
if (mListener != null) mListener.onLoadingComplete();
mMultiStateView.setViewState(MultiStateView.ViewState.CONTENT);
if (mCurrentPage == 0) {
if (GalleryFragment.this instanceof GallerySearchFragment) {
((GallerySearchFragment)GalleryFragment.this).onSuccessfulSearch();
}
mMultiStateView.post(new Runnable(){
@Override public void run(){
  mGrid.setSelection(0);
}
}
);
}
break;
case MESSAGE_ACTION_FAILED:
if (getAdapter() == null || getAdapter().isEmpty()) {
if (mListener != null) {
mListener.onError((Integer)msg.obj);
}
mMultiStateView.setErrorText(R.id.errorMessage,(Integer)msg.obj);
mMultiStateView.setErrorButtonText(R.id.errorButton,R.string.retry);
mMultiStateView.setErrorButtonClickListener(R.id.errorButton,new View.OnClickListener(){
@Override public void onClick(View view){
mMultiStateView.setViewState(MultiStateView.ViewState.LOADING);
fetchGallery();
}
}
);
mMultiStateView.setViewState(MultiStateView.ViewState.ERROR);
}
break;
case MESSAGE_EMPTY_RESULT:
if (GalleryFragment.this instanceof GallerySearchFragment) {
((GallerySearchFragment)GalleryFragment.this).onEmptyResults();
}
break;
default :
super.handleMessage(msg);
break;
}
mIsLoading=false;
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (getActivity() == null || getActivity().isFinishing() || isRemoving()) {
    LogUtil.w(TAG,"String_Node_Str");
    return;
  }
  mRefreshLayout.setRefreshing(false);
switch (msg.what) {
case MESSAGE_ACTION_COMPLETE:
    List<ImgurBaseObject> gallery=(List<ImgurBaseObject>)msg.obj;
  if (getAdapter() == null) {
    setUpGridTop();
    setAdapter(new GalleryAdapter(getActivity(),SetUniqueList.decorate(gallery)));
  }
 else {
    getAdapter().addItems(gallery);
  }
if (mListener != null) mListener.onLoadingComplete();
mMultiStateView.setViewState(MultiStateView.ViewState.CONTENT);
if (mCurrentPage == 0) {
if (GalleryFragment.this instanceof GallerySearchFragment) {
((GallerySearchFragment)GalleryFragment.this).onSuccessfulSearch();
}
mMultiStateView.post(new Runnable(){
@Override public void run(){
  mGrid.setSelection(0);
}
}
);
}
break;
case MESSAGE_ACTION_FAILED:
if (getAdapter() == null || getAdapter().isEmpty()) {
if (mListener != null) {
mListener.onError((Integer)msg.obj);
}
mMultiStateView.setErrorText(R.id.errorMessage,(Integer)msg.obj);
mMultiStateView.setErrorButtonText(R.id.errorButton,R.string.retry);
mMultiStateView.setErrorButtonClickListener(R.id.errorButton,new View.OnClickListener(){
@Override public void onClick(View view){
mMultiStateView.setViewState(MultiStateView.ViewState.LOADING);
fetchGallery();
}
}
);
mMultiStateView.setViewState(MultiStateView.ViewState.ERROR);
}
break;
case MESSAGE_EMPTY_RESULT:
if (GalleryFragment.this instanceof GallerySearchFragment) {
((GallerySearchFragment)GalleryFragment.this).onEmptyResults();
}
break;
default :
super.handleMessage(msg);
break;
}
mIsLoading=false;
}