Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/src/main/java/org/openimis/imispolicies/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ public void onReceivedTitle(WebView view, String title) {
View headerview = navigationView.getHeaderView(0);
Login = headerview.findViewById(R.id.tvLogin);
OfficerName = headerview.findViewById(R.id.tvOfficerName);
SetLoggedIn();
OfficerName.setText(global.getOfficerName());

Login.setOnClickListener(v -> {
wv.loadUrl("file:///android_asset/pages/Login.html?s=3");
Expand All @@ -320,6 +322,7 @@ public void onReceivedTitle(WebView view, String title) {
if (ca.isMasterDataAvailable() > 0) {
loadLanguages();
}
ensureOfficerNameLoaded();
navigationView.setCheckedItem(R.id.nav_home);
if (checkRequirements()) {
onAllRequirementsMet();
Expand All @@ -340,7 +343,22 @@ private void setVisibilityOfPaymentMenu() {
@Override
protected void onResume() {
super.onResume();
ensureOfficerNameLoaded();
OfficerName.setText(global.getOfficerName());
SetLoggedIn();
}

private void ensureOfficerNameLoaded() {
String officerCode = global.getOfficerCode();
String officerName = global.getOfficerName();
if (ca == null || TextUtils.isEmpty(officerCode) || !TextUtils.isEmpty(officerName)) {
return;
}
try {
ca.isOfficerCodeValid(officerCode);
} catch (JSONException e) {
Log.w(LOG_TAG, "Failed to resolve officer name from officer code", e);
}
}

public static void SetLoggedIn() {
Expand All @@ -349,6 +367,9 @@ public static void SetLoggedIn() {
return;
}
activity.runOnUiThread(() -> {
if (activity.Login == null) {
return;
}
if (global.isLoggedIn()) {
activity.Login.setText(R.string.Logout);
} else {
Expand Down
Loading