Coder Social home page Coder Social logo

offline's Introduction

Dcloud 最新版离线打包精简版示例

  • master 分支为Dcloud

    git clone -master https://github.com/lovewmf/Offline.git

  • apicloud 分支为ApiCloud

    git clone -apicloud https://github.com/lovewmf/Offline.git

如需操作Application,必须要继承自DCloudApplication

public void onStart(Context pContext, Bundle pSavedInstanceState, String[] pRuntimeArgs) {
    mCtx = getDPluginContext();
    Log.e(TAG,"Dcloud离线打包插件开始执行");
}
PluginShowToastSync 异步 居中原生Toast

html

ZySoftPlugin.PluginShowToastSync();

java

//同步无参无返回值
public void PluginShowToast(IWebview pWebview, JSONArray array){
    Log.e(TAG,"This is an synchronization Toast");
    Toast toast = Toast.makeText(mCtx, "This is an synchronization Toast",Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
}
PluginShowToast 同步 居中原生Toast

html

 ZySoftPlugin.PluginShowToast();

java

//同步无参无返回值
public void PluginShowToast(IWebview pWebview, JSONArray array){
    Log.e(TAG,"This is an synchronization Toast");
    Toast toast = Toast.makeText(mCtx, "This is an synchronization Toast",Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
}
PluginArgs 异步有传参有返回值

html

ZySoftPlugin.PluginArgs("Dcloud",function(success){
    alert(success.toString());
},function(error){
    alert(error.toString());
});

java

 //异步有参有返回值
public void PluginArgs(IWebview pWebview, JSONArray array){
    Log.e(TAG,"异步有参有返回值");
    String CallBackID = array.optString(0);
    JSONArray newArray = new JSONArray();
    newArray.put(array.optString(1));
    JSUtil.execCallback(pWebview, CallBackID, newArray, JSUtil.OK, false);//成功回调
    //JSUtil.execCallback(pWebview, CallBackID, newArray, JSUtil.ERROR, false);失败回调
}
PluginArgsSync 同步有传参有返回值

html

ZySoftPlugin.PluginArgsSync("Dcloud");

java

//同步有参有返回值
public String PluginArgsSync(IWebview pWebview, JSONArray array){
    Log.e(TAG,"同步有参有返回值");
    Log.e(TAG,array.toString());
    String inValue1 = array.optString(0);
    return JSUtil.wrapJsVar(inValue1,true);
}

ApiCloud 离线打包模块开发

https://docs.apicloud.com/Module-Dev/module-dev-guide-for-android-studio

配置module.json

{
    "modules":[
        {
            "name":"moduleZySoft",
            "class":"com.wmf.moduleZySoft.APIModuleZySoft"
        }
    ]
}

使用方式

<script type="text/javascript">
    var zysoft = null;
    apiready = function(){
        zysoft = api.require('moduleZySoft');//引入模块
        $api.addEvt($api.byId('Suspension'), 'click', function(){
            zysoft.ShowToast();//执行模块里面的方法
        }, false);
    };
</script>

offline's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.