mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 14:21:16 +00:00
Fixed some crashes
This commit is contained in:
parent
d2323b5c1d
commit
9209a8fb6c
2 changed files with 10 additions and 9 deletions
|
@ -348,9 +348,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
|||
for (Map.Entry<String, Connections.Connection> e : connections.connections.entrySet()) {
|
||||
e.getValue().completion = getDeviceCompletion(e.getKey());
|
||||
|
||||
Connections.Connection prev = mPreviousConnections
|
||||
.transform(c -> c.connections.get(e.getKey()))
|
||||
.or(new Connections.Connection());
|
||||
Connections.Connection prev =
|
||||
(mPreviousConnections.isPresent() && mPreviousConnections.get().connections.containsKey(e.getKey()))
|
||||
? mPreviousConnections.get().connections.get(e.getKey())
|
||||
: new Connections.Connection();
|
||||
e.getValue().setTransferRate(prev, msElapsed);
|
||||
}
|
||||
Connections.Connection prev =
|
||||
|
|
|
@ -43,21 +43,21 @@ public class DevicesAdapter extends ArrayAdapter<Device> {
|
|||
TextView upload = (TextView) convertView.findViewById(R.id.upload);
|
||||
|
||||
String deviceId = getItem(position).deviceID;
|
||||
Optional<Connections.Connection> conn = mConnections.transform(a -> a.connections.get(deviceId));
|
||||
|
||||
name.setText(getItem(position).getDisplayName());
|
||||
Resources r = getContext().getResources();
|
||||
if (conn.isPresent() && conn.get().connected) {
|
||||
if (conn.get().completion == 100) {
|
||||
if (mConnections.isPresent() && mConnections.get().connections.containsKey(deviceId)) {
|
||||
Connections.Connection conn = mConnections.get().connections.get(deviceId);
|
||||
if (conn.completion == 100) {
|
||||
status.setText(r.getString(R.string.device_up_to_date));
|
||||
status.setTextColor(ContextCompat.getColor(getContext(), R.color.text_green));
|
||||
}
|
||||
else {
|
||||
status.setText(r.getString(R.string.device_syncing, conn.get().completion));
|
||||
status.setText(r.getString(R.string.device_syncing, conn.completion));
|
||||
status.setTextColor(ContextCompat.getColor(getContext(), R.color.text_blue));
|
||||
}
|
||||
download.setText(Util.readableTransferRate(getContext(), conn.get().inBits));
|
||||
upload.setText(Util.readableTransferRate(getContext(), conn.get().outBits));
|
||||
download.setText(Util.readableTransferRate(getContext(), conn.inBits));
|
||||
upload.setText(Util.readableTransferRate(getContext(), conn.outBits));
|
||||
}
|
||||
else {
|
||||
download.setText(Util.readableTransferRate(getContext(), 0));
|
||||
|
|
Loading…
Reference in a new issue