{"id":1226,"date":"2023-03-18T09:13:26","date_gmt":"2023-03-18T01:13:26","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1226"},"modified":"2023-04-29T09:36:18","modified_gmt":"2023-04-29T01:36:18","slug":"atlas-loads-and-runs-remote-bundles-through-remotetransactor","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/18\/atlas-loads-and-runs-remote-bundles-through-remotetransactor\/","title":{"rendered":"Atlas\u901a\u8fc7RemoteTransactor\u52a0\u8f7d\u5e76\u8fd0\u884c\u8fdc\u7a0bBundle"},"content":{"rendered":"<h2>Bundle\u95f4\u901a\u4fe1RemoteTransactor<\/h2>\n<p>\u4ee5\u8c03\u7528\u56fe\u7247\u53ca\u89c6\u9891\u9884\u89c8\u63d2\u4ef6\u4e3a\u4f8b<\/p>\n<h3>\u5b9a\u4e49PreviewRemote\u5b9e\u73b0IRemote\u63a5\u53e3<\/h3>\n<p><!-- more --><\/p>\n<pre><code class=\"language-java\">public class PreviewRemote implements IRemote {\n\n    public PreviewRemote() {\n        RuntimeVariables.androidApplication.registerComponentCallbacks(new ComponentCallbacks2() {\n            @Override\n            public void onTrimMemory(int level) {\n                if (level == ContentProvider.TRIM_MEMORY_UI_HIDDEN) {\n                    HostTransactor remote = HostTransactor.get(PreviewRemote.this);\n                    if (remote != null) {\n                        remote.call(&quot;SLEEP_NOTIFY&quot;, null, null);\n                    }\n                }\n            }\n\n            @Override\n            public void onConfigurationChanged(Configuration configuration) {\n\n            }\n\n            @Override\n            public void onLowMemory() {\n\n            }\n        });\n    }\n\n    @Override\n    public Bundle call(String commandName, Bundle bundle, IResponse callback) {\n        NLog.i(Constants.TAG, &quot;PreviewRemote.call&quot;);\n        return null;\n    }\n\n    @Override\n    public &lt;T&gt; T getRemoteInterface(Class&lt;T&gt; clazz, Bundle bundle) {\n        NLog.i(Constants.TAG, &quot;PreviewRemote.getRemoteInterface&quot;);\n        if (clazz == IPreviewBridge.class) {\n            T instance = (T) new IPreviewBridge() {\n                @Override\n                public void startImagePreview(Activity activity, @NonNull List imgUrls) {\n                    GPreviewBuilder.from(activity)\n                            .setData(imgUrls)\n                            .setCurrentIndex(0)\n                            .setSingleFling(true)\n                            .setType(GPreviewBuilder.IndicatorType.Dot)\n                            .start();\n                }\n\n                @Override\n                public void startImagePreview(Fragment fragment, @NonNull List imgUrls) {\n                    GPreviewBuilder.from(fragment)\n                            .setData(imgUrls)\n                            .setCurrentIndex(0)\n                            .setSingleFling(true)\n                            .setType(GPreviewBuilder.IndicatorType.Dot)\n                            .start();\n                }\n            };\n            return instance;\n        }\n        return null;\n    }\n}<\/code><\/pre>\n<h3>\u6ce8\u518cPreviewRemote<\/h3>\n<pre><code class=\"language-xml\">&lt;meta-data android:name=&quot;atlas.transaction.intent.action.START_PREVIEW&quot; android:value=&quot;me.yezhou.lib.preview.remote.PreviewRemote&quot;\/&gt;<\/code><\/pre>\n<h3>Bundle\u95f4\u8fdc\u7a0b\u8c03\u7528PreviewRemote<\/h3>\n<pre><code class=\"language-java\">RemoteFactory.requestRemote(RemoteTransactor.class, activity, new Intent(&quot;atlas.transaction.intent.action.START_PREVIEW&quot;),\n        new RemoteFactory.OnRemoteStateListener&lt;RemoteTransactor&gt;() {\n            @Override\n            public void onRemotePrepared(RemoteTransactor iRemote) {\n                IPreviewBridge&lt;IPreviewInfo&gt; previewBridge = iRemote.getRemoteInterface(IPreviewBridge.class,null);\n                previewBridge.startImagePreview(activity, previewInfoList);\n            }\n\n            @Override\n            public void onFailed(String s) {\n                NLog.e(Constants.TAG, s);\n            }\n        });<\/code><\/pre>\n<h2>\u52a0\u8f7d\u5e76\u8fd0\u884c\u8fdc\u7a0bBundle<\/h2>\n<p>Bundle\u95f4\u901a\u8fc7RemoteTransactor\u901a\u4fe1\u5df2\u7ecf\u5b9e\u73b0\uff0c\u4f46\u662f\u5982\u679c\u672a\u5b89\u88c5\u8fdc\u7a0bBundle\u800c\u76f4\u63a5\u52a0\u8f7d\uff0c\u5219\u4f1a\u62a5\u9519<\/p>\n<pre><code>E\/BundleInstaller: me.yezhou.lib.preview--&gt;[me.yezhou.lib.preview], thread=Thread[bundle_installer,5,main]\nE\/Framework: restoreExisted: me.yezhou.lib.preview| 3dfyw7sljnuzq| null\nE\/BundleInstaller: notify finish [me.yezhou.lib.preview]\nE\/yezhou: install bundle failed: me.yezhou.lib.preview<\/code><\/pre>\n<p>\u56e0\u6b64\uff0c\u9996\u5148\u9700\u8981\u52a0\u8f7d\u5e76\u8fd0\u884c\u8fdc\u7a0bBundle<\/p>\n<ol>\n<li>\u89e6\u53d1\u52a0\u8f7d\u8fdc\u7a0bBundle\uff0c\u82e5Bundle\u4e0d\u5b58\u5728\u5bfc\u81f4\u52a0\u8f7d\u5931\u8d25\uff0c\u5219\u63d0\u4ea4\u670d\u52a1\u5668\u8bf7\u6c42\u8fdc\u7a0bBundle\u4e0b\u8f7d<\/li>\n<li>\u8fdc\u7a0bBundle\u4e0b\u8f7d\u5b8c\u6210\uff0c\u7acb\u5373\u5b89\u88c5<\/li>\n<li>\u518d\u6b21\u89e6\u53d1\u52a0\u8f7d\u5e76\u8fd0\u884cBundle<\/li>\n<\/ol>\n<pre><code class=\"language-java\">public static void startPreview(final Activity activity, final List&lt;IPreviewInfo&gt; previewInfoList) {\n    RemoteFactory.requestRemote(RemoteTransactor.class, activity, new Intent(&quot;atlas.transaction.intent.action.START_PREVIEW&quot;),\n            new RemoteFactory.OnRemoteStateListener&lt;RemoteTransactor&gt;() {\n                @Override\n                public void onRemotePrepared(RemoteTransactor iRemote) {\n                    IPreviewBridge&lt;IPreviewInfo&gt; previewBridge = iRemote.getRemoteInterface(IPreviewBridge.class,null);\n                    previewBridge.startImagePreview(activity, previewInfoList);\n                }\n\n                @Override\n                public void onFailed(String s) {\n                    NLog.e(Constants.TAG, s);\n                    AppBundleHelper.bundleExplicitly(activity, &quot;preview&quot;, &quot;me.yezhou.lib&quot;, new AtlasBundleLoadedListener() {\n                        @Override\n                        public void onBundleLoaded() {\n                            startPreview(activity, previewInfoList);\n                        }\n                    });\n                }\n            });\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Bundle\u95f4\u901a\u4fe1RemoteTransactor \u4ee5\u8c03\u7528\u56fe\u7247\u53ca\u89c6\u9891\u9884\u89c8\u63d2\u4ef6\u4e3a\u4f8b \u5b9a\u4e49PreviewRemot [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[275],"tags":[],"class_list":["post-1226","post","type-post","status-publish","format-standard","hentry","category-atlas"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1226"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1226\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}