本文整理汇总了Java中org.luaj.vm2.Globals类的典型用法代码示例。如果您正苦于以下问题:Java Globals类的具体用法?Java Globals怎么用?Java Globals使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Globals类属于org.luaj.vm2包,在下文中一共展示了Globals类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LVRefreshScroller
import org.luaj.vm2.Globals; //导入依赖的package包/类
public LVRefreshScroller(Globals globals, LuaValue metaTable, Varargs varargs) {
super(globals.getContext());
mLuaUserdata = new UDRefreshScroller(this, globals, metaTable, varargs != null ? varargs.arg1() : null);
LayoutInflater inflater = (LayoutInflater) globals.getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
View view = inflater.inflate(R.layout.lv_scroller, null);
this.addView(view, LuaViewUtil.createRelativeLayoutParamsMM());
mHeaderContainer = (RelativeLayout) view.findViewById(R.id.header_container);
mPinnedContainer = (RelativeLayout) view.findViewById(R.id.pinned_container);
mContentContainer = (RelativeLayout) view.findViewById(R.id.content_container);
// 测试
this.setEnabled(false);
}
示例2: standardGlobals
import org.luaj.vm2.Globals; //导入依赖的package包/类
/**
* Create a standard set of globals for JSE including all the libraries.
*
* @return Table of globals initialized with the standard JSE libraries
* @see #debugGlobals()
* @see JsePlatform
* @see JmePlatform
*/
public static Globals standardGlobals(Globals globals) {
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new CoroutineLib());
globals.load(new JseMathLib());
globals.load(new JseOsLib());
// globals.load(new JseIoLib());//安全考虑,删除for LuaView
// globals.load(new LuajavaLib());//安全考虑,删除for LuaView
LoadState.install(globals);
LuaC.install(globals);
return globals;
}
示例3: setupCompilerGlobal
import org.luaj.vm2.Globals; //导入依赖的package包/类
private static Globals setupCompilerGlobal() {
// Create server globals with just enough library support to compile user
// scripts.
compiler = new Globals();
compiler.load(new JseBaseLib());
compiler.load(new PackageLib());
compiler.load(new StringLib());
// To load scripts, we occasionally need a math library in addition to compiler
// support.
// To limit scripts using the debug library, they must be closures, so we only
// install LuaC.
compiler.load(new JseMathLib());
LoadState.install(compiler);
LuaC.install(compiler);
// Set up the LuaString metatable to be read-only since it is shared across all
// scripts.
LuaString.s_metatable = new ReadOnlyLuaTable(LuaString.s_metatable);
return compiler;
}
示例4: createView
import org.luaj.vm2.Globals; //导入依赖的package包/类
/**
* create view
*
* @param pos
* @return
*/
private LuaValue createView(int pos, int currentItem) {
Globals globals = this.mLuaUserdata.getGlobals();
//View封装
final LVViewGroup container = createCellLayout();
final UDViewGroup cell = new UDViewGroup(container, globals, null);
//对外数据封装,必须使用LuaTable
final UDLuaTable cellData = new UDLuaTable(cell);
//call init
globals.saveContainer(container);
this.mLuaUserdata.callCellInit(cellData, pos, currentItem);//初始化
globals.restoreContainer();
//set tag
View view = cellData.getView();
if (view != null) {
view.setTag(Constants.RES_LV_TAG, cellData);
}
return cellData;
}
示例5: main
import org.luaj.vm2.Globals; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
//Globals globals = JsePlatform.standardGlobals();
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new CoroutineLib());
globals.load(new JseMathLib());
globals.load(new JseIoLib());
globals.load(new JseOsLib());
globals.load(new JavaLibInteractionTest());
LoadState.install(globals);
LuaC.install(globals);
System.out.println(new File(".").getAbsolutePath());
System.out.println(new File(args[0]).exists());
LuaValue chunk = globals.loadfile(new File(args[0]).getAbsolutePath());
chunk.call();
}
示例6: preCreateGlobals
import org.luaj.vm2.Globals; //导入依赖的package包/类
/**
* pre create globals
*
* @return
*/
public static synchronized void preCreateGlobals() {
synchronized (LuaViewManager.class) {
if (sStaticGlobals == null) {
new SimpleTask0() {
@Override
public void doTask() {
synchronized (LuaViewManager.class) {
if (sStaticGlobals == null) {
sStaticGlobals = setupGlobals(new Globals());
}
}
}
}.executeInPool();
}
}
}
示例7: createGlobalsAsync
import org.luaj.vm2.Globals; //导入依赖的package包/类
/**
* 创建Globals
* 根据是否用lua-to-java bytecode来处理(如果使用LuaJC的话则会使用库bcel 533k)
*
* @return
*/
public static Globals createGlobalsAsync() {
if (sStaticGlobals != null) {
synchronized (sStaticGlobals) {
Globals result = sStaticGlobals;
sStaticGlobals = null;
return result;
}
} else {
final Globals globals = new Globals();
new SimpleTask<Globals>() {
@Override
public void doTask(Globals... params) {
setupGlobals(params != null && params.length > 0 ? params[0] : null);
}
}.executeSerial(globals);//TODO 这里放到serial线程中执行,而不是executeInPool中执行,为了保证后续的执行时序列
return globals;
}
}
示例8: setupGlobals
import org.luaj.vm2.Globals; //导入依赖的package包/类
/**
* setup global values
*
* @param globals
*/
private static Globals setupGlobals(Globals globals) {
if (globals != null) {
if (LuaViewConfig.isOpenDebugger()) {
JsePlatform.debugGlobals(globals);
} else {
JsePlatform.standardGlobals(globals);//加载系统libs TODO 性能瓶颈
}
if (LuaViewConfig.isUseLuaDC()) {
LuaDC.install(globals);
}
loadLuaViewLibs(globals);//加载用户lib TODO 性能瓶颈
globals.isInited = true;
}
return globals;
}
示例9: newStandard
import org.luaj.vm2.Globals; //导入依赖的package包/类
/**
* Create a new lua Globals object representing the standard one used in this game
*
* @return a new Globals instance
*/
public static Globals newStandard() {
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new JseMathLib());
LoadState.install(globals);
LuaC.install(globals);
LuaJC.install(globals);
return globals;
}
示例10: getActionBar
import org.luaj.vm2.Globals; //导入依赖的package包/类
/**
* 获得actionbar
*
* @param globals
* @return
*/
public static ActionBar getActionBar(Globals globals) {
if (globals != null && globals.getContext() instanceof Activity) {
return ((Activity) (globals.getContext())).getActionBar();
}
return null;
}
示例11: children
import org.luaj.vm2.Globals; //导入依赖的package包/类
/**
* 提供View的构造环境,注意,callback里面不能有异步操作,否则操作的时序上会混乱
*
* @param callback
* @return
*/
public UDViewGroup children(LuaFunction callback) {
if (getView() instanceof ViewGroup) {
Globals globals = getGlobals();
if (globals != null) {
globals.pushContainer(getView());
LuaUtil.callFunction(callback, this);
globals.popContainer();
}
}
return this;
}
示例12: init
import org.luaj.vm2.Globals; //导入依赖的package包/类
private void init(Globals globals) {
globals.saveContainer(mRecyclerView);
this.addView(mRecyclerView, LuaViewUtil.createRelativeLayoutParamsMM());
globals.restoreContainer();
if (!globals.isRefreshContainerEnable) {
this.setEnabled(false);
} else {
((UDRefreshRecyclerView) getUserdata()).initPullRefresh();
}
}
示例13: LVViewGroup
import org.luaj.vm2.Globals; //导入依赖的package包/类
public LVViewGroup(Context context, Globals globals, LuaValue metaTable, Varargs varargs) {
super(context);
this.mLuaUserdata = createUserdata(globals, metaTable, varargs);
//改在UDViewGroup中设置,减少影响面
// this.setFocusableInTouchMode(true);//需要设置,否则onKeyUp等事件无法监听,排查是否会带来其他问题(点击的时候需要点击两下)
// this.setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
// this.setClipChildren(false);
}
示例14: luaMain
import org.luaj.vm2.Globals; //导入依赖的package包/类
/**
* Simple wrapper for invoking a lua function with command line arguments.
* The supplied function is first given a new Globals object,
* then the program is run with arguments.
*/
public static void luaMain(LuaValue mainChunk, String[] args) {
Globals g = standardGlobals();
int n = args.length;
LuaValue[] vargs = new LuaValue[args.length];
for (int i = 0; i < n; ++i)
vargs[i] = LuaValue.valueOf(args[i]);
LuaValue arg = LuaValue.listOf(vargs);
arg.set("n", n);
g.set("arg", arg);
mainChunk.initupvalue1(g);
mainChunk.invoke(LuaValue.varargsOf(vargs));
}
示例15: LVTextView
import org.luaj.vm2.Globals; //导入依赖的package包/类
public LVTextView(Globals globals, LuaValue metaTable, Varargs varargs) {
super(globals.getContext());
this.mLuaUserdata = new UDTextView(this, globals, metaTable, varargs);
this.setIncludeFontPadding(false);//设置默认TextView不包含字体的padding,否则adjustSize的时候拿到的高度有问题
this.setGravity(Gravity.CENTER_VERTICAL);//默认竖直居中
this.setLines(1);//默认一行
this.setTextSize(UDFontSize.FONTSIZE_SMALL);
// this.setEllipsize(TextUtils.TruncateAt.END);//默认在最后有3个点
}