Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.57 KB | None | 0 0
  1. package com.digipro.fesdkcore.Componentes;
  2.  
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.content.pm.PackageManager;
  6. import androidx.databinding.DataBindingUtil;
  7. import androidx.databinding.ObservableField;
  8. import android.graphics.Bitmap;
  9. import android.graphics.BitmapFactory;
  10. import android.net.Uri;
  11. import android.os.Bundle;
  12. import android.os.Handler;
  13. import android.os.Looper;
  14. import com.google.android.material.floatingactionbutton.FloatingActionButton;
  15. import androidx.appcompat.app.AppCompatActivity;
  16. import android.view.View;
  17. import android.view.WindowManager;
  18. import android.widget.TextView;
  19. import android.widget.Toast;
  20.  
  21. import com.digipro.fesdkcore.FeSdkCore;
  22. import com.digipro.fesdkcore.R;
  23. import com.digipro.fesdkcore.R2;
  24. import com.digipro.fesdkcore.databinding.ComponenteCameravideoBinding;
  25. import com.digipro.fesdkcore.dto.Constantes;
  26. import com.digipro.fesdkcore.repositorios.LogErrorRepository;
  27. import com.digipro.fesdkcore.utils.Extension;
  28. import com.digipro.fesdkcore.widgets.Spotlight.prefs.PreferencesManager;
  29. import com.digipro.fesdkcore.widgets.Spotlight.utils.SpotlightSequence;
  30. import com.digipro.fesdkcore.widgets.Spotlight.utils.Utils;
  31. import com.otaliastudios.cameraview.CameraListener;
  32. import com.otaliastudios.cameraview.CameraLogger;
  33. import com.otaliastudios.cameraview.CameraOptions;
  34. import com.otaliastudios.cameraview.CameraView;
  35. import com.otaliastudios.cameraview.Facing;
  36. import com.otaliastudios.cameraview.SessionType;
  37. import com.otaliastudios.cameraview.Size;
  38. import com.otaliastudios.cameraview.VideoQuality;
  39.  
  40. import java.io.File;
  41. import java.io.FileOutputStream;
  42.  
  43. import butterknife.BindView;
  44. import butterknife.ButterKnife;
  45. import es.dmoral.toasty.Toasty;
  46.  
  47. import static com.otaliastudios.cameraview.Flash.OFF;
  48. import static com.otaliastudios.cameraview.Flash.TORCH;
  49.  
  50.  
  51. public class Camera extends AppCompatActivity {
  52.  
  53. private static final String IDbtnstopVideo = "IDbtnstopVideo";
  54. private static final String IDtxttextviewanchorstext = "IDtxttextviewanchorstext";
  55. private static final String IDbtncaptureVideo = "IDbtncaptureVideo";
  56. private static final String IDbtncapturePhoto = "IDbtncapturePhoto";
  57. private static final String IDbtntoggleCamera = "IDbtntoggleCamera";
  58. private static final String IDbtnfab_flash = "IDbtnfab_flash";
  59. private static final String IDbtnfab_cancelar_camara = "IDbtnfab_cancelar_camara";
  60. private static Handler handler = new Handler(Looper.getMainLooper());
  61. private static Runnable runnable;
  62. public ObservableField<String> textreadvideo = new ObservableField<>();
  63. @BindView(R2.id.camera)
  64. CameraView camera;
  65. Context mContext;
  66. @BindView(R2.id.capturePhoto)
  67. FloatingActionButton capturePhoto;
  68. @BindView(R2.id.captureVideo)
  69. FloatingActionButton captureVideo;
  70. @BindView(R2.id.stopVideo)
  71. FloatingActionButton stopVideo;
  72. @BindView(R2.id.toggleCamera)
  73. FloatingActionButton toggleCamera;
  74.  
  75. // private ViewGroup controlPanel;
  76. @BindView(R2.id.fab_flash)
  77. FloatingActionButton fab_flash;
  78. @BindView(R2.id.textviewanchorstext)
  79. TextView textviewanchorstext;
  80. @BindView(R2.id.ayudaFoto)
  81. FloatingActionButton ayudaFoto;
  82. @BindView(R2.id.fab_cancelar_camara)
  83. FloatingActionButton fab_cancelar_camara;
  84. boolean deviceHasFlash = true;
  85. boolean deviceHasFrontCamera = true;
  86. boolean expand = true;
  87. private Uri uriPath;
  88. private boolean flashEnabled = false;
  89. private boolean camaraTrasera = true;
  90. private boolean mCapturingPicture;
  91. private boolean mCapturingVideo;
  92. // To show stuff in the callback
  93. private Size mCaptureNativeSize;
  94. private long mCaptureTime;
  95.  
  96. @Override
  97. protected void onCreate(Bundle savedInstanceState) {
  98. super.onCreate(savedInstanceState);
  99. try {
  100. getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
  101. WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
  102. CameraLogger.setLogLevel(CameraLogger.LEVEL_VERBOSE);
  103.  
  104. ComponenteCameravideoBinding binding = DataBindingUtil.setContentView(this, R.layout.componente_cameravideo);
  105. ButterKnife.bind(this);
  106. startSendScreenNameAnalytics();
  107. mContext = getBaseContext();
  108.  
  109. String fotoVideo = getIntent().getStringExtra("fotoVideo");
  110. String modocamara = getIntent().getStringExtra("modocamara");
  111. String leyendavideo = getIntent().getStringExtra("leyendavideo");
  112.  
  113. if (fotoVideo.equals("VIDEO")) {
  114. if (leyendavideo.isEmpty()) textviewanchorstext.setVisibility(View.GONE);
  115. else textviewanchorstext.setVisibility(View.VISIBLE);
  116. }
  117. binding.setTextreadvideo(textreadvideo);
  118. textreadvideo.set(leyendavideo);
  119. ayudaFoto.setOnClickListener(new View.OnClickListener() {
  120. @Override
  121. public void onClick(View v) {
  122. expand = !expand;
  123. PreferencesManager mPreferencesManager = new PreferencesManager(mContext);
  124. mPreferencesManager.resetAll();
  125. if (fotoVideo.equals("FOTO")) {
  126. showSecuenseHintFoto();
  127. } else {
  128. showSecuenseHintVideo();
  129. }
  130. }
  131. });
  132.  
  133. checkHasFlash();
  134. checkHasFrontCamera();
  135.  
  136. if (!modocamara.isEmpty() && modocamara.equals("front") && deviceHasFrontCamera) {
  137. camera.setFacing(Facing.FRONT);
  138. camaraTrasera = false;
  139. } else {
  140. camaraTrasera = true;
  141. camera.setFacing(Facing.BACK);
  142. }
  143.  
  144.  
  145. fab_flash.setOnClickListener(new View.OnClickListener() {
  146. @Override
  147. public void onClick(View v) {
  148. flashEnabled = !flashEnabled;
  149. if (flashEnabled)
  150. camera.setFlash(TORCH);
  151. else
  152. camera.setFlash(OFF);
  153. }
  154. });
  155.  
  156. if (fotoVideo.equals("FOTO")) {
  157. camera.setSessionType(SessionType.PICTURE);
  158. textviewanchorstext.setVisibility(View.GONE);
  159. capturePhoto.setVisibility(View.VISIBLE);
  160. captureVideo.setVisibility(View.GONE);
  161. } else {
  162. camera.setSessionType(SessionType.VIDEO);
  163. camera.setVideoMaxSize(4000 * 1000); // 4 mb
  164. camera.setVideoQuality(VideoQuality.MAX_480P);
  165. capturePhoto.setVisibility(View.GONE);
  166. captureVideo.setVisibility(View.VISIBLE);
  167. }
  168. camera.addCameraListener(new CameraListener() {
  169. public void onCameraOpened(CameraOptions options) {
  170. // onOpened();
  171. }
  172.  
  173. public void onPictureTaken(byte[] jpeg) {
  174. onPicture(jpeg);
  175. }
  176.  
  177. @Override
  178. public void onVideoTaken(File video) {
  179. super.onVideoTaken(video);
  180. onVideo(video);
  181. }
  182. });
  183.  
  184. capturePhoto.setOnClickListener(new View.OnClickListener() {
  185. @Override
  186. public void onClick(View v) {
  187. ayudaFoto.setVisibility(View.GONE);
  188. capturePhoto();
  189. }
  190. });
  191. captureVideo.setOnClickListener(new View.OnClickListener() {
  192. @Override
  193. public void onClick(View v) {
  194. ayudaFoto.setVisibility(View.GONE);
  195. captureVideo();
  196. }
  197. });
  198. toggleCamera.setOnClickListener(new View.OnClickListener() {
  199. @Override
  200. public void onClick(View v) {
  201. toggleCamera();
  202. }
  203. });
  204. stopVideo.setOnClickListener(new View.OnClickListener() {
  205. @Override
  206. public void onClick(View v) {
  207.  
  208. if (camera.isCapturingVideo())
  209. camera.stopCapturingVideo();
  210.  
  211. // ayudaFoto.setVisibility(View.VISIBLE);
  212. // fab_cancelar_camara.setVisibility(View.VISIBLE);
  213. }
  214. });
  215. // controlPanel = findViewById(R.id.controls);
  216. // ViewGroup group = (ViewGroup) controlPanel.getChildAt(0);
  217. // Control[] controls = Control.values();
  218. // for (Control control : controls) {
  219. // ControlView view = new ControlView(this, control, this);
  220. // group.addView(view, ViewGroup.LayoutParams.MATCH_PARENT,
  221. // ViewGroup.LayoutParams.WRAP_CONTENT);
  222. // }
  223.  
  224. // controlPanel.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
  225. // @Override
  226. // public void onGlobalLayout() {
  227. // BottomSheetBehavior b = BottomSheetBehavior.from(controlPanel);
  228. // b.setState(BottomSheetBehavior.STATE_HIDDEN);
  229. // }
  230. // });
  231.  
  232. fab_cancelar_camara.setOnClickListener(new View.OnClickListener() {
  233. @Override
  234. public void onClick(View view) {
  235. finish();
  236. }
  237. });
  238. } catch (Exception ex) {
  239. // AnalyticsUtilssendException(ex, true);
  240. LogErrorRepository.BuildLogError(ex);
  241. Toasty.error(mContext, getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  242. }
  243. }
  244.  
  245. private void checkHasFlash() {
  246. try {
  247. deviceHasFlash = mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
  248. if (deviceHasFlash)
  249. if (camaraTrasera)
  250. fab_flash.setVisibility(View.VISIBLE);
  251. else
  252. fab_flash.setVisibility(View.GONE);
  253. } catch (Exception ex) {
  254. // AnalyticsUtilssendException(ex, true);
  255. LogErrorRepository.BuildLogError(ex);
  256. Toasty.error(mContext, mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  257. }
  258. }
  259.  
  260. private void checkHasFrontCamera() {
  261. try {
  262. deviceHasFrontCamera = mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
  263. if (deviceHasFrontCamera){
  264. toggleCamera.setVisibility(View.VISIBLE);
  265. }
  266. } catch (Exception ex) {
  267. // AnalyticsUtilssendException(ex, true);
  268. LogErrorRepository.BuildLogError(ex);
  269. Toasty.error(mContext, mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  270. }
  271. }
  272.  
  273. private void message(String content, boolean important) {
  274. try {
  275. int length = important ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;
  276. Toast.makeText(this, content, length).show();
  277. } catch (Exception ex) {
  278. // AnalyticsUtilssendException(ex, true);
  279. LogErrorRepository.BuildLogError(ex);
  280. Toasty.error(mContext, mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  281. }
  282. }
  283.  
  284. // private void onOpened() {
  285. // ViewGroup group = (ViewGroup) controlPanel.getChildAt(0);
  286. // for (int i = 0; i < group.getChildCount(); i++) {
  287. // ControlView view = (ControlView) group.getChildAt(i);
  288. // view.onCameraOpened(camera);
  289. // }
  290. // }
  291.  
  292. private void onPicture(byte[] jpeg) {
  293. try {
  294. mCapturingPicture = false;
  295. long callbackTime = System.currentTimeMillis();
  296. if (mCapturingVideo) {
  297. message("Captured while taking video. Size=" + mCaptureNativeSize, false);
  298. return;
  299. }
  300.  
  301. // This can happen if picture was taken with a gesture.
  302. if (mCaptureTime == 0) mCaptureTime = callbackTime - 300;
  303. if (mCaptureNativeSize == null) mCaptureNativeSize = camera.getPictureSize();
  304.  
  305. final BitmapFactory.Options options = new BitmapFactory.Options();
  306. options.inSampleSize = 4;
  307. Bitmap originalBitmap = BitmapFactory.decodeByteArray(jpeg, 0, jpeg.length, options);
  308.  
  309. File file = Extension.createFile(Constantes.DB_Usuario + FeSdkCore.configSaved.LastCodigoUsed + "_" + FeSdkCore.usuarioSaved.User + Constantes.DB_Anexo, Extension.getFormatDate("yyyyMMddHHmmssSSS"), getBaseContext());
  310. FileOutputStream out = new FileOutputStream(file);
  311. originalBitmap.compress(Bitmap.CompressFormat.PNG, 75, out); // bmp is your Bitmap instance
  312. out.close();
  313.  
  314. uriPath = Uri.fromFile(file);
  315.  
  316. mCaptureTime = 0;
  317. mCaptureNativeSize = null;
  318.  
  319. saveResult();
  320.  
  321. } catch (Exception ex) {
  322. // AnalyticsUtilssendException(ex, true);
  323. LogErrorRepository.BuildLogError(ex);
  324. Toasty.error(getBaseContext(), mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  325. }
  326. }
  327.  
  328. private void onVideo(File video) {
  329. try {
  330. mCapturingVideo = false;
  331. uriPath = Uri.fromFile(video);
  332. saveResult();
  333. } catch (Exception ex) {
  334. // AnalyticsUtilssendException(ex, true);
  335. LogErrorRepository.BuildLogError(ex);
  336. Toasty.error(mContext, mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  337. }
  338. }
  339.  
  340.  
  341. @Override
  342. public void onBackPressed() {
  343. try {
  344. finish();
  345. } catch (Exception ex) {
  346. // AnalyticsUtilssendException(ex, true);
  347. LogErrorRepository.BuildLogError(ex);
  348. Toasty.error(mContext, mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  349. }
  350. }
  351.  
  352.  
  353. private void capturePhoto() {
  354. try {
  355. if (mCapturingPicture) return;
  356. mCapturingPicture = true;
  357. mCaptureTime = System.currentTimeMillis();
  358. mCaptureNativeSize = camera.getPictureSize();
  359. message("Capturando", false);
  360. camera.capturePicture();
  361. } catch (Exception ex) {
  362. // AnalyticsUtilssendException(ex, true);
  363. LogErrorRepository.BuildLogError(ex);
  364. Toasty.error(mContext, mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  365. }
  366. }
  367.  
  368. private void captureVideo() {
  369. try {
  370. if (camera.getSessionType() != SessionType.VIDEO) {
  371. message("No es posible grabar si se encuentra en Foto", false);
  372. return;
  373. }
  374.  
  375. ayudaFoto.setVisibility(View.GONE);
  376. fab_cancelar_camara.setVisibility(View.GONE);
  377.  
  378. if (mCapturingPicture || mCapturingVideo) return;
  379. mCapturingVideo = true;
  380. message("Grabando...", false);
  381.  
  382. runnable = new Runnable() {
  383. @Override
  384. public void run() {
  385. try {
  386. stopVideo.setVisibility(View.VISIBLE);
  387. } catch (Exception ex) {
  388. LogErrorRepository.BuildLogError(ex);
  389. }
  390. handler.removeCallbacks(runnable);
  391. }
  392. };
  393. handler.postDelayed(runnable, 1000);
  394.  
  395. toggleCamera.setVisibility(View.GONE);
  396. captureVideo.setVisibility(View.GONE);
  397. // message("Recording for 8 seconds...", true);
  398. File file = Extension.createFile(Constantes.DB_Usuario + FeSdkCore.configSaved.LastCodigoUsed + "_" + FeSdkCore.usuarioSaved.User + Constantes.DB_Anexo, Extension.getFormatDate("yyyyMMddHHmmssSSS"), getBaseContext());
  399. camera.startCapturingVideo(file, 8000);
  400. } catch (Exception ex) {
  401. // AnalyticsUtilssendException(ex, true);
  402. LogErrorRepository.BuildLogError(ex);
  403. Toasty.error(getBaseContext(), mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  404. }
  405. }
  406.  
  407. private void toggleCamera() {
  408. try {
  409. if (mCapturingPicture) return;
  410. switch (camera.toggleFacing()) {
  411. case BACK:
  412. // message("Camara Trasera", false);
  413. camaraTrasera = true;
  414. checkHasFlash();
  415. break;
  416. case FRONT:
  417. // message("Camara Frontal", false);
  418. camaraTrasera = false;
  419. checkHasFlash();
  420. break;
  421. }
  422. } catch (Exception ex) {
  423. // AnalyticsUtilssendException(ex, true);
  424. LogErrorRepository.BuildLogError(ex);
  425. Toasty.error(mContext, mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  426. }
  427. }
  428.  
  429.  
  430. //endregion
  431. private void startSendScreenNameAnalytics() {
  432. // startGoogleAnalytics(this);
  433. // AnalyticsUtilssendScreenName(Camera.class.getSimpleName());
  434. }
  435.  
  436. public void saveResult() {
  437. try {
  438. Intent intent = new Intent();
  439. intent.setData(uriPath);
  440. setResult(RESULT_OK, intent);
  441. super.onBackPressed();
  442. } catch (Exception ex) {
  443. // AnalyticsUtilssendException(ex, true);
  444. LogErrorRepository.BuildLogError(ex);
  445. Toasty.error(mContext, mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  446. }
  447. }
  448.  
  449. private void showSecuenseHintFoto() {
  450. int visibilityfab_flash = fab_flash.getVisibility();
  451. int visibilitytoggleCamera = toggleCamera.getVisibility();
  452. int visibilitycapturePhoto = capturePhoto.getVisibility();
  453. int visibilityfab_cancelar_camara = fab_cancelar_camara.getVisibility();
  454.  
  455. new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
  456. @Override
  457. public void run() {
  458. // showSequence.resetSpotlights(mContext);
  459. Utils.mostrar_ocultar_boton(null, 0, fab_flash, visibilityfab_flash);
  460. SpotlightSequence.getInstance(Camera.this, null)
  461. .addSpotlight(fab_flash, "Flash", "Activar flash", IDbtnfab_flash, Utils.configSpotlightColor(fab_flash.getBackgroundTintList().getDefaultColor()), () -> {
  462. Utils.mostrar_ocultar_boton(fab_flash, visibilityfab_flash, toggleCamera, visibilitytoggleCamera);
  463. })
  464. .addSpotlight(toggleCamera, "Frontal/Trasera", "Cambiar camara Frontal/Trasera", IDbtntoggleCamera, Utils.configSpotlightColor(toggleCamera.getBackgroundTintList().getDefaultColor()), () -> {
  465. Utils.mostrar_ocultar_boton(toggleCamera, visibilitytoggleCamera, capturePhoto, visibilitycapturePhoto);
  466. })
  467. .addSpotlight(capturePhoto, "Capturar", "Capturar foto", IDbtncapturePhoto, Utils.configSpotlightColor(capturePhoto.getBackgroundTintList().getDefaultColor()), () -> {
  468. Utils.mostrar_ocultar_boton(capturePhoto, visibilitycapturePhoto, null, 0);
  469. })
  470. .addSpotlight(fab_cancelar_camara, mContext.getResources().getString(R.string.Spotlight_Title_Cancelar), mContext.getResources().getString(R.string.Spotlight_Subtitle_Cancelar), IDbtnfab_cancelar_camara, Utils.configSpotlightColor(fab_cancelar_camara.getBackgroundTintList().getDefaultColor()), () -> {
  471. Utils.mostrar_ocultar_boton(fab_cancelar_camara, visibilityfab_cancelar_camara, null, 0);
  472. })
  473. .startSequence();
  474. }
  475. }, 200);
  476. }
  477.  
  478. private void showSecuenseHintVideo() {
  479. int visibilityfab_flash = fab_flash.getVisibility();
  480. int visibilitytoggleCamera = toggleCamera.getVisibility();
  481. int visibilitycaptureVideo = captureVideo.getVisibility();
  482. int visibilitystopVideo = stopVideo.getVisibility();
  483. int visibilityfab_cancelar_camara = fab_cancelar_camara.getVisibility();
  484.  
  485. new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
  486. @Override
  487. public void run() {
  488. SpotlightSequence.getInstance(Camera.this, null)
  489. .addSpotlight(textviewanchorstext, "Leyenda", "Texto a leer durante la grabacion", IDtxttextviewanchorstext, () -> Utils.mostrar_ocultar_boton(null, 0, fab_flash, visibilityfab_flash))
  490. .addSpotlight(fab_flash, "Flash", "Activar fash", IDbtnfab_flash, Utils.configSpotlightColor(fab_flash.getBackgroundTintList().getDefaultColor()), () -> Utils.mostrar_ocultar_boton(fab_flash, visibilityfab_flash, toggleCamera, visibilitytoggleCamera))
  491. .addSpotlight(toggleCamera, "Frontal/Trasera", "Cambiar camara Frontal/Trasera", IDbtntoggleCamera, Utils.configSpotlightColor(toggleCamera.getBackgroundTintList().getDefaultColor()), () -> {
  492. Utils.mostrar_ocultar_boton(null, 0, captureVideo, visibilitycaptureVideo);
  493. })
  494. .addSpotlight(captureVideo, "Grabar", "Grabar video", IDbtncaptureVideo, Utils.configSpotlightColor(captureVideo.getBackgroundTintList().getDefaultColor()), () -> {
  495. captureVideo.setVisibility(View.GONE);
  496. Utils.mostrar_ocultar_boton(null, 0, stopVideo, visibilitystopVideo);
  497. })
  498. .addSpotlight(stopVideo, "Detener", "Detener grabación", IDbtnstopVideo, Utils.configSpotlightColor(stopVideo.getBackgroundTintList().getDefaultColor()), () -> {
  499. Utils.mostrar_ocultar_boton(captureVideo, visibilitycaptureVideo, fab_cancelar_camara, visibilityfab_cancelar_camara);
  500. resetVisiblility(visibilityfab_flash, visibilitytoggleCamera, visibilitycaptureVideo, visibilitystopVideo);
  501. })
  502. .addSpotlight(fab_cancelar_camara, mContext.getResources().getString(R.string.Spotlight_Title_Cancelar), mContext.getResources().getString(R.string.Spotlight_Subtitle_Cancelar), IDbtnfab_cancelar_camara, Utils.configSpotlightColor(fab_cancelar_camara.getBackgroundTintList().getDefaultColor()), () -> {
  503. Utils.mostrar_ocultar_boton(fab_cancelar_camara, visibilityfab_cancelar_camara, null, 0);
  504. })
  505. .startSequence();
  506. }
  507. }, 200);
  508.  
  509. }
  510.  
  511. void resetVisiblility(int visibilityfab_flash, int visibilitytoggleCamera, int visibilitycaptureVideo, int visibilitystopVideo) {
  512. fab_flash.setVisibility(visibilityfab_flash);
  513. toggleCamera.setVisibility(visibilitytoggleCamera);
  514. captureVideo.setVisibility(visibilitycaptureVideo);
  515. stopVideo.setVisibility(visibilitystopVideo);
  516. }
  517.  
  518. @Override
  519. protected void onResume() {
  520. try {
  521. super.onResume();
  522. camera.start();
  523. } catch (Exception ex) {
  524. // AnalyticsUtilssendException(ex, true);
  525. LogErrorRepository.BuildLogError(ex);
  526. Toasty.error(mContext, mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  527. }
  528. }
  529.  
  530. @Override
  531. protected void onPause() {
  532. try {
  533. super.onPause();
  534. camera.destroy();
  535. super.onBackPressed();
  536. } catch (Exception ex) {
  537. // AnalyticsUtilssendException(ex, true);
  538. LogErrorRepository.BuildLogError(ex);
  539. Toasty.error(mContext, mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  540. }
  541. }
  542.  
  543. @Override
  544. protected void onDestroy() {
  545. try {
  546. super.onDestroy();
  547. camera.destroy();
  548. } catch (Exception ex) {
  549. // AnalyticsUtilssendException(ex, true);
  550. LogErrorRepository.BuildLogError(ex);
  551. Toasty.error(mContext, mContext.getString(R.string.Mensaje_ErrorInterno), Toast.LENGTH_SHORT, true).show();
  552. }
  553. }
  554. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement