mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 04:41:16 +00:00
Use inSyncBytes instead of localBytes to calculate sync progress (fixes #93).
Also rename variable to clarify.
This commit is contained in:
parent
77eaffa4b7
commit
8d781844a2
2 changed files with 12 additions and 14 deletions
|
@ -548,8 +548,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
|||
return;
|
||||
|
||||
Long now = System.currentTimeMillis();
|
||||
Long difference = (now - mPreviousConnectionTime) / 1000;
|
||||
if (difference < 1) {
|
||||
Long timeElapsed = (now - mPreviousConnectionTime) / 1000;
|
||||
if (timeElapsed < 1) {
|
||||
listener.onReceiveConnections(mPreviousConnections);
|
||||
return;
|
||||
}
|
||||
|
@ -573,12 +573,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
|||
? mPreviousConnections.get(deviceId)
|
||||
: new Connection();
|
||||
mPreviousConnectionTime = now;
|
||||
if (difference != 0) {
|
||||
c.InBits = Math.max(0, 8 *
|
||||
(conn.getLong("InBytesTotal") - prev.InBytesTotal) / difference);
|
||||
c.OutBits = Math.max(0, 8 *
|
||||
(conn.getLong("OutBytesTotal") - prev.OutBytesTotal) / difference);
|
||||
}
|
||||
c.InBits = Math.max(0, 8 *
|
||||
(conn.getLong("InBytesTotal") - prev.InBytesTotal) / timeElapsed);
|
||||
c.OutBits = Math.max(0, 8 *
|
||||
(conn.getLong("OutBytesTotal") - prev.OutBytesTotal) / timeElapsed);
|
||||
|
||||
connections.put(deviceId, c);
|
||||
|
||||
|
|
|
@ -47,14 +47,14 @@ public class FoldersAdapter extends ArrayAdapter<RestApi.Folder>
|
|||
state.setTextColor(getContext().getResources().getColor(R.color.text_green));
|
||||
directory.setText((folder.Path));
|
||||
if (model != null) {
|
||||
int percentage = (model.globalBytes != 0)
|
||||
? (int) Math.floor(100 * model.inSyncBytes / model.globalBytes)
|
||||
: 100;
|
||||
state.setText(getContext().getString(R.string.folder_progress_format, model.state,
|
||||
(model.globalBytes <= 0)
|
||||
? 100
|
||||
: (int) ((model.localBytes / (float) model.globalBytes) * 100)
|
||||
));
|
||||
percentage));
|
||||
items.setText(getContext()
|
||||
.getString(R.string.files, model.localFiles, model.globalFiles));
|
||||
size.setText(RestApi.readableFileSize(getContext(), model.localBytes) + " / " +
|
||||
.getString(R.string.files, model.inSyncFiles, model.globalFiles));
|
||||
size.setText(RestApi.readableFileSize(getContext(), model.inSyncBytes) + " / " +
|
||||
RestApi.readableFileSize(getContext(), model.globalBytes));
|
||||
if (folder.Invalid.equals("")) {
|
||||
invalid.setText(model.invalid);
|
||||
|
|
Loading…
Reference in a new issue