Upstream version 8.36.156.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / android / core_internal / src / org / xwalk / core / internal / extension / api / presentation / PresentationView.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.os.Build;
8 import android.content.Context;
9 import android.view.Display;
10 import android.view.View;
11
12 /**
13  * A helper class to abstract the presentation view for different android build version.
14  *
15  * A PresentationView is a special kind of UI widget whose purpose is to present content
16  * on a secondary display. A PresentationView is associated with the target Display at
17  * creation time and configures its context and resource configuration according to the
18  * display's metrics.
19  */
20 public abstract class PresentationView {
21     protected PresentationListener mListener;
22
23     /**
24      * Return an instance of PresentationView according to the build version.
25      */
26     public static PresentationView createInstance(Context context, Display display) {
27         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
28             return new PresentationViewJBMR1(context, display);
29         } else {
30             return new PresentationViewNull();
31         }
32     }
33
34     public abstract void show();
35
36     public abstract void dismiss();
37
38     public abstract void cancel();
39
40     public abstract void setContentView(View contentView);
41
42     public abstract Display getDisplay();
43
44     public void setPresentationListener(PresentationListener listener) {
45         mListener = listener;
46     }
47
48     /**
49      * Interface used to allow the creator of a PresentationView to run some code
50      * when it is showed or dismissed.
51      */
52     public interface PresentationListener {
53         /**
54          * Invoked when the presentation view is showed.
55          */
56         public void onShow(PresentationView view);
57
58         /**
59          * Invoked when the presentation view is dismissed.
60          */
61         public void onDismiss(PresentationView view);
62     }
63 }
64