use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetDevice in project AntennaPod by AntennaPod.
the class GpodderAuthenticationFragment method createDevice.
private void createDevice(View view) {
final EditText deviceName = view.findViewById(R.id.deviceName);
final TextView txtvError = view.findViewById(R.id.deviceSelectError);
final ProgressBar progBarCreateDevice = view.findViewById(R.id.progbarCreateDevice);
String deviceNameStr = deviceName.getText().toString();
if (isDeviceInList(deviceNameStr)) {
return;
}
progBarCreateDevice.setVisibility(View.VISIBLE);
txtvError.setVisibility(View.GONE);
deviceName.setEnabled(false);
Observable.fromCallable(() -> {
String deviceId = generateDeviceId(deviceNameStr);
service.configureDevice(deviceId, deviceNameStr, GpodnetDevice.DeviceType.MOBILE);
return new GpodnetDevice(deviceId, deviceNameStr, GpodnetDevice.DeviceType.MOBILE.toString(), 0);
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(device -> {
progBarCreateDevice.setVisibility(View.GONE);
selectedDevice = device;
advance();
}, error -> {
deviceName.setEnabled(true);
progBarCreateDevice.setVisibility(View.GONE);
txtvError.setText(error.getMessage());
txtvError.setVisibility(View.VISIBLE);
});
}
use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetDevice in project AntennaPod by AntennaPod.
the class GpodderAuthenticationFragment method setupDeviceView.
private void setupDeviceView(View view) {
final EditText deviceName = view.findViewById(R.id.deviceName);
final LinearLayout devicesContainer = view.findViewById(R.id.devicesContainer);
deviceName.setText(generateDeviceName());
MaterialButton createDeviceButton = view.findViewById(R.id.createDeviceButton);
createDeviceButton.setOnClickListener(v -> createDevice(view));
for (GpodnetDevice device : devices) {
View row = View.inflate(getContext(), R.layout.gpodnetauth_device_row, null);
Button selectDeviceButton = row.findViewById(R.id.selectDeviceButton);
selectDeviceButton.setOnClickListener(v -> {
selectedDevice = device;
advance();
});
selectDeviceButton.setText(device.getCaption());
devicesContainer.addView(row);
}
}
Aggregations