1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-23 12:51:16 +00:00

Fixed crash when closing DeviceFragment early (reported on GPlay)

This commit is contained in:
Felix Ableitner 2016-08-19 02:54:24 +02:00
parent 972f38755a
commit 77c2d4bd55
2 changed files with 4 additions and 3 deletions

View file

@ -397,7 +397,7 @@ public class DeviceFragment extends Fragment implements
* Sends the updated device info if in edit mode. * Sends the updated device info if in edit mode.
*/ */
private void updateDevice() { private void updateDevice() {
if (!mIsCreateMode && mDeviceNeedsToUpdate) { if (!mIsCreateMode && mDeviceNeedsToUpdate && mDevice != null) {
mSyncthingService.getApi().editDevice(mDevice, getActivity(), this); mSyncthingService.getApi().editDevice(mDevice, getActivity(), this);
} }
} }

View file

@ -7,6 +7,7 @@ import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
@ -834,8 +835,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
* @param device Settings of the device to edit. To create a device, pass a non-existant device ID. * @param device Settings of the device to edit. To create a device, pass a non-existant device ID.
* @param listener for the normalized device ID (may be null). * @param listener for the normalized device ID (may be null).
*/ */
public void editDevice(final Device device, final Activity activity, public void editDevice(@NonNull final Device device, final Activity activity,
final OnDeviceIdNormalizedListener listener) { final OnDeviceIdNormalizedListener listener) {
normalizeDeviceId(device.deviceID, normalizeDeviceId(device.deviceID,
new RestApi.OnDeviceIdNormalizedListener() { new RestApi.OnDeviceIdNormalizedListener() {
@Override @Override