Upgrade to EventBus 3.X

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-02-17 20:27:11 -08:00
parent d5b7ff58e2
commit 1b1470aae2
9 changed files with 26 additions and 20 deletions

View File

@ -69,7 +69,7 @@ dependencies {
compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.makeramen:roundedimageview:2.1.0' compile 'com.makeramen:roundedimageview:2.1.0'
compile 'com.pnikosis:materialish-progress:1.5' compile 'com.pnikosis:materialish-progress:1.5'
compile 'de.greenrobot:eventbus:2.4.0' compile 'org.greenrobot:eventbus:3.0.0'
compile 'pl.tajchert:waitingdots:0.1.0' compile 'pl.tajchert:waitingdots:0.1.0'
compile 'com.soundcloud.android:android-crop:0.9.10@aar' compile 'com.soundcloud.android:android-crop:0.9.10@aar'
compile 'com.melnykov:floatingactionbutton:1.3.0' compile 'com.melnykov:floatingactionbutton:1.3.0'
@ -138,7 +138,7 @@ dependencyVerification {
'com.github.bumptech.glide:glide:76ef123957b5fbaebb05fcbe6606dd58c3bc3fcdadb257f99811d0ac9ea9b88b', 'com.github.bumptech.glide:glide:76ef123957b5fbaebb05fcbe6606dd58c3bc3fcdadb257f99811d0ac9ea9b88b',
'com.makeramen:roundedimageview:1f5a1865796b308c6cdd114acc6e78408b110f0a62fc63553278fbeacd489cd1', 'com.makeramen:roundedimageview:1f5a1865796b308c6cdd114acc6e78408b110f0a62fc63553278fbeacd489cd1',
'com.pnikosis:materialish-progress:d71d80e00717a096784482aee21001a9d299fec3833e4ebd87739ed36cf77c54', 'com.pnikosis:materialish-progress:d71d80e00717a096784482aee21001a9d299fec3833e4ebd87739ed36cf77c54',
'de.greenrobot:eventbus:61d743a748156a372024d083de763b9e91ac2dcb3f6a1cbc74995c7ddab6e968', 'org.greenrobot:eventbus:180d4212467df06f2fbc9c8d8a2984533ac79c87769ad883bc421612f0b4e17c',
'pl.tajchert:waitingdots:2835d49e0787dbcb606c5a60021ced66578503b1e9fddcd7a5ef0cd5f095ba2c', 'pl.tajchert:waitingdots:2835d49e0787dbcb606c5a60021ced66578503b1e9fddcd7a5ef0cd5f095ba2c',
'com.soundcloud.android:android-crop:ffd4b973cf6e97f7d64118a0dc088df50e9066fd5634fe6911dd0c0c5d346177', 'com.soundcloud.android:android-crop:ffd4b973cf6e97f7d64118a0dc088df50e9066fd5634fe6911dd0c0c5d346177',
'com.melnykov:floatingactionbutton:15d58d4fac0f7a288d0e5301bbaf501a146f5b3f5921277811bf99bd3b397263', 'com.melnykov:floatingactionbutton:15d58d4fac0f7a288d0e5301bbaf501a146f5b3f5921277811bf99bd3b397263',

View File

@ -35,6 +35,9 @@ import android.util.Log;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.thoughtcrime.redphone.ui.CallControls; import org.thoughtcrime.redphone.ui.CallControls;
import org.thoughtcrime.redphone.ui.CallScreen; import org.thoughtcrime.redphone.ui.CallScreen;
import org.thoughtcrime.redphone.util.AudioUtils; import org.thoughtcrime.redphone.util.AudioUtils;
@ -43,7 +46,6 @@ import org.thoughtcrime.securesms.events.RedPhoneEvent;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.TextSecurePreferences;
import de.greenrobot.event.EventBus;
/** /**
* The main UI class for RedPhone. Most of the heavy lifting is * The main UI class for RedPhone. Most of the heavy lifting is
@ -87,7 +89,7 @@ public class RedPhone extends Activity {
super.onResume(); super.onResume();
initializeScreenshotSecurity(); initializeScreenshotSecurity();
EventBus.getDefault().registerSticky(this); EventBus.getDefault().register(this);
registerBluetoothReceiver(); registerBluetoothReceiver();
} }
@ -305,7 +307,7 @@ public class RedPhone extends Activity {
}, delayMillis); }, delayMillis);
} }
@SuppressWarnings("unused") @Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(final RedPhoneEvent event) { public void onEventMainThread(final RedPhoneEvent event) {
Log.w(TAG, "Got message from service: " + event.getType()); Log.w(TAG, "Got message from service: " + event.getType());

View File

@ -37,6 +37,7 @@ import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.util.Pair; import android.util.Pair;
import org.greenrobot.eventbus.EventBus;
import org.thoughtcrime.redphone.audio.IncomingRinger; import org.thoughtcrime.redphone.audio.IncomingRinger;
import org.thoughtcrime.redphone.audio.OutgoingRinger; import org.thoughtcrime.redphone.audio.OutgoingRinger;
import org.thoughtcrime.redphone.call.CallManager; import org.thoughtcrime.redphone.call.CallManager;
@ -71,7 +72,6 @@ import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import de.greenrobot.event.EventBus;
/** /**
* The major entry point for all of the heavy lifting associated with * The major entry point for all of the heavy lifting associated with

View File

@ -35,6 +35,9 @@ import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.thoughtcrime.redphone.util.AudioUtils; import org.thoughtcrime.redphone.util.AudioUtils;
import org.thoughtcrime.securesms.components.webrtc.WebRtcCallControls; import org.thoughtcrime.securesms.components.webrtc.WebRtcCallControls;
import org.thoughtcrime.securesms.components.webrtc.WebRtcCallScreen; import org.thoughtcrime.securesms.components.webrtc.WebRtcCallScreen;
@ -51,8 +54,6 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.ViewUtil; import org.thoughtcrime.securesms.util.ViewUtil;
import org.whispersystems.libsignal.IdentityKey; import org.whispersystems.libsignal.IdentityKey;
import de.greenrobot.event.EventBus;
public class WebRtcCallActivity extends Activity { public class WebRtcCallActivity extends Activity {
private static final String TAG = WebRtcCallActivity.class.getSimpleName(); private static final String TAG = WebRtcCallActivity.class.getSimpleName();
@ -91,7 +92,7 @@ public class WebRtcCallActivity extends Activity {
super.onResume(); super.onResume();
if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStarted(this); if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStarted(this);
initializeScreenshotSecurity(); initializeScreenshotSecurity();
EventBus.getDefault().registerSticky(this); EventBus.getDefault().register(this);
registerBluetoothReceiver(); registerBluetoothReceiver();
registerWiredHeadsetReceiver(); registerWiredHeadsetReceiver();
@ -306,7 +307,7 @@ public class WebRtcCallActivity extends Activity {
}, delayMillis); }, delayMillis);
} }
@SuppressWarnings("unused") @Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(final WebRtcViewModel event) { public void onEventMainThread(final WebRtcViewModel event) {
Log.w(TAG, "Got message from service: " + event); Log.w(TAG, "Got message from service: " + event);

View File

@ -22,6 +22,9 @@ import android.widget.TextView;
import com.pnikosis.materialishprogress.ProgressWheel; import com.pnikosis.materialishprogress.ProgressWheel;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.audio.AudioSlidePlayer; import org.thoughtcrime.securesms.audio.AudioSlidePlayer;
import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.crypto.MasterSecret;
@ -34,7 +37,6 @@ import org.thoughtcrime.securesms.util.Util;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import de.greenrobot.event.EventBus;
public class AudioView extends FrameLayout implements AudioSlidePlayer.Listener { public class AudioView extends FrameLayout implements AudioSlidePlayer.Listener {
@ -97,7 +99,7 @@ public class AudioView extends FrameLayout implements AudioSlidePlayer.Listener
@Override @Override
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();
if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().registerSticky(this); if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().register(this);
} }
@Override @Override
@ -323,7 +325,7 @@ public class AudioView extends FrameLayout implements AudioSlidePlayer.Listener
} }
} }
@SuppressWarnings("unused") @Subscribe(sticky = true, threadMode = ThreadMode.ASYNC)
public void onEventAsync(final PartProgressEvent event) { public void onEventAsync(final PartProgressEvent event) {
if (audioSlidePlayer != null && event.attachment.equals(this.audioSlidePlayer.getAudioSlide().asAttachment())) { if (audioSlidePlayer != null && event.attachment.equals(this.audioSlidePlayer.getAudioSlide().asAttachment())) {
Util.runOnMain(new Runnable() { Util.runOnMain(new Runnable() {

View File

@ -20,6 +20,9 @@ import com.nineoldandroids.animation.ValueAnimator;
import com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener; import com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener;
import com.pnikosis.materialishprogress.ProgressWheel; import com.pnikosis.materialishprogress.ProgressWheel;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.database.AttachmentDatabase; import org.thoughtcrime.securesms.database.AttachmentDatabase;
import org.thoughtcrime.securesms.events.PartProgressEvent; import org.thoughtcrime.securesms.events.PartProgressEvent;
@ -27,8 +30,6 @@ import org.thoughtcrime.securesms.mms.Slide;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil; import org.thoughtcrime.securesms.util.ViewUtil;
import de.greenrobot.event.EventBus;
public class TransferControlView extends FrameLayout { public class TransferControlView extends FrameLayout {
private static final int TRANSITION_MS = 300; private static final int TRANSITION_MS = 300;
@ -81,7 +82,7 @@ public class TransferControlView extends FrameLayout {
@Override @Override
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();
if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().registerSticky(this); if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().register(this);
} }
@Override @Override
@ -162,7 +163,7 @@ public class TransferControlView extends FrameLayout {
return anim; return anim;
} }
@SuppressWarnings("unused") @Subscribe(sticky = true, threadMode = ThreadMode.ASYNC)
public void onEventAsync(final PartProgressEvent event) { public void onEventAsync(final PartProgressEvent event) {
if (this.slide != null && event.attachment.equals(this.slide.asAttachment())) { if (this.slide != null && event.attachment.equals(this.slide.asAttachment())) {
Util.runOnMain(new Runnable() { Util.runOnMain(new Runnable() {

View File

@ -5,6 +5,7 @@ import android.support.annotation.VisibleForTesting;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import org.greenrobot.eventbus.EventBus;
import org.thoughtcrime.securesms.attachments.Attachment; import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.attachments.AttachmentId; import org.thoughtcrime.securesms.attachments.AttachmentId;
import org.thoughtcrime.securesms.crypto.AsymmetricMasterSecret; import org.thoughtcrime.securesms.crypto.AsymmetricMasterSecret;
@ -33,7 +34,6 @@ import java.io.InputStream;
import javax.inject.Inject; import javax.inject.Inject;
import de.greenrobot.event.EventBus;
import ws.com.google.android.mms.MmsException; import ws.com.google.android.mms.MmsException;
public class AttachmentDownloadJob extends MasterSecretJob implements InjectableType { public class AttachmentDownloadJob extends MasterSecretJob implements InjectableType {

View File

@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.jobs;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import org.greenrobot.eventbus.EventBus;
import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.TextSecureExpiredException; import org.thoughtcrime.securesms.TextSecureExpiredException;
import org.thoughtcrime.securesms.attachments.Attachment; import org.thoughtcrime.securesms.attachments.Attachment;
@ -29,7 +30,6 @@ import java.io.InputStream;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import de.greenrobot.event.EventBus;
import ws.com.google.android.mms.ContentType; import ws.com.google.android.mms.ContentType;
public abstract class PushSendJob extends SendJob { public abstract class PushSendJob extends SendJob {

View File

@ -21,6 +21,7 @@ import android.util.Pair;
import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.InvalidProtocolBufferException;
import org.greenrobot.eventbus.EventBus;
import org.thoughtcrime.redphone.RedPhoneService; import org.thoughtcrime.redphone.RedPhoneService;
import org.thoughtcrime.redphone.audio.IncomingRinger; import org.thoughtcrime.redphone.audio.IncomingRinger;
import org.thoughtcrime.redphone.call.LockManager; import org.thoughtcrime.redphone.call.LockManager;
@ -95,7 +96,6 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject; import javax.inject.Inject;
import de.greenrobot.event.EventBus;
import static org.thoughtcrime.securesms.webrtc.CallNotificationManager.TYPE_ESTABLISHED; import static org.thoughtcrime.securesms.webrtc.CallNotificationManager.TYPE_ESTABLISHED;
import static org.thoughtcrime.securesms.webrtc.CallNotificationManager.TYPE_INCOMING_RINGING; import static org.thoughtcrime.securesms.webrtc.CallNotificationManager.TYPE_INCOMING_RINGING;