diff --git a/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageView.java b/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageView.java index 7c98a215eca6..0c2c54cf0f9c 100644 --- a/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageView.java +++ b/android/java/org/chromium/chrome/browser/ntp/BraveNewTabPageView.java @@ -362,27 +362,6 @@ private void initilizeSponsoredTab() { mNTPBackgroundImagesBridge.getTopSites(); } - private TabObserver mTabObserver = new EmptyTabObserver() { - @Override - public void onInteractabilityChanged(Tab tab, boolean interactable) { - // Force a layout update if the tab is now in the foreground. - if (interactable) { - if (sponsoredTab == null) - initilizeSponsoredTab(); - if (!sponsoredTab.isMoreTabs()) { - checkAndShowNTPImage(false); - } - } else { - if (!isFromBottomSheet) { - mNewTabPageLayout.setBackgroundResource(0); - if (imageDrawable != null && imageDrawable.getBitmap() != null && !imageDrawable.getBitmap().isRecycled()) { - imageDrawable.getBitmap().recycle(); - } - } - } - } - }; - private NewTabPageListener newTabPageListener = new NewTabPageListener() { @Override public void updateInteractableFlag(boolean isBottomSheet) { diff --git a/android/java/org/chromium/chrome/browser/ntp_background_images/util/NTPUtil.java b/android/java/org/chromium/chrome/browser/ntp_background_images/util/NTPUtil.java index f2b9ae3235ea..6ef4dfd08428 100644 --- a/android/java/org/chromium/chrome/browser/ntp_background_images/util/NTPUtil.java +++ b/android/java/org/chromium/chrome/browser/ntp_background_images/util/NTPUtil.java @@ -373,8 +373,8 @@ public static Bitmap getCalculatedBitmap(Bitmap imageBitmap, float centerPointX, } imageBitmap = Bitmap.createScaledBitmap(imageBitmap, newImageWidth, newImageHeight, true); - - Bitmap newBitmap = Bitmap.createBitmap(imageBitmap, startX, startY, layoutWidth, (int) layoutHeight); + + Bitmap newBitmap = Bitmap.createBitmap(imageBitmap, (startX + layoutWidth) <= imageBitmap.getWidth() ? startX : 0, (startY + (int) layoutHeight) <= imageBitmap.getHeight() ? startY : 0, layoutWidth, (int) layoutHeight); Bitmap bitmapWithGradient = ImageUtils.addGradient(newBitmap); imageBitmap.recycle();