1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-23 12:51:16 +00:00

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); setListAdapter(mAdapter);
} }
// Prevent scroll position reset due to list update from clear().
mAdapter.setNotifyOnChange(false);
mAdapter.clear(); mAdapter.clear();
List<RestApi.Device> devices = activity.getApi().getDevices(false); List<RestApi.Device> devices = activity.getApi().getDevices(false);
Collections.sort(devices, DEVICES_COMPARATOR); Collections.sort(devices, DEVICES_COMPARATOR);
mAdapter.addAll(devices); mAdapter.addAll(devices);
mAdapter.updateConnections(activity.getApi()); mAdapter.updateConnections(activity.getApi());
mAdapter.notifyDataSetChanged();
setListShown(true); setListShown(true);
} }

View file

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

View file

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