Skip to content

Commit

Permalink
Upgrade to EventBus 3.X
Browse files Browse the repository at this point in the history
// FREEBIE
  • Loading branch information
moxie0 committed Feb 19, 2017
1 parent d5b7ff5 commit 1b1470a
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dependencies {
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.makeramen:roundedimageview:2.1.0'
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 'com.soundcloud.android:android-crop:0.9.10@aar'
compile 'com.melnykov:floatingactionbutton:1.3.0'
Expand Down Expand Up @@ -138,7 +138,7 @@ dependencyVerification {
'com.github.bumptech.glide:glide:76ef123957b5fbaebb05fcbe6606dd58c3bc3fcdadb257f99811d0ac9ea9b88b',
'com.makeramen:roundedimageview:1f5a1865796b308c6cdd114acc6e78408b110f0a62fc63553278fbeacd489cd1',
'com.pnikosis:materialish-progress:d71d80e00717a096784482aee21001a9d299fec3833e4ebd87739ed36cf77c54',
'de.greenrobot:eventbus:61d743a748156a372024d083de763b9e91ac2dcb3f6a1cbc74995c7ddab6e968',
'org.greenrobot:eventbus:180d4212467df06f2fbc9c8d8a2984533ac79c87769ad883bc421612f0b4e17c',
'pl.tajchert:waitingdots:2835d49e0787dbcb606c5a60021ced66578503b1e9fddcd7a5ef0cd5f095ba2c',
'com.soundcloud.android:android-crop:ffd4b973cf6e97f7d64118a0dc088df50e9066fd5634fe6911dd0c0c5d346177',
'com.melnykov:floatingactionbutton:15d58d4fac0f7a288d0e5301bbaf501a146f5b3f5921277811bf99bd3b397263',
Expand Down
8 changes: 5 additions & 3 deletions src/org/thoughtcrime/redphone/RedPhone.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
import android.view.Window;
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.CallScreen;
import org.thoughtcrime.redphone.util.AudioUtils;
Expand All @@ -43,7 +46,6 @@
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.TextSecurePreferences;

import de.greenrobot.event.EventBus;

/**
* The main UI class for RedPhone. Most of the heavy lifting is
Expand Down Expand Up @@ -87,7 +89,7 @@ public void onResume() {
super.onResume();

initializeScreenshotSecurity();
EventBus.getDefault().registerSticky(this);
EventBus.getDefault().register(this);
registerBluetoothReceiver();
}

Expand Down Expand Up @@ -305,7 +307,7 @@ public void run() {
}, delayMillis);
}

@SuppressWarnings("unused")
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(final RedPhoneEvent event) {
Log.w(TAG, "Got message from service: " + event.getType());

Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/redphone/RedPhoneService.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import android.util.Log;
import android.util.Pair;

import org.greenrobot.eventbus.EventBus;
import org.thoughtcrime.redphone.audio.IncomingRinger;
import org.thoughtcrime.redphone.audio.OutgoingRinger;
import org.thoughtcrime.redphone.call.CallManager;
Expand Down Expand Up @@ -71,7 +72,6 @@
import java.security.SecureRandom;
import java.util.concurrent.ExecutionException;

import de.greenrobot.event.EventBus;

/**
* The major entry point for all of the heavy lifting associated with
Expand Down
9 changes: 5 additions & 4 deletions src/org/thoughtcrime/securesms/WebRtcCallActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
import android.view.Window;
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.securesms.components.webrtc.WebRtcCallControls;
import org.thoughtcrime.securesms.components.webrtc.WebRtcCallScreen;
Expand All @@ -51,8 +54,6 @@
import org.thoughtcrime.securesms.util.ViewUtil;
import org.whispersystems.libsignal.IdentityKey;

import de.greenrobot.event.EventBus;

public class WebRtcCallActivity extends Activity {

private static final String TAG = WebRtcCallActivity.class.getSimpleName();
Expand Down Expand Up @@ -91,7 +92,7 @@ public void onResume() {
super.onResume();
if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStarted(this);
initializeScreenshotSecurity();
EventBus.getDefault().registerSticky(this);
EventBus.getDefault().register(this);

registerBluetoothReceiver();
registerWiredHeadsetReceiver();
Expand Down Expand Up @@ -306,7 +307,7 @@ public void run() {
}, delayMillis);
}

@SuppressWarnings("unused")
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(final WebRtcViewModel event) {
Log.w(TAG, "Got message from service: " + event);

Expand Down
8 changes: 5 additions & 3 deletions src/org/thoughtcrime/securesms/components/AudioView.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

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.audio.AudioSlidePlayer;
import org.thoughtcrime.securesms.crypto.MasterSecret;
Expand All @@ -34,7 +37,6 @@
import java.io.IOException;
import java.util.concurrent.TimeUnit;

import de.greenrobot.event.EventBus;

public class AudioView extends FrameLayout implements AudioSlidePlayer.Listener {

Expand Down Expand Up @@ -97,7 +99,7 @@ public AudioView(Context context, AttributeSet attrs, int defStyleAttr) {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().registerSticky(this);
if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().register(this);
}

@Override
Expand Down Expand Up @@ -323,7 +325,7 @@ public boolean onTouch(View v, MotionEvent event) {
}
}

@SuppressWarnings("unused")
@Subscribe(sticky = true, threadMode = ThreadMode.ASYNC)
public void onEventAsync(final PartProgressEvent event) {
if (audioSlidePlayer != null && event.attachment.equals(this.audioSlidePlayer.getAudioSlide().asAttachment())) {
Util.runOnMain(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
import com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener;
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.database.AttachmentDatabase;
import org.thoughtcrime.securesms.events.PartProgressEvent;
import org.thoughtcrime.securesms.mms.Slide;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;

import de.greenrobot.event.EventBus;

public class TransferControlView extends FrameLayout {
private static final int TRANSITION_MS = 300;

Expand Down Expand Up @@ -81,7 +82,7 @@ public void setClickable(boolean clickable) {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().registerSticky(this);
if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().register(this);
}

@Override
Expand Down Expand Up @@ -162,7 +163,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
return anim;
}

@SuppressWarnings("unused")
@Subscribe(sticky = true, threadMode = ThreadMode.ASYNC)
public void onEventAsync(final PartProgressEvent event) {
if (this.slide != null && event.attachment.equals(this.slide.asAttachment())) {
Util.runOnMain(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.text.TextUtils;
import android.util.Log;

import org.greenrobot.eventbus.EventBus;
import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.attachments.AttachmentId;
import org.thoughtcrime.securesms.crypto.AsymmetricMasterSecret;
Expand Down Expand Up @@ -33,7 +34,6 @@

import javax.inject.Inject;

import de.greenrobot.event.EventBus;
import ws.com.google.android.mms.MmsException;

public class AttachmentDownloadJob extends MasterSecretJob implements InjectableType {
Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/securesms/jobs/PushSendJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.util.Log;

import org.greenrobot.eventbus.EventBus;
import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.TextSecureExpiredException;
import org.thoughtcrime.securesms.attachments.Attachment;
Expand All @@ -29,7 +30,6 @@
import java.util.LinkedList;
import java.util.List;

import de.greenrobot.event.EventBus;
import ws.com.google.android.mms.ContentType;

public abstract class PushSendJob extends SendJob {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.google.protobuf.InvalidProtocolBufferException;

import org.greenrobot.eventbus.EventBus;
import org.thoughtcrime.redphone.RedPhoneService;
import org.thoughtcrime.redphone.audio.IncomingRinger;
import org.thoughtcrime.redphone.call.LockManager;
Expand Down Expand Up @@ -95,7 +96,6 @@

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_INCOMING_RINGING;
Expand Down

0 comments on commit 1b1470a

Please sign in to comment.