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.
5 package org.xwalk.core.internal.extension.api.presentation;
7 import android.os.Build;
8 import android.content.Context;
9 import android.view.Display;
10 import android.view.View;
13 * A helper class to abstract the presentation view for different android build version.
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
20 public abstract class PresentationView {
21 protected PresentationListener mListener;
24 * Return an instance of PresentationView according to the build version.
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);
30 return new PresentationViewNull();
34 public abstract void show();
36 public abstract void dismiss();
38 public abstract void cancel();
40 public abstract void setContentView(View contentView);
42 public abstract Display getDisplay();
44 public void setPresentationListener(PresentationListener listener) {
49 * Interface used to allow the creator of a PresentationView to run some code
50 * when it is showed or dismissed.
52 public interface PresentationListener {
54 * Invoked when the presentation view is showed.
56 public void onShow(PresentationView view);
59 * Invoked when the presentation view is dismissed.
61 public void onDismiss(PresentationView view);