Skip to content

fix(widget): resolve ProgressLayout content visibility not restored#1021

Merged
wax911 merged 2 commits into
developfrom
fix/progress-layout-content-visibility
Jun 1, 2026
Merged

fix(widget): resolve ProgressLayout content visibility not restored#1021
wax911 merged 2 commits into
developfrom
fix/progress-layout-content-visibility

Conversation

@wax911

@wax911 wax911 commented Jun 1, 2026

Copy link
Copy Markdown
Member

Description

The ProgressLayout migrated from a third-party library would show the loading spinner but never restore content visibility. This was caused by two issues:

1. Caller-level: Null-drawable guards leaving state stuck in LOADING

8 call sites across 5 files called showLoading() before showError() but guarded showError() behind an if (drawable != null) check. When the drawable was null (e.g., missing context or stripped resource), showError() was skipped, leaving the widget permanently in LOADING state.

Fix: Remove the preemptive showLoading() call and the null-drawable guard. Pass the nullable drawable directly to stateLayout.showError(), which already handles null drawables correctly.

Files fixed:

  • base/custom/sheet/BottomSheetList.ktshowError, showEmpty
  • view/sheet/BottomSheetListUsers.ktshowError, showEmpty
  • base/custom/fragment/FragmentBaseList.ktshowError, showEmpty
  • base/custom/fragment/FragmentBaseComment.ktshowError, showEmpty (+ removed spurious showLoading() outside condition)
  • base/custom/fragment/FragmentChannelBase.ktshowError, showEmpty

2. Widget-level: Content visibility reverted by child layout passes

applyState() correctly set content children to VISIBLE, but child Views (CustomSwipeRefreshLayout, RecyclerView) reverted their visibility during their own layout pass. The fix adds a post { } safety net that re-checks and re-asserts content visibility after layout completes.

Fix in ProgressLayout.kt:

  • putIfAbsent → direct [child] = assignment (always saves current visibility)
  • child.visibility = saved ?: View.VISIBLE (fallback for untracked children)
  • post { } re-check after state transitions to CONTENT

Instrumentation tests added

13 test cases covering state transitions, error handling, null drawables, multi-child visibility, multiple state cycles, and synchronous visibility restoration.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

…fter loading

The ProgressLayout migrated from a third-party library would show the
loading spinner but never restore content visibility. Root cause was
two-fold:

1. Callers (8 instances across 5 files) called showLoading() before
   showError() but guarded showError() behind a null-drawable check.
   When the drawable was null, showError() was skipped and the widget
   stayed permanently in LOADING state.

2. Content child visibility was reverted by child layout passes after
   applyState() set them to VISIBLE. Fix: use post-guard to re-assert
   visibility after layout completes.

Changes:
- ProgressLayout: direct map assignment + post safety net in applyState
- FragmentBaseList/BaseComment/ChannelBase: remove showLoading + guard
- BottomSheetList/BottomSheetListUsers: remove showLoading + guard
- Add instrumentation tests (13 test cases) for ProgressLayout state
  machine, visibility restoration, and regression scenarios
@github-actions github-actions Bot added the bugfix label Jun 1, 2026
@wax911 wax911 enabled auto-merge (squash) June 1, 2026 08:04
@codacy-production

codacy-production Bot commented Jun 1, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 3 medium · 12 minor

Alerts:
⚠ 15 issues (≤ 0 issues of at least minor severity)

Results:
15 new issues

Category Results
Documentation 12 minor
Complexity 3 medium

View in Codacy

🟢 Metrics 30 complexity · 19 duplication

Metric Results
Complexity 30
Duplication 19

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

…th LinearLayout

- Reduce widget internal padding from 24dp (spacing_small) to 8dp
  (lg_margin) for CommentWidget, StatusEditWidget, UsersWidget,
  FavouriteWidget, and StatusDeleteWidget
- Replace FrameLayout with horizontal LinearLayout + Space(weight=1)
  in adapter_feed_status.xml, adapter_feed_progress.xml, and
  adapter_feed_message.xml to prevent UsersWidget and action button
  row from overlapping when multiple buttons are visible
- Verified on all 3 Status Feed tabs with all 5 widgets visible

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved automated PR

@wax911 wax911 merged commit 5d31ffb into develop Jun 1, 2026
9 of 10 checks passed
@wax911 wax911 deleted the fix/progress-layout-content-visibility branch June 1, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant