Search in sources :

Example 21 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-track-player by react-native-kit.

the class TrackModule method remove.

@ReactMethod
public void remove(ReadableArray tracks, final Promise callback) {
    final ArrayList trackList = Arguments.toList(tracks);
    waitForConnection(new Runnable() {

        @Override
        public void run() {
            binder.remove(trackList, callback);
        }
    });
}
Also used : ArrayList(java.util.ArrayList) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 22 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-system-setting by c19354837.

the class SystemSetting method setAppBrightness.

@ReactMethod
public void setAppBrightness(float val) {
    final Activity curActivity = getCurrentActivity();
    if (curActivity == null) {
        return;
    }
    final WindowManager.LayoutParams lp = curActivity.getWindow().getAttributes();
    lp.screenBrightness = val;
    curActivity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            curActivity.getWindow().setAttributes(lp);
        }
    });
}
Also used : Activity(android.app.Activity) WindowManager(android.view.WindowManager) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 23 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-system-setting by c19354837.

the class SystemSetting method isBluetoothEnabled.

@ReactMethod
public void isBluetoothEnabled(Promise promise) {
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    promise.resolve(bluetoothAdapter != null && bluetoothAdapter.isEnabled());
}
Also used : BluetoothAdapter(android.bluetooth.BluetoothAdapter) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 24 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-system-setting by c19354837.

the class SystemSetting method openWriteSetting.

@ReactMethod
public void openWriteSetting() {
    Intent intent = new Intent(SysSettings.WRITESETTINGS.action, Uri.parse("package:" + mContext.getPackageName()));
    mContext.getCurrentActivity().startActivityForResult(intent, SysSettings.WRITESETTINGS.requestCode);
    switchSetting(SysSettings.WRITESETTINGS);
}
Also used : Intent(android.content.Intent) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 25 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-system-setting by c19354837.

the class SystemSetting method getAppBrightness.

@ReactMethod
public void getAppBrightness(Promise promise) {
    final Activity curActivity = getCurrentActivity();
    if (curActivity == null) {
        return;
    }
    try {
        float result = curActivity.getWindow().getAttributes().screenBrightness;
        if (result < 0) {
            int val = Settings.System.getInt(getReactApplicationContext().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
            promise.resolve(val * 1.0f / 255);
        } else {
            promise.resolve(result);
        }
    } catch (Exception e) {
        e.printStackTrace();
        promise.reject("-1", "get app's brightness fail", e);
    }
}
Also used : Activity(android.app.Activity) ReactMethod(com.facebook.react.bridge.ReactMethod)

Aggregations

ReactMethod (com.facebook.react.bridge.ReactMethod)82 Activity (android.app.Activity)21 Intent (android.content.Intent)11 WritableMap (com.facebook.react.bridge.WritableMap)11 Bundle (android.os.Bundle)9 ReactApplicationContext (com.facebook.react.bridge.ReactApplicationContext)6 WritableArray (com.facebook.react.bridge.WritableArray)6 ArrayList (java.util.ArrayList)5 Camera (android.hardware.Camera)4 NativeViewHierarchyManager (com.facebook.react.uimanager.NativeViewHierarchyManager)4 UIBlock (com.facebook.react.uimanager.UIBlock)4 UIManagerModule (com.facebook.react.uimanager.UIManagerModule)4 ShareContent (com.facebook.share.model.ShareContent)4 LayoutNode (com.reactnativenavigation.options.LayoutNode)4 LoginManager (com.facebook.login.LoginManager)3 ReactActivity (com.facebook.react.ReactActivity)3 LatLng (com.google.android.gms.maps.model.LatLng)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2 RemoteException (android.os.RemoteException)2 JSApplicationIllegalArgumentException (com.facebook.react.bridge.JSApplicationIllegalArgumentException)2