@@ -39,6 +39,7 @@ public class MainActivity extends SimpleActivity {
3939
4040 private static Bus mBus ;
4141 private MyCameraImpl mCameraImpl ;
42+ private boolean mJustGrantedPermission ;
4243
4344 @ Override
4445 protected void onCreate (Bundle savedInstanceState ) {
@@ -99,7 +100,6 @@ private void setupCameraImpl() {
99100
100101 @ OnClick (R .id .toggle_btn )
101102 public void toggleFlashlight () {
102- mStroboscopeBar .setVisibility (View .INVISIBLE );
103103 mCameraImpl .toggleFlashlight ();
104104 }
105105
@@ -131,6 +131,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
131131 super .onRequestPermissionsResult (requestCode , permissions , grantResults );
132132
133133 if (requestCode == CAMERA_PERMISSION ) {
134+ mJustGrantedPermission = true ;
134135 if (isCameraPermissionGranted ()) {
135136 toggleStroboscope ();
136137 } else {
@@ -152,6 +153,10 @@ protected void onStart() {
152153 @ Override
153154 protected void onResume () {
154155 super .onResume ();
156+ if (mJustGrantedPermission ) {
157+ mJustGrantedPermission = false ;
158+ return ;
159+ }
155160 mCameraImpl .handleCameraSetup ();
156161 mCameraImpl .checkFlashlight ();
157162
@@ -197,9 +202,11 @@ public void stateChangedEvent(Events.StateChanged event) {
197202 }
198203
199204 public void enableFlashlight () {
200- changeIconColor (R .color .translucent_white , mStroboscopeBtn );
201205 changeIconColor (R .color .colorPrimary , mToggleBtn );
202206 getWindow ().addFlags (WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON );
207+
208+ changeIconColor (R .color .translucent_white , mStroboscopeBtn );
209+ mStroboscopeBar .setVisibility (View .INVISIBLE );
203210 }
204211
205212 public void disableFlashlight () {
0 commit comments