mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-30 08:11:17 +00:00
Fixed bug where devices were always shown as disconnected (fixes #800)
This commit is contained in:
parent
2778394b8f
commit
8bcf33b051
1 changed files with 4 additions and 5 deletions
|
@ -10,7 +10,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
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.model.Connections;
|
import com.nutomic.syncthingandroid.model.Connections;
|
||||||
import com.nutomic.syncthingandroid.model.Device;
|
import com.nutomic.syncthingandroid.model.Device;
|
||||||
|
@ -22,7 +21,7 @@ import com.nutomic.syncthingandroid.util.Util;
|
||||||
*/
|
*/
|
||||||
public class DevicesAdapter extends ArrayAdapter<Device> {
|
public class DevicesAdapter extends ArrayAdapter<Device> {
|
||||||
|
|
||||||
private Optional<Connections> mConnections = Optional.absent();
|
private Connections mConnections;
|
||||||
|
|
||||||
public DevicesAdapter(Context context) {
|
public DevicesAdapter(Context context) {
|
||||||
super(context, R.layout.item_device_list);
|
super(context, R.layout.item_device_list);
|
||||||
|
@ -46,8 +45,8 @@ public class DevicesAdapter extends ArrayAdapter<Device> {
|
||||||
|
|
||||||
name.setText(getItem(position).getDisplayName());
|
name.setText(getItem(position).getDisplayName());
|
||||||
Resources r = getContext().getResources();
|
Resources r = getContext().getResources();
|
||||||
if (mConnections.isPresent() && mConnections.get().connections.containsKey(deviceId)) {
|
if (mConnections != null && mConnections.connections.get(deviceId).connected) {
|
||||||
Connections.Connection conn = mConnections.get().connections.get(deviceId);
|
Connections.Connection conn = mConnections.connections.get(deviceId);
|
||||||
if (conn.completion == 100) {
|
if (conn.completion == 100) {
|
||||||
status.setText(r.getString(R.string.device_up_to_date));
|
status.setText(r.getString(R.string.device_up_to_date));
|
||||||
status.setTextColor(ContextCompat.getColor(getContext(), R.color.text_green));
|
status.setTextColor(ContextCompat.getColor(getContext(), R.color.text_green));
|
||||||
|
@ -79,7 +78,7 @@ public class DevicesAdapter extends ArrayAdapter<Device> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReceiveConnections(Connections connections) {
|
public void onReceiveConnections(Connections connections) {
|
||||||
mConnections = Optional.of(connections);
|
mConnections = connections;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue