org.chromium.base.ActivityState Java Examples

The following examples show how to use org.chromium.base.ActivityState. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Called by the system when the activity changes from fullscreen mode to multi-window mode
 * and visa-versa.
 * @param isInMultiWindowMode True if the activity is in multi-window mode.
 */
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    recordMultiWindowModeChangedUserAction(isInMultiWindowMode);

    if (!isInMultiWindowMode
            && ApplicationStatus.getStateForActivity(this) == ActivityState.RESUMED) {
        // Start a new UMA session when exiting multi-window mode if the activity is currently
        // resumed. When entering multi-window Android recents gains focus, so ChromeActivity
        // will get a call to onPauseWithNative(), ending the current UMA session. When exiting
        // multi-window, however, if ChromeActivity is resumed it stays in that state.
        markSessionEnd();
        markSessionResume();
        FeatureUtilities.setIsInMultiWindowMode(
                MultiWindowUtils.getInstance().isInMultiWindowMode(this));
    }

    super.onMultiWindowModeChanged(isInMultiWindowMode);
}
 
Example #2
Source File: IncognitoNotificationService.java    From delion with Apache License 2.0 6 votes vote down vote up
private Set<Integer> getTaskIdsForVisibleActivities() {
    List<WeakReference<Activity>> runningActivities =
            ApplicationStatus.getRunningActivities();
    Set<Integer> visibleTaskIds = new HashSet<>();
    for (int i = 0; i < runningActivities.size(); i++) {
        Activity activity = runningActivities.get(i).get();
        if (activity == null) continue;

        int activityState = ApplicationStatus.getStateForActivity(activity);
        if (activityState != ActivityState.STOPPED
                && activityState != ActivityState.DESTROYED) {
            visibleTaskIds.add(activity.getTaskId());
        }
    }
    return visibleTaskIds;
}
 
Example #3
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Called by the system when the activity changes from fullscreen mode to multi-window mode
 * and visa-versa.
 * @param isInMultiWindowMode True if the activity is in multi-window mode.
 */
@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    recordMultiWindowModeChangedUserAction(isInMultiWindowMode);

    if (!isInMultiWindowMode
            && ApplicationStatus.getStateForActivity(this) == ActivityState.RESUMED) {
        // Start a new UMA session when exiting multi-window mode if the activity is currently
        // resumed. When entering multi-window Android recents gains focus, so ChromeActivity
        // will get a call to onPauseWithNative(), ending the current UMA session. When exiting
        // multi-window, however, if ChromeActivity is resumed it stays in that state.
        markSessionEnd();
        markSessionResume();
        FeatureUtilities.setIsInMultiWindowMode(
                MultiWindowUtils.getInstance().isInMultiWindowMode(this));
    }

    super.onMultiWindowModeChanged(isInMultiWindowMode);
}
 
Example #4
Source File: ChromeFullscreenManager.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.STOPPED) {
        // Exit fullscreen in onStop to ensure the system UI flags are set correctly when
        // showing again (on JB MR2+ builds, the omnibox would be covered by the
        // notification bar when this was done in onStart()).
        setPersistentFullscreenMode(false);
    } else if (newState == ActivityState.STARTED) {
        // Force the controls to be shown until we get an update from a Tab.  This is a
        // workaround for when the renderer is killed but the Tab is not notified.
        mActivityShowToken = showControlsPersistentAndClearOldToken(mActivityShowToken);
    } else if (newState == ActivityState.DESTROYED) {
        ApplicationStatus.unregisterActivityStateListener(this);
        ((BaseChromiumApplication) mWindow.getContext().getApplicationContext())
                .unregisterWindowFocusChangedListener(this);
    }
}
 
Example #5
Source File: ChromeBrowserInitializer.java    From delion with Apache License 2.0 6 votes vote down vote up
private ActivityStateListener createActivityStateListener() {
    return new ActivityStateListener() {
        @Override
        public void onActivityStateChange(Activity activity, int newState) {
            if (newState == ActivityState.CREATED || newState == ActivityState.DESTROYED) {
                // Android destroys Activities at some point after a locale change, but doesn't
                // kill the process.  This can lead to a bug where Chrome is halfway RTL, where
                // stale natively-loaded resources are not reloaded (http://crbug.com/552618).
                if (!mInitialLocale.equals(Locale.getDefault())) {
                    Log.e(TAG, "Killing process because of locale change.");
                    Process.killProcess(Process.myPid());
                }

                DeviceFormFactor.resetValuesIfNeeded(mApplication);
            }
        }
    };
}
 
Example #6
Source File: RecentTabsPage.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Updates whether the page is in the foreground based on whether the application is in the
 * foreground and whether {@link #mView} is attached to the application window. If the page is
 * no longer in the foreground, records the time that the page spent in the foreground to UMA.
 */
private void updateForegroundState() {
    boolean inForeground = mIsAttachedToWindow
            && ApplicationStatus.getStateForActivity(mActivity) == ActivityState.RESUMED;
    if (mInForeground == inForeground) {
        return;
    }

    mInForeground = inForeground;
    if (mInForeground) {
        mForegroundTimeMs = SystemClock.elapsedRealtime();
        StartupMetrics.getInstance().recordOpenedRecents();
    } else {
        RecordHistogram.recordLongTimesHistogram("NewTabPage.RecentTabsPage.TimeVisibleAndroid",
                SystemClock.elapsedRealtime() - mForegroundTimeMs, TimeUnit.MILLISECONDS);
    }
}
 
Example #7
Source File: RecentTabsPage.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Updates whether the page is in the foreground based on whether the application is in the
 * foreground and whether {@link #mView} is attached to the application window. If the page is
 * no longer in the foreground, records the time that the page spent in the foreground to UMA.
 */
private void updateForegroundState() {
    boolean inForeground = mIsAttachedToWindow
            && ApplicationStatus.getStateForActivity(mActivity) == ActivityState.RESUMED;
    if (mInForeground == inForeground) {
        return;
    }

    mInForeground = inForeground;
    if (mInForeground) {
        mForegroundTimeMs = SystemClock.elapsedRealtime();
        StartupMetrics.getInstance().recordOpenedRecents();
    } else {
        RecordHistogram.recordLongTimesHistogram("NewTabPage.RecentTabsPage.TimeVisibleAndroid",
                SystemClock.elapsedRealtime() - mForegroundTimeMs, TimeUnit.MILLISECONDS);
    }
}
 
Example #8
Source File: ChromeActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Called by the system when the activity changes from fullscreen mode to multi-window mode
 * and visa-versa.
 * @param isInMultiWindowMode True if the activity is in multi-window mode.
 */
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    recordMultiWindowModeChangedUserAction(isInMultiWindowMode);

    if (!isInMultiWindowMode
            && ApplicationStatus.getStateForActivity(this) == ActivityState.RESUMED) {
        // Start a new UMA session when exiting multi-window mode if the activity is currently
        // resumed. When entering multi-window Android recents gains focus, so ChromeActivity
        // will get a call to onPauseWithNative(), ending the current UMA session. When exiting
        // multi-window, however, if ChromeActivity is resumed it stays in that state.
        markSessionEnd();
        markSessionResume();
        FeatureUtilities.setIsInMultiWindowMode(
                MultiWindowUtils.getInstance().isInMultiWindowMode(this));
    }
}
 
Example #9
Source File: IncognitoNotificationService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private Set<Integer> getTaskIdsForVisibleActivities() {
    List<WeakReference<Activity>> runningActivities =
            ApplicationStatus.getRunningActivities();
    Set<Integer> visibleTaskIds = new HashSet<>();
    for (int i = 0; i < runningActivities.size(); i++) {
        Activity activity = runningActivities.get(i).get();
        if (activity == null) continue;

        int activityState = ApplicationStatus.getStateForActivity(activity);
        if (activityState != ActivityState.STOPPED
                && activityState != ActivityState.DESTROYED) {
            visibleTaskIds.add(activity.getTaskId());
        }
    }
    return visibleTaskIds;
}
 
Example #10
Source File: VrShellDelegate.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private VrShellDelegate(ChromeActivity activity, VrClassesWrapper wrapper) {
    mActivity = activity;
    mVrClassesWrapper = wrapper;
    // If an activity isn't resumed at the point, it must have been paused.
    mPaused = ApplicationStatus.getStateForActivity(activity) != ActivityState.RESUMED;
    updateVrSupportLevel();
    mNativeVrShellDelegate = nativeInit();
    mFeedbackFrequency = VrFeedbackStatus.getFeedbackFrequency();
    mEnterVrHandler = new Handler();
    Choreographer.getInstance().postFrameCallback(new FrameCallback() {
        @Override
        public void doFrame(long frameTimeNanos) {
            if (mNativeVrShellDelegate == 0) return;
            Display display =
                    ((WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE))
                            .getDefaultDisplay();
            nativeUpdateVSyncInterval(
                    mNativeVrShellDelegate, frameTimeNanos, 1.0d / display.getRefreshRate());
        }
    });
    ApplicationStatus.registerStateListenerForAllActivities(this);
}
 
Example #11
Source File: ChromeBrowserInitializer.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private ActivityStateListener createActivityStateListener() {
    return new ActivityStateListener() {
        @Override
        public void onActivityStateChange(Activity activity, int newState) {
            if (newState == ActivityState.CREATED || newState == ActivityState.DESTROYED) {
                // Android destroys Activities at some point after a locale change, but doesn't
                // kill the process.  This can lead to a bug where Chrome is halfway RTL, where
                // stale natively-loaded resources are not reloaded (http://crbug.com/552618).
                if (!mInitialLocale.equals(Locale.getDefault())) {
                    Log.e(TAG, "Killing process because of locale change.");
                    Process.killProcess(Process.myPid());
                }

                DeviceFormFactor.resetValuesIfNeeded(mApplication);
            }
        }
    };
}
 
Example #12
Source File: OverlayPanel.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    boolean isMultiWindowMode = MultiWindowUtils.getInstance().isLegacyMultiWindow(mActivity)
            || MultiWindowUtils.getInstance().isInMultiWindowMode(mActivity);

    // In multi-window mode the activity that was interacted with last is resumed and
    // all others are paused. We should not close Contextual Search in this case,
    // because the activity may be visible even though it is paused.
    if (isMultiWindowMode
            && (newState == ActivityState.PAUSED || newState == ActivityState.RESUMED)) {
        return;
    }

    if (newState == ActivityState.RESUMED
            || newState == ActivityState.STOPPED
            || newState == ActivityState.DESTROYED) {
        closePanel(StateChangeReason.UNKNOWN, false);
    }
}
 
Example #13
Source File: RecentTabsPage.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Updates whether the page is in the foreground based on whether the application is in the
 * foreground and whether {@link #mView} is attached to the application window. If the page is
 * no longer in the foreground, records the time that the page spent in the foreground to UMA.
 */
private void updateForegroundState() {
    boolean inForeground = mIsAttachedToWindow
            && ApplicationStatus.getStateForActivity(mActivity) == ActivityState.RESUMED;
    if (mInForeground == inForeground) {
        return;
    }

    mInForeground = inForeground;
    if (mInForeground) {
        mForegroundTimeMs = SystemClock.elapsedRealtime();
        StartupMetrics.getInstance().recordOpenedRecents();
    } else {
        RecordHistogram.recordLongTimesHistogram("NewTabPage.RecentTabsPage.TimeVisibleAndroid",
                SystemClock.elapsedRealtime() - mForegroundTimeMs, TimeUnit.MILLISECONDS);
    }
}
 
Example #14
Source File: OverlayPanel.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    boolean isMultiWindowMode = MultiWindowUtils.getInstance().isLegacyMultiWindow(mActivity)
            || MultiWindowUtils.getInstance().isInMultiWindowMode(mActivity);

    // In multi-window mode the activity that was interacted with last is resumed and
    // all others are paused. We should not close Contextual Search in this case,
    // because the activity may be visible even though it is paused.
    if (isMultiWindowMode
            && (newState == ActivityState.PAUSED || newState == ActivityState.RESUMED)) {
        return;
    }

    if (newState == ActivityState.RESUMED
            || newState == ActivityState.STOPPED
            || newState == ActivityState.DESTROYED) {
        closePanel(StateChangeReason.UNKNOWN, false);
    }
}
 
Example #15
Source File: ChromeBrowserInitializer.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private ActivityStateListener createActivityStateListener() {
    return new ActivityStateListener() {
        @Override
        public void onActivityStateChange(Activity activity, int newState) {
            if (newState == ActivityState.CREATED || newState == ActivityState.DESTROYED) {
                // Android destroys Activities at some point after a locale change, but doesn't
                // kill the process.  This can lead to a bug where Chrome is halfway RTL, where
                // stale natively-loaded resources are not reloaded (http://crbug.com/552618).
                if (!mInitialLocale.equals(Locale.getDefault())) {
                    Log.e(TAG, "Killing process because of locale change.");
                    Process.killProcess(Process.myPid());
                }

                DeviceFormFactor.resetValuesIfNeeded(mApplication);
            }
        }
    };
}
 
Example #16
Source File: ChromeFullscreenManager.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.STOPPED && mExitFullscreenOnStop) {
        // Exit fullscreen in onStop to ensure the system UI flags are set correctly when
        // showing again (on JB MR2+ builds, the omnibox would be covered by the
        // notification bar when this was done in onStart()).
        setPersistentFullscreenMode(false);
    } else if (newState == ActivityState.STARTED) {
        ThreadUtils.postOnUiThreadDelayed(new Runnable() {
            @Override
            public void run() {
                mBrowserVisibilityDelegate.showControlsTransient();
            }
        }, ACTIVITY_RETURN_SHOW_REQUEST_DELAY_MS);
    } else if (newState == ActivityState.DESTROYED) {
        ApplicationStatus.unregisterActivityStateListener(this);
        ((BaseChromiumApplication) mWindow.getContext().getApplicationContext())
                .unregisterWindowFocusChangedListener(this);

        mTabModelObserver.destroy();
    }
}
 
Example #17
Source File: IncognitoNotificationService.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private Set<Integer> getTaskIdsForVisibleActivities() {
    List<WeakReference<Activity>> runningActivities =
            ApplicationStatus.getRunningActivities();
    Set<Integer> visibleTaskIds = new HashSet<>();
    for (int i = 0; i < runningActivities.size(); i++) {
        Activity activity = runningActivities.get(i).get();
        if (activity == null) continue;

        int activityState = ApplicationStatus.getStateForActivity(activity);
        if (activityState != ActivityState.STOPPED
                && activityState != ActivityState.DESTROYED) {
            visibleTaskIds.add(activity.getTaskId());
        }
    }
    return visibleTaskIds;
}
 
Example #18
Source File: ChromeFullscreenManager.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.STOPPED) {
        // Exit fullscreen in onStop to ensure the system UI flags are set correctly when
        // showing again (on JB MR2+ builds, the omnibox would be covered by the
        // notification bar when this was done in onStart()).
        setPersistentFullscreenMode(false);
    } else if (newState == ActivityState.STARTED) {
        ThreadUtils.postOnUiThreadDelayed(new Runnable() {
            @Override
            public void run() {
                mBrowserVisibilityDelegate.showControlsTransient();
            }
        }, ACTIVITY_RETURN_SHOW_REQUEST_DELAY_MS);
    } else if (newState == ActivityState.DESTROYED) {
        ApplicationStatus.unregisterActivityStateListener(this);
        ((BaseChromiumApplication) mWindow.getContext().getApplicationContext())
                .unregisterWindowFocusChangedListener(this);

        mTabModelObserver.destroy();
    }
}
 
Example #19
Source File: OverlayPanel.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    boolean isMultiWindowMode = MultiWindowUtils.getInstance().isLegacyMultiWindow(mActivity)
            || MultiWindowUtils.getInstance().isInMultiWindowMode(mActivity);

    // In multi-window mode the activity that was interacted with last is resumed and
    // all others are paused. We should not close Contextual Search in this case,
    // because the activity may be visible even though it is paused.
    if (isMultiWindowMode
            && (newState == ActivityState.PAUSED || newState == ActivityState.RESUMED)) {
        return;
    }

    if (newState == ActivityState.RESUMED
            || newState == ActivityState.STOPPED
            || newState == ActivityState.DESTROYED) {
        closePanel(StateChangeReason.UNKNOWN, false);
    }
}
 
Example #20
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    super.onMultiWindowModeChanged(isInMultiWindowMode);
    if (!FeatureUtilities.isTabModelMergingEnabled()) return;
    if (!isInMultiWindowMode) {
        // If the activity is currently resumed when multi-window mode is exited, try to merge
        // tabs from the other activity instance.
        if (ApplicationStatus.getStateForActivity(this) == ActivityState.RESUMED) {
            maybeMergeTabs();
        } else {
            mMergeTabsOnResume = true;
        }
    }
}
 
Example #21
Source File: ContextualSearchPanel.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    super.onActivityStateChange(activity, newState);
    if (newState == ActivityState.PAUSED) {
        mManagementDelegate.logCurrentState();
    }
}
 
Example #22
Source File: ActivityWindowAndroid.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.STOPPED) {
        onActivityStopped();
    } else if (newState == ActivityState.STARTED) {
        onActivityStarted();
    }
}
 
Example #23
Source File: TabWindowManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.DESTROYED && mAssignments.containsKey(activity)) {
        int index = mSelectors.indexOf(mAssignments.remove(activity));
        if (index >= 0) mSelectors.set(index, null);
        // TODO(dtrainor): Move TabModelSelector#destroy() calls here.
    }
}
 
Example #24
Source File: ContextualSearchPanel.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    super.onActivityStateChange(activity, newState);
    if (newState == ActivityState.PAUSED) {
        mManagementDelegate.logCurrentState();
    }
}
 
Example #25
Source File: SuggestionsSheetVisibilityChangeObserver.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Compares the current state of the bottom sheet and activity with the ones recorded at the
 * previous call and generates events based on the difference.
 * @see #onContentShown()
 * @see #onContentHidden()
 * @see #onContentStateChanged(int)
 */
private void onStateChange() {
    boolean newVisibility = mBottomSheet.isSheetOpen()
            && mBottomSheet.getCurrentSheetContent() == mContentObserved
            && ApplicationStatus.getStateForActivity(mActivity) == ActivityState.RESUMED;

    // As the visibility we track is the one for a specific sheet content rather than the
    // whole BottomSheet, we also need to reflect that in the state, marking it "peeking" here
    // even though the BottomSheet itself is not.
    @BottomSheet.SheetState
    int newContentState =
            newVisibility ? mBottomSheet.getSheetState() : BottomSheet.SHEET_STATE_PEEK;

    // Flag overall changes to the visible state of the content, while ignoring transient states
    // like |STATE_SCROLLING|.
    boolean hasMeaningfulStateChange = BottomSheet.isStateStable(newContentState)
            && (mCurrentContentState != newContentState || mCurrentVisibility != newVisibility);

    if (newVisibility != mCurrentVisibility) {
        if (newVisibility) {
            onContentShown();
        } else {
            onContentHidden();
        }
        mCurrentVisibility = newVisibility;
    }

    if (hasMeaningfulStateChange) {
        onContentStateChanged(newContentState);
        mCurrentContentState = newContentState;
    }
}
 
Example #26
Source File: OfflinePageTabObserver.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private static void ensureObserverMapInitialized() {
    if (sObservers != null) return;
    sObservers = new HashMap<>();
    ApplicationStatus.registerStateListenerForAllActivities(new ActivityStateListener() {
        @Override
        public void onActivityStateChange(Activity activity, int newState) {
            if (newState != ActivityState.DESTROYED) return;
            OfflinePageTabObserver observer = sObservers.remove(activity);
            if (observer == null) return;
            observer.destroy();
        }
    });
}
 
Example #27
Source File: MultiWindowUtils.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.RESUMED && activity instanceof ChromeTabbedActivity) {
        mLastResumedTabbedActivity =
                new WeakReference<ChromeTabbedActivity>((ChromeTabbedActivity) activity);
    }
}
 
Example #28
Source File: TabWebContentsDelegateAndroid.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void activateContents() {
    ChromeActivity activity = mTab.getActivity();
    if (activity == null) {
        Log.e(TAG, "Activity not set activateContents().  Bailing out.");
        return;
    }
    if (activity.isActivityDestroyed()) {
        Log.e(TAG, "Activity destroyed before calling activateContents().  Bailing out.");
        return;
    }
    if (!mTab.isInitialized()) {
        Log.e(TAG, "Tab not initialized before calling activateContents().  Bailing out.");
        return;
    }

    // Do nothing if the tab can currently be interacted with by the user.
    if (mTab.isUserInteractable()) return;

    TabModel model = getTabModel();
    int index = model.indexOf(mTab);
    if (index == TabModel.INVALID_TAB_INDEX) return;
    TabModelUtils.setIndex(model, index);

    // Do nothing if the activity is visible (STOPPED is the only valid invisible state as we
    // explicitly check isActivityDestroyed above).
    if (ApplicationStatus.getStateForActivity(activity) == ActivityState.STOPPED) {
        bringActivityToForeground();
    }
}
 
Example #29
Source File: ChromeApplication.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Shows an error dialog following a startup error, and then exits the application.
 * @param e The exception reported by Chrome initialization.
 */
public static void reportStartupErrorAndExit(final ProcessInitException e) {
    Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
    if (ApplicationStatus.getStateForActivity(activity) == ActivityState.DESTROYED) {
        return;
    }
    InvalidStartupDialog.show(activity, e.getErrorCode());
}
 
Example #30
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);

    maybeRemoveWindowBackground();

    Tab tab = getActivityTab();
    if (tab == null) return;
    if (hasFocus) {
        tab.onActivityShown();
    } else {
        boolean stopped = ApplicationStatus.getStateForActivity(this) == ActivityState.STOPPED;
        if (stopped) tab.onActivityHidden();
    }
}