- if (mFiles.size() <= position) {\r
- throw new IndexOutOfBoundsException("Incorrect item selected");\r
- }\r
- OCFile file = mFiles.get(position);\r
- \r
- /// Click on a directory\r
- if (file.getMimetype().equals("DIR")) {\r
- // just local updates\r
- mFile = file;\r
- listDirectory(file);\r
- // any other updates are let to the container Activity\r
- mContainerActivity.onDirectoryClick(file);\r
+ OCFile file = (OCFile) mAdapter.getItem(position);\r
+ if (file != null) {\r
+ /// Click on a directory\r
+ if (file.getMimetype().equals("DIR")) {\r
+ // just local updates\r
+ mFile = file;\r
+ listDirectory(file);\r
+ // any other updates are let to the container Activity\r
+ mContainerActivity.onDirectoryClick(file);\r
+ \r
+ } else { /// Click on a file\r
+ mContainerActivity.onFileClick(file);\r
+ }\r