Java Code Examples for org.luaj.vm2.LuaValue#FALSE

The following examples show how to use org.luaj.vm2.LuaValue#FALSE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LVViewManagerPlugin.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Varargs invoke(Varargs args) {
    if (rootView == null) {//VideoOsLuaView
        return LuaValue.FALSE;
    }
    ViewGroup parent = (ViewGroup) rootView.getParent();
    int argsNum = args.narg();
    final int fixIndex = VenvyLVLibBinder.fixIndex(args);
    if (argsNum > 1) {
        String id = LuaUtil.getString(args, fixIndex + 1);
        if (!TextUtils.isEmpty(id)) {
            View view = parent != null ? parent.findViewWithTag(id) : null;
            if (view != null) {
                parent.removeView(view);
            }
            return LuaValue.TRUE;
        }
    }
    if (parent != null) {
        parent.removeView(rootView);
        return LuaValue.TRUE;
    }
    return LuaValue.FALSE;
}
 
Example 2
Source File: LVViewGroup.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        LuaValue result = mLuaUserdata != null ? mLuaUserdata.callOnBack() : LuaValue.FALSE;
        return result != null && result.optboolean(false);
    }
    return super.onKeyUp(keyCode, event);
}
 
Example 3
Source File: UDJson.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
LuaValue isValid(LuaValue target) {
    if (target instanceof UDData) {
        return valueOf(JsonUtil.isJson(((UDData) target).toJson(UDData.DEFAULT_ENCODE)));
    } else if (LuaUtil.isString(target)) {
        return valueOf(JsonUtil.isJson(target.optjstring(null)));
    }
    return LuaValue.FALSE;
}
 
Example 4
Source File: JsonStorage.java    From Lukkit with MIT License 5 votes vote down vote up
@Override
public LuaBoolean setDefaultValue(LuaString path, LuaValue value) throws StorageObjectException {
    if (object.has(path.checkjstring())) {
        setValue(path, value);
        return LuaValue.TRUE;
    }
    return LuaValue.FALSE;
}
 
Example 5
Source File: JsonStorage.java    From Lukkit with MIT License 5 votes vote down vote up
@Override
protected LuaBoolean clearVaule(LuaString path) throws StorageObjectException {
    if (object.has(path.checkjstring())) {
        object.remove(path.checkjstring());
        return LuaValue.TRUE;
    }
    return LuaValue.FALSE;
}
 
Example 6
Source File: YamlStorage.java    From Lukkit with MIT License 5 votes vote down vote up
@Override
public LuaBoolean setDefaultValue(LuaString path, LuaValue value) throws StorageObjectException {
    if (this.yamlConfiguration.get(path.checkjstring()) == null) {
        this.yamlConfiguration.set(path.checkjstring(), Utilities.getObjectFromLuavalue(value));
        return LuaValue.TRUE;
    }

    return LuaValue.FALSE;
}
 
Example 7
Source File: YamlStorage.java    From Lukkit with MIT License 5 votes vote down vote up
@Override
protected LuaBoolean clearVaule(LuaString path) throws StorageObjectException {
    if (this.yamlConfiguration.get(path.checkjstring()) == null) {
        this.yamlConfiguration.set(path.checkjstring(), null);
        return LuaValue.TRUE;
    }

    return LuaValue.FALSE;
}
 
Example 8
Source File: CoerceJavaToLua.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue coerce(Object javaValue) {
    Boolean b = (Boolean) javaValue;
    return b.booleanValue() ? LuaValue.TRUE : LuaValue.FALSE;
}
 
Example 9
Source File: LVEventPlugin.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
        public Varargs invoke(Varargs args) {
            final int fixIndex = VenvyLVLibBinder.fixIndex(args);
            if (mPlatform == null || mPlatform.getContentViewGroup() == null) {
                return LuaValue.FALSE;
            }
            if (args.narg() > fixIndex) {
                final String urlString = LuaUtil.getString(args, fixIndex + 1);
                final LuaTable table = LuaUtil.getTable(args, fixIndex + 2);
                if (TextUtils.isEmpty(urlString)) {
                    return LuaValue.FALSE;
                }
                Uri uri = Uri.parse(new String(VenvyBase64.decode(urlString)));
                PostInfo info = VenvyRouterManager.getInstance().setUri(uri);
                Set<String> params = uri.getQueryParameterNames();
                HashMap<String, String> map = new HashMap<>();
                if (table != null) {
                    map.put("data", JsonUtil.toString(table));
                }
                if (params != null && params.size() > 0) {
                    for (String key : params) {
                        String value = uri.getQueryParameter(key);
                        if (!TextUtils.isEmpty(value)) {
                            map.put(key, value);
                        }
                    }
                }
                if(!map.keySet().contains("miniAppId")){
                    // 如果过来的uri中不带miniAppId,则需要尝试去table中找miniAppId put进 map里
                    try {
                        JSONObject jsonObject = new JSONObject(JsonUtil.toString(table));
                        JSONObject miniAppInfo = jsonObject.optJSONObject("miniAppInfo");
                        if(miniAppInfo != null){
                            String miniAppId = miniAppInfo.optString("miniAppId");
                            if(!TextUtils.isEmpty(miniAppId)){
                                map.put("miniAppId",miniAppId);
                            }
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }

                if (map.size() > 0) {
                    info.withSerializable("data", map);
                }
                String protocolHost = uri.getHost();
                if (protocolHost.equalsIgnoreCase("defaultLuaView")) {
                    // A类容器内部跳转
                    info.withTargetViewParent(mPlatform.getContentViewGroup()).withTargetPlatform("platform", mPlatform).navigation();

                } else if (protocolHost.equalsIgnoreCase("topLuaView")) {
                    // 标签小程序 - [top level]
//                    Bundle bundle = new Bundle();
//                    bundle.putString(VenvyObservableTarget.Constant.CONSTANT_LUA_NAME, info.getBundle().getString("template"));
//                    bundle.putString(VenvyObservableTarget.Constant.CONSTANT_ID, info.getBundle().getString("id"));
                    ObservableManager.getDefaultObserable().sendToTarget(VenvyObservableTarget.TAG_ADD_LUA_SCRIPT_TO_TOP_LEVEL, info.getBundle());

                } else if (protocolHost.equalsIgnoreCase("applets")) {
                    String type = info.getBundle().getString("type");
                    String appType = info.getBundle().getString("appType");
                    if (TextUtils.isEmpty(appType)) {
                        VenvyLog.d("appType is null");
                        // appType为空默认指定为lua
                        appType = String.valueOf(VenvyObservableTarget.Constant.CONSTANT_APP_TYPE_LUA);
                    }
                    VenvyLog.d("type is " + type + " , appType is " + appType);
                    if (TextUtils.isEmpty(type)) {
                        // B类小程序内部跳转
                        info.withTargetViewParent(mPlatform.getContentViewGroup()).withTargetPlatform("platform", mPlatform).navigation();
                        ObservableManager.getDefaultObserable().sendToTarget(VenvyObservableTarget.TAG_ADD_LUA_SCRIPT_TO_VISION_PROGRAM, null);

                    } else {
                        // 发起一个视联网小程序
                        Bundle bundle = new Bundle();
                        bundle.putString(VenvyObservableTarget.KEY_APPLETS_ID, info.getBundle().getString("appletId"));
                        bundle.putString(VenvyObservableTarget.KEY_ORIENTATION_TYPE, type);
                        bundle.putString(VenvyObservableTarget.Constant.CONSTANT_APP_TYPE, appType);
                        if (table != null) {
                            bundle.putString(VenvyObservableTarget.Constant.CONSTANT_DATA, JsonUtil.toString(table));
                        }
                        ObservableManager.getDefaultObserable().sendToTarget(VenvyObservableTarget.TAG_LAUNCH_VISION_PROGRAM, bundle);
                    }


                }
                return LuaValue.TRUE;
            }
            return LuaValue.FALSE;
        }
 
Example 10
Source File: VenvyAcrCloudMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue acrEnable(U target, Varargs args) {
    return target.acrEnable() ? LuaValue.TRUE : LuaValue.FALSE;
}
 
Example 11
Source File: CoerceJavaToLua.java    From XPrivacyLua with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue coerce( Object javaValue ) {
	Boolean b = (Boolean) javaValue;
	return b.booleanValue()? LuaValue.TRUE: LuaValue.FALSE;
}
 
Example 12
Source File: CoerceJavaToLua.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
public LuaValue coerce( Object javaValue ) {
	Boolean b = (Boolean) javaValue;
	return b.booleanValue()? LuaValue.TRUE: LuaValue.FALSE;
}
 
Example 13
Source File: CoerceJavaToLua.java    From luaj with MIT License 4 votes vote down vote up
public LuaValue coerce( Object javaValue ) {
	Boolean b = (Boolean) javaValue;
	return b.booleanValue()? LuaValue.TRUE: LuaValue.FALSE;
}
 
Example 14
Source File: JsonStorage.java    From Lukkit with MIT License 4 votes vote down vote up
@Override
protected LuaBoolean exists(String path) {
    return object.has(path) ? LuaValue.TRUE : LuaValue.FALSE;
}
 
Example 15
Source File: YamlStorage.java    From Lukkit with MIT License 4 votes vote down vote up
@Override
protected LuaBoolean exists(String path) {
    return yamlConfiguration.get(path) != null ? LuaValue.TRUE : LuaValue.FALSE;
}