Giter Site home page Giter Site logo

Comments (6)

smallbuer avatar smallbuer commented on June 26, 2024

我想在Activity中单独添加个Handler,源码中初始化BridgeTiny的时候已经添加了所有的Handler, 想在Activity中单独添加该怎么做呢(weview和Activity在用一个页面的需求)

是想每个webview只添加单独的Handle吗,目前实现的相当于APP用的所有的webview使用的handle都在初始化的时候设置好;

from jsbridge-android.

AnAnKK avatar AnAnKK commented on June 26, 2024

是的, 因为我这里有个需求, 是webview和avtivity是同一个页面的, 我想实现在同一个页面原生和js交互; 但是Handler的handler(Context context, String data, CallBackFunction function) 方法无法写到Activity中, 导致没法交互; 因此我想在webview中添加个抽象方法来动态添加Handle,但我不知道怎么写, 请大佬看看这个我该咋实现呢

from jsbridge-android.

smallbuer avatar smallbuer commented on June 26, 2024

是的, 因为我这里有个需求, 是webview和avtivity是同一个页面的, 我想实现在同一个页面原生和js交互; 但是Handler的handler(Context context, String data, CallBackFunction function) 方法无法写到Activity中, 导致没法交互; 因此我想在webview中添加个抽象方法来动态添加Handle,但我不知道怎么写, 请大佬看看这个我该咋实现呢

如果需要这种场景,也就是单独给UI中的webview添加JS桥,其实这种也是很容易满足的,直接扩展IWebview接口,添加两个方法,void addHandlerLocal(String handlerName,BridgeHandler bridgeHandler)和Map<String, BridgeHandler> getLocalMessageHandlers();接口,然后再各个webview中实现一个Map集合的维护,在回调的时候优先匹配webview中的桥,如果匹配到就直接return

from jsbridge-android.

AnAnKK avatar AnAnKK commented on June 26, 2024

好的 多谢大佬指导

from jsbridge-android.

smallbuer avatar smallbuer commented on June 26, 2024

好的 多谢大佬指导

下个版本加一个这种功能,需求还是挺不错的

from jsbridge-android.

smallbuer avatar smallbuer commented on June 26, 2024

已经添加1.0.4

from jsbridge-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.