@@ -310,6 +310,8 @@ public void onReceivedTitle(WebView view, String title) {
310310 View headerview = navigationView .getHeaderView (0 );
311311 Login = headerview .findViewById (R .id .tvLogin );
312312 OfficerName = headerview .findViewById (R .id .tvOfficerName );
313+ SetLoggedIn ();
314+ OfficerName .setText (global .getOfficerName ());
313315
314316 Login .setOnClickListener (v -> {
315317 wv .loadUrl ("file:///android_asset/pages/Login.html?s=3" );
@@ -320,6 +322,7 @@ public void onReceivedTitle(WebView view, String title) {
320322 if (ca .isMasterDataAvailable () > 0 ) {
321323 loadLanguages ();
322324 }
325+ ensureOfficerNameLoaded ();
323326 navigationView .setCheckedItem (R .id .nav_home );
324327 if (checkRequirements ()) {
325328 onAllRequirementsMet ();
@@ -340,7 +343,22 @@ private void setVisibilityOfPaymentMenu() {
340343 @ Override
341344 protected void onResume () {
342345 super .onResume ();
346+ ensureOfficerNameLoaded ();
343347 OfficerName .setText (global .getOfficerName ());
348+ SetLoggedIn ();
349+ }
350+
351+ private void ensureOfficerNameLoaded () {
352+ String officerCode = global .getOfficerCode ();
353+ String officerName = global .getOfficerName ();
354+ if (ca == null || TextUtils .isEmpty (officerCode ) || !TextUtils .isEmpty (officerName )) {
355+ return ;
356+ }
357+ try {
358+ ca .isOfficerCodeValid (officerCode );
359+ } catch (JSONException e ) {
360+ Log .w (LOG_TAG , "Failed to resolve officer name from officer code" , e );
361+ }
344362 }
345363
346364 public static void SetLoggedIn () {
@@ -349,6 +367,9 @@ public static void SetLoggedIn() {
349367 return ;
350368 }
351369 activity .runOnUiThread (() -> {
370+ if (activity .Login == null ) {
371+ return ;
372+ }
352373 if (global .isLoggedIn ()) {
353374 activity .Login .setText (R .string .Logout );
354375 } else {
0 commit comments