diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2021-05-18 14:27:51 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2021-05-19 07:42:57 +0200 |
commit | 128f67e0efa02294205a1abe1be874557ecdcecd (patch) | |
tree | e6abc32e410b7b6f7f01fb1146adc9bd4c521b0a /android | |
parent | e96f72184ecdb589bbed6b3b30c7be3bfd726edc (diff) |
tdf#142348 android: Avoid extra refresh after loading doc
commit 1bc42472200c32c9a0a10dd1c3cd6c6a8a5d47d2
Date: Fri Apr 9 13:59:43 2021 +0200
tdf#95517 android: Rework app/doc lifecycle handling
changed activity lifecycle for Android Viewer's
'LibreOfficeMainActivity'. It moved sending an event to
trigger loading of the document from the 'onStart' to the
'onCreate' method and added sending a more lightweight refresh
event the 'onStart' method instead.
However, since a refresh is already done when loading the
document, there's no need to do another refresh when the 'onStart'
method is called right after the 'onCreate' method.
Therefore, set a flag in the 'onCreate' method and use that
to skip sending the extra refresh event for that case. This
not only avoids doing unnecessary work but also avoids that
the two could get into each others way, resulting in Calc
documents sometimes not being rendered on initial load.
Change-Id: I5c47e1b5f7a42a49fb903891aa84585b36994a4b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115750
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r-- | android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java index 9d8828811ade..3927cc744eb4 100644 --- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java +++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java @@ -100,6 +100,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin private LOKitTileProvider mTileProvider; private String mPassword; private boolean mPasswordProtected; + private boolean mbSkipNextRefresh; public boolean pendingInsertGraphic; // boolean indicating a pending insert graphic action, used in LOKitTileProvider.postLoad() public GeckoLayerClient getLayerClient() { @@ -213,6 +214,9 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin Log.e(LOGTAG, "No document specified. This should never happen."); return; } + // the loadDocument/loadNewDocument event already triggers a refresh as well, + // so there's no need to do another refresh in 'onStart' + mbSkipNextRefresh = true; mDrawerLayout = findViewById(R.id.drawer_layout); @@ -466,7 +470,10 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin protected void onStart() { Log.i(LOGTAG, "onStart.."); super.onStart(); - LOKitShell.sendEvent(new LOEvent(LOEvent.REFRESH)); + if (!mbSkipNextRefresh) { + LOKitShell.sendEvent(new LOEvent(LOEvent.REFRESH)); + } + mbSkipNextRefresh = false; } @Override |