3b0e12e51987d05c721a1c4149a78e25a077bb38
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / android / sample / src / org / xwalk / core / sample / MultiXWalkViewActivity.java
1 // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.xwalk.core.sample;
6
7 import org.xwalk.core.XWalkView;
8
9 import android.os.Bundle;
10 import android.widget.LinearLayout;
11
12 public class MultiXWalkViewActivity extends XWalkBaseActivity {
13
14     private XWalkView mXWalkView2;
15
16     @Override
17     protected void onCreate(Bundle savedInstanceState) {
18         super.onCreate(savedInstanceState);
19
20         setContentView(R.layout.container);
21         LinearLayout parent = (LinearLayout) findViewById(R.id.container);
22
23         LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
24                 LinearLayout.LayoutParams.MATCH_PARENT,
25                 LinearLayout.LayoutParams.MATCH_PARENT);
26         params.weight = 1;
27
28         mXWalkView = new XWalkView(this, this);
29         parent.addView(mXWalkView, params);
30
31         mXWalkView2 = new XWalkView(this, this);
32         parent.addView(mXWalkView2, params);
33
34         mXWalkView.load("http://www.intel.com", null);
35         mXWalkView2.load("http://www.baidu.com", null);
36     }
37
38     @Override
39     public void onPause() {
40         super.onPause();
41         if (mXWalkView2 != null) {
42             mXWalkView2.onHide();
43             mXWalkView2.pauseTimers();
44         }
45     }
46
47     @Override
48     public void onResume() {
49         super.onResume();
50         if (mXWalkView2 != null) {
51             mXWalkView2.onShow();
52             mXWalkView2.resumeTimers();
53         }
54     }
55
56     @Override
57     public void onDestroy() {
58         super.onDestroy();
59         if (mXWalkView2 != null) {
60             mXWalkView2.onDestroy();
61         }
62     }
63 }