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

Add loadBundle method in BundleCore & Framework. #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bundle/src/ctrip/android/bundle/framework/BundleCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public Bundle installBundle(String location, InputStream inputStream) throws Bun
return Framework.installNewBundle(location, inputStream);
}

public Bundle loadBundle(String location) throws Exception {
return Framework.loadBundle(location);
}

public void updateBundle(String location, InputStream inputStream) throws BundleException {
Bundle bundle = Framework.getBundle(location);
Expand Down
9 changes: 9 additions & 0 deletions bundle/src/ctrip/android/bundle/framework/Framework.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,14 @@ static BundleImpl installNewBundle(String location, InputStream inputStream) thr
return bundleImpl;
}

static BundleImpl loadBundle(String location) throws Exception {
BundleImpl bundleImpl = (BundleImpl) getBundle(location);
if (bundleImpl != null) {
return bundleImpl;
}
bundleImpl = new BundleImpl(new File(location));
bundles.put(location, bundleImpl);
return bundleImpl;
}

}
11 changes: 11 additions & 0 deletions sample/src/ctrip/android/sample/BundleBaseApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ public void onCreate() {
BundleCore.getInstance().startup(properties);
if (isDexInstalled) {
HotPatchManager.getInstance().run();
File libsPath = new File(getFilesDir() + "/storage/");
try {
for (File bundleDir : libsPath.listFiles()){
if (!bundleDir.isDirectory()){ //Skip meta file.
continue;
}
BundleCore.getInstance().loadBundle(bundleDir.getAbsolutePath());
}
} catch (Exception e){
e.printStackTrace();
}
BundleCore.getInstance().run();
} else {
new Thread(new Runnable() {
Expand Down