Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
新增jsBridge的demo,演示:jsBridge面向组件的封装及跨进程通信(WebActivity在子进程中)
- Loading branch information
1 parent
9bb1660
commit 5e58dd7
Showing
32 changed files
with
729 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
demo_component_b/src/main/java/com/billy/cc/demo/component/b/BProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ponent_b/src/main/java/com/billy/cc/demo/component/b/processor/GetLoginUserProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.billy.cc.demo.component.b.processor; | ||
|
||
import com.billy.cc.core.component.CC; | ||
import com.billy.cc.core.component.CCResult; | ||
import com.billy.cc.demo.component.b.Global; | ||
|
||
|
||
/** | ||
* 获取当前登录用户信息 | ||
* @author billy.qi | ||
*/ | ||
public class GetLoginUserProcessor implements IActionProcessor { | ||
|
||
@Override | ||
public String getActionName() { | ||
return "getLoginUser"; | ||
} | ||
|
||
@Override | ||
public boolean onActionCall(CC cc) { | ||
if (Global.loginUser != null) { | ||
//already login, return username | ||
CCResult result = CCResult.success(Global.KEY_USER, Global.loginUser); | ||
CC.sendCCResult(cc.getCallId(), result); | ||
} else { | ||
CC.sendCCResult(cc.getCallId(), CCResult.error("no login user")); | ||
} | ||
return false; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
demo_component_b/src/main/java/com/billy/cc/demo/component/b/processor/LogoutProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.billy.cc.demo.component.b.processor; | ||
|
||
import com.billy.cc.core.component.CC; | ||
import com.billy.cc.core.component.CCResult; | ||
import com.billy.cc.demo.component.b.Global; | ||
|
||
|
||
/** | ||
* 退出登录 | ||
* @author billy.qi | ||
*/ | ||
public class LogoutProcessor implements IActionProcessor { | ||
|
||
@Override | ||
public String getActionName() { | ||
return "logout"; | ||
} | ||
|
||
@Override | ||
public boolean onActionCall(CC cc) { | ||
Global.loginUser = null; | ||
CC.sendCCResult(cc.getCallId(), CCResult.success()); | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apply from: rootProject.file("cc-settings-demo.gradle") | ||
|
||
android { | ||
compileSdkVersion rootProject.compileVersion | ||
buildToolsVersion rootProject.buildVersion | ||
|
||
defaultConfig { | ||
minSdkVersion 9 // support v7 minSdkVersion is 9 | ||
targetSdkVersion rootProject.compileVersion | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
|
||
} | ||
resourcePrefix "demo_jsbridge_" | ||
|
||
buildTypes { | ||
release { | ||
postprocessing { | ||
removeUnusedCode false | ||
removeUnusedResources false | ||
obfuscate false | ||
optimizeCode false | ||
proguardFile 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation "com.android.support:appcompat-v7:${rootProject.supportVersion}" | ||
api 'com.github.lzyzsd:jsbridge:1.0.4' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.billy.cc.demo.component.jsbridge"> | ||
|
||
<application> | ||
<activity android:name=".WebActivity" android:process=":web" /> | ||
</application> | ||
</manifest> |
Oops, something went wrong.