mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make it possible to load Sky demos from local bundles
This CL teaches SkyDemo how to load Sky applications from local bundles. It also teaches home.dart how to request a load from a bundle. TBR=eseidel@chromium.org Review URL: https://codereview.chromium.org/1213203008.
This commit is contained in:
parent
ac568866f1
commit
4c41ecb0d5
@ -85,4 +85,14 @@ public class SkyActivity extends Activity {
|
||||
public void loadUrl(String url) {
|
||||
mView.loadUrl(url);
|
||||
}
|
||||
|
||||
public boolean loadBundleByName(String name) {
|
||||
File dataDir = new File(PathUtils.getDataDirectory(this));
|
||||
File bundle = new File(dataDir, name);
|
||||
if (!bundle.exists()) {
|
||||
return false;
|
||||
}
|
||||
mView.loadBundle(bundle.getPath());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,25 @@ public class SkyApplication extends BaseChromiumApplication {
|
||||
initJavaUtils();
|
||||
initResources();
|
||||
initNative();
|
||||
initServiceRegistry();
|
||||
onServiceRegistryAvailable(ServiceRegistry.SHARED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this function to add more resources for extraction.
|
||||
*/
|
||||
protected void onBeforeResourceExtraction(ResourceExtractor extractor) {
|
||||
extractor.addResources(SKY_RESOURCES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this function to register more services.
|
||||
*/
|
||||
protected void onServiceRegistryAvailable(ServiceRegistry registry) {
|
||||
registry.register(NetworkService.MANAGER.getName(), new ServiceFactory() {
|
||||
public void connectToService(Context context, Core core, MessagePipeHandle pipe) {
|
||||
new NetworkServiceImpl(context, core, pipe);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initJavaUtils() {
|
||||
@ -51,7 +69,7 @@ public class SkyApplication extends BaseChromiumApplication {
|
||||
|
||||
private void initResources() {
|
||||
mResourceExtractor = new ResourceExtractor(getApplicationContext());
|
||||
mResourceExtractor.addResources(SKY_RESOURCES);
|
||||
onBeforeResourceExtraction(mResourceExtractor);
|
||||
mResourceExtractor.start();
|
||||
}
|
||||
|
||||
@ -63,12 +81,4 @@ public class SkyApplication extends BaseChromiumApplication {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initServiceRegistry() {
|
||||
ServiceRegistry.SHARED.register(NetworkService.MANAGER.getName(), new ServiceFactory() {
|
||||
public void connectToService(Context context, Core core, MessagePipeHandle pipe) {
|
||||
new NetworkServiceImpl(context, core, pipe);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user