5858import java .util .ArrayList ;
5959import java .util .List ;
6060
61+ import io .sentry .Sentry ;
62+ import io .sentry .android .core .SentryAndroid ;
63+
6164
6265public class MainActivity extends ImisActivity {
6366 private static final int REQUEST_PERMISSIONS_CODE = 1 ;
@@ -109,49 +112,53 @@ public boolean onCreateOptionsMenu(Menu menu) {
109112 @ Override
110113 protected void onCreate (Bundle savedInstanceState ) {
111114 super .onCreate (savedInstanceState );
112- setContentView (R .layout .activity_main );
115+ try {
116+ setContentView (R .layout .activity_main );
113117
114- isSDCardAvailable ();
118+ isSDCardAvailable ();
115119
116- broadcastList = new ArrayList <>();
117- broadcastList .add (SynchronizeService .ACTION_CLAIM_COUNT_RESULT );
120+ broadcastList = new ArrayList <>();
121+ broadcastList .add (SynchronizeService .ACTION_CLAIM_COUNT_RESULT );
118122
119- progressDialog = new ProgressDialog (this );
120- progressDialog .setCancelable (false );
123+ progressDialog = new ProgressDialog (this );
124+ progressDialog .setCancelable (false );
121125
122- Toolbar toolbar = findViewById (R .id .toolbar );
123- setSupportActionBar (toolbar );
124- actionBar = getSupportActionBar ();
126+ Toolbar toolbar = findViewById (R .id .toolbar );
127+ setSupportActionBar (toolbar );
128+ actionBar = getSupportActionBar ();
125129
126- new Thread (this ::checkForUpdates ).start ();
130+ new Thread (this ::checkForUpdates ).start ();
127131
128- drawer = findViewById (R .id .drawer_layout );
129- ActionBarDrawerToggle toggle = new ActionBarDrawerToggle (
130- this , drawer , toolbar , R .string .navigation_drawer_open , R .string .navigation_drawer_close );
131- drawer .addDrawerListener (toggle );
132- toggle .syncState ();
132+ drawer = findViewById (R .id .drawer_layout );
133+ ActionBarDrawerToggle toggle = new ActionBarDrawerToggle (
134+ this , drawer , toolbar , R .string .navigation_drawer_open , R .string .navigation_drawer_close );
135+ drawer .addDrawerListener (toggle );
136+ toggle .syncState ();
133137
134- NavigationView navigationView = findViewById (R .id .nav_view );
135- navigationView .setNavigationItemSelectedListener (this ::onNavigationItemSelected );
138+ NavigationView navigationView = findViewById (R .id .nav_view );
139+ navigationView .setNavigationItemSelectedListener (this ::onNavigationItemSelected );
136140
137- View header = navigationView .getHeaderView (0 );
138- loginText = header .findViewById (R .id .LoginText );
139- loginText .setText (global .isLoggedIn () ? R .string .Logout : R .string .Login );
140- RelativeLayout loginButton = header .findViewById (R .id .LoginButton );
141- loginButton .setOnClickListener ((view ) -> changeLoginState ());
141+ View header = navigationView .getHeaderView (0 );
142+ loginText = header .findViewById (R .id .LoginText );
143+ loginText .setText (global .isLoggedIn () ? R .string .Logout : R .string .Login );
144+ RelativeLayout loginButton = header .findViewById (R .id .LoginButton );
145+ loginButton .setOnClickListener ((view ) -> changeLoginState ());
142146
143- accepted_count = findViewById (R .id .accepted_count );
144- rejected_count = findViewById (R .id .rejected_count );
145- entered_Count = findViewById (R .id .entered_count );
147+ accepted_count = findViewById (R .id .accepted_count );
148+ rejected_count = findViewById (R .id .rejected_count );
149+ entered_Count = findViewById (R .id .entered_count );
146150
147- accepted_count .setText ("0" );
148- rejected_count .setText ("0" );
149- entered_Count .setText ("0" );
151+ accepted_count .setText ("0" );
152+ rejected_count .setText ("0" );
153+ entered_Count .setText ("0" );
150154
151- AdminName = findViewById (R .id .AdminName );
155+ AdminName = findViewById (R .id .AdminName );
152156
153- if (checkRequirements ()) {
154- onAllRequirementsMet ();
157+ if (checkRequirements ()) {
158+ onAllRequirementsMet ();
159+ }
160+ } catch (Exception exception ) {
161+ Sentry .captureException (exception );
155162 }
156163 }
157164
@@ -283,6 +290,7 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
283290 (d , i ) -> finish ());
284291 }
285292 } catch (Exception e ) {
293+ Sentry .captureException (e );
286294 Log .e (LOG_TAG , "Error while copying master data." , e );
287295 }
288296 }
@@ -303,6 +311,7 @@ public void PickMasterDataFileDialog() {
303311 try {
304312 startActivityForResult (intent , REQUEST_PICK_MD_FILE );
305313 } catch (ActivityNotFoundException e ) {
314+ Sentry .captureException (e );
306315 Toast .makeText (getApplicationContext (), getResources ().getString (R .string .NoFileExporerInstalled ), Toast .LENGTH_SHORT ).show ();
307316 }
308317 }).setNegativeButton (getResources ().getString (R .string .No ),
@@ -319,6 +328,7 @@ public AlertDialog confirmRefreshMap() {
319328 try {
320329 doLoggedIn (() -> DownLoadDiagnosesServicesItems (global .getOfficerCode ()));
321330 } catch (Exception e ) {
331+ Sentry .captureException (e );
322332 e .printStackTrace ();
323333 }
324334 },
@@ -409,6 +419,7 @@ public AlertDialog DownloadMasterDialog() {
409419 }
410420 } catch (Exception e ) {
411421 e .printStackTrace ();
422+ Sentry .captureException (e );
412423 DownloadMasterDialog ();
413424 }
414425 } else {
@@ -442,6 +453,7 @@ private void checkForUpdates() {
442453 try {
443454 mNotificationManager .notify (SIMPLE_NOTIFICATION_ID , builder .build ());
444455 } catch (Exception e ) {
456+ Sentry .captureException (e );
445457 e .printStackTrace ();
446458 }
447459
@@ -479,6 +491,7 @@ public void run() {
479491 });
480492 } catch (Exception e ) {
481493 e .printStackTrace ();
494+ Sentry .captureException (e );
482495 runOnUiThread (() -> {
483496 progressDialog .dismiss ();
484497 ErrorDialogBox (e .getMessage ());
@@ -519,6 +532,7 @@ public void getClaimAdmins() {
519532 });
520533 } catch (Exception e ) {
521534 e .printStackTrace ();
535+ Sentry .captureException (e );
522536 runOnUiThread (() -> progressDialog .dismiss ());
523537 }
524538 });
@@ -553,6 +567,7 @@ public void validateClaimAdminCode(final String claimAdminCode) {
553567 progressDialog .dismiss ();
554568 doLoggedIn (() -> DownLoadDiagnosesServicesItems (claimAdminCode ));
555569 } catch (Exception e ) {
570+ Sentry .captureException (e );
556571 e .printStackTrace ();
557572 }
558573 }
@@ -636,6 +651,7 @@ public void run() {
636651 });
637652 } catch (Exception e ) {
638653 e .printStackTrace ();
654+ Sentry .captureException (e );
639655 runOnUiThread (() -> {
640656 progressDialog .dismiss ();
641657 Toast .makeText (MainActivity .this , e .getMessage () + "-" + getResources ().getString (R .string .SomethingWentWrongServer ), Toast .LENGTH_LONG ).show ();
@@ -680,6 +696,7 @@ public void run() {
680696 });
681697 } catch (Exception e ) {
682698 e .printStackTrace ();
699+ Sentry .captureException (e );
683700 runOnUiThread (() -> {
684701 progressDialog .dismiss ();
685702 Toast .makeText (MainActivity .this , e .getMessage () + "-" + getResources ().getString (R .string .AccessDenied ), Toast .LENGTH_LONG ).show ();
0 commit comments