Skip to content

Commit

Permalink
Fix not being able to open library after going back to New Tab
Browse files Browse the repository at this point in the history
  • Loading branch information
haanhvu committed Dec 3, 2024
1 parent 06a1cd7 commit 63bf929
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ private void updateUI() {
v.requestFocusFromTouch();

if (mViewModel.getBackToNewTabEnabled().getValue().get()) {
//mAttachedWindow.showNewTab();
getSession().loadUri(UrlUtils.ABOUT_NEWTAB);
mAttachedWindow.showNewTab();
}

if (getSession().canGoBack()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,31 +535,35 @@ private void showPanel(Windows.ContentType contentType, boolean switchSurface) {
mViewModel.setIsFindInPage(false);
mViewModel.setCurrentContentType(contentType);
mViewModel.setUrl(contentType.URL);
if (mView == null) {
//if (mView == null) {
if (mView != mLibrary) {
Log.e("New Tab PR", "mView == null");
setView(mLibrary, switchSurface);
mLibrary.selectPanel(contentType);
mLibrary.onShow();
if (mRestoreFirstPaint == null && !isFirstPaintReady() && (mFirstDrawCallback != null) && (mSurface != null)) {
//if (mRestoreFirstPaint == null && !isFirstPaintReady() && (mFirstDrawCallback != null) && (mSurface != null)) {
if (mRestoreFirstPaint == null) {
Log.e("New Tab PR", "if clause is run");
final Runnable firstDrawCallback = mFirstDrawCallback;
onFirstContentfulPaint(mSession.getWSession());
//onFirstContentfulPaint(mSession.getWSession());
mRestoreFirstPaint = () -> {
setFirstPaintReady(false);
setFirstDrawCallback(firstDrawCallback);
if (mWidgetManager != null) {
//setFirstDrawCallback(firstDrawCallback);
/*if (mWidgetManager != null) {
mWidgetManager.updateWidget(WindowWidget.this);
}
}*/
};
} else {
Log.e("New Tab PR", "if clause is NOT run");
}
} else if (mView == mLibrary) {
Log.e("New Tab PR", "mView == null");
mLibrary.selectPanel(contentType);
//} else if (mView == mLibrary) {
} else {
Log.e("New Tab PR", "Other case");
Log.e("New Tab PR", "mView == mLibrary");
mLibrary.selectPanel(contentType);
}
//else {
//Log.e("New Tab PR", "Other case");
//}
}

public void showNewTab() {
Expand All @@ -570,15 +574,16 @@ public void showNewTab() {
mViewModel.enableBackToNewTab(false);
setView(mNewTab, true);
onFirstContentfulPaint(mSession.getWSession());
if (mRestoreFirstPaint == null && !isFirstPaintReady() && (mFirstDrawCallback != null) && (mSurface != null)) {
//if (mRestoreFirstPaint == null && !isFirstPaintReady() && (mFirstDrawCallback != null) && (mSurface != null)) {
if (mRestoreFirstPaint == null) {
final Runnable firstDrawCallback = mFirstDrawCallback;
onFirstContentfulPaint(mSession.getWSession());
//onFirstContentfulPaint(mSession.getWSession());
mRestoreFirstPaint = () -> {
setFirstPaintReady(false);
setFirstDrawCallback(firstDrawCallback);
if (mWidgetManager != null) {
//setFirstDrawCallback(firstDrawCallback);
/*if (mWidgetManager != null) {
mWidgetManager.updateWidget(WindowWidget.this);
}
}*/
};
}
}
Expand Down Expand Up @@ -625,7 +630,7 @@ private void hideNewTab(boolean switchSurface) {
mRestoreFirstPaint.run();
mRestoreFirstPaint = null;
} else {
Log.e("New Tab PR", "Cannot make mRestoreFirstPaint null");
Log.e("New Tab PR", "mRestoreFirstPaint is already null => Cannot make mRestoreFirstPaint null");
}
}

Expand Down

0 comments on commit 63bf929

Please sign in to comment.