io.flutter.plugin.common.PluginRegistry Java Examples

The following examples show how to use io.flutter.plugin.common.PluginRegistry. 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: FlutterAMapNavView.java    From flutter_amap_plugin with MIT License 6 votes vote down vote up
public FlutterAMapNavView(Context context, AtomicInteger atomicInteger, PluginRegistry.Registrar registrar, int id, Activity activity, AMapNavModel model) {
    this.context = context;
    this.atomicInteger = atomicInteger;
    this.registrar = registrar;
    this.mOptions = model;
    this.activity = activity;

    navChannel = new MethodChannel(registrar.messenger(), NAV_CHANNEL_NAME + "/" + id);
    navChannel.setMethodCallHandler(this);

    aMapNav = AMapNavi.getInstance(activity);
    aMapNav.addAMapNaviListener(this);
    aMapNav = AMapNavi.getInstance(this.context);
    aMapNav.setUseInnerVoice(true);

    view = View.inflate(activity, R.layout.amap_nav, null);
    navView = view.findViewById(R.id.navi_view);

    registrar.activity().getApplication().registerActivityLifecycleCallbacks(this);
}
 
Example #2
Source File: QrReaderView.java    From flutter_qr_reader with MIT License 6 votes vote down vote up
public QrReaderView(Context context, PluginRegistry.Registrar registrar, int id, Map<String, Object> params){
    this.mContext = context;
    this.mParams = params;
    this.mRegistrar = registrar;

    // 创建视图
    int width = (int) mParams.get("width");
    int height = (int) mParams.get("height");
    _view = new QRCodeReaderView(mContext);
    ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(width, height);
    _view.setLayoutParams(layoutParams);
    _view.setOnQRCodeReadListener(this);
    _view.setQRDecodingEnabled(true);
    _view.forceAutoFocus();
    int interval = mParams.containsKey(EXTRA_FOCUS_INTERVAL) ? (int) mParams.get(EXTRA_FOCUS_INTERVAL) : 2000;
    _view.setAutofocusInterval(interval);
    _view.setTorchEnabled((boolean)mParams.get(EXTRA_TORCH_ENABLED));

    // 操作监听
    mMethodChannel = new MethodChannel(registrar.messenger(), "me.hetian.flutter_qr_reader.reader_view_" + id);
    mMethodChannel.setMethodCallHandler(this);
}
 
Example #3
Source File: FlutterMobileVisionPlugin.java    From flutter_mobile_vision with MIT License 6 votes vote down vote up
private void setup(
        final BinaryMessenger messenger,

        final Activity activity,
        final PluginRegistry.Registrar registrar,
        final ActivityPluginBinding activityBinding) {
    this.activity = activity;
    this.delegate = new FlutterMobileVisionDelegate(activity);
    channel = new MethodChannel(messenger, CHANNEL);
    channel.setMethodCallHandler(this);
    if (registrar != null) {
        // V1 embedding setup for activity listeners.
        registrar.addActivityResultListener(delegate);
        registrar.addRequestPermissionsResultListener(delegate);
    } else {
        // V2 embedding setup for activity listeners.
        activityBinding.addActivityResultListener(delegate);
        activityBinding.addRequestPermissionsResultListener(delegate);
    }
}
 
Example #4
Source File: FlutterYoutubePlugin.java    From FlutterYoutube with Apache License 2.0 6 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {
  final MethodChannel channel = new MethodChannel(registrar.messenger(), "PonnamKarthik/flutter_youtube");
  channel.setMethodCallHandler(new FlutterYoutubePlugin(registrar.activity()));
  registrar.addActivityResultListener(new PluginRegistry.ActivityResultListener() {
    @Override
    public boolean onActivityResult(int i, int i1, Intent intent) {
      if(i == YOUTUBE_PLAYER_RESULT) {
        if(intent != null) {
          if(intent.getIntExtra("done", -1) == 0) {
            if(events != null) {
              events.success("done");
            }
          }
        }
      }
      return false;
    }
  });

  final EventChannel eventChannel = new EventChannel(registrar.messenger(), STREAM_CHANNEL_NAME);
  FlutterYoutubePlugin youtubeWithEventChannel = new FlutterYoutubePlugin(registrar.activity());
  eventChannel.setStreamHandler(youtubeWithEventChannel);
}
 
Example #5
Source File: GeneratedPluginRegistrant.java    From simple_share with MIT License 5 votes vote down vote up
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
  final String key = GeneratedPluginRegistrant.class.getCanonicalName();
  if (registry.hasPlugin(key)) {
    return true;
  }
  registry.registrarFor(key);
  return false;
}
 
Example #6
Source File: GeneratedPluginRegistrant.java    From test-samples with Apache License 2.0 5 votes vote down vote up
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
  final String key = GeneratedPluginRegistrant.class.getCanonicalName();
  if (registry.hasPlugin(key)) {
    return true;
  }
  registry.registrarFor(key);
  return false;
}
 
Example #7
Source File: GeneratedPluginRegistrant.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
  final String key = GeneratedPluginRegistrant.class.getCanonicalName();
  if (registry.hasPlugin(key)) {
    return true;
  }
  registry.registrarFor(key);
  return false;
}
 
Example #8
Source File: GeneratedPluginRegistrant.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void registerWith(PluginRegistry registry) {
  if (alreadyRegisteredWith(registry)) {
    return;
  }
  ImagePickerPlugin.registerWith(registry.registrarFor("io.flutter.plugins.imagepicker.ImagePickerPlugin"));
  PathProviderPlugin.registerWith(registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"));
  SharedPreferencesPlugin.registerWith(registry.registrarFor("io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"));
}
 
Example #9
Source File: GeneratedPluginRegistrant.java    From CrazyDaily with Apache License 2.0 5 votes vote down vote up
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
    final String key = GeneratedPluginRegistrant.class.getCanonicalName();
    if (registry.hasPlugin(key)) {
        return true;
    }
    registry.registrarFor(key);
    return false;
}
 
Example #10
Source File: GeneratedPluginRegistrant.java    From CrazyDaily with Apache License 2.0 5 votes vote down vote up
public static void registerWith(PluginRegistry registry) {
        if (alreadyRegisteredWith(registry)) {
            return;
        }
        FluttertoastPlugin.registerWith(registry.registrarFor(FluttertoastPlugin.CHANNEL_NAME));
        FlutterRouterMethodPlugin.registerWith(registry.registrarFor(FlutterRouterMethodPlugin.CHANNEL_NAME));
//        FlutterRefreshEventPlugin.registerWith(registry.registrarFor(FlutterRefreshEventPlugin.CHANNEL_NAME));
    }
 
Example #11
Source File: QRCodeReaderPlugin.java    From flutter_qrcode_reader with MIT License 5 votes vote down vote up
public static void registerWith(PluginRegistry.Registrar registrar) {
//        if (instance == null) {
           final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL);
           final QRCodeReaderPlugin instance = new QRCodeReaderPlugin(registrar.activity());
           registrar.addActivityResultListener(instance);
           registrar.addRequestPermissionsResultListener(instance);
           channel.setMethodCallHandler(instance);
    // }
   }
 
Example #12
Source File: FlutterDownloaderPlugin.java    From flutter_downloader with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressLint("NewApi")
public static void registerWith(PluginRegistry.Registrar registrar) {
    if (instance == null) {
        instance = new FlutterDownloaderPlugin();
    }
    instance.onAttachedToEngine(registrar.context(), registrar.messenger());
}
 
Example #13
Source File: GeneratedPluginRegistrant.java    From WiFiFlutter with MIT License 5 votes vote down vote up
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
  final String key = GeneratedPluginRegistrant.class.getCanonicalName();
  if (registry.hasPlugin(key)) {
    return true;
  }
  registry.registrarFor(key);
  return false;
}
 
Example #14
Source File: SmsQuery.java    From flutter_sms with MIT License 5 votes vote down vote up
SmsQueryHandler(PluginRegistry.Registrar registrar, MethodChannel.Result result, SmsQueryRequest request,
                int start, int count, int threadId, String address) {
  this.registrar = registrar;
  this.result = result;
  this.request = request;
  this.start = start;
  this.count = count;
  this.threadId = threadId;
  this.address = address;
}
 
Example #15
Source File: GeneratedPluginRegistrant.java    From simple_share with MIT License 5 votes vote down vote up
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
  final String key = GeneratedPluginRegistrant.class.getCanonicalName();
  if (registry.hasPlugin(key)) {
    return true;
  }
  registry.registrarFor(key);
  return false;
}
 
Example #16
Source File: GeneratedPluginRegistrant.java    From simple_share with MIT License 5 votes vote down vote up
public static void registerWith(PluginRegistry registry) {
  if (alreadyRegisteredWith(registry)) {
    return;
  }
  FilePickerPlugin.registerWith(registry.registrarFor("com.mr.flutter.plugin.filepicker.FilePickerPlugin"));
  ImagePickerPlugin.registerWith(registry.registrarFor("io.flutter.plugins.imagepicker.ImagePickerPlugin"));
  PathProviderPlugin.registerWith(registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"));
  SimpleSharePlugin.registerWith(registry.registrarFor("com.juanito21.simpleshare.SimpleSharePlugin"));
}
 
Example #17
Source File: GeneratedPluginRegistrant.java    From simple_share with MIT License 5 votes vote down vote up
public static void registerWith(PluginRegistry registry) {
  if (alreadyRegisteredWith(registry)) {
    return;
  }
  FilePickerPlugin.registerWith(registry.registrarFor("com.mr.flutter.plugin.filepicker.FilePickerPlugin"));
  ImagePickerPlugin.registerWith(registry.registrarFor("io.flutter.plugins.imagepicker.ImagePickerPlugin"));
  PathProviderPlugin.registerWith(registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"));
  SimpleSharePlugin.registerWith(registry.registrarFor("com.juanito21.simpleshare.SimpleSharePlugin"));
}
 
Example #18
Source File: AudioServiceBinder.java    From media_player with MIT License 5 votes vote down vote up
public void create(PluginRegistry.Registrar registrar, MethodCall call, Result result) {
    Log.i(TAG, "starting player in bakground");
    TextureRegistry.SurfaceTextureEntry handle = registrar.textures().createSurfaceTexture();

    EventChannel eventChannel = new EventChannel(registrar.messenger(), "media_player_event_channel" + handle.id());

    VideoPlayer player;

    player = new VideoPlayer(registrar.context(), eventChannel, handle, result);
    if ((boolean) call.argument("showNotification")) {
        PersistentNotification.create(service, player);
    }
    videoPlayers.put(handle.id(), player);

}
 
Example #19
Source File: AudioQueryDelegate.java    From flutter_audio_query with MIT License 5 votes vote down vote up
private AudioQueryDelegate(final PluginRegistry.Registrar registrar){

        m_artistLoader = new ArtistLoader(registrar.context() );
        m_albumLoader = new AlbumLoader(registrar.context() );
        m_songLoader = new SongLoader( registrar.context() );
        m_genreLoader = new GenreLoader( registrar.context() );
        m_playlistLoader = new PlaylistLoader( registrar.context() );

        m_permissionManager = new PermissionManager() {
            @Override
            public boolean isPermissionGranted(String permissionName) {

                return (ActivityCompat.checkSelfPermission( registrar.activity(), permissionName)
                    == PackageManager.PERMISSION_GRANTED);
            }

            @Override
            public void askForPermission(String permissionName, int requestCode) {
                ActivityCompat.requestPermissions(registrar.activity(), new String[] {permissionName}, requestCode);
            }
        };

        registrar.addRequestPermissionsResultListener(this);
        registrar.addViewDestroyListener(new PluginRegistry.ViewDestroyListener() {
            @Override
            public boolean onViewDestroy(FlutterNativeView flutterNativeView) {
                // ideal
                Log.i("MDBG", "onViewDestroy");
                return true;
            }
        });
    }
 
Example #20
Source File: FlutterBarcodeScannerPlugin.java    From flutter_barcode_scanner with MIT License 5 votes vote down vote up
/**
 * Setup method
 * Created after Embedding V2 API release
 *
 * @param messenger
 * @param applicationContext
 * @param activity
 * @param registrar
 * @param activityBinding
 */
private void createPluginSetup(
        final BinaryMessenger messenger,
        final Application applicationContext,
        final Activity activity,
        final PluginRegistry.Registrar registrar,
        final ActivityPluginBinding activityBinding) {


    this.activity = (FlutterActivity) activity;
    eventChannel =
            new EventChannel(messenger, "flutter_barcode_scanner_receiver");
    eventChannel.setStreamHandler(this);


    this.applicationContext = applicationContext;
    channel = new MethodChannel(messenger, CHANNEL);
    channel.setMethodCallHandler(this);
    if (registrar != null) {
        // V1 embedding setup for activity listeners.
        observer = new LifeCycleObserver(activity);
        applicationContext.registerActivityLifecycleCallbacks(
                observer); // Use getApplicationContext() to avoid casting failures.
        registrar.addActivityResultListener(this);
    } else {
        // V2 embedding setup for activity listeners.
        activityBinding.addActivityResultListener(this);
        lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
        observer = new LifeCycleObserver(activity);
        lifecycle.addObserver(observer);
    }
}
 
Example #21
Source File: FlutterAMapView.java    From flutter_amap_plugin with MIT License 5 votes vote down vote up
public FlutterAMapView(Context context, AtomicInteger atomicInteger, PluginRegistry.Registrar registrar, int id, AMapMapModel model) {
    this.context = context;
    this.atomicInteger = atomicInteger;
    this.registrar = registrar;
    this.options = model;


    mapChannel = new MethodChannel(registrar.messenger(), MAP_CHANNEL_NAME + "/" + id);
    mapChannel.setMethodCallHandler(this);

    mapView = new TextureMapView(this.context);
    mapView.onCreate(null);

    setUpMap();
}
 
Example #22
Source File: AdvCameraFactory.java    From adv_camera with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
AdvCameraFactory(PluginRegistry.Registrar registrar) {
    super(StandardMessageCodec.INSTANCE);
    mPluginRegistrar = registrar;
}
 
Example #23
Source File: QrReaderFactory.java    From flutter_qr_reader with MIT License 4 votes vote down vote up
public QrReaderFactory(PluginRegistry.Registrar registrar) {
    super(StandardMessageCodec.INSTANCE);
    this.registrar = registrar;
}
 
Example #24
Source File: FlutterCrashlyticsPlugin.java    From flutter_crashlytics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static void registerWith(PluginRegistry.Registrar registrar) {
    final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_crashlytics");
    channel.setMethodCallHandler(new FlutterCrashlyticsPlugin(registrar.context()));
}
 
Example #25
Source File: PluginExample.java    From streams_channel with Apache License 2.0 4 votes vote down vote up
public static void registerWith(PluginRegistry.Registrar registrar) {
  final StreamsChannel channel = new StreamsChannel(registrar.messenger(), "streams_channel_example");
  channel.setStreamHandlerFactory(arguments -> new StreamHandler());
}
 
Example #26
Source File: MainApplication.java    From android_job_scheduler with Apache License 2.0 4 votes vote down vote up
@Override
public void registerWith(PluginRegistry pluginRegistry) {
    GeneratedPluginRegistrant.registerWith(pluginRegistry);
}
 
Example #27
Source File: AndroidJobScheduler.java    From android_job_scheduler with Apache License 2.0 4 votes vote down vote up
public static void setPluginRegistrantCallback(PluginRegistry.PluginRegistrantCallback callback) {
    AndroidJobScheduler.pluginRegistrantCallback = callback;
}
 
Example #28
Source File: FlutterBarcodeScannerPlugin.java    From flutter_barcode_scanner with MIT License 4 votes vote down vote up
private FlutterBarcodeScannerPlugin(FlutterActivity activity, final PluginRegistry.Registrar registrar) {
    FlutterBarcodeScannerPlugin.activity = activity;
}
 
Example #29
Source File: FlutterAMapViewFactory.java    From flutter_amap_plugin with MIT License 4 votes vote down vote up
public FlutterAMapViewFactory(AtomicInteger state, PluginRegistry.Registrar registrar) {
    super(StandardMessageCodec.INSTANCE);
    mActivityState = state;
    mPluginRegistrar = registrar;
}
 
Example #30
Source File: FlutterRouterMethodPlugin.java    From CrazyDaily with Apache License 2.0 4 votes vote down vote up
static void registerWith(PluginRegistry.Registrar registrar) {
    final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME);
    channel.setMethodCallHandler(new FlutterRouterMethodPlugin(registrar.activity()));
}