-
Notifications
You must be signed in to change notification settings - Fork 32
MOB-11663-InApp-Calculations #949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Needs reduction in code. Lot of repition. Heavy review and testing needed. Committing as inapps are looking stable and are sticking with the layout with back to back phone rotations when inapp performance would fail usually
private String messageId; | ||
|
||
// Resize debouncing fields | ||
private Handler resizeHandler = new Handler(); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
Handler.Handler
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
To fix this issue, we should replace new Handler()
with new Handler(Looper.getMainLooper())
, which constructs a Handler associated with the main thread's message queue. This is the recommended approach per Android documentation starting in API level 30, and has the same effect as the deprecated default constructor in most cases targeting UI work.
The changes are confined to line 64 in the file iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppFragmentHTMLNotification.java
. To implement this fix, we also need to import android.os.Looper
if it isn't already imported. The rest of the code that uses resizeHandler
can remain unchanged.
-
Copy modified line R18 -
Copy modified line R65
@@ -15,6 +15,7 @@ | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.os.Looper; | ||
import android.util.DisplayMetrics; | ||
import android.view.Display; | ||
import android.view.Gravity; | ||
@@ -61,7 +62,7 @@ | ||
private String messageId; | ||
|
||
// Resize debouncing fields | ||
private Handler resizeHandler = new Handler(); | ||
private Handler resizeHandler = new Handler(Looper.getMainLooper()); | ||
private Runnable pendingResizeRunnable; | ||
private float lastContentHeight = -1; | ||
private static final int RESIZE_DEBOUNCE_DELAY_MS = 200; |
lastOrientation = currentOrientation; | ||
|
||
// Use longer delay for orientation changes to allow layout to stabilize | ||
final Handler handler = new Handler(); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
Handler.Handler
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
To resolve the deprecated method usage, replace instances of new Handler()
with new Handler(Looper.getMainLooper())
when the handler is to be used for main thread/UI actions (as is the case here, since DialogFragment callback code executes on the main thread). This is a trivial change: update the handler initialization on line 260 to pass Looper.getMainLooper()
as an argument to the Handler constructor. To do this, we also need to import android.os.Looper
, which is already provided in all Android environments.
Files to edit: only iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppFragmentHTMLNotification.java
.
- Add the necessary import for
android.os.Looper
- Update line 260: change
new Handler()
tonew Handler(Looper.getMainLooper())
-
Copy modified line R18 -
Copy modified line R261
@@ -15,6 +15,7 @@ | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.os.Looper; | ||
import android.util.DisplayMetrics; | ||
import android.view.Display; | ||
import android.view.Gravity; | ||
@@ -257,7 +258,7 @@ | ||
lastOrientation = currentOrientation; | ||
|
||
// Use longer delay for orientation changes to allow layout to stabilize | ||
final Handler handler = new Handler(); | ||
final Handler handler = new Handler(Looper.getMainLooper()); | ||
handler.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { |
Needs reduction in code. Lot of repition. Heavy review and testing needed. Committing as inapps are looking stable and are sticking with the layout with back to back phone rotations when inapp performance would fail usually
🔹 Jira Ticket(s) if any
✏️ Description