Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. if (img != null && detector.detect(img, width, height)) {
  2.  
  3. // The delay is necessary to avoid taking a picture while in
  4. // the
  5. // middle of taking another. This problem can causes some
  6. // phones
  7. // to reboot.
  8. long now = System.currentTimeMillis();
  9. if (now > (mReferenceTime + Preferences.PICTURE_DELAY)) {
  10. mReferenceTime = now;
  11.  
  12. Bitmap previous = null;
  13. if (Preferences.SAVE_PREVIOUS && pre != null) {
  14. if (Preferences.USE_RGB) previous = ImageProcessing.rgbToBitmap(pre, width, height);
  15. else previous = ImageProcessing.lumaToGreyscale(pre, width, height);
  16. }
  17.  
  18. Bitmap original = null;
  19. if (Preferences.SAVE_ORIGINAL && org != null) {
  20. if (Preferences.USE_RGB) original = ImageProcessing.rgbToBitmap(org, width, height);
  21. else original = ImageProcessing.lumaToGreyscale(org, width, height);
  22. }
  23.  
  24. Bitmap bitmap = null;
  25. if (Preferences.SAVE_CHANGES) {
  26. if (Preferences.USE_RGB) bitmap = ImageProcessing.rgbToBitmap(img, width, height);
  27. else bitmap = ImageProcessing.lumaToGreyscale(img, width, height);
  28. }
  29. //<----SwitchPreference---->
  30. SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(MotionDetectionActivity.this);
  31. boolean enablesmsnotif = sharedPref.getBoolean(ENABLE_SMS_NOTIFICATION, true);
  32. boolean enablemailnotif=sharedPref.getBoolean(ENABLE_EMAIL_NOTIFICATION,true);
  33. if (enablesmsnotif) {
  34. sendSMS(ref);
  35. }
  36. if (enablemailnotif) {
  37. sendEmail(ref);
  38. }
  39.  
  40.  
  41.  
  42. Log.i(TAG, "Saving.. previous=" + previous + " original=" + original + " bitmap=" + bitmap);
  43. Looper.prepare();
  44. new SavePhotoTask().execute(previous, original, bitmap);
  45. } else {
  46. Log.i(TAG, "Not taking picture because not enough time has passed since the creation of the Surface");
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement