@@ -85,36 +85,28 @@ void fetchContentsInternal(@NonNull String[] categories) {
8585 if (validateResponse (checkResponse )) {
8686 L .d ("[ModuleContent] fetchContentsInternal, got new content data, showing it" );
8787
88- iRGenerator .CreatePreflightRequestMaker ().doWork (checkResponse .optString ("html" ), null , cp , false , true , preflightResponse -> {
89- if (preflightResponse == null ) {
90- L .d ("[ModuleContent] fetchContentsInternal, preflight check failed, skipping showing content" );
91- return ;
92- }
93-
94- Map <Integer , TransparentActivityConfig > placementCoordinates = parseContent (checkResponse , displayMetrics );
95- if (placementCoordinates .isEmpty ()) {
96- L .d ("[ModuleContent] fetchContentsInternal, placement coordinates are empty, skipping" );
97- return ;
98- }
99-
100- L .d ("[ModuleContent] fetchContentsInternal, preflight check succeeded" );
101- Intent intent = new Intent (_cly .context_ , TransparentActivity .class );
102- intent .putExtra (TransparentActivity .CONFIGURATION_LANDSCAPE , placementCoordinates .get (Configuration .ORIENTATION_LANDSCAPE ));
103- intent .putExtra (TransparentActivity .CONFIGURATION_PORTRAIT , placementCoordinates .get (Configuration .ORIENTATION_PORTRAIT ));
104- intent .putExtra (TransparentActivity .ORIENTATION , _cly .context_ .getResources ().getConfiguration ().orientation );
105-
106- Long id = System .currentTimeMillis ();
107- intent .putExtra (TransparentActivity .ID_CALLBACK , id );
108- if (globalContentCallback != null ) {
109- TransparentActivity .contentCallbacks .put (id , globalContentCallback );
110- }
111-
112- intent .addFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
113- _cly .context_ .startActivity (intent );
114-
115- shouldFetchContents = false ; // disable fetching contents until the next time, this will disable the timer fetching
116- isCurrentlyInContentZone = true ;
117- }, L );
88+ Map <Integer , TransparentActivityConfig > placementCoordinates = parseContent (checkResponse , displayMetrics );
89+ if (placementCoordinates .isEmpty ()) {
90+ L .d ("[ModuleContent] fetchContentsInternal, placement coordinates are empty, skipping" );
91+ return ;
92+ }
93+
94+ Intent intent = new Intent (_cly .context_ , TransparentActivity .class );
95+ intent .putExtra (TransparentActivity .CONFIGURATION_LANDSCAPE , placementCoordinates .get (Configuration .ORIENTATION_LANDSCAPE ));
96+ intent .putExtra (TransparentActivity .CONFIGURATION_PORTRAIT , placementCoordinates .get (Configuration .ORIENTATION_PORTRAIT ));
97+ intent .putExtra (TransparentActivity .ORIENTATION , _cly .context_ .getResources ().getConfiguration ().orientation );
98+
99+ Long id = System .currentTimeMillis ();
100+ intent .putExtra (TransparentActivity .ID_CALLBACK , id );
101+ if (globalContentCallback != null ) {
102+ TransparentActivity .contentCallbacks .put (id , globalContentCallback );
103+ }
104+
105+ intent .addFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
106+ _cly .context_ .startActivity (intent );
107+
108+ shouldFetchContents = false ; // disable fetching contents until the next time, this will disable the timer fetching
109+ isCurrentlyInContentZone = true ;
118110 } else {
119111 L .w ("[ModuleContent] fetchContentsInternal, response is not valid, skipping" );
120112 }
@@ -204,13 +196,13 @@ private String prepareContentFetchRequest(@NonNull DisplayMetrics displayMetrics
204196 if (displayOption == WebViewDisplayOption .SAFE_AREA ) {
205197 L .d ("[ModuleContent] prepareContentFetchRequest, calculating safe area dimensions..." );
206198 SafeAreaDimensions safeArea = SafeAreaCalculator .calculateSafeAreaDimensions (_cly .context_ , L );
207-
199+
208200 // px to dp
209201 portraitWidth = (int ) Math .ceil (safeArea .portraitWidth / displayMetrics .density );
210202 portraitHeight = (int ) Math .ceil (safeArea .portraitHeight / displayMetrics .density );
211203 landscapeWidth = (int ) Math .ceil (safeArea .landscapeWidth / displayMetrics .density );
212204 landscapeHeight = (int ) Math .ceil (safeArea .landscapeHeight / displayMetrics .density );
213-
205+
214206 L .d ("[ModuleContent] prepareContentFetchRequest, safe area dimensions (px->dp) - Portrait: [" + safeArea .portraitWidth + "x" + safeArea .portraitHeight + " px] -> [" + portraitWidth + "x" + portraitHeight + " dp], topOffset: [" + safeArea .portraitTopOffset + " px]" );
215207 L .d ("[ModuleContent] prepareContentFetchRequest, safe area dimensions (px->dp) - Landscape: [" + safeArea .landscapeWidth + "x" + safeArea .landscapeHeight + " px] -> [" + landscapeWidth + "x" + landscapeHeight + " dp], topOffset: [" + safeArea .landscapeTopOffset + " px]" );
216208 } else {
@@ -221,7 +213,7 @@ private String prepareContentFetchRequest(@NonNull DisplayMetrics displayMetrics
221213 portraitHeight = portrait ? scaledHeight : scaledWidth ;
222214 landscapeWidth = portrait ? scaledHeight : scaledWidth ;
223215 landscapeHeight = portrait ? scaledWidth : scaledHeight ;
224-
216+
225217 L .d ("[ModuleContent] prepareContentFetchRequest, using immersive mode (full screen) dimensions (dp) - Portrait: [" + portraitWidth + "x" + portraitHeight + "], Landscape: [" + landscapeWidth + "x" + landscapeHeight + "]" );
226218 }
227219
@@ -250,24 +242,24 @@ Map<Integer, TransparentActivityConfig> parseContent(@NonNull JSONObject respons
250242
251243 WebViewDisplayOption displayOption = _cly .config_ .webViewDisplayOption ;
252244 SafeAreaDimensions safeArea = null ;
253-
245+
254246 if (displayOption == WebViewDisplayOption .SAFE_AREA ) {
255247 L .d ("[ModuleContent] parseContent, calculating safe area for coordinate adjustment..." );
256248 safeArea = SafeAreaCalculator .calculateSafeAreaDimensions (_cly .context_ , L );
257249 }
258250
259- placementCoordinates .put (Configuration .ORIENTATION_PORTRAIT ,
260- extractOrientationPlacements (coordinates , displayMetrics .density , "p" , content ,
251+ placementCoordinates .put (Configuration .ORIENTATION_PORTRAIT ,
252+ extractOrientationPlacements (coordinates , displayMetrics .density , "p" , content ,
261253 displayOption , safeArea != null ? safeArea .portraitTopOffset : 0 , safeArea != null ? safeArea .portraitLeftOffset : 0 ));
262- placementCoordinates .put (Configuration .ORIENTATION_LANDSCAPE ,
263- extractOrientationPlacements (coordinates , displayMetrics .density , "l" , content ,
254+ placementCoordinates .put (Configuration .ORIENTATION_LANDSCAPE ,
255+ extractOrientationPlacements (coordinates , displayMetrics .density , "l" , content ,
264256 displayOption , safeArea != null ? safeArea .landscapeTopOffset : 0 , safeArea != null ? safeArea .landscapeLeftOffset : 0 ));
265257
266258 return placementCoordinates ;
267259 }
268260
269- private TransparentActivityConfig extractOrientationPlacements (@ NonNull JSONObject placements ,
270- float density , @ NonNull String orientation , @ NonNull String content ,
261+ private TransparentActivityConfig extractOrientationPlacements (@ NonNull JSONObject placements ,
262+ float density , @ NonNull String orientation , @ NonNull String content ,
271263 WebViewDisplayOption displayOption , int topOffset , int leftOffset ) {
272264 if (placements .has (orientation )) {
273265 JSONObject orientationPlacements = placements .optJSONObject (orientation );
@@ -277,21 +269,21 @@ private TransparentActivityConfig extractOrientationPlacements(@NonNull JSONObje
277269 int w = orientationPlacements .optInt ("w" );
278270 int h = orientationPlacements .optInt ("h" );
279271 L .d ("[ModuleContent] extractOrientationPlacements, orientation: [" + orientation + "], x: [" + x + "], y: [" + y + "], w: [" + w + "], h: [" + h + "]" );
280-
272+
281273 int xPx = Math .round (x * density );
282274 int yPx = Math .round (y * density );
283275 int wPx = Math .round (w * density );
284276 int hPx = Math .round (h * density );
285277 L .d ("[ModuleContent] extractOrientationPlacements, orientation: [" + orientation + "], converting dp->px: [" + w + "x" + h + " dp] -> [" + wPx + "x" + hPx + " px], density: [" + density + "]" );
286-
278+
287279 TransparentActivityConfig config = new TransparentActivityConfig (xPx , yPx , wPx , hPx );
288280 config .url = content ;
289281 config .useSafeArea = (displayOption == WebViewDisplayOption .SAFE_AREA );
290282 config .topOffset = topOffset ;
291283 config .leftOffset = leftOffset ;
292-
284+
293285 L .d ("[ModuleContent] extractOrientationPlacements, orientation: [" + orientation + "], created config - useSafeArea: [" + config .useSafeArea + "], topOffset: [" + config .topOffset + "], leftOffset: [" + config .leftOffset + "]" );
294-
286+
295287 return config ;
296288 }
297289
0 commit comments