forward ThemedReactContext#has/getCurrentActivity calls to wrapped context

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 #9310 on github.

Reviewed By: mkonicek

Differential Revision: D3703005

fbshipit-source-id: 363e87ac91d50516899b413e823d5312cbb807f4
This commit is contained in:
Felix Oghina 2016-08-11 07:19:53 -07:00 committed by Facebook Github Bot 4
parent f76f4cf432
commit 96e41218ed
1 changed files with 13 additions and 3 deletions

View File

@ -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;
@ -47,4 +47,14 @@ public class ThemedReactContext extends ReactContext {
public void removeLifecycleEventListener(LifecycleEventListener listener) {
mReactApplicationContext.removeLifecycleEventListener(listener);
}
@Override
public boolean hasCurrentActivity() {
return mReactApplicationContext.hasCurrentActivity();
}
@Override
public @Nullable Activity getCurrentActivity() {
return mReactApplicationContext.getCurrentActivity();
}
}