Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Android custom PageRenderer

$
0
0

I have this in my iOS project to get Zxing working with Xamarin.Forms:

[assembly: ExportRenderer(typeof(KleverLogic.FlashValet.Customer.Shared.Pages.ScannerPage),
typeof(KleverLogic.FlashValet.Customer.iOS.Renderers.ScannerPageRenderer))]

namespace KleverLogic.FlashValet.Customer.iOS.Renderers
{
    public class ScannerPageRenderer : PageRenderer
    {
        ZXingScannerView scanner;

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.View.BackgroundColor = UIColor.Black;

            this.scanner = new ZXingScannerView(this.View.Frame);

            this.View.AddSubview(this.scanner);
        }

        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            scanner.StartScanning(this.Result);
        }

        public void Result(Result result)
        {
        if (result == null || string.IsNullOrEmpty(result.Text))
            return;

        scanner.StopScanning();

            KleverLogic.FlashValet.Customer.Shared.Pages.ScannerPage.Result = result;

        this.InvokeOnMainThread(() => this.NavigationController.PopViewControllerAnimated(true));
        }
    }
}

However, when it comes to Android I'm a bit lost - not sure what event to override, what to add the ZXingScannerFragment to etc - any pointers?

Dino


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>