Skip to content

Commit

Permalink
Implement null check for GcmReceiverUIForeground
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor committed Apr 21, 2016
1 parent be55aaa commit 54fefb6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Add RxGcm dependency and Google Services plugin to project level build.gradle.
apply plugin: 'com.google.gms.google-services'
dependencies {
compile 'com.github.VictorAlbertos:RxGcm:0.2.1'
compile 'com.github.VictorAlbertos:RxGcm:0.2.2'
compile 'io.reactivex:rxjava:1.1.0'
}
```
Expand Down
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ Wrapper retrieve(String screenName, Activity activity){
if(fragment != null && isVisible(fragment) && fragment instanceof GcmReceiverUIForeground) {
GcmReceiverUIForeground gcmReceiverUIForeground = (GcmReceiverUIForeground) fragment;

boolean targetScreen = gcmReceiverUIForeground.target().equals(screenName);
receiverCandidate = new Wrapper(gcmReceiverUIForeground, targetScreen);
String target = gcmReceiverUIForeground.target() != null ? gcmReceiverUIForeground.target() : "";

if (targetScreen) return receiverCandidate;
boolean isTargetScreen = target.equals(screenName);
receiverCandidate = new Wrapper(gcmReceiverUIForeground, isTargetScreen);

if (isTargetScreen) return receiverCandidate;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions rx_gcm/src/main/java/rx_gcm/internal/RxGcm.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ private void notifyGcmReceiverForegroundMessage(Message message) {
}

final GetGcmReceiversUIForeground.Wrapper wrapperGcmReceiverUIForeground = getGcmReceiversUIForeground.retrieve(message.target(), activitiesLifecycle.getLiveActivityOrNull());
if (wrapperGcmReceiverUIForeground == null) return;

if (wrapperGcmReceiverUIForeground.isTargetScreen()) {
Observable.just(message).observeOn(mainThreadScheduler)
Expand Down

0 comments on commit 54fefb6

Please sign in to comment.