Skip to content

Commit a1d8cb3

Browse files
committed
Backup point -- back to prior commit functionality
1 parent c68ad34 commit a1d8cb3

5 files changed

Lines changed: 61 additions & 103 deletions

File tree

AndroidFilePickerLightLibrary/src/main/java/com/maxieds/androidfilepickerlightlibrary/BasicFileProvider.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,19 +351,18 @@ public Cursor queryChildDocuments(String parentDocumentId, String[] projection,
351351
int startFileIndex = getFilesStartIndex();
352352
int lastFileIndex = startFileIndex + getFilesListLength();
353353
if(lastFileIndex >= docsQueryFilesList.length) {
354-
//int truncateDiff = lastFileIndex + 1 - docsQueryFilesList.length;
355354
lastFileIndex = docsQueryFilesList.length - 1;
356355
startFileIndex = Math.max(0, lastFileIndex - getFilesListLength());
357356
}
358357
int curFileIndex = 0;
359-
for(int folderIndex = startFileIndex; folderIndex < docsQueryFilesList.length; folderIndex++) {
360-
if(curFileIndex > lastFileIndex) {
361-
++curFileIndex;
358+
for(File file : docsQueryFilesList) {
359+
if(curFileIndex++ < startFileIndex) {
360+
continue;
361+
}
362+
else if(curFileIndex > lastFileIndex) {
362363
break;
363364
}
364-
File nextFile = docsQueryFilesList[folderIndex];
365-
includeFile(mcResult, null, nextFile);
366-
++curFileIndex;
365+
includeFile(mcResult, null, file);
367366
}
368367
return mcResult;
369368
}

AndroidFilePickerLightLibrary/src/main/java/com/maxieds/androidfilepickerlightlibrary/DisplayAdapters.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,16 @@ public FileListAdapter(List<String> nextFileListData, List<DisplayTypes.FileType
4747
this.fileListData.addAll(nextFileListData);
4848
this.fileItemsData = new ArrayList<DisplayTypes.FileType>();
4949
this.fileItemsData.addAll(nextFileItemsData);
50-
//this.setHasStableIds(true); // TODO ???
50+
this.setHasStableIds(false); // TODO ???
5151
notifyDataSetChanged();
5252
}
5353

54-
public void reloadDataSets(List<String> nextDataSet, List<DisplayTypes.FileType> nextFileItemsData, boolean notifyAdapter) {
54+
public void reloadDataSets(List<String> nextDataSet, List<DisplayTypes.FileType> nextFileItemsData) {
5555
fileListData.clear();
5656
fileListData.addAll(nextDataSet);
5757
fileItemsData.clear();
5858
fileItemsData.addAll(nextFileItemsData);
59-
if(notifyAdapter) {
60-
notifyDataSetChanged();
61-
}
59+
notifyDataSetChanged();
6260
}
6361

6462
@Override
@@ -134,7 +132,7 @@ public BaseViewHolder(View v) {
134132
v.setOnClickListener(this);
135133
v.setOnLongClickListener(this);
136134
displayText = (TextView) v.findViewById(R.id.fileEntryBaseName);
137-
setIsRecyclable(false);
135+
//setIsRecyclable(false);
138136
}
139137

140138
public TextView getDisplayText() { return displayText; }

AndroidFilePickerLightLibrary/src/main/java/com/maxieds/androidfilepickerlightlibrary/DisplayFragments.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -238,27 +238,14 @@ public void displayNextDirectoryFilesList(List<DisplayTypes.FileType> workingDir
238238
activeFileItemsDataList.clear();
239239
fileItemBasePathsList.clear();
240240

241-
// This apparently needs to be done when updating the recycler view by posting new data.
242-
// Without this, the size of the list of views it stores grows without bound.
243-
// The other option is to set rv.setHasFixedSize(true), but this similarly causes problems by
244-
// freezing the scrolling when trying to update the layout with new data.
245-
// Thus we are having to just manually clear all the views on each data update to initialize the
246-
// list of subdisplays from a blank container (or thereabouts explains it).
247-
DisplayAdapters.FileListAdapter rvAdapter = (DisplayAdapters.FileListAdapter) mainFileListRecyclerView.getAdapter();
248-
LinearLayoutManager rvLayoutManager = (LinearLayoutManager) getMainRecyclerView().getLayoutManager();
249-
//rvLayoutManager.removeAllViews();
250-
//rvAdapter.notifyDataSetChanged();
251-
252241
final List<DisplayTypes.FileType> filteredFileContents = workingDirContentsList;
253242
for(int fidx = 0; fidx < filteredFileContents.size(); fidx++) {
254243
DisplayTypes.FileType fileItem = filteredFileContents.get(fidx);
255244
fileItemBasePathsList.add(fileItem.getBaseName());
256245
activeFileItemsDataList.add(fileItem);
257-
/*rvAdapter.reloadDataSets(fileItemBasePathsList, activeFileItemsDataList, true);
258-
DisplayAdapters.BaseViewHolder bvHolder = rvAdapter.createViewHolder(getMainRecyclerView(), VIEW_TYPE_FILE_ITEM);
259-
rvAdapter.bindViewHolder(bvHolder, fidx);*/
260246
}
261-
rvAdapter.reloadDataSets(fileItemBasePathsList, activeFileItemsDataList, true);
247+
DisplayAdapters.FileListAdapter rvAdapter = (DisplayAdapters.FileListAdapter) mainFileListRecyclerView.getAdapter();
248+
rvAdapter.reloadDataSets(fileItemBasePathsList, activeFileItemsDataList);
262249

263250
}
264251

AndroidFilePickerLightLibrary/src/main/java/com/maxieds/androidfilepickerlightlibrary/DisplayTypes.java

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,15 @@ public DirectoryResultContext(MatrixCursor mcResult, String parentFolderDocId, S
7474
public static final int STATUS_SUCCESS = 0;
7575
public static final int STATUS_END_OF_FOLDER = 2;
7676

77-
public int computeDirectoryContents(int startIndexPos, int maxIndexPos,
77+
public void computeDirectoryContents(int startIndexPos, int maxIndexPos,
7878
int trimFromFrontCount, int trimFromBackCount, int newItemsCount,
7979
boolean updateGlobalIndices) {
8080
Log.i(LOGTAG, String.format(Locale.getDefault(), "STARTING: Computing dir contents [%d, %d] -- %s", startIndexPos, maxIndexPos, activeCWDAbsPath));
8181
BasicFileProvider fpInst = BasicFileProvider.getInstance();
8282
if(fpInst == null) {
83-
return STATUS_ERROR;
83+
return;
8484
}
8585
fpInst.setFilesStartIndex(startIndexPos);
86-
//fpInst.setFilesListLength(Math.abs(newItemsCount));
8786
int initStartIndexPos = startIndexPos;
8887
try {
8988
fpInst.noUpdateQueryFilesList(); // save some time processing if we haven't recently loaded a new folder to process
@@ -95,13 +94,13 @@ public int computeDirectoryContents(int startIndexPos, int maxIndexPos,
9594
if(startIndexPos >= getInitialMatrixCursor().getCount() || maxIndexPos < startIndexPos) {
9695
Log.e(LOGTAG, String.format("RETURNING cursor positions out of range %d / [%d, %d] ... ", getInitialMatrixCursor().getCount(), startIndexPos, maxIndexPos));
9796
directoryContentsList.clear();
98-
return STATUS_ERROR;
97+
return;
9998
}
10099
startIndexPos = newItemsCount < 0 ? startIndexPos : startIndexPos + numItemsRequested - newItemsCount;
101100
maxIndexPos = newItemsCount > 0 ? maxIndexPos : maxIndexPos + newItemsCount;
102101
initMatrixCursorListing.moveToFirst();
103102
boolean appendNewItems = newItemsCount > 0;
104-
List<FileType> filesDataList = new ArrayList<FileType>();
103+
List<FileType> filesDataList = new ArrayList<FileType>(directoryContentsList.subList(trimFromFrontCount, directoryContentsList.size() - trimFromBackCount));
105104
int prependInsertIdx = 0, mcRowIdx;
106105
for (mcRowIdx = 0; mcRowIdx < Math.min(initMatrixCursorListing.getCount(), Math.abs(newItemsCount)); mcRowIdx++) {
107106
String[] filePropertiesList = fpInst.getPropertiesOfCurrentRow(initMatrixCursorListing, !BasicFileProvider.CURSOR_TYPE_IS_ROOT);
@@ -112,17 +111,15 @@ public int computeDirectoryContents(int startIndexPos, int maxIndexPos,
112111
boolean isDir = Boolean.parseBoolean(filePropertiesList[BasicFileProvider.PROPERTY_ISDIR]);
113112
boolean isHidden = Boolean.parseBoolean(filePropertiesList[BasicFileProvider.PROPERTY_ISHIDDEN]);
114113
FileType nextFileItem = new FileType(fileAbsPath, fileSize, filePosixPerms, isDir, isHidden, fileProviderDocId, this);
115-
filesDataList.add(nextFileItem);
114+
if(appendNewItems) {
115+
filesDataList.add(nextFileItem);
116+
}
117+
else {
118+
filesDataList.add(prependInsertIdx, nextFileItem);
119+
prependInsertIdx++;
120+
}
116121
initMatrixCursorListing.moveToNext();
117122
}
118-
ArrayList<FileType> priorListings = new ArrayList<FileType>(directoryContentsList.subList(trimFromFrontCount, directoryContentsList.size() - trimFromBackCount));
119-
if(appendNewItems) {
120-
filesDataList.addAll(priorListings);
121-
}
122-
else {
123-
priorListings.addAll(filesDataList);
124-
filesDataList = priorListings;
125-
}
126123
if(updateGlobalIndices) {
127124
int resultSizeDiff = Math.abs(newItemsCount) - mcRowIdx;
128125
Log.i(LOGTAG, String.format(Locale.getDefault(), "UPDATING GLOBAL INDICES: [%d, %d] -> [%d, %d]", initStartIndexPos,
@@ -131,24 +128,19 @@ public int computeDirectoryContents(int startIndexPos, int maxIndexPos,
131128
DisplayFragments.getInstance().lastFileDataEndIndex = DisplayFragments.getInstance().lastFileDataEndIndex - resultSizeDiff;
132129
}
133130
setNextDirectoryContents(filesDataList);
134-
if(mcRowIdx == Math.abs(newItemsCount)) {
135-
return STATUS_SUCCESS;
136-
}
137-
else {
138-
return STATUS_END_OF_FOLDER;
139-
}
140131
}
141132
catch(FileNotFoundException ioe) {
142133
ioe.printStackTrace();
134+
return;
143135
}
144-
return STATUS_ERROR;
136+
145137
}
146138

147-
public int computeDirectoryContents(int startIndexPos, int maxIndexPos) {
139+
public void computeDirectoryContents(int startIndexPos, int maxIndexPos) {
148140
BasicFileProvider fpInst = BasicFileProvider.getInstance();
149141
fpInst.setFilesListLength(DisplayFragments.getViewportMaxFilesCount());
150-
return computeDirectoryContents(startIndexPos, maxIndexPos,
151-
0, directoryContentsList.size(),maxIndexPos + 1 - startIndexPos, true);
142+
computeDirectoryContents(startIndexPos, maxIndexPos,
143+
0, directoryContentsList.size(),maxIndexPos + 1 - startIndexPos, true);
152144
}
153145

154146
public void clearDirectoryContentsList() {

0 commit comments

Comments
 (0)