Skip to content

Commit

Permalink
Cache the reader instance
Browse files Browse the repository at this point in the history
Previously this was being recreated repeatedly so the set options weren't actually being used for analyzing frames.
  • Loading branch information
Redth committed Aug 30, 2022
1 parent 92e06c7 commit 8db0e5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 3 additions & 1 deletion ZXing.Net.MAUI/CameraBarcodeReaderViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ public CameraBarcodeReaderViewHandler(PropertyMapper mapper = null) : base(mappe

CameraManager cameraManager;

Readers.IBarcodeReader barcodeReader;

protected Readers.IBarcodeReader BarcodeReader
=> Services.GetService<Readers.IBarcodeReader>();
=> barcodeReader ??= Services.GetService<Readers.IBarcodeReader>();

protected override NativePlatformCameraPreviewView CreatePlatformView()
{
Expand Down
8 changes: 3 additions & 5 deletions ZXing.Net.MAUI/ZXingBarcodeReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace ZXing.Net.Maui.Readers
{


public class ZXingBarcodeReader : Readers.IBarcodeReader
{
BarcodeReaderGeneric zxingReader;
Expand All @@ -21,9 +19,9 @@ public BarcodeReaderOptions Options
set
{
options = value;
zxingReader.Options.PossibleFormats = Options.Formats.ToZXingList();
zxingReader.Options.TryHarder = Options.TryHarder;
zxingReader.AutoRotate = Options.AutoRotate;
zxingReader.Options.PossibleFormats = options.Formats.ToZXingList();
zxingReader.Options.TryHarder = options.TryHarder;
zxingReader.AutoRotate = options.AutoRotate;
}
}

Expand Down

0 comments on commit 8db0e5f

Please sign in to comment.