Search in sources :

Example 1 with GpodnetDevice

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);
    });
}
Also used : EditText(android.widget.EditText) TextView(android.widget.TextView) ProgressBar(android.widget.ProgressBar) GpodnetDevice(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetDevice)

Example 2 with GpodnetDevice

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);
    }
}
Also used : EditText(android.widget.EditText) MaterialButton(com.google.android.material.button.MaterialButton) Button(android.widget.Button) MaterialButton(com.google.android.material.button.MaterialButton) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) GpodnetDevice(de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetDevice)

Aggregations

EditText (android.widget.EditText)2 TextView (android.widget.TextView)2 GpodnetDevice (de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetDevice)2 View (android.view.View)1 Button (android.widget.Button)1 LinearLayout (android.widget.LinearLayout)1 ProgressBar (android.widget.ProgressBar)1 MaterialButton (com.google.android.material.button.MaterialButton)1