Example usage for android.view Display getDisplayId

List of usage examples for android.view Display getDisplayId

Introduction

In this page you can find the example usage for android.view Display getDisplayId.

Prototype

public int getDisplayId() 

Source Link

Document

Gets the display id.

Usage

From source file:org.acra.collector.DisplayManagerCollector.java

@NonNull
private String collectFlags(@NonNull Display display) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        final int flags = display.getFlags();
        for (Field field : display.getClass().getFields()) {
            if (field.getName().startsWith("FLAG_")) {
                try {
                    flagNames.put(field.getInt(null), field.getName());
                } catch (IllegalAccessException ignored) {
                }//from   w ww.j  a v a2  s . c  o  m
            }
        }
        return display.getDisplayId() + ".flags=" + activeFlags(flags) + '\n';
    }
    return "";
}

From source file:com.quectel.presentationtest.PresentationTest.java

/**
 * Shows a {@link Presentation} on the specified display.
 *//*w  w  w. j a  va 2  s .  c  o m*/
private void showPresentation(Display display, DemoPresentationContents contents) {
    final int displayId = display.getDisplayId();
    if (mActivePresentations.get(displayId) != null) {
        return;
    }

    Log.d(TAG, "Showing presentation photo #" + contents.photo + " on display #" + displayId + ".");

    DemoPresentation presentation = new DemoPresentation(this, display, contents);
    presentation.show();
    presentation.setOnDismissListener(mOnDismissListener);
    mActivePresentations.put(displayId, presentation);
}

From source file:com.quectel.presentationtest.PresentationTest.java

@Override
protected void onResume() {
    // Be sure to call the super class.
    super.onResume();

    // Update our list of displays on resume.
    mDisplayListAdapter.updateContents();

    // Restore presentations from before the activity was paused.
    final int numDisplays = mDisplayListAdapter.getCount();
    for (int i = 0; i < numDisplays; i++) {
        final Display display = mDisplayListAdapter.getItem(i);
        final DemoPresentationContents contents = mSavedPresentationContents.get(display.getDisplayId());
        if (contents != null) {
            showPresentation(display, contents);
        }//from www.  j a v  a  2 s  .  co m
    }
    mSavedPresentationContents.clear();

    // Register to receive events from the display manager.
    mDisplayManager.registerDisplayListener(mDisplayListener, null);
}

From source file:de.fhg.fokus.famium.presentation.CDVPresentationPlugin.java

private void addDisplay(final Display display) {
    if ((display.getFlags() & Display.FLAG_PRESENTATION) != 0) {
        getActivity().runOnUiThread(new Runnable() {
            @Override/*from w w w .j av a 2s .c o m*/
            public void run() {
                int oldSize = getSessions().size();
                SecondScreenPresentation presentation = new SecondScreenPresentation(getActivity(), display,
                        getDefaultDisplay());
                getPresentations().put(display.getDisplayId(), presentation);
                presentation.show();
                int newSize = getPresentations().size();
                CallbackContext callbackContext = getAvailableChangeCallbackContext();
                if (oldSize == 0 && newSize == 1 && callbackContext != null) {
                    sendAvailableChangeResult(callbackContext, getPresentations().size() > 0);
                }
            }
        });
    }
}

From source file:com.quectel.presentationtest.PresentationTest.java

/**
 * Called when the Info button next to a display is clicked to show information
 * about the display.//from  w ww . j  av  a  2s.  c  o  m
 */
@Override
public void onClick(View v) {
    Context context = v.getContext();
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final Display display = (Display) v.getTag();
    Resources r = context.getResources();
    AlertDialog alert = builder
            .setTitle(r.getString(R.string.presentation_alert_info_text, display.getDisplayId()))
            .setMessage(display.toString())
            .setNeutralButton(R.string.presentation_alert_dismiss_text, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
    alert.show();
}