• Stars
    star
    195
  • Rank 199,374 (Top 4 %)
  • Language
    Java
  • Created over 8 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

js and java call each other.(一个JS与Java互相通信框架)

RainbowBridge

A safe JsBridge framework!


Gif

JsBridge

Js invoke Native protocol

rainbow://class:port/method?params

params is a json string.

Return to the Js data format

resultData = {
    status: {
        code: 0,//0:Success,1:Failure
        msg: 'request timeout'//Failure to display a message, success can be null
    },
    data: {}//resultData,can be null
};

Call the Js callback format

javascript:JsBridge.onComplete('port','resultData');

The method`s format can be invoked by Js

public static void ***(WebView webView, JSONObject data, JsCallback callback) {
	 //...
	 JsCallback.invokeJsCallback(callback, true, result, null);
}

If the native method is time consuming operation.Such use:

public static void ***(WebView webView, JSONObject data, JsCallback callback) {
	 AsyncTaskExecutor.runOnAsyncThread(new Runnable() {
        @Override
        public void run() {
            //IO、decode、sqlite... 
            JsCallback.invokeJsCallback(callback, true, result, null);
        }
    });
}
        

License

The MIT License (MIT)

Copyright (c) 2016 郑晓勇

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

Tiny

an image compression framework.(一个高保真、高压缩比的图片压缩框架)
C
2,601
star
2

Recovery

a crash recovery framework.(一个App异常恢复框架)
Java
1,705
star
3

ApiInspect

An api compatibility inspect gradle plugin.(一个Api兼容性检测的Gradle插件)
Groovy
90
star
4

UrlRouter

a routing framework support via the url to jump to the activity.
Java
75
star
5

Android-ScalingActivityAnimator

an interesting pop-view animation.
Java
51
star
6

FFmpeg-Compile-For-Android

Compile FFmpeg shared libraries for android platform.
Shell
36
star
7

Android-QuickReturnHeaderAndFooter

a quick return effect, use a custom CoordinatorLayout.Behavior.
Java
25
star
8

SwipeBackActivity

A gesture activity support sliding back to the right!
Java
24
star
9

findViewById-support

The IDEA plugin for generate findViewById code automatic. Support Java and Kotlin.(一个自动生成FindViewById的IDEA插件,支持Java和Kotlin)
Java
20
star
10

FrescoPlus

fresco library of secondary packaging.
Java
19
star
11

flutter-wrapper-cli

Batchfile
8
star
12

external-plugin-support

The IDEA plugin to show the source code [Groovy、Java、Class] for Android Gradle Plugin and Custom Gradle Plugin. Such as External Libraries.(一个用于显示Gradle Plugin源码树的IDEA插件,类似External Libraries)
8
star
13

gradle-plugin-support

The IDEA plugin for help to create and develop a standard Gradle Plugin project.(一个用于创建和开发一个标准的Gradle Plugin工程的IDEA插件,包含生成标准的Gradle Plugin工程、BuildSrc工程与Groovy Class)
Java
8
star
14

PullToLoad

a refresh framework supports any view and multiple nested views, and contains the wrapper which can load more.
Java
6
star
15

AsyncExecutor

An asynchronous task processing lightweight framework!
Java
3
star
16

Librtmp-Compile-For-Android

Compile Librtmp shared libraries for android platform.
C
3
star
17

langtools

The langtools repository of OpenJDK , including javac source code.
Java
2
star
18

ImageRepository

Image Repository.
2
star
19

Android-DropAnimationSample

Animation with a timestamp drop down
Java
1
star