2525import android .location .Location ;
2626import android .text .TextUtils ;
2727
28+ import androidx .annotation .NonNull ;
2829import androidx .annotation .Nullable ;
2930import com .leanplum .ActionContext .ContextualValues ;
3031import com .leanplum .callbacks .ActionCallback ;
32+ import com .leanplum .callbacks .ForceContentUpdateCallback ;
3133import com .leanplum .callbacks .MessageDisplayedCallback ;
3234import com .leanplum .callbacks .RegisterDeviceCallback ;
3335import com .leanplum .callbacks .RegisterDeviceFinishedCallback ;
@@ -2018,7 +2020,7 @@ private static void resumeStateInternal() {
20182020 * inconsistent state or user experience.
20192021 */
20202022 public static void forceContentUpdate () {
2021- forceContentUpdate (null );
2023+ forceContentUpdate (success -> {} );
20222024 }
20232025
20242026 /**
@@ -2029,10 +2031,26 @@ public static void forceContentUpdate() {
20292031 * @param callback The callback to invoke when the call completes from the server. The callback
20302032 * will fire regardless of whether the variables have changed.
20312033 */
2032- @ SuppressWarnings ("SameParameterValue" )
2033- public static void forceContentUpdate (final VariablesChangedCallback callback ) {
2034+ public static void forceContentUpdate (VariablesChangedCallback callback ) {
2035+ forceContentUpdate (success -> {
2036+ if (callback != null ) {
2037+ callback .variablesChanged ();
2038+ }
2039+ });
2040+ }
2041+
2042+ /**
2043+ * Forces content to update from the server. If variables have changed, the appropriate callbacks
2044+ * will fire. Use sparingly as if the app is updated, you'll have to deal with potentially
2045+ * inconsistent state or user experience.
2046+ *
2047+ * @param callback The callback to invoke when the call completes from the server. The callback
2048+ * will fire regardless of whether the variables have changed. Null value is not
2049+ * permitted.
2050+ */
2051+ public static void forceContentUpdate (@ NonNull ForceContentUpdateCallback callback ) {
20342052 if (Constants .isNoop ()) {
2035- OperationQueue .sharedInstance ().addUiOperation (callback );
2053+ OperationQueue .sharedInstance ().addUiOperation (() -> callback . onContentUpdated ( false ) );
20362054 return ;
20372055 }
20382056 try {
@@ -2064,7 +2082,7 @@ public void response(JSONObject response) {
20642082 Map <String , String > filenameToURLs = parseFilenameToURLs (response );
20652083 FileManager .setFilenameToURLs (filenameToURLs );
20662084 }
2067- OperationQueue .sharedInstance ().addUiOperation (callback );
2085+ OperationQueue .sharedInstance ().addUiOperation (() -> callback . onContentUpdated ( true ) );
20682086 } catch (Throwable t ) {
20692087 Log .exception (t );
20702088 }
@@ -2073,7 +2091,7 @@ public void response(JSONObject response) {
20732091 req .onError (new Request .ErrorCallback () {
20742092 @ Override
20752093 public void error (Exception e ) {
2076- OperationQueue .sharedInstance ().addUiOperation (callback );
2094+ OperationQueue .sharedInstance ().addUiOperation (() -> callback . onContentUpdated ( false ) );
20772095 LeanplumInbox .getInstance ().triggerInboxSyncedWithStatus (false );
20782096 }
20792097 });
0 commit comments