-
Notifications
You must be signed in to change notification settings - Fork 432
Faster start times #2700
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
Faster start times #2700
Conversation
This reverts commit 6c9d6c6.
| * This Activity exists solely to launch activities with the correct intent | ||
| * it is necessary as widget and shortcut intents do not respect MultipleTask etc | ||
| */ | ||
| public class OpenFromShortcutOrWidgetActivity extends MarkorBaseActivity { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MarkorBaseActivity does some extra work here which is unnecessary
| startLine = intent.getIntExtra(Document.EXTRA_FILE_LINE_NUMBER, -1); | ||
| } else if (intentData != null) { | ||
| final String line = intentData.getQueryParameter("line"); | ||
| startLine = GsTextUtils.tryParseInt(line, -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bugfix to how the start line and start in preview interact
|
|
||
| private HighlightingEditor _hlEditor; | ||
| private WebView _webView; | ||
| private ViewStub _webViewStub; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The webview is the heaviest view in the document fragment. This loads it lazily when necessary
| _lineNumbersView.setup(_hlEditor); | ||
| _lineNumbersView.setLineNumbersEnabled(_appSettings.getDocumentLineNumbersEnabled(_document.path)); | ||
|
|
||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && _appSettings.getSetWebViewFulldrawing()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same code moved into block which is called when webview is actually required and loaded
| _hlEditor.setMinHeight(height); | ||
| } | ||
| }); | ||
| _verticalScrollView.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> ensureMinHeight.run()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Listening to a scrollview layout change instead of a global layout change
| // Setup viewpager | ||
| _viewPager.setAdapter(new SectionsPagerAdapter(getSupportFragmentManager())); | ||
| _viewPager.setOffscreenPageLimit(4); | ||
| _sectionsAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When main activity is loaded we do not load not shown tabs immediately.
Instead we load them lazily.
After tabs are loaded, they are cached by the adapter
| public void hideKeyboard() { | ||
| _cu.showSoftKeyboard(this, false, _quicknote.getEditor()); | ||
| _cu.showSoftKeyboard(this, false, _todo.getEditor()); | ||
| if (_quicknote != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fragments may not be loaded
| final boolean isImage = m.group(1) != null; | ||
| final String link = m.group(3); | ||
| return new Link(m.group(2), link == null ? null : link.trim(), isImage, start, end); | ||
| final String link = GsTextUtils.decodeUrl(m.group(3)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated fix for how file links with spaces are parsed
%20 now converted to and from space more correctly
| final File sel = currentSelection.iterator().next(); | ||
| final File file = _filesystemViewerAdapter.resolveVirtualFile(sel); | ||
| final String title = GsFileUtils.getFilenameWithoutExtension(sel); | ||
| _cu.createLauncherDesktopShortcut(getContext(), file, title); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correctly resolving shortcuts to special folders
| } | ||
|
|
||
| if (!dest.isFile() && GsTextUtils.endsWith(sb, File.separator)) { | ||
| if (GsTextUtils.endsWith(sb, File.separator)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing separator on file vs folder
| #Thu Dec 02 03:48:33 CET 2021 | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to update gradle to get this to work on my new laptop
| final foldername = dir.name | ||
| if (foldername.startsWith('values-') && !dir.absolutePath.contains("build" + File.separator + "intermediates") && !foldername.matches(".*values-((.*[0-9])|(land)|(port)).*")) { | ||
| dir.eachFile { file -> | ||
| if (file.name.toLowerCase().endsWith(".xml") && file.getText('UTF-8').contains("<string")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes needed to get the build working
|
@gsantner This is ready for review |
This reverts commit 9584150.
|
@guanglinn Would you be willing to review this? |
I'm willing to review it, but may provide limited suggestions based on my limited understanding of Markor and Android. 😌 |
This is pretty much the only Java and Android project I work on as well. I'll take any feedback |
|
Thank you, I will try to find time on sunday to review |
|
Hi. Should this affect delays that I am experiencing such as
Or will it affect only opening the app itself? I ask because I was about to open an Issue about a very noticeable performance degradation when upgrading from 2.14.1 to 2.15.2 (which still does not include this PR). My problem is with a very large markdown file (214Kb, 3717 lines, hundreds of headings). But I've always used this big file quite successfully with Markor... Should I open the Issue or is it better to wait for this PR to come out in a release? Thanks! I love Markor! |
|
There should not have been a regression between 2.14.1 and 2.15.2. Could you share a file and steps to reproduce? Perhaps in a ticket. |
|
This PR should only affect startup times (indirectly perceived load time) |
|
Hi, @harshad1 The master branch code after merging this PR will throw NullPointerException here: Steps to reproduce:
|
Done, #2716 Thanks! |
|
I couldn't reproduce the webview crash, but I pushed a change to master to add a check there, which should fix that for you. |

In this PR I have made the initialization of several components a little faster.
Having really fast launch times makes the experience of using markor nicer.