All Projects → gubaojian → DuktapeJava

gubaojian / DuktapeJava

Licence: MIT license
Tiny Powerfull JavaScript Engine On Android Platform integrating with java

Programming Languages

c
50402 projects - #5 most used programming language
java
68154 projects - #9 most used programming language
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to DuktapeJava

pyduktape
Embed the Duktape JS interpreter in Python
Stars: ✭ 77 (+4.05%)
Mutual labels:  duktape, javascript-engine
Duktape
Duktape - embeddable Javascript engine with a focus on portability and compact footprint
Stars: ✭ 5,076 (+6759.46%)
Mutual labels:  duktape, javascript-engine
dtw-python
Python port of R's Comprehensive Dynamic Time Warp algorithms package
Stars: ✭ 139 (+87.84%)
Mutual labels:  dynamic
github-readme-linkedin
📋 A serverless application to get dynamically generated images from your LinkedIn profile on your GitHub READMEs
Stars: ✭ 52 (-29.73%)
Mutual labels:  dynamic
aqua-core
Transform any object-graph into a dynamic, composed dictionaries like structure, holding serializable values and type information
Stars: ✭ 17 (-77.03%)
Mutual labels:  dynamic
SuluFormBundle
Form Bundle for handling Dynamic and Symfony Forms in https://sulu.io
Stars: ✭ 51 (-31.08%)
Mutual labels:  dynamic
godot-InventorySystem
Easily modifiable Inventory System ready for use. If you need anything further, you can add it.
Stars: ✭ 27 (-63.51%)
Mutual labels:  dynamic
leaflet.minichart
Leaflet.minichart is a leaflet plugin for adding to a leaflet map small animated charts
Stars: ✭ 27 (-63.51%)
Mutual labels:  dynamic
DynamicComponents-AI2
An App Inventor extension to add full support for creating any type of component at runtime, in your app.
Stars: ✭ 47 (-36.49%)
Mutual labels:  dynamic
scavenger
Scrape and take screenshots of dynamic and static webpages
Stars: ✭ 14 (-81.08%)
Mutual labels:  dynamic
dynamic-input-fields-reactjs
Example of the dynamic input fields in ReactJS
Stars: ✭ 31 (-58.11%)
Mutual labels:  dynamic
AgileStringDecryptor
a dynamic Agile.NET string decryptor that relies on invoke by wwh1004 | Version : 6.X
Stars: ✭ 24 (-67.57%)
Mutual labels:  dynamic
DPB
Dynamic Project Builder
Stars: ✭ 22 (-70.27%)
Mutual labels:  dynamic
yantra
JavaScript Engine for .NET Standard
Stars: ✭ 32 (-56.76%)
Mutual labels:  javascript-engine
tenjin
📝 A template engine.
Stars: ✭ 15 (-79.73%)
Mutual labels:  dynamic
simple json
Simple way to dynamically convert from and to JSON using build-time generators given a type.
Stars: ✭ 15 (-79.73%)
Mutual labels:  dynamic
lets-hotfix
Dynamic class reloading for java。Java代码热更新,支持本地、远程
Stars: ✭ 124 (+67.57%)
Mutual labels:  dynamic
steps
Simulation Toolkit for Electrical Power Systems
Stars: ✭ 23 (-68.92%)
Mutual labels:  dynamic
lp-loader
Frictionless language packs for Webpack.
Stars: ✭ 14 (-81.08%)
Mutual labels:  dynamic
dynamic-datasource-starter
springboot 动态切换数据的基本思想与实现方法
Stars: ✭ 12 (-83.78%)
Mutual labels:  dynamic

DuktapeJava

JavaScript Engine on android platform base on Duktape, which is tiny, powerful, low memory cost. you can use any java method in javascript by just small engine, give you endless power integrating java with javascript on android platform.

Quick Start

1、how to use engine in your studio project

compile 'com.furture.react:DuktapeJava:1.2.0'

or

compile 'com.furture.react:DuktapeJava:1.2.0@aar'

2、new DuktapeEngine instance,put js context then execute javascript code.

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	duktapeEngine = new DuktapeEngine();
	duktapeEngine.put("activity",this);
	duktapeEngine.execute(AssetScript.toScript(getBaseContext(), "duk.js"));
	duktapeEngine.call("activityListener", "onCreate", savedInstanceState);
}

  @Override
protected void onDestroy() {
	if (duktapeEngine != null) {
		 duktapeEngine.destory();
		 duktapeEngine = null;
	}
	super.onDestroy();
}

3、duk.js javascript code sample

importClass("com.furture.react.R")
importClass("android.view.View.OnClickListener")
importClass("android.widget.Toast")
importClass("java.lang.Runnable")

var activityListener = {};
activityListener.onCreate = function(){
			print("activity onCreate onJavaScript");
			activity.setContentView(R.layout.activity_duk)
			button1 = activity.findViewById(R.id.button1);
			button1.setOnClickListener(new OnClickListener(function(){
				Toast.makeText(activity, "Button1 Clicked", Toast.LENGTH_SHORT).show();
				var intent = new Intent(activity, "com.furture.react.activity.DetailActivity");
				activity.startActivity(intent);
			}));

			button2 = activity.findViewById(R.id.button2);
			button2.setOnClickListener(new OnClickListener({
				onClick:function(){
				   Toast.makeText(activity, "Button2 Clicked", Toast.LENGTH_SHORT).show();
				}
			}));
};

 Toast.makeText(activity, "Hello World JavaScript", Toast.LENGTH_SHORT).show();

Javascript Guide

1、JavaScript call java method like java

 importClass("android.widget.Toast")
 Toast.makeText(activity, "Javascript Hi Toast", Toast.LENGTH_SHORT).show();
importClass("android.view.View")

var view = new View(activity);
importClass("android.view.View.OnClickListener")
view.setOnClickListener(new OnClickListener(function(){
	Toast.makeText(activity, "Button1 Clicked", Toast.LENGTH_SHORT).show();
	var intent = new Intent(activity, "com.furture.react.activity.DetailActivity");
	activity.startActivity(intent);
}));

view2.setOnClickListener(new OnClickListener({
	onClick:function(){
		 Toast.makeText(activity, "Button2 Clicked", Toast.LENGTH_SHORT).show();
	}
}));

2、JavaScript new java abstract instance with specific implemation

importClass("com.furture.react.ext.JSBaseAdapter")

gridView.setAdapter(new JSBaseAdapter({
	getCount : function() {
		return 8;
	},
	getView : function(position,  convertView, parent){
			if(convertView == null){
					convertView = ui.fromXml(gridItemXml, null);
			}
			return convertView;
	},
	getViewTypeCount : function () {
			return 1;
	}
}));

Java Guide

1、Java Call JavaScript Method

Java Code Sample

public class DataUtils{
	public static void showData(JSRef ref){
			int count = ((Number)ref.call("count")).intValue();
			for(int i=0; i<count; i++){
					Log.d("DataUtils", "Call JavaScript getItem Method :  " + ref.call("getItem", i));
			}
	 }
}   

javascript code sample

  importClass("com.efurture.react.DataUtils")
  var data = {};
  data.count =  10;
  data.getItem = function(index){
         return "Javascript Data " + index;
  }
  DataUtils.showData(data);

Share Common Context For Multi Engine Instance

JSContext Provide Share Context For Multi DuktapeEngine, All Context Will Auto Be Imported To DuktapeEngine when Instance Created. you can use it share context.

JSContext.put("application", application);

Product Usage

AssetScript class and JSTransformer.jar is only for development usage. for Product, you should not include it on your app. you can use JSTransformer.jar transform JavaScript source, then use transformed js in your app.

cd JSTransformer/js
java -jar JSTransformer.jar  ui.js  transformed/ui.js

then use transformed/ui.js to your app.

you can also use gulp tool. see dev-server demo. write source in src/ then javascript will auto be transformed in build/ directory

cd  dev-server
npm install
npm start

License

DuktapeJava is MIT licensed

Reference

DuktapeJava Java Docs

https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java

http://www.w3schools.com/js/default.asp

https://github.com/jasonsantos/luajava

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].