Esempio n. 1
0
  /**
   * 初始化
   *
   * @param web_view
   * @param activity
   * @return
   */
  public static WebView WebSettingInit(WebView web_view, final Activity activity) {
    WebSettings ws = web_view.getSettings();
    ws.setJavaScriptEnabled(true); // 支持js
    ws.setBuiltInZoomControls(false); // 支持缩放按钮
    ws.setUseWideViewPort(true); // 设置此属性,可任意比例缩放 将图片调整到适合webview的大小
    ws.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
    ws.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
    ws.setSupportZoom(false); // 支持缩放
    // 设置 缓存模式
    ws.setCacheMode(WebSettings.LOAD_NO_CACHE); // 关闭webview中缓存

    web_view.clearCache(true);
    web_view.setTag(true);
    // 开启 DOM storage API 功能
    ws.setDomStorageEnabled(true);

    ws.setRenderPriority(RenderPriority.HIGH);
    // 开启 database storage API 功能
    ws.setDatabaseEnabled(false);

    web_view.setWebChromeClient(
        new WebChromeClient() {

          @Override
          public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            return super.onJsAlert(view, url, message, result);
          }
        });
    return web_view;
  }
  @OnClick(R.id.login_btn_2)
  public void loginBtnClicked_2() {
    final WebView webView = (WebView) this.findViewById(R.id.webView);
    //        final ProgressBar progressBar = (ProgressBar) this.findViewById(R.id.progressBar);
    // https://mnscorp.sharepoint.com/sites/MSW/SiteAssets/MSW-SiteLogo.png
    // https://mnscorp.sharepoint.com/Style%20Library/mands/images/logo.png
    String spHome = "https://mnscorp.sharepoint.com/Pages/Home.aspx";
    String simpleSPImageUrl =
        "https://mnscorp.sharepoint.com/sites/MSW/SiteAssets/MSW-SiteLogo.png"; // this request
                                                                                // login, but
                                                                                // doesn't create
                                                                                // cookie.
    String simpleSPPageUrl =
        "https://mnscorp.sharepoint.com/sites/MSW/Lists/Site%20Links/DispForm.aspx";
    String simpleSPHtmlUrl = "https://mnscorp.sharepoint.com/sites/MSW/home";
    String url = simpleSPHtmlUrl;

    String cookieRoot = "mnscorp.sharepoint.com";
    String cookie = CookieManager.getInstance().getCookie(cookieRoot);

    Log.i("xxxxxx", "cookie = " + cookie);
    if (cookie != null) {
      // logged in before, already loggedin .
      // however, the user account may expired.

      showTheRealApp();

    } else {
      webView.setVisibility(View.VISIBLE);
      webView.setTag("web");
      WebViewController.getInstance()
          .initWebView(
              webView,
              url,
              new ICallback() {
                @Override
                public void success() {
                  webView.setVisibility(View.GONE);
                  showTheRealApp();
                }

                @Override
                public void failure(String message) {}
              });
    }
  }
Esempio n. 3
0
  public View getView(int position, View convertView, ViewGroup parent) {

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View gridView;

    if (convertView == null) {

      gridView = new View(context);

      // get layout from mobile.xml
      gridView = inflater.inflate(R.layout.exchange_gift_row, null);
      gridView.setTag(position);
      // set value into textview
      TextView textView = (TextView) gridView.findViewById(R.id.grid_item_label);
      textView.setText(arraylist.get(position).getHotel_name());

      // set image based on selected text

      String S = "<html> <head> <title>banner</title> </head><body>   <img src=";
      S =
          S
              + "\""
              + arraylist.get(position).getImages()
              + "\""
              + "alt=\"\"width=\"100%\" height=\"100%\"/></a></body></html>";

      WebView w = (WebView) gridView.findViewById(R.id.img);
      w.loadData(S, "text/html", "UTF-8");
      w.setVerticalScrollBarEnabled(false);
      w.setHorizontalScrollBarEnabled(false);
      w.setTag(position);
      /*w.setOnClickListener(new OnClickListener() {

      	@Override
      	public void onClick(View v) {
      		// TODO Auto-generated method stub
      		  int id = (Integer) v.getTag();
      	       MainActivity.loadinwebview(arraylist.get(id).getHotel_link());
      	}
      });*/

      w.setOnTouchListener(
          new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
              // TODO Auto-generated method stub
              int id = (Integer) v.getTag();
              switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                  DBHelper.addRowhistoy(arraylist.get(id));
                  // MainActivity.loadinwebview(arraylist.get(id).getHotel_link(),arraylist.get(id).getImages(),arraylist.get(id).getHotel_name());

                  break;
                case MotionEvent.ACTION_MOVE:
                  break;
                case MotionEvent.ACTION_UP:
                  break;

                default:
                  break;
              }

              return true;
            }
          });

      final ImageView fav = (ImageView) gridView.findViewById(R.id.favourite);
      fav.setTag(position);
      fav.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              int id = (Integer) v.getTag();
              DBHelper.addRowfavourite(arraylist.get(id));
              fav.setImageResource(android.R.drawable.star_big_on);
            }
          });
      /*	gridView.setOnClickListener(new OnClickListener() {

      	@Override
      	public void onClick(View v) {
      		// TODO Auto-generated method stub
             int id = (Integer) v.getTag();
             DBHelper.addRowhistoy(arraylist.get(id));
             Log.d("dfdf", ""+id);
             MainActivity.loadinwebview(arraylist.get(id).getHotel_link());
      	}
      });*/
      // w.loadUrl(arraylist.get(position).getImages());
      // String mobile = arraylist.get(position).getImages();
      /*
      if (mobile.equals("Windows")) {
      	imageView.setImageResource(R.drawable.windows_logo);
      } else if (mobile.equals("iOS")) {
      	imageView.setImageResource(R.drawable.ios_logo);
      } else if (mobile.equals("Blackberry")) {
      	imageView.setImageResource(R.drawable.blackberry_logo);
      } else {
      	imageView.setImageResource(R.drawable.android_logo);
      }*/

    } else {
      gridView = (View) convertView;
    }

    return gridView;
  }