|
1 |
| -/* This Source Code Form is subject to the terms of the Mozilla Public |
| 1 | +/* Copyright (c) 2023 The Brave Authors. All rights reserved. |
| 2 | + * This Source Code Form is subject to the terms of the Mozilla Public |
2 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
3 |
| - * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | + * You can obtain one at https://mozilla.org/MPL/2.0/. */ |
4 | 5 |
|
5 | 6 | package org.chromium.chrome.browser;
|
6 | 7 |
|
|
18 | 19 | import org.chromium.base.Log;
|
19 | 20 | import org.chromium.chrome.R;
|
20 | 21 | import org.chromium.chrome.browser.BraveRewardsNativeWorker;
|
| 22 | +import org.chromium.chrome.browser.init.AsyncInitializationActivity; |
21 | 23 | import org.chromium.chrome.browser.rewards.BraveRewardsAmountChangeListener;
|
22 | 24 | import org.chromium.chrome.browser.rewards.BraveRewardsBannerInfo;
|
23 | 25 | import org.chromium.chrome.browser.rewards.BraveRewardsCreatorPanelFragment;
|
|
26 | 28 | import org.chromium.chrome.browser.rewards.BraveRewardsTipFailureFragment;
|
27 | 29 | import org.chromium.chrome.browser.rewards.BraveRewardsTippingPanelFragment;
|
28 | 30 |
|
29 |
| -public class BraveRewardsSiteBannerActivity |
30 |
| - extends FragmentActivity implements BraveRewardsTipConfirmationListener, |
31 |
| - BraveRewardsAmountChangeListener, BraveRewardsObserver { |
| 31 | +public class BraveRewardsSiteBannerActivity extends AsyncInitializationActivity |
| 32 | + implements BraveRewardsTipConfirmationListener, BraveRewardsAmountChangeListener, |
| 33 | + BraveRewardsObserver { |
32 | 34 | private ToggleButton radio_tip_amount[] = new ToggleButton[3];
|
33 | 35 | public static final String TAB_ID_EXTRA = "currentTabId";
|
34 | 36 | public static final String IS_MONTHLY_CONTRIBUTION = "is_monthly_contribution";
|
@@ -60,24 +62,32 @@ public class BraveRewardsSiteBannerActivity
|
60 | 62 | private static final String TAG = "TippingBanner";
|
61 | 63 |
|
62 | 64 | @Override
|
63 |
| - protected void onCreate(Bundle savedInstanceState) { |
64 |
| - |
65 |
| - //inflate |
66 |
| - super.onCreate(savedInstanceState); |
| 65 | + protected void triggerLayoutInflation() { |
| 66 | + // inflate |
67 | 67 | setContentView(R.layout.brave_rewards_site_banner);
|
68 | 68 | mIsActivityIsActive = true;
|
69 | 69 | mProgressBar = findViewById(R.id.progressBar);
|
70 |
| - mBraveRewardsNativeWorker = BraveRewardsNativeWorker.getInstance(); |
71 |
| - mBraveRewardsNativeWorker.AddObserver(this); |
72 | 70 |
|
73 | 71 | currentTabId_ = IntentUtils.safeGetIntExtra(getIntent(), TAB_ID_EXTRA, -1);
|
74 | 72 | mIsMonthlyContribution =
|
75 | 73 | IntentUtils.safeGetBooleanExtra(getIntent(), IS_MONTHLY_CONTRIBUTION, false);
|
76 |
| - if (savedInstanceState == null) { |
77 |
| - mBraveRewardsNativeWorker.GetPublisherBanner( |
78 |
| - mBraveRewardsNativeWorker.GetPublisherId(currentTabId_)); |
79 |
| - } |
| 74 | + |
80 | 75 | clickOnCloseButton();
|
| 76 | + onInitialLayoutInflationComplete(); |
| 77 | + } |
| 78 | + |
| 79 | + @Override |
| 80 | + public void finishNativeInitialization() { |
| 81 | + super.finishNativeInitialization(); |
| 82 | + mBraveRewardsNativeWorker = BraveRewardsNativeWorker.getInstance(); |
| 83 | + mBraveRewardsNativeWorker.AddObserver(this); |
| 84 | + mBraveRewardsNativeWorker.GetPublisherBanner( |
| 85 | + mBraveRewardsNativeWorker.GetPublisherId(currentTabId_)); |
| 86 | + } |
| 87 | + |
| 88 | + @Override |
| 89 | + public boolean shouldStartGpuProcess() { |
| 90 | + return true; |
81 | 91 | }
|
82 | 92 |
|
83 | 93 | private void clickOnCloseButton() {
|
|
0 commit comments