Search in sources :

Example 6 with StateLao

use of com.github.dedis.popstellar.model.network.method.message.data.lao.StateLao in project popstellar by dedis.

the class MessageHandler method notifyLaoUpdate.

/**
 * Keep the UI up to date by notifying all observers the updated LAO state.
 *
 * <p>The LAO is updated if the channel of the message is a LAO channel and the message is not a
 * WitnessSignatureMessage.
 *
 * <p>If a LAO has been created or modified then the LAO lists in the LAORepository are updated.
 *
 * @param laoRepository the repository to access the LAO lists
 * @param data the data received
 * @param channel the channel of the message received
 */
private void notifyLaoUpdate(LAORepository laoRepository, Data data, Channel channel) {
    if (!(data instanceof WitnessMessageSignature) && channel.isLaoChannel()) {
        LAOState laoState = laoRepository.getLaoById().get(channel.extractLaoId());
        // Trigger an onNext
        laoState.publish();
        if (data instanceof StateLao || data instanceof CreateLao) {
            laoRepository.setAllLaoSubject();
        }
    }
}
Also used : WitnessMessageSignature(com.github.dedis.popstellar.model.network.method.message.data.message.WitnessMessageSignature) LAOState(com.github.dedis.popstellar.repository.LAOState) CreateLao(com.github.dedis.popstellar.model.network.method.message.data.lao.CreateLao) StateLao(com.github.dedis.popstellar.model.network.method.message.data.lao.StateLao)

Aggregations

StateLao (com.github.dedis.popstellar.model.network.method.message.data.lao.StateLao)6 MessageGeneral (com.github.dedis.popstellar.model.network.method.message.MessageGeneral)4 UpdateLao (com.github.dedis.popstellar.model.network.method.message.data.lao.UpdateLao)4 Channel (com.github.dedis.popstellar.model.objects.Channel)4 Lao (com.github.dedis.popstellar.model.objects.Lao)4 KeyPair (com.github.dedis.popstellar.model.objects.security.KeyPair)3 CreateLao (com.github.dedis.popstellar.model.network.method.message.data.lao.CreateLao)2 WitnessMessageSignature (com.github.dedis.popstellar.model.network.method.message.data.message.WitnessMessageSignature)2 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)2 Disposable (io.reactivex.disposables.Disposable)2 Manifest (android.Manifest)1 Application (android.app.Application)1 PackageManager (android.content.pm.PackageManager)1 Log (android.util.Log)1 Toast (android.widget.Toast)1 NonNull (androidx.annotation.NonNull)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 ContextCompat (androidx.core.content.ContextCompat)1 AndroidViewModel (androidx.lifecycle.AndroidViewModel)1 LiveData (androidx.lifecycle.LiveData)1