Fix concurrent modification of adapter in dropbox sample

Fixes #75
This commit is contained in:
Jonas Kalderstam 2016-02-24 02:24:57 +01:00
parent 9880562413
commit b7baea3711
1 changed files with 21 additions and 1 deletions

View File

@ -210,7 +210,7 @@ public class DropboxFilePickerFragment
@Override
public SortedList<DropboxAPI.Entry> loadInBackground() {
SortedList<DropboxAPI.Entry> files = new SortedList<>(DropboxAPI.Entry.class,
new SortedListAdapterCallback<DropboxAPI.Entry>(getAdapter()) {
new SortedListAdapterCallback<DropboxAPI.Entry>(null) {
@Override
public int compare(DropboxAPI.Entry lhs, DropboxAPI.Entry rhs) {
if (isDir(lhs) && !isDir(rhs)) {
@ -223,6 +223,26 @@ public class DropboxFilePickerFragment
}
}
@Override
public void onInserted(int position, int count) {
// Ignore (DO NOT MODIFY ADAPTER HERE!)
}
@Override
public void onRemoved(int position, int count) {
// Ignore (DO NOT MODIFY ADAPTER HERE!)
}
@Override
public void onMoved(int fromPosition, int toPosition) {
// Ignore (DO NOT MODIFY ADAPTER HERE!)
}
@Override
public void onChanged(int position, int count) {
// Ignore (DO NOT MODIFY ADAPTER HERE!)
}
@Override
public boolean areContentsTheSame(DropboxAPI.Entry lhs, DropboxAPI.Entry rhs) {
return lhs.fileName().equals(rhs.fileName()) && (lhs.isDir == rhs.isDir);