Upstream version 8.36.161.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / android / core_internal / src / org / xwalk / core / internal / extension / api / presentation / PresentationViewJBMR1.java
1 // Copyright (c) 2013 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.internal.extension.api.presentation;
6
7 import android.app.Presentation;
8 import android.os.Build;
9 import android.content.Context;
10 import android.content.DialogInterface;
11 import android.view.Display;
12 import android.view.View;
13
14 /**
15  * A wrapper class of android.app.Presentation class introduced from API level 17.
16  */
17 public class PresentationViewJBMR1 extends PresentationView
18         implements DialogInterface.OnShowListener, DialogInterface.OnDismissListener {
19
20     private Presentation mPresentation;
21
22     public PresentationViewJBMR1(Context context, Display display) {
23         mPresentation = new Presentation(context, display);
24     }
25
26     @Override
27     public void show() {
28         mPresentation.show();
29     }
30
31     @Override
32     public void dismiss() {
33         mPresentation.dismiss();
34     }
35
36     @Override
37     public void cancel() {
38         mPresentation.cancel();
39     }
40
41     @Override
42     public void setContentView(View contentView) {
43         mPresentation.setContentView(contentView);
44     }
45
46     @Override
47     public Display getDisplay() {
48         return mPresentation.getDisplay();
49     }
50
51     @Override
52     public void setPresentationListener(PresentationView.PresentationListener listener) {
53         super.setPresentationListener(listener);
54
55         if (mListener != null) {
56             mPresentation.setOnShowListener(this);
57             mPresentation.setOnDismissListener(this);
58         } else {
59             mPresentation.setOnShowListener(null);
60             mPresentation.setOnDismissListener(null);
61         }
62     }
63
64     @Override
65     public void onShow(DialogInterface dialog) {
66         if (mListener != null) mListener.onShow(this);
67     }
68
69     @Override
70     public void onDismiss(DialogInterface dialog) {
71         if (mListener != null) mListener.onDismiss(this);
72     }
73 }
74