Skip to content

Commit

Permalink
Do both button state updates on the ui thread
Browse files Browse the repository at this point in the history
  • Loading branch information
sz3 committed Mar 3, 2024
1 parent 86eda96 commit a19a56b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
applicationId "org.cimbar.camerafilecopy"
minSdkVersion 21
targetSdkVersion 30
versionCode 14
versionCode 15
versionName "0.6.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
Expand Down
24 changes: 15 additions & 9 deletions app/src/main/java/org/cimbar/camerafilecopy/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,25 @@ public Mat onCameraFrame(CvCameraViewFrame frame) {
if (res.startsWith("/")) {
if (res.length() >= 2 && res.charAt(1) == '4') {
detectedMode = 4;
mModeSwitch.setActivated(true);
runOnUiThread(new Runnable() {
@Override
public void run() {
mModeSwitch.setActivated(true);
mModeSwitch.setChecked(true);
}
});
}
else {
detectedMode = 68;
mModeSwitch.setActivated(false);
runOnUiThread(new Runnable() {
@Override
public void run() {
mModeSwitch.setActivated(false);
mModeSwitch.setChecked(true);
}
});
}
// the check toggle needs to be on the UI thread!
runOnUiThread(new Runnable() {
@Override
public void run() {
mModeSwitch.setChecked(true);
}
});

}
else if (!res.isEmpty()) {
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
Expand Down

0 comments on commit a19a56b

Please sign in to comment.