예제 #1
0
 public boolean onTouchEvent(MotionEvent e) {
   if (emulatorButtons != null) {
     emulatorButtons.onEmulatorButtonEvent(e);
   }
   activity.onTouchEvent(e);
   try {
     Thread.sleep(16);
   } catch (Exception ex) {
   }
   return true;
 }
예제 #2
0
 public LGameAndroid2DView(LGameAndroid2DActivity activity, boolean isLandscape, LMode mode) {
   super(activity.getApplicationContext());
   try {
     LSystem.setupHandler(activity, this, isLandscape, mode);
     this.handler = LSystem.getSystemHandler();
     this.handler.initScreen();
     this.activity = handler.getLGameActivity();
     this.setFPS(LSystem.DEFAULT_MAX_FPS);
     this.createScreen();
   } catch (Exception e) {
   }
 }
예제 #3
0
 /** 通过Url进行跳转 */
 public void loadUrl(String url) {
   boolean isURL =
       url.startsWith("http://") || url.startsWith("https://") || url.startsWith("ftp://");
   if (!isURL) {
     try {
       if (activity.getAssets().open(url) != null) {
         super.loadUrl("file:///android_asset/" + url);
       } else {
         super.loadUrl("http://" + url);
       }
     } catch (IOException e) {
       super.loadUrl("http://" + url);
     }
   } else {
     super.loadUrl(url);
   }
 }
예제 #4
0
  public LGameWeb(
      final LGameAndroid2DActivity activity, final WebProcess webProcess, final String url) {

    super(activity);
    this.url = url;
    this.activity = activity;
    // 允许显示滚动条
    this.setHorizontalScrollBarEnabled(true);
    // 清空原有的缓存数据
    this.clearCache(true);
    // 隐藏当前View
    this.setVisible(false);
    // 不要背景图
    this.setBackgroundDrawable(null);
    // 进行细节设置
    webSettings = getSettings();
    // 数据库访问权限开启
    webSettings.setAllowFileAccess(true);
    // 密码保存与Form信息不保存
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    // 响应JavaScript事件
    webSettings.setJavaScriptEnabled(true);
    // 允许JavaScript脚本打开新的窗口
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    // 允许自动加载图像资源
    webSettings.setLoadsImagesAutomatically(true);
    // 不支持网页缩放
    webSettings.setSupportZoom(false);

    // 当流程监听存在时
    if (webProcess != null) {
      setWebViewClient(
          new WebViewClient() {

            public void onPageStarted(WebView view, String url, Bitmap favicon) {
              webProcess.onPageStarted(url, favicon);
              super.onPageStarted(view, url, favicon);
            }

            public void onPageFinished(WebView view, String url) {
              webProcess.onPageFinished(url);
              super.onPageFinished(view, url);
            }

            public void onLoadResource(WebView view, String url) {
              webProcess.onLoadResource(url);
              super.onLoadResource(view, url);
            }

            public boolean shouldOverrideUrlLoading(WebView view, String url) {
              webProcess.shouldOverrideUrlLoading(url);
              return super.shouldOverrideUrlLoading(view, url);
            }

            public void onReceivedHttpAuthRequest(
                WebView view, HttpAuthHandler handler, String host, String realm) {
              webProcess.onReceivedHttpAuthRequest(handler, host, realm);
              super.onReceivedHttpAuthRequest(view, handler, host, realm);
            }
          });
    }

    // 加载进度条
    final ProgressBar progress = new ProgressBar(activity);
    activity.addView(progress, Location.CENTER);
    setWebChromeClient(
        new WebChromeClient() {
          public void onProgressChanged(final WebView view, final int newProgress) {
            LSystem.post(
                new Runnable() {
                  public void run() {
                    progress.setProgress(newProgress);
                    progress.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE);
                    if (newProgress == 100) {
                      activity.removeView(progress);
                    }
                    setVisible(newProgress == 100 ? true : false);
                  }
                });
          }
        });

    if (url != null) {
      loadUrl(url);
    }
  }