1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 22:31:16 +00:00

Don't crash if global discovery disabled

This commit is contained in:
Felix Ableitner 2016-10-30 16:43:24 +09:00
parent f60e591a90
commit 60446d4381

View file

@ -9,6 +9,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.google.common.base.Optional;
import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.activities.MainActivity;
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));
mRamUsage.setText(Util.readableFileSize(mActivity, info.sys));
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",
announceConnected, announceTotal));
int color = (announceConnected > 0)