Skip to content

Drop redundant runOnUiThread in getCurrentPosition handler#19

Merged
timbortnik merged 1 commit into
mainfrom
drop-redundant-runonuithread
May 31, 2026
Merged

Drop redundant runOnUiThread in getCurrentPosition handler#19
timbortnik merged 1 commit into
mainfrom
drop-redundant-runonuithread

Conversation

@timbortnik
Copy link
Copy Markdown
Owner

@timbortnik timbortnik commented May 31, 2026

LocationProvider.getCurrentPosition already invokes its callback on the main thread — requestLocationUpdates is registered with the main Looper, the timeout uses a main-Looper Handler, and the early-return paths run synchronously on the calling (main) thread. Wrapping result.success in runOnUiThread was therefore unnecessary indirection.

Per CodeRabbit review on #18.

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of location retrieval on Android devices.

LocationProvider.getCurrentPosition already invokes its callback on the
main thread — requestLocationUpdates is registered with the main Looper,
the timeout uses a main-Looper Handler, and the early-return paths run
synchronously on the calling (main) thread. Wrapping result.success in
runOnUiThread was therefore unnecessary indirection.

Per CodeRabbit review on #18.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 354f300d-e433-474d-8bcb-2dc2a3ff283c

📥 Commits

Reviewing files that changed from the base of the PR and between 997c9df and 057dd8d.

📒 Files selected for processing (1)
  • android/app/src/main/kotlin/org/bortnik/meteogram/MainActivity.kt

📝 Walkthrough

Walkthrough

The MainActivity method-channel handler for "getCurrentPosition" is simplified by removing the runOnUiThread wrapper around the success callback. The callback is now invoked directly from LocationProvider.getCurrentPosition, with a comment documenting that this callback always executes on the main thread.

Changes

Location Provider Callback Threading

Layer / File(s) Summary
getCurrentPosition callback dispatch
android/app/src/main/kotlin/org/bortnik/meteogram/MainActivity.kt
The success callback is no longer wrapped in runOnUiThread and is instead invoked directly from the LocationProvider callback, with documentation that the callback always runs on the main thread.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: removing redundant runOnUiThread wrapping from the getCurrentPosition handler.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch drop-redundant-runonuithread

Comment @coderabbitai help to get the list of available commands and usage tips.

@timbortnik timbortnik merged commit a2e8c0b into main May 31, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant