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

[use]:如何去掉加载bundle时的loading效果 #354

Open
joyruby opened this issue Apr 18, 2019 · 0 comments
Open

[use]:如何去掉加载bundle时的loading效果 #354

joyruby opened this issue Apr 18, 2019 · 0 comments

Comments

@joyruby
Copy link

joyruby commented Apr 18, 2019

我们的app有个启动页,启动页之后会启动首页。但是首页以bundle的方式存在的,所以每次启动页之后都会出现一个默认的loading,请问应该如何去掉?

目前发现一个方式:在调用startActivity之前,先install一下bundle ,代码如下:

    /**
     * 跳转首页
     *
     * @param context
     */
    public static void gotoHome(final Activity context) {
        final Intent intent = new Intent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setClassName(context,"");
        AtlasBundleUtils.getBundle(AtlasBundleUtils.LITE_HOME_BUNDLE, new AtlasBundleUtils.InstallListener() {
            @Override
            public void onFinished(BundleImpl impl) {
                context.startActivity(intent);
                context.finish();
            }
        });
    }
public class AtlasBundleUtils {
    public final static String LITE_UPPER_BUNDLE = "com.**.**";
    public final static String LITE_HOME_BUNDLE = "com.**.**";
    public static void initBundle(final String bundle, final InstallListener listener) {
        BundleImpl impl = (BundleImpl) Atlas.getInstance().getBundle(bundle);
        if (impl != null && listener != null) {
            listener.onFinished(impl);
        } else {
            initBundle(new String[]{bundle}, new BundleInstaller.InstallListener() {
                @Override
                public void onFinished() {
                    BundleImpl impl = (BundleImpl) Atlas.getInstance().getBundle(bundle);
                    if (impl != null) {
                        try {
                            impl.start();
                            if (listener != null) {
                                listener.onFinished(impl);
                            }
                        } catch (BundleException e) {
                            e.printStackTrace();
                        }
                    }
                }
            });
        }

    }

    public static void initBundle(String[] bundles, BundleInstaller.InstallListener listener) {
        Atlas.getInstance().installBundleTransitivelyAsync(
            bundles,
            listener);
    }

    public static void getBundle(String bundle, InstallListener listener) {
        initBundle(bundle, listener);
    }

    public interface InstallListener {
        void onFinished(BundleImpl impl);
    }

求解答:

  1. 有没有直接去掉或者替换loading的方法?
  2. 可不可以在application里手动install一下bundle?
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

1 participant