本文整理汇总了Java中com.taobao.weex.utils.WXFileUtils类的典型用法代码示例。如果您正苦于以下问题:Java WXFileUtils类的具体用法?Java WXFileUtils怎么用?Java WXFileUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WXFileUtils类属于com.taobao.weex.utils包,在下文中一共展示了WXFileUtils类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: renderByUrl
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
public void renderByUrl(String pageName, final String url, Map<String, Object> options, final String jsonInitData, final int width, final int height, final WXRenderStrategy flag) {
pageName = wrapPageName(pageName, url);
mBundleUrl = url;
if (options == null) {
options = new HashMap<String, Object>();
}
if (!options.containsKey(BUNDLE_URL)) {
options.put(BUNDLE_URL, url);
}
Uri uri=Uri.parse(url);
if(uri!=null && TextUtils.equals(uri.getScheme(),"file")){
render(pageName, WXFileUtils.loadAsset(assembleFilePath(uri), mContext),options,jsonInitData,width,height,flag);
return;
}
IWXHttpAdapter adapter=WXSDKManager.getInstance().getIWXHttpAdapter();
WXRequest wxRequest = new WXRequest();
wxRequest.url = url;
if (wxRequest.paramMap == null) {
wxRequest.paramMap = new HashMap<String, String>();
}
wxRequest.paramMap.put("user-agent", WXHttpUtil.assembleUserAgent(mContext,WXEnvironment.getConfig()));
adapter.sendRequest(wxRequest, new WXHttpListener(pageName, options, jsonInitData, width, height, flag, System.currentTimeMillis()));
mWXHttpAdapter = adapter;
}
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:30,代码来源:WXSDKInstance.java
示例2: setup
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
@Before
public void setup() throws Exception {
mockStatic(WXSoInstallMgrSdk.class);
when(WXSoInstallMgrSdk.initSo("weexv8", 1, null)).thenReturn(true);
WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build());
mInstance = createInstance();
WXBridgeManagerTest.getLooper().idle();
mockStatic(WXFileUtils.class);
when(WXFileUtils.loadAsset(null,null)).thenReturn("{}");
}
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:12,代码来源:WXSDKInstanceTest.java
示例3: onOptionsItemSelected
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_refresh) {
if(!TextUtils.equals(CURRENT_IP,DEFAULT_IP)){
createWeexInstance();
if(TextUtils.equals(CURRENT_IP,DEFAULT_IP)){
renderPage(WXFileUtils.loadAsset("index.js", this),WEEX_INDEX_URL);
}else{
renderPageByURL(WEEX_INDEX_URL);
}
mProgressBar.setVisibility(View.VISIBLE);
return true;
}
} else if (id == R.id.action_scan) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
Toast.makeText(this, "please give me the permission", Toast.LENGTH_SHORT).show();
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, CAMERA_PERMISSION_REQUEST_CODE);
}
} else {
startActivity(new Intent(this, CaptureActivity.class));
}
return true;
}
return super.onOptionsItemSelected(item);
}
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:29,代码来源:IndexActivity.java
示例4: renderByUrlInternal
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
private void renderByUrlInternal(String pageName,
final String url,
Map<String, Object> options,
final String jsonInitData,
final WXRenderStrategy flag) {
ensureRenderArchor();
pageName = wrapPageName(pageName, url);
mBundleUrl = url;
if(WXSDKManager.getInstance().getValidateProcessor()!=null) {
mNeedValidate = WXSDKManager.getInstance().getValidateProcessor().needValidate(mBundleUrl);
}
Map<String, Object> renderOptions = options;
if (renderOptions == null) {
renderOptions = new HashMap<>();
}
if (!renderOptions.containsKey(BUNDLE_URL)) {
renderOptions.put(BUNDLE_URL, url);
}
Uri uri = Uri.parse(url);
if (uri != null && TextUtils.equals(uri.getScheme(), "file")) {
render(pageName, WXFileUtils.loadFileOrAsset(assembleFilePath(uri), mContext), renderOptions, jsonInitData, flag);
return;
}
IWXHttpAdapter adapter = WXSDKManager.getInstance().getIWXHttpAdapter();
WXRequest wxRequest = new WXRequest();
wxRequest.url = rewriteUri(Uri.parse(url),URIAdapter.BUNDLE).toString();
if (wxRequest.paramMap == null) {
wxRequest.paramMap = new HashMap<String, String>();
}
wxRequest.paramMap.put(KEY_USER_AGENT, WXHttpUtil.assembleUserAgent(mContext,WXEnvironment.getConfig()));
WXHttpListener httpListener =
new WXHttpListener(pageName, renderOptions, jsonInitData, flag, System.currentTimeMillis());
httpListener.setSDKInstance(this);
adapter.sendRequest(wxRequest, (IWXHttpAdapter.OnHttpListener) httpListener);
}
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:41,代码来源:WXSDKInstance.java
示例5: renderByUrlInternal
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
private void renderByUrlInternal(String pageName,
final String url,
Map<String, Object> options,
final String jsonInitData,
final WXRenderStrategy flag) {
ensureRenderArchor();
pageName = wrapPageName(pageName, url);
mBundleUrl = url;
Map<String, Object> renderOptions = options;
if (renderOptions == null) {
renderOptions = new HashMap<>();
}
if (!renderOptions.containsKey(BUNDLE_URL)) {
renderOptions.put(BUNDLE_URL, url);
}
Uri uri = Uri.parse(url);
if (uri != null && TextUtils.equals(uri.getScheme(), "file")) {
render(pageName, WXFileUtils.loadAsset(assembleFilePath(uri), mContext), renderOptions, jsonInitData, flag);
return;
}
IWXHttpAdapter adapter = WXSDKManager.getInstance().getIWXHttpAdapter();
WXRequest wxRequest = new WXRequest();
wxRequest.url = rewriteUri(Uri.parse(url),URIAdapter.BUNDLE).toString();
if (wxRequest.paramMap == null) {
wxRequest.paramMap = new HashMap<String, String>();
}
wxRequest.paramMap.put(KEY_USER_AGENT, WXHttpUtil.assembleUserAgent(mContext,WXEnvironment.getConfig()));
adapter.sendRequest(wxRequest, new WXHttpListener(pageName, renderOptions, jsonInitData, flag, System.currentTimeMillis()));
}
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:35,代码来源:WXSDKInstance.java
示例6: loadWXfromLocal
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
private void loadWXfromLocal(boolean reload) {
if (reload && mInstance != null) {
mInstance.destroy();
mInstance = null;
}
if (mInstance == null) {
mInstance = new WXSDKInstance(this);
// mInstance.setImgLoaderAdapter(new ImageAdapter(this));
mInstance.registerRenderListener(this);
mInstance.setNestedInstanceInterceptor(this);
}
mContainer.post(new Runnable() {
@Override
public void run() {
Activity ctx = WXPageActivity.this;
Rect outRect = new Rect();
ctx.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
mConfigMap.put("bundleUrl", mUri.toString());
String path = mUri.getScheme().equals("file") ? assembleFilePath(mUri) : mUri.toString();
mInstance.render(mUri.toString(), WXFileUtils.loadAsset(path, WXPageActivity.this),
mConfigMap, null,
ScreenUtil.getDisplayWidth(WXPageActivity.this), ScreenUtil
.getDisplayHeight(WXPageActivity.this),
WXRenderStrategy.APPEND_ASYNC);
}
});
}
开发者ID:weexteam,项目名称:weex-analyzer-android,代码行数:28,代码来源:WXPageActivity.java
示例7: loadWXfromLocal
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
private void loadWXfromLocal(boolean reload) {
if (reload && mInstance != null) {
mInstance.destroy();
mInstance = null;
}
if (mInstance == null) {
mInstance = new WXSDKInstance(this);
// mInstance.setImgLoaderAdapter(new ImageAdapter(this));
mInstance.registerRenderListener(this);
mInstance.setNestedInstanceInterceptor(this);
}
mContainer.post(new Runnable() {
@Override
public void run() {
Activity ctx = WXPageActivity.this;
Rect outRect = new Rect();
ctx.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
mConfigMap.put("bundleUrl", mUri.toString());
String path = mUri.getScheme().equals("file") ? assembleFilePath(mUri) : mUri.toString();
mInstance.render(TAG, WXFileUtils.loadAsset(path, WXPageActivity.this),
mConfigMap, null,
ScreenUtil.getDisplayWidth(WXPageActivity.this), ScreenUtil
.getDisplayHeight(WXPageActivity.this),
WXRenderStrategy.APPEND_ASYNC);
}
});
}
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:28,代码来源:WXPageActivity.java
示例8: rendWXPage
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
private void rendWXPage() {
if (TextUtils.equals("http", mUri.getScheme()) || TextUtils.equals("https", mUri.getScheme())) {
// if url has key "_wx_tpl" then get weex bundle js
String weexTpl = mUri.getQueryParameter(Constants.WEEX_TPL_KEY);
String url = TextUtils.isEmpty(weexTpl) ? mUri.toString() : weexTpl;
loadWXfromService(url);
startHotRefresh();
} else {
if (mInstance == null) {
mInstance = new WXSDKInstance(this);
// mInstance.setImgLoaderAdapter(new ImageAdapter(this));
mInstance.registerRenderListener(this);
}
mContainer.post(new Runnable() {
@Override
public void run() {
Activity ctx = WXPageActivity.this;
Rect outRect = new Rect();
ctx.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
mConfigMap.put("bundleUrl", mUri.toString());
String path = mUri.getScheme().equals("file") ? assembleFilePath(mUri) : mUri.toString();
mInstance.render(TAG, WXFileUtils.loadFileContent(path, WXPageActivity.this),
mConfigMap, null,
ScreenUtil.getDisplayWidth(WXPageActivity.this), ScreenUtil
.getDisplayHeight(WXPageActivity.this),
WXRenderStrategy.APPEND_ASYNC);
}
});
}
}
开发者ID:Laisly,项目名称:weex,代码行数:32,代码来源:WXPageActivity.java
示例9: onCreate
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_index);
setContainer((ViewGroup) findViewById(R.id.index_container));
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("WEEX");
setSupportActionBar(toolbar);
mProgressBar = (ProgressBar) findViewById(R.id.index_progressBar);
mTipView = (TextView) findViewById(R.id.index_tip);
mProgressBar.setVisibility(View.VISIBLE);
mTipView.setVisibility(View.VISIBLE);
if(!WXSoInstallMgrSdk.isCPUSupport()){
mProgressBar.setVisibility(View.INVISIBLE);
mTipView.setText(R.string.cpu_not_support_tip);
return;
}
if(TextUtils.equals(CURRENT_IP,DEFAULT_IP)){
renderPage(WXFileUtils.loadFileContent("index.js", this),WEEX_INDEX_URL);
}else{
renderPageByURL(WEEX_INDEX_URL);
}
}
开发者ID:Laisly,项目名称:weex,代码行数:28,代码来源:IndexActivity.java
示例10: onCreate
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_index);
setContainer((ViewGroup) findViewById(R.id.index_container));
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("WEEX");
setSupportActionBar(toolbar);
mProgressBar = (ProgressBar) findViewById(R.id.index_progressBar);
mTipView = (TextView) findViewById(R.id.index_tip);
mProgressBar.setVisibility(View.VISIBLE);
mTipView.setVisibility(View.VISIBLE);
if(!WXSoInstallMgrSdk.isCPUSupport()){
mProgressBar.setVisibility(View.INVISIBLE);
mTipView.setText(R.string.cpu_not_support_tip);
return;
}
if(TextUtils.equals(CURRENT_IP,DEFAULT_IP)){
renderPage(WXFileUtils.loadAsset("index.js", this),WEEX_INDEX_URL);
}else{
renderPageByURL(WEEX_INDEX_URL);
}
mReloadReceiver=new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
createWeexInstance();
if(TextUtils.equals(CURRENT_IP,DEFAULT_IP)){
renderPage(WXFileUtils.loadAsset("index.js", IndexActivity.this),WEEX_INDEX_URL);
}else{
renderPageByURL(WEEX_INDEX_URL);
}
mProgressBar.setVisibility(View.VISIBLE);
}
};
LocalBroadcastManager.getInstance(this).registerReceiver(mReloadReceiver,new IntentFilter(WXSDKEngine.JS_FRAMEWORK_RELOAD));
}
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:44,代码来源:IndexActivity.java
示例11: testRender
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
@Test
public void testRender() throws Exception {
assertEquals(WXFileUtils.loadAsset(null,null),"{}");
mInstance.render("{}",null,null,null);
}
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:8,代码来源:WXSDKInstanceTest.java
示例12: onCreate
import com.taobao.weex.utils.WXFileUtils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
mWXSDKInstance = new WXSDKInstance(this);
mWXSDKInstance.registerRenderListener(this);
mWXSDKInstance.render(WXFileUtils.loadAsset("index.js", this));
}
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:14,代码来源:MainActivity.java
注:本文中的com.taobao.weex.utils.WXFileUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论