package com.taobao.android.luaview.playground; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.taobao.luaview.global.Constants; import com.taobao.luaview.global.LuaView; /** * Created by tuoli on 17/3/27. */ public class CommonActivity extends AppCompatActivity { private LuaView mLuaView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LuaView.createAsync(this, new LuaView.CreatedCallback() { @Override public void onCreated(LuaView luaView) { mLuaView = luaView; if (mLuaView != null) { setContentView(mLuaView); mLuaView.register("Bridge", new MyBridge(CommonActivity.this)); mLuaView.setUseStandardSyntax(true); // 使用标准语法 mLuaView.load(getLuaUri(), null, null); } } }); } /** * 获取文件名称 * * @return */ private String getLuaUri() { if (getIntent() != null && getIntent().hasExtra(Constants.PARAM_URI)) { return getIntent().getStringExtra(Constants.PARAM_URI); } return null; } @Override protected void onDestroy() { super.onDestroy(); if (mLuaView != null) { mLuaView.onDestroy(); } } }