Skip to content

Commit

Permalink
forward ThemedReactContext#has/getCurrentActivity calls to wrapped co…
Browse files Browse the repository at this point in the history
…ntext

Summary:
`ThemedReactContext` wraps the actual `ReactContext` but doesn't actually receive any lifecycle events, which would set `mCurrentActivity`, so that's always stuck as `null`. To fix, we override `has/getCurrentActivity` and forward the call to the wrapped context, which actually has the correct lifecycle status.

Fixes issue facebook#9310 on github.

Reviewed By: mkonicek

Differential Revision: D3703005

fbshipit-source-id: 363e87ac91d50516899b413e823d5312cbb807f4
  • Loading branch information
foghina authored and Morgan Pretty committed Aug 24, 2016
1 parent efb2cbe commit 5e8d1b8
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

package com.facebook.react.uimanager;

import javax.annotation.Nullable;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
Expand Down Expand Up @@ -47,4 +47,14 @@ public void addLifecycleEventListener(LifecycleEventListener listener) {
public void removeLifecycleEventListener(LifecycleEventListener listener) {
mReactApplicationContext.removeLifecycleEventListener(listener);
}

@Override
public boolean hasCurrentActivity() {
return mReactApplicationContext.hasCurrentActivity();
}

@Override
public @Nullable Activity getCurrentActivity() {
return mReactApplicationContext.getCurrentActivity();
}
}

0 comments on commit 5e8d1b8

Please sign in to comment.