mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 06:09:55 +01:00
Add a MutableLiveData to RemoteWipeSetupState
This commit is contained in:
@@ -31,7 +31,7 @@ public class RemoteWipeSetupActivity extends BriarActivity implements
|
|||||||
viewModel = new ViewModelProvider(this, viewModelFactory)
|
viewModel = new ViewModelProvider(this, viewModelFactory)
|
||||||
.get(RemoteWipeSetupViewModel.class);
|
.get(RemoteWipeSetupViewModel.class);
|
||||||
|
|
||||||
// viewModel.getState().observeEvent(this, this::onStateChanged);
|
viewModel.getState().observe(this, this::onStateChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,6 +43,7 @@ public class RemoteWipeSetupActivity extends BriarActivity implements
|
|||||||
} else {
|
} else {
|
||||||
showInitialFragment(WiperSelectorFragment.newInstance());
|
showInitialFragment(WiperSelectorFragment.newInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -57,4 +58,15 @@ public class RemoteWipeSetupActivity extends BriarActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onStateChanged(RemoteWipeSetupState state) {
|
||||||
|
if (state.equals(RemoteWipeSetupState.SUCCESS)) {
|
||||||
|
Toast.makeText(this,
|
||||||
|
"Success",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
} else if (state.equals(RemoteWipeSetupState.FAILED)) {
|
||||||
|
Toast.makeText(this,
|
||||||
|
"Failed",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package org.briarproject.briar.android.remotewipe;
|
||||||
|
|
||||||
|
public enum RemoteWipeSetupState {
|
||||||
|
FAILED,
|
||||||
|
SUCCESS
|
||||||
|
}
|
||||||
@@ -16,10 +16,12 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.AndroidViewModel;
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
public class RemoteWipeSetupViewModel extends AndroidViewModel {
|
public class RemoteWipeSetupViewModel extends AndroidViewModel {
|
||||||
private final RemoteWipeManager remoteWipeManager;
|
private final RemoteWipeManager remoteWipeManager;
|
||||||
private final DatabaseComponent db;
|
private final DatabaseComponent db;
|
||||||
|
private final MutableLiveData<RemoteWipeSetupState> state = new MutableLiveData<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RemoteWipeSetupViewModel(
|
RemoteWipeSetupViewModel(
|
||||||
@@ -44,7 +46,12 @@ public class RemoteWipeSetupViewModel extends AndroidViewModel {
|
|||||||
throws DbException, FormatException {
|
throws DbException, FormatException {
|
||||||
db.transaction(false, txn -> {
|
db.transaction(false, txn -> {
|
||||||
remoteWipeManager.setup(txn, (List<ContactId>) wipers);
|
remoteWipeManager.setup(txn, (List<ContactId>) wipers);
|
||||||
|
state.postValue(RemoteWipeSetupState.SUCCESS);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<RemoteWipeSetupState> getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user