Example usage for com.facebook.react.bridge UiThreadUtil runOnUiThread

List of usage examples for com.facebook.react.bridge UiThreadUtil runOnUiThread

Introduction

In this page you can find the example usage for com.facebook.react.bridge UiThreadUtil runOnUiThread.

Prototype

public static void runOnUiThread(Runnable runnable) 

Source Link

Document

Runs the given Runnable on the UI thread.

Usage

From source file:com.rn.full.screen.FullScreen.java

License:Open Source License

@ReactMethod
public void onFullScreen() {
    UiThreadUtil.runOnUiThread(new Runnable() {
        @Override//  w w  w. jav a  2  s .c o m
        public void run() {
            getCurrentActivity().getWindow().getDecorView()
                    .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                            | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                            | View.SYSTEM_UI_FLAG_IMMERSIVE);
        }
    });

}

From source file:com.rn.full.screen.FullScreen.java

License:Open Source License

@ReactMethod
public void offFullScreen() {
    UiThreadUtil.runOnUiThread(new Runnable() {
        @Override/*from ww  w  .  j  a  v a2s . co m*/
        public void run() {
            getCurrentActivity().getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        }
    });

}

From source file:me.yiii.RCTIJKPlayer.TextureRenderView.java

License:Apache License

@Override
public void requestLayout() {
    Log.d(TAG, "Overrided requestLayout called");
    super.requestLayout();

    UiThreadUtil.runOnUiThread(new Runnable() {
        public void run() {
            if (widthMeasureSpec != 0 && heightMeasureSpec != 0) {
                // TODO fix this
                Log.d(TAG, "ui measureAndLayout");
                measure(widthMeasureSpec, heightMeasureSpec);
                Log.e(TAG, String.format("getLeft(), getTop(), getRight(), getBottom() %d %d %d %d", getLeft(),
                        getTop(), getRight(), getBottom()));
                Log.e(TAG, String.format("getLeft(), getTop(), getRight(), getBottom() %d %d %d %d",
                        getMeasuredHeight(), getMeasuredWidth(), View.MeasureSpec.getSize(getMeasuredHeight()),
                        View.MeasureSpec.getSize(getMeasuredWidth())));

                int left = getLeft();
                int top = getTop();
                int right = getRight();
                int bottom = getBottom();

                int height = View.MeasureSpec.getSize(getMeasuredHeight());
                int width = View.MeasureSpec.getSize(getMeasuredWidth());

                int h1 = bottom - top;
                layout(getLeft(), top + (h1 - height) / 2, getRight(), top + (h1 - height) / 2 + height);
            }/*from w w w.  j a v a 2 s .c om*/

        }
    });

    // post(measureAndLayout);
}

From source file:org.jitsi.meet.sdk.invite.InviteModule.java

License:Apache License

/**
 * Signals that a click/tap has been performed on {@code InviteButton} and
 * that the execution flow for adding/inviting people to the current
 * conference/meeting is to begin/*  www .j  a va2  s .c  o  m*/
 *
 * @param externalAPIScope the unique identifier of the
 * {@code JitsiMeetView} whose {@code InviteButton} was clicked/tapped.
 */
@ReactMethod
public void beginAddPeople(final String externalAPIScope) {
    // Make sure InviteControllerListener (like all other listeners of the
    // SDK) is invoked on the UI thread. It was requested by SDK consumers.
    if (!UiThreadUtil.isOnUiThread()) {
        UiThreadUtil.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                beginAddPeople(externalAPIScope);
            }
        });
        return;
    }

    InviteController inviteController = findInviteControllerByExternalAPIScope(externalAPIScope);

    if (inviteController != null) {
        inviteController.beginAddPeople(getReactApplicationContext());
    }
}

From source file:org.jitsi.meet.sdk.invite.InviteModule.java

License:Apache License

/**
 * Callback for invitation failures/*from www.j av  a2 s.c  o  m*/
 *
 * @param failedInvitees the items for which the invitation failed
 * @param addPeopleControllerScope a string that represents a connection to a specific AddPeopleController
 */
@ReactMethod
public void inviteSettled(final String externalAPIScope, final String addPeopleControllerScope,
        final ReadableArray failedInvitees) {
    // Make sure AddPeopleControllerListener (like all other listeners of
    // the SDK) is invoked on the UI thread. It was requested by SDK
    // consumers.
    if (!UiThreadUtil.isOnUiThread()) {
        UiThreadUtil.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                inviteSettled(externalAPIScope, addPeopleControllerScope, failedInvitees);
            }
        });
        return;
    }

    InviteController inviteController = findInviteControllerByExternalAPIScope(externalAPIScope);

    if (inviteController == null) {
        Log.w("InviteModule", "Invite settled, but failed to find active controller to notify");
    } else {
        inviteController.inviteSettled(addPeopleControllerScope, failedInvitees);
    }
}

From source file:org.jitsi.meet.sdk.invite.InviteModule.java

License:Apache License

/**
 * Callback for results received from the JavaScript invite search call
 *
 * @param results the results in a ReadableArray of ReadableMap objects
 * @param query the query associated with the search
 * @param addPeopleControllerScope a string that represents a connection to a specific AddPeopleController
 *///from  ww w . j  av  a 2s  .  c o m
@ReactMethod
public void receivedResults(final String externalAPIScope, final String addPeopleControllerScope,
        final String query, final ReadableArray results) {
    // Make sure AddPeopleControllerListener (like all other listeners of
    // the SDK) is invoked on the UI thread. It was requested by SDK
    // consumers.
    if (!UiThreadUtil.isOnUiThread()) {
        UiThreadUtil.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                receivedResults(externalAPIScope, addPeopleControllerScope, query, results);
            }
        });
        return;
    }

    InviteController inviteController = findInviteControllerByExternalAPIScope(externalAPIScope);

    if (inviteController == null) {
        Log.w("InviteModule", "Received results, but failed to find active controller to send results back");
    } else {
        inviteController.receivedResultsForQuery(addPeopleControllerScope, query, results);
    }
}

From source file:org.jitsi.meet.sdk.ListenerUtils.java

License:Apache License

/**
 * Executes the right listener method for the given event.
 * NOTE: This function will run asynchronously on the UI thread.
 *
 * @param listener - The listener on which the method will be called.
 * @param listenerMethods - Mapping with event names and the matching
 *                        methods./* w w  w  . java  2 s  . c  o  m*/
 * @param eventName - Name of the event.
 * @param eventData - Data associated with the event.
 */
public static void runListenerMethod(final Object listener, final Map<String, Method> listenerMethods,
        final String eventName, final ReadableMap eventData) {
    // Make sure listener methods are invoked on the UI thread. It
    // was requested by SDK consumers.
    if (UiThreadUtil.isOnUiThread()) {
        runListenerMethodOnUiThread(listener, listenerMethods, eventName, eventData);
    } else {
        UiThreadUtil.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                runListenerMethodOnUiThread(listener, listenerMethods, eventName, eventData);
            }
        });
    }
}

From source file:org.jitsi.meet.sdk.proximity.ProximityModule.java

License:Apache License

/**
 * Acquires / releases the proximity sensor wake lock.
 *
 * @param enabled {@code true} to enable the proximity sensor; otherwise,
 * {@code false}./*from   w  w w. j a  v a  2  s.  co m*/
 */
@ReactMethod
public void setEnabled(final boolean enabled) {
    if (wakeLock == null) {
        return;
    }

    UiThreadUtil.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (enabled) {
                if (!wakeLock.isHeld()) {
                    wakeLock.acquire();
                }
            } else if (wakeLock.isHeld()) {
                wakeLock.release();
            }
        }
    });
}