mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 12:51:16 +00:00
Don't crash if global discovery disabled
This commit is contained in:
parent
f60e591a90
commit
60446d4381
1 changed files with 4 additions and 1 deletions
|
@ -9,6 +9,8 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.nutomic.syncthingandroid.R;
|
import com.nutomic.syncthingandroid.R;
|
||||||
import com.nutomic.syncthingandroid.activities.MainActivity;
|
import com.nutomic.syncthingandroid.activities.MainActivity;
|
||||||
import com.nutomic.syncthingandroid.activities.SettingsActivity;
|
import com.nutomic.syncthingandroid.activities.SettingsActivity;
|
||||||
|
@ -166,7 +168,8 @@ public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemI
|
||||||
mCpuUsage.setText(percentFormat.format(info.cpuPercent / 100));
|
mCpuUsage.setText(percentFormat.format(info.cpuPercent / 100));
|
||||||
mRamUsage.setText(Util.readableFileSize(mActivity, info.sys));
|
mRamUsage.setText(Util.readableFileSize(mActivity, info.sys));
|
||||||
int announceTotal = info.discoveryMethods;
|
int announceTotal = info.discoveryMethods;
|
||||||
int announceConnected = announceTotal - info.discoveryErrors.size();
|
int announceConnected =
|
||||||
|
announceTotal - Optional.fromNullable(info.discoveryErrors).transform(Map::size).or(0);
|
||||||
mAnnounceServer.setText(String.format(Locale.getDefault(), "%1$d/%2$d",
|
mAnnounceServer.setText(String.format(Locale.getDefault(), "%1$d/%2$d",
|
||||||
announceConnected, announceTotal));
|
announceConnected, announceTotal));
|
||||||
int color = (announceConnected > 0)
|
int color = (announceConnected > 0)
|
||||||
|
|
Loading…
Reference in a new issue