Don't reset scroll position when updating device/folder list (fixes #579).

This commit is contained in:
Felix Ableitner 2016-03-20 19:28:25 +01:00
parent deda1582df
commit 02c93dee6e
3 changed files with 7 additions and 1 deletions

View File

@ -104,11 +104,14 @@ public class DeviceListFragment extends ListFragment implements SyncthingService
setListAdapter(mAdapter);
}
// Prevent scroll position reset due to list update from clear().
mAdapter.setNotifyOnChange(false);
mAdapter.clear();
List<RestApi.Device> devices = activity.getApi().getDevices(false);
Collections.sort(devices, DEVICES_COMPARATOR);
mAdapter.addAll(devices);
mAdapter.updateConnections(activity.getApi());
mAdapter.notifyDataSetChanged();
setListShown(true);
}

View File

@ -105,11 +105,14 @@ public class FolderListFragment extends ListFragment implements SyncthingService
setListAdapter(mAdapter);
}
// Prevent scroll position reset due to list update from clear().
mAdapter.setNotifyOnChange(false);
mAdapter.clear();
List<RestApi.Folder> folders = activity.getApi().getFolders();
Collections.sort(folders, FOLDERS_COMPARATOR);
mAdapter.addAll(folders);
mAdapter.updateModel(activity.getApi());
mAdapter.notifyDataSetChanged();
setListShown(true);
}

View File

@ -79,6 +79,6 @@ public class DevicesAdapter extends ArrayAdapter<RestApi.Device>
@Override
public void onReceiveConnections(Map<String, RestApi.Connection> connections) {
mConnections = connections;
notifyDataSetInvalidated();
notifyDataSetChanged();
}
}