Giter VIP home page Giter VIP logo

app-browser's People

Contributors

kenwheeler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

app-browser's Issues

Any ideas for getting the RCTFrame working on Android?

Here is my attempt at the android Frame native module.

package com.inceptionhost.rctframe;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.common.LifecycleState;
import com.facebook.react.ReactApplication;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.*;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactRootView;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;

public class RCTFrameManager extends SimpleViewManager<ReactRootView> {
    public static final String REACT_CLASS = "RCTFrame";
    public String _bundlePath;
    RCTFrameManager(){
        String _bundlePath = "";
    }


    @Override
    public String getName() {
        // Tell React the name of the module
        // https://facebook.github.io/react-native/docs/native-components-android.html#1-create-the-viewmanager-subclass
        return REACT_CLASS;
    }

    @Override
    public ReactRootView createViewInstance(ThemedReactContext context){
        ReactInstanceManager mReactInstanceManager;
        Application app = new Application();
        Context appctx = app.getBaseContext();
        ReactApplicationContext RCT_CTX = new ReactApplicationContext(appctx);
        mReactInstanceManager = ReactInstanceManager
                .builder()
                .setApplication(app)
                .setCurrentActivity(new Activity())
                .setDefaultHardwareBackBtnHandler(new DefaultHardwareBackBtnHandler() {
                    @Override
                    public void invokeDefaultOnBackPressed() {

                    }
                })
                .setJSBundleFile(_bundlePath)// or
                ////.setJSMainModulePath("")
                .build();
        mReactInstanceManager.getDevSupportManager().setDevSupportEnabled(false);
        mReactInstanceManager.createReactContextInBackground();
        ReactRootView _rootView = new ReactRootView(context);
        _rootView.startReactApplication(mReactInstanceManager, "ExampleApp");
        return _rootView;

        //maybe something like this?
        //ReactRootView mReactRootView = new ReactRootView(app.getApplicationContext());
        //mReactInstanceManager = ReactInstanceManager.builder()
        //        .setApplication(app)//getApplication()
        //        .setJSBundleFile(_bundlePath)
        //        .addPackage(new MainReactPackage())
        //        .setUseDeveloperSupport(BuildConfig.DEBUG)
        //        .setInitialLifecycleState(LifecycleState.RESUMED)
        //        .build();
        // The string here (e.g. "MyReactNativeApp") has to match
        // the string in AppRegistry.registerComponent() in index.js
        //mReactRootView.startReactApplication(
        //        mReactInstanceManager,
        //        "ExampleApp",
        //        null
        //);
        //return mReactRootView;
    }

    @ReactProp(name = "bundle")
    public void setBundle(ReactRootView view, String prop) {
        // Set properties from React onto your native component via a setter method
        // https://facebook.github.io/react-native/docs/native-components-android.html#3-expose-view-property-setters-using-reactprop-or-reactpropgroup-annotation
        _bundlePath = prop;
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.