Program: 11145
Project: 11145
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mContext=this;
  themeType=(ThemeType)getIntent().getSerializableExtra(THEME_TYPE);
  if (themeType == null) {
    themeType=ThemeType.ACTIVITY;
  }
  setThemeType(themeType);
  areButtonsShowing=false;
  try {
    getActionBar().setDisplayHomeAsUpEnabled(true);
  }
 catch (  NullPointerException e) {
    e.printStackTrace();
  }
  Object rawMimeTypeParameter=getIntent().getExtras().get(MIME_TYPE);
  if (rawMimeTypeParameter instanceof String) {
    mimeType=(String)rawMimeTypeParameter;
  }
 else   if (rawMimeTypeParameter instanceof FileType) {
    mimeType=((FileType)rawMimeTypeParameter).getMimeType();
  }
 else {
    mimeType=null;
  }
  setUpAnimations();
  Intent givenIntent=getIntent();
  scopeType=(Scope)givenIntent.getSerializableExtra(SCOPE_TYPE);
  if (scopeType == null) {
    scopeType=Scope.ALL;
  }
  requestCode=(Request)givenIntent.getSerializableExtra(REQUEST_CODE);
  colorId=givenIntent.getIntExtra(INTENT_EXTRA_COLOR_ID,android.R.color.holo_blue_light);
  drawableId=givenIntent.getIntExtra(INTENT_EXTRA_DRAWABLE_ID,-1);
  fabColorId=givenIntent.getIntExtra(INTENT_EXTRA_FAB_COLOR_ID,-1);
  setContentView(R.layout.file_picker_activity_layout);
  listView=(ListView)findViewById(android.R.id.list);
  listView.setOnScrollListener(new AbsListView.OnScrollListener(){
    @Override public void onScrollStateChanged(    AbsListView view,    int scrollState){
    }
    @Override public void onScroll(    AbsListView view,    int firstVisibleItem,    int visibleItemCount,    int totalItemCount){
      if (areButtonsShowing) {
        if (Math.abs(firstVisibleItem - mLastFirstVisibleItem) >= 3) {
          hideButtons();
          adapter.setSelectedPosition(-1);
          mLastFirstVisibleItem=firstVisibleItem;
        }
 else         if (firstVisibleItem > adapter.getSelectedPosition()) {
          hideButtons();
          adapter.setSelectedPosition(-1);
        }
      }
 else {
        mLastFirstVisibleItem=firstVisibleItem;
      }
    }
  }
);
  listHeaderView=getLayoutInflater().inflate(R.layout.file_list_header_view,null);
  listHeaderView.setFocusable(false);
  listHeaderView.setClickable(false);
  listHeaderView.setOnClickListener(null);
  listHeaderView.setActivated(false);
  initializeViews();
  setHeaderBackground(colorId,drawableId);
  if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
    int permissionCheck=ContextCompat.checkSelfPermission(this,Manifest.permission.READ_EXTERNAL_STORAGE);
    if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
      if (ActivityCompat.shouldShowRequestPermissionRationale(this,Manifest.permission.READ_EXTERNAL_STORAGE)) {
        new MaterialDialog.Builder(this).title(R.string.file_picker_permission_rationale_dialog_title).content(R.string.file_picker_permission_rationale_dialog_content).positiveText(R.string.file_picker_ok).negativeText(R.string.file_picker_cancel).onPositive(new MaterialDialog.SingleButtonCallback(){
          @Override public void onClick(          @NonNull MaterialDialog dialog,          @NonNull DialogAction which){
            ActivityCompat.requestPermissions(FilePickerActivity.this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE},REQUEST_FOR_READ_EXTERNAL_STORAGE);
          }
        }
).onNegative(new MaterialDialog.SingleButtonCallback(){
          @Override public void onClick(          @NonNull MaterialDialog dialog,          @NonNull DialogAction which){
            setResult(RESULT_CANCELED);
            finish();
          }
        }
).show();
      }
 else {
        ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE},REQUEST_FOR_READ_EXTERNAL_STORAGE);
      }
    }
 else {
      init();
    }
  }
 else {
    init();
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mContext=this;
  themeType=(ThemeType)getIntent().getSerializableExtra(THEME_TYPE);
  if (themeType == null) {
    themeType=ThemeType.ACTIVITY;
  }
  setThemeType(themeType);
  areButtonsShowing=false;
  try {
    getActionBar().setDisplayHomeAsUpEnabled(true);
  }
 catch (  NullPointerException e) {
    e.printStackTrace();
  }
  Object rawMimeTypeParameter=getIntent().getExtras().get(MIME_TYPE);
  if (rawMimeTypeParameter instanceof String) {
    mimeType=(String)rawMimeTypeParameter;
  }
 else   if (rawMimeTypeParameter instanceof MimeType) {
    mimeType=((MimeType)rawMimeTypeParameter).getMimeType();
  }
 else {
    mimeType=null;
  }
  setUpAnimations();
  Intent givenIntent=getIntent();
  scopeType=(Scope)givenIntent.getSerializableExtra(SCOPE);
  if (scopeType == null) {
    scopeType=Scope.ALL;
  }
  requestCode=(Request)givenIntent.getSerializableExtra(REQUEST);
  colorId=givenIntent.getIntExtra(INTENT_EXTRA_COLOR_ID,android.R.color.holo_blue_light);
  drawableId=givenIntent.getIntExtra(INTENT_EXTRA_DRAWABLE_ID,-1);
  fabColorId=givenIntent.getIntExtra(INTENT_EXTRA_FAB_COLOR_ID,-1);
  setContentView(R.layout.file_picker_activity_layout);
  listView=(ListView)findViewById(android.R.id.list);
  listView.setOnScrollListener(new AbsListView.OnScrollListener(){
    @Override public void onScrollStateChanged(    AbsListView view,    int scrollState){
    }
    @Override public void onScroll(    AbsListView view,    int firstVisibleItem,    int visibleItemCount,    int totalItemCount){
      if (areButtonsShowing) {
        if (Math.abs(firstVisibleItem - mLastFirstVisibleItem) >= 3) {
          hideButtons();
          adapter.setSelectedPosition(-1);
          mLastFirstVisibleItem=firstVisibleItem;
        }
 else         if (firstVisibleItem > adapter.getSelectedPosition()) {
          hideButtons();
          adapter.setSelectedPosition(-1);
        }
      }
 else {
        mLastFirstVisibleItem=firstVisibleItem;
      }
    }
  }
);
  listHeaderView=getLayoutInflater().inflate(R.layout.file_list_header_view,null);
  listHeaderView.setFocusable(false);
  listHeaderView.setClickable(false);
  listHeaderView.setOnClickListener(null);
  listHeaderView.setActivated(false);
  initializeViews();
  setHeaderBackground(colorId,drawableId);
  if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
    int permissionCheck=ContextCompat.checkSelfPermission(this,Manifest.permission.READ_EXTERNAL_STORAGE);
    if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
      if (ActivityCompat.shouldShowRequestPermissionRationale(this,Manifest.permission.READ_EXTERNAL_STORAGE)) {
        new MaterialDialog.Builder(this).title(R.string.file_picker_permission_rationale_dialog_title).content(R.string.file_picker_permission_rationale_dialog_content).positiveText(R.string.file_picker_ok).negativeText(R.string.file_picker_cancel).onPositive(new MaterialDialog.SingleButtonCallback(){
          @Override public void onClick(          @NonNull MaterialDialog dialog,          @NonNull DialogAction which){
            ActivityCompat.requestPermissions(FilePickerActivity.this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE},REQUEST_FOR_READ_EXTERNAL_STORAGE);
          }
        }
).onNegative(new MaterialDialog.SingleButtonCallback(){
          @Override public void onClick(          @NonNull MaterialDialog dialog,          @NonNull DialogAction which){
            setResult(RESULT_CANCELED);
            finish();
          }
        }
).show();
      }
 else {
        ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE},REQUEST_FOR_READ_EXTERNAL_STORAGE);
      }
    }
 else {
      init();
    }
  }
 else {
    init();
  }
}