Java Code Examples for io.flutter.plugin.common.PluginRegistry#Registrar

The following examples show how to use io.flutter.plugin.common.PluginRegistry#Registrar . 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: 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 4
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 5
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 6
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 7
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 8
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 9
Source File: ContactPhotoQuery.java    From flutter_sms with MIT License 4 votes vote down vote up
ContactPhotoQueryHandler(PluginRegistry.Registrar registrar, MethodChannel.Result result, String photoUri, boolean fullSize) {
  this.registrar = registrar;
  this.result = result;
  this.photoUri = photoUri;
  this.fullSize = fullSize;
}
 
Example 10
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 11
Source File: ContactQuery.java    From flutter_sms with MIT License 4 votes vote down vote up
ContactQueryHandler(PluginRegistry.Registrar registrar, MethodChannel.Result result, String contactAddress) {
    this.registrar = registrar;
    this.result = result;
    this.contactAddress = contactAddress;
}
 
Example 12
Source File: SmsStateHandler.java    From flutter_sms with MIT License 4 votes vote down vote up
public SmsStateHandler(PluginRegistry.Registrar registrar) {
    this.registrar = registrar;
    this.permissions = new Permissions(registrar.activity());
    registrar.addRequestPermissionsResultListener(this);
}
 
Example 13
Source File: SimCardsProvider.java    From flutter_sms with MIT License 4 votes vote down vote up
SimCardsProvider(PluginRegistry.Registrar registrar) {
    this.registrar = registrar;
    permissions = new Permissions(registrar.activity());
}
 
Example 14
Source File: SimCardsProvider.java    From flutter_sms with MIT License 4 votes vote down vote up
SimCardsHandler(PluginRegistry.Registrar registrar, MethodChannel.Result result) {
    this.registrar = registrar;
    this.result = result;
}
 
Example 15
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()));
}
 
Example 16
Source File: UserProfileProvider.java    From flutter_sms with MIT License 4 votes vote down vote up
UserProfileProvider(PluginRegistry.Registrar registrar) {
    this.registrar = registrar;
    permissions = new Permissions(registrar.activity());
}
 
Example 17
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 18
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 19
Source File: ContactPhotoQuery.java    From flutter_sms with MIT License 4 votes vote down vote up
ContactPhotoQuery(PluginRegistry.Registrar registrar) {
    this.registrar = registrar;
    permissions = new Permissions(registrar.activity());
}
 
Example 20
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;
}