Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

缺一个文件啊 #11

Open
susanwater opened this issue Apr 25, 2016 · 17 comments
Open

缺一个文件啊 #11

susanwater opened this issue Apr 25, 2016 · 17 comments

Comments

@susanwater
Copy link

AbsRnInfo 就是这个文件的 源码啊

@susanwater
Copy link
Author

AbsRnInfo

@cnsnake11
Copy link
Owner

你根据RnInfo自己封装一下,或者直接使用RnInfo,而不用AbsRnInfo。

@susanwater
Copy link
Author

susanwater commented Apr 26, 2016

自己封装,请问您传进去的两个参数,如何解释呢,以及您重载的AbsRnInfo类的方法又如何向被调用者去解释呢
public RnInfo(String moduleName) {
this.mModuleName = moduleName;
}

public RnInfo(String moduleName, Bundle launchOptions) {
    this.mModuleName = moduleName;
    this.mLaunchOptions = launchOptions;
}

@Nullable
@Override
public Bundle getLaunchOptions() {
    return mLaunchOptions;
}

@Override
public String getMainComponentName() {
    return mModuleName;
}

@Override
public String getJSMainModuleName() {
    return RNKeys.Default.DEf_JS_MAIN_MODULE_NAME;
}

@Nullable
@Override
public String getJSBundleFile() {
    return RNManager.getJsBundlePath();
}

@Override
public boolean getUseDeveloperSupport() {
    return true;
}

@Override
public List<ReactPackage> getPackages() {
    return Arrays.asList(
            new MainReactPackage(),
            new BBReactPackage()
    );
}

@cnsnake11
Copy link
Owner

这其实是仿造官方提供的例子来编写的,,,官方例子代码如下:

package com.awesomeproject;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;

import java.util.Arrays;
import java.util.List;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "AwesomeProject";
    }

    /**
     * Returns whether dev mode should be enabled.
     * This enables e.g. the dev menu.
     */
    @Override
    protected boolean getUseDeveloperSupport() {
        return true;
    }

    /**
     * A list of packages used by the app. If the app uses additional views
     * or modules besides the default ones, add more packages here.
     */
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
                new MainReactPackage());
    }


    /**
     * Returns the name of the main module. Determines the URL used to fetch the JS bundle
     * from the packager server. It is only used when dev support is enabled.
     * This is the first file to be executed once the {@link ReactInstanceManager} is created.
     * e.g. "index.android"
     */
    @Override
    protected String getJSMainModuleName() {
        return "demo/index";
    }



    /**
     * Returns the name of the bundle in assets. If this is null, and no file path is specified for
     * the bundle, the app will only work with {@code getUseDeveloperSupport} enabled and will
     * always try to load the JS bundle from the packager server.
     * e.g. "index.android.bundle"
     */
    @Override
    protected  String getBundleAssetName() {
        return "index.jsbundle";
    };
}

@cnsnake11
Copy link
Owner

RnInfo只是一个传递rn参数的载体,没有任何逻辑,是一个纯的数据对象。根据你的app的业务逻辑,如何进行初始化,各个参数如何赋值,你是可以修改的。

@dunhuang
Copy link

强烈建议给个demo吧!

@cnsnake11
Copy link
Owner

@dunhuang 有空弄一个

@Kennytian
Copy link

强烈建议给个demo吧!+1

@dunhuang
Copy link

亲 一个月了 有木有抽空弄一个。。。。

@1148030615
Copy link

强烈建议给个demo吧!+1

@cnsnake11
Copy link
Owner

抱歉 最近太忙 争取抽时间弄一个。。。。不过我们现在用的版本是0.20.0啊,不知道还有参考价值没有。

@dunhuang
Copy link

@cnsnake11 应该不行 0.29以后又有重大升级

@DavidSongzw
Copy link

现在版本已经0.30了,可能需要更改下了。

@cnsnake11
Copy link
Owner

0.30.0android下还是有初始化的白屏问题 是吗?

@shihpeng
Copy link

shihpeng commented Aug 18, 2016

还是有白屏问题的,只要Activity.onCreate()中有呼叫到

mReactRootView = new ReactRootView(this);
mReactRootView.startReactApplication(mReactInstanceManager, moduleName);

就会白屏大约200ms。

如果能有个cache ReactRootView的demo就太完美了:)

@YanYanLun
Copy link

我也遇到这问题,不知道能不能完美解决

@amyliu1062
Copy link

0.59.1 都有白屏问题@cnsnake11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants