Java Code Examples for io.flutter.plugin.common.EventChannel#EventSink

The following examples show how to use io.flutter.plugin.common.EventChannel#EventSink . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlutterIsolatePlugin.java    From flutter_isolate with MIT License 6 votes vote down vote up
@Override
public void onListen(Object o, EventChannel.EventSink sink) {

    IsolateHolder isolate = queuedIsolates.remove();
    sink.success(isolate.isolateId);
    sink.endOfStream();
    activeIsolates.put(isolate.isolateId, isolate);

    isolate.result.success(null);
    isolate.startupChannel = null;
    isolate.result = null;

    if (queuedIsolates.size() != 0)
        startNextIsolate();

}
 
Example 2
Source File: FlutterBarcodeScannerPlugin.java    From flutter_barcode_scanner with MIT License 5 votes vote down vote up
@Override
public void onListen(Object o, EventChannel.EventSink eventSink) {
    try {
        barcodeStream = eventSink;
    } catch (Exception e) {
    }
}
 
Example 3
Source File: ScreenStatePlugin.java    From flutter-plugins with MIT License 5 votes vote down vote up
@Override
public void onListen(Object o, EventChannel.EventSink eventSink) {
  IntentFilter filter = new IntentFilter();
  filter.addAction(Intent.ACTION_SCREEN_ON); // Turn on screen
  filter.addAction(Intent.ACTION_SCREEN_OFF); // Turn off Screen
  filter.addAction(Intent.ACTION_USER_PRESENT); // Unlock screen

  mReceiver = new ScreenReceiver(eventSink);
  context.registerReceiver(mReceiver, filter);
}
 
Example 4
Source File: RequestPermissionsHandler.java    From background_location_updates with Apache License 2.0 5 votes vote down vote up
@Override
public void onListen(Object o, EventChannel.EventSink eventSink) {
    this.sink = eventSink;
    if (RequestPermissionsHandler.hasPermission(this.mContext)) {
        this.result = PermissionResult.GRANTED;
    } else {
        this.result = PermissionResult.DENIED;
    }
    Log.v(TAG, String.format("Permission Granted: %s", this.result));
    eventSink.success(this.result.result);
}
 
Example 5
Source File: BackgroundLocationUpdatesPlugin.java    From background_location_updates with Apache License 2.0 5 votes vote down vote up
@Override
public void onListen(Object o, EventChannel.EventSink eventSink) {
  if (mContext.getSharedPreferences(SHARED_PREFS, Context.MODE_PRIVATE).contains(KEY_PERSISTED_REQUEST_INTERVAL)) {
    eventSink.success(true);
  } else {
    eventSink.success(false);
  }
  this.isTrackingActiveEventSink = eventSink;
}
 
Example 6
Source File: WifiIotPlugin.java    From WiFiFlutter with MIT License 5 votes vote down vote up
private BroadcastReceiver createReceiver(final EventChannel.EventSink eventSink){
    return new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            eventSink.success(handleNetworkScanResult().toString());
        }
    };
}
 
Example 7
Source File: WifiIotPlugin.java    From WiFiFlutter with MIT License 5 votes vote down vote up
@Override
public void onListen(Object o, EventChannel.EventSink eventSink) {
    int PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION = 65655434;
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && moContext.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED){
        moActivity.requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION);
    }
    receiver = createReceiver(eventSink);

    moContext.registerReceiver(receiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
}
 
Example 8
Source File: LightPlugin.java    From flutter-plugins with MIT License 5 votes vote down vote up
SensorEventListener createSensorEventListener(final EventChannel.EventSink events) {
  return new SensorEventListener() {
    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {
    }

    @TargetApi(Build.VERSION_CODES.CUPCAKE)
    @Override
    public void onSensorChanged(SensorEvent event) {
      int lux = (int) event.values[0];
      events.success(lux);
    }
  };
}
 
Example 9
Source File: SmsStateHandler.java    From flutter_sms with MIT License 5 votes vote down vote up
@Override
public void onListen(Object o, EventChannel.EventSink eventSink) {
    this.eventSink = eventSink;
    smsStateChangeReceiver = new SmsStateChangeReceiver(eventSink);
    if(permissions.checkAndRequestPermission(
            new String[]{Manifest.permission.RECEIVE_SMS},
            Permissions.BROADCAST_SMS)){
        registerDeliveredReceiver();
        registerSentReceiver();
    }
}
 
Example 10
Source File: MovisensFlutterPlugin.java    From flutter-plugins with MIT License 4 votes vote down vote up
@Override
public void onListen(Object o, EventChannel.EventSink eventSink) {
    this.eventSink = eventSink;
}
 
Example 11
Source File: PluginExample.java    From streams_channel with Apache License 2.0 4 votes vote down vote up
@Override
public void onListen(Object o, final EventChannel.EventSink eventSink) {
  System.out.println("StreamHandler - onListen: " + o);
  this.eventSink = eventSink;
  runnable.run();
}
 
Example 12
Source File: PedometerPlugin.java    From flutter-plugins with MIT License 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.CUPCAKE)
@Override
public void onListen(Object arguments, EventChannel.EventSink events) {
  sensorEventListener = createSensorEventListener(events);
  sensorManager.registerListener(sensorEventListener, sensor, sensorManager.SENSOR_DELAY_FASTEST);
}
 
Example 13
Source File: SmsStateChangeReceiver.java    From flutter_sms with MIT License 4 votes vote down vote up
public SmsStateChangeReceiver(EventChannel.EventSink eventSink) {
    this.eventSink = eventSink;
}
 
Example 14
Source File: FlutterYoutubePlugin.java    From FlutterYoutube with Apache License 2.0 4 votes vote down vote up
@Override
public void onListen(Object o, EventChannel.EventSink eventSink) {
  events = eventSink;
}
 
Example 15
Source File: MedcorderAudioPlugin.java    From flutter_audio with MIT License 4 votes vote down vote up
@Override
public void onListen(Object arguments, EventChannel.EventSink events) {
  eventSink = events;
}
 
Example 16
Source File: AeyriumSensorPlugin.java    From aeyrium-sensor with MIT License 4 votes vote down vote up
@Override
public void onListen(Object arguments, EventChannel.EventSink events) {
  sensorEventListener = createSensorEventListener(events);
  sensorManager.registerListener(sensorEventListener, sensor, sensorManager.SENSOR_DELAY_UI);
}
 
Example 17
Source File: AmapLocationPlugin.java    From location_plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void onListen(Object o, EventChannel.EventSink eventSink) {
	this.mEventSink = eventSink;
}
 
Example 18
Source File: QueuingEventSink.java    From media_player with MIT License 4 votes vote down vote up
public void setDelegate(EventChannel.EventSink delegate) {
  this.delegate = delegate;
  maybeFlush();
}
 
Example 19
Source File: StreamsChannel.java    From streams_channel with Apache License 2.0 4 votes vote down vote up
private Stream(EventChannel.EventSink sink, EventChannel.StreamHandler handler) {
  this.sink = sink;
  this.handler = handler;
}
 
Example 20
Source File: FlutterFlipperkitPlugin.java    From flutter_flipperkit with MIT License 4 votes vote down vote up
@Override
public void onListen(Object args, EventChannel.EventSink eventSink) {
    this.eventSink = eventSink;
    flipperDatabaseBrowserPlugin.setEventSink(this.eventSink);
}