Skip to content

Commit

Permalink
Merge pull request #9 from BigRoomStudios/android-ui-lag
Browse files Browse the repository at this point in the history
start readers in its own thread
  • Loading branch information
Brian Leighton authored Aug 15, 2022
2 parents 53983d0 + 983d4de commit 2acab1c
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;

import java.lang.Thread;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -78,8 +79,14 @@ public void setDebugging(boolean shouldDebug) {
@ReactMethod
public void activateDevice() {

final SwiperControllerManager swipManager = SwiperControllerManager.getInstance();
((CCSwiperController) swipManager.getSwiperController()).startReaders(swipManager.getSwiperCaptureMode());
// call start readers in it's own thread because it was blocking the UI otherwise, even when using a promise
new Thread(new Runnable() {
public void run() {

final SwiperControllerManager swipManager = SwiperControllerManager.getInstance();
((CCSwiperController) swipManager.getSwiperController()).startReaders(swipManager.getSwiperCaptureMode());
}
}).start();
}

@ReactMethod
Expand Down

0 comments on commit 2acab1c

Please sign in to comment.