Dbrant has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/233969

Change subject: Fix possible crash upon screen rotation.
......................................................................

Fix possible crash upon screen rotation.

This fixes a NPE when the user rotates the screen before the lead section
of the page is fetched (and it's the first page in the backstack), by
leveraging the isLoading() function of PageLoadStrategy.

Bug: T109966
Change-Id: I795c5a212f1c800abd70d3906dae560033ef2ac0
---
M app/src/main/java/org/wikipedia/page/PageFragment.java
1 file changed, 11 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia 
refs/changes/69/233969/1

diff --git a/app/src/main/java/org/wikipedia/page/PageFragment.java 
b/app/src/main/java/org/wikipedia/page/PageFragment.java
index fdbde74..4e770ea 100755
--- a/app/src/main/java/org/wikipedia/page/PageFragment.java
+++ b/app/src/main/java/org/wikipedia/page/PageFragment.java
@@ -479,14 +479,17 @@
     @Override
     public void onConfigurationChanged(Configuration newConfig) {
         super.onConfigurationChanged(newConfig);
-        // if the screen orientation changes, then re-layout the lead image 
container
-        leadImagesHandler.beginLayout(new 
LeadImagesHandler.OnLeadImageLayoutListener() {
-            @Override
-            public void onLayoutComplete() {
-                // when it's finished laying out, make sure the toolbar is 
shown appropriately.
-                
searchBarHideHandler.setFadeEnabled(leadImagesHandler.isLeadImageEnabled());
-            }
-        });
+        // if the screen orientation changes, then re-layout the lead image 
container,
+        // but only if we've finished fetching the page.
+        if (!pageLoadStrategy.isLoading()) {
+            leadImagesHandler.beginLayout(new 
LeadImagesHandler.OnLeadImageLayoutListener() {
+                @Override
+                public void onLayoutComplete() {
+                    // when it's finished laying out, make sure the toolbar is 
shown appropriately.
+                    
searchBarHideHandler.setFadeEnabled(leadImagesHandler.isLeadImageEnabled());
+                }
+            });
+        }
     }
 
     public Tab getCurrentTab() {

-- 
To view, visit https://gerrit.wikimedia.org/r/233969
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I795c5a212f1c800abd70d3906dae560033ef2ac0
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to