mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 22:31:16 +00:00
Don't reset scroll position when updating device/folder list (fixes #579).
This commit is contained in:
parent
deda1582df
commit
02c93dee6e
3 changed files with 7 additions and 1 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue