Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Prev Previous commit
Next Next commit
Add support for ANDROIDX_LOCAL_BROADCAST_MANAGER
  • Loading branch information
dodgex committed Jul 1, 2018
commit ed9d164277478cc0a9f45686192861e6a0fc02b8
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ private void registerAndUnregisterReceiver(HasReceiverRegistration holder, Recei

IJExpression broadcastManager;
if (local) {
broadcastManager = getClasses().LOCAL_BROADCAST_MANAGER.staticInvoke("getInstance").arg(holder.getContextRef());
if (getProcessingEnvironment().getElementUtils().getTypeElement(CanonicalNameConstants.LOCAL_BROADCAST_MANAGER) == null) {
broadcastManager = getClasses().ANDROIDX_LOCAL_BROADCAST_MANAGER.staticInvoke("getInstance").arg(holder.getContextRef());
} else {
broadcastManager = getClasses().LOCAL_BROADCAST_MANAGER.staticInvoke("getInstance").arg(holder.getContextRef());
}
} else {
broadcastManager = holder.getContextRef();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,9 @@ public void hasSupportV4JarIfLocal(Element element, ElementValidation valid) {
boolean local = element.getAnnotation(Receiver.class).local();
if (local) {
Elements elementUtils = annotationHelper.getElementUtils();
if (elementUtils.getTypeElement(CanonicalNameConstants.LOCAL_BROADCAST_MANAGER) == null) {
valid.addError("To use the LocalBroadcastManager, you MUST include the android-support-v4 jar");
if (elementUtils.getTypeElement(CanonicalNameConstants.LOCAL_BROADCAST_MANAGER) == null
&& elementUtils.getTypeElement(CanonicalNameConstants.ANDROIDX_LOCAL_BROADCAST_MANAGER) == null) {
valid.addError("To use the LocalBroadcastManager, you MUST include the android-support-v4 or androidx.localbroadcastmanager jar");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public class Classes {
*/
public final AbstractJClass ANDROIDX_ACTIVITY_COMPAT = refClass(CanonicalNameConstants.ANDROIDX_ACTIVITY_COMPAT);
public final AbstractJClass ANDROIDX_FRAGMENT_ACTIVITY = refClass(CanonicalNameConstants.ANDROIDX_FRAGMENT_ACTIVITY);
public final AbstractJClass ANDROIDX_LOCAL_BROADCAST_MANAGER = refClass(CanonicalNameConstants.ANDROIDX_LOCAL_BROADCAST_MANAGER);

/*
* HttpClient
Expand Down