From 1bf90a55747c4493229439b467bbb900f835128d Mon Sep 17 00:00:00 2001 From: Sagar S Date: Wed, 5 Aug 2020 19:41:26 +0530 Subject: [PATCH] Fixed null pointer exception on Vitals --- .../VisitSummaryActivity.java | 34 +++++++------------ .../client/networkApiCalls/ApiClient.java | 2 +- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/app/intelehealth/client/activities/visitSummaryActivity/VisitSummaryActivity.java b/app/src/main/java/app/intelehealth/client/activities/visitSummaryActivity/VisitSummaryActivity.java index 25db86d1da..b31b7bd847 100644 --- a/app/src/main/java/app/intelehealth/client/activities/visitSummaryActivity/VisitSummaryActivity.java +++ b/app/src/main/java/app/intelehealth/client/activities/visitSummaryActivity/VisitSummaryActivity.java @@ -750,13 +750,12 @@ public void run() { respiratory.setVisibility(View.GONE); } - if(height.getValue().trim().equals("0")) - { - heightView.setText("-"); - } - else - { - heightView.setText(height.getValue()); + if (height.getValue() != null) { + if (height.getValue().trim().equals("0")) { + heightView.setText("-"); + } else { + heightView.setText(height.getValue()); + } } weightView.setText(weight.getValue()); @@ -1458,7 +1457,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) { public void onPageFinished(WebView view, String url) { Log.i("Patient WebView", "page finished loading " + url); int webview_heightContent = view.getContentHeight(); - Log.d("variable i", "variable i: "+webview_heightContent); + Log.d("variable i", "variable i: " + webview_heightContent); createWebPrintJob(view, webview_heightContent); mWebView = null; } @@ -1763,7 +1762,7 @@ public void onPageFinished(WebView view, String url) { /** * This method creates a print job using PrintManager instance and PrintAdapter Instance * - * @param webView object of type WebView. + * @param webView object of type WebView. * @param contentHeight */ private void createWebPrintJob(WebView webView, int contentHeight) { @@ -1774,10 +1773,9 @@ private void createWebPrintJob(WebView webView, int contentHeight) { // Get a print adapter instance PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter(); - Log.d("webview content height", "webview content height: "+contentHeight); + Log.d("webview content height", "webview content height: " + contentHeight); - if(contentHeight > 2683 && contentHeight <= 3000) - { + if (contentHeight > 2683 && contentHeight <= 3000) { //medium size prescription... PrintAttributes.Builder pBuilder = new PrintAttributes.Builder(); pBuilder.setMediaSize(PrintAttributes.MediaSize.ISO_B4); @@ -1785,9 +1783,7 @@ private void createWebPrintJob(WebView webView, int contentHeight) { String jobName = getString(R.string.app_name) + " Visit Summary"; PrintJob printJob = printManager.print(jobName, printAdapter, pBuilder.build()); - } - else if(contentHeight == 0) - { + } else if (contentHeight == 0) { //in case of webview bug of 0 contents... PrintAttributes.Builder pBuilder = new PrintAttributes.Builder(); pBuilder.setMediaSize(PrintAttributes.MediaSize.JIS_B4); @@ -1795,9 +1791,7 @@ else if(contentHeight == 0) String jobName = getString(R.string.app_name) + " Visit Summary"; PrintJob printJob = printManager.print(jobName, printAdapter, pBuilder.build()); - } - else if (contentHeight > 3000) - { + } else if (contentHeight > 3000) { //large size prescription... PrintAttributes.Builder pBuilder = new PrintAttributes.Builder(); pBuilder.setMediaSize(PrintAttributes.MediaSize.JIS_B4); @@ -1805,9 +1799,7 @@ else if (contentHeight > 3000) String jobName = getString(R.string.app_name) + " Visit Summary"; PrintJob printJob = printManager.print(jobName, printAdapter, pBuilder.build()); - } - else - { + } else { //small size prescription... // Create a print job with name and adapter instance String jobName = getString(R.string.app_name) + " Visit Summary"; diff --git a/app/src/main/java/app/intelehealth/client/networkApiCalls/ApiClient.java b/app/src/main/java/app/intelehealth/client/networkApiCalls/ApiClient.java index 46d5092763..a47385da60 100644 --- a/app/src/main/java/app/intelehealth/client/networkApiCalls/ApiClient.java +++ b/app/src/main/java/app/intelehealth/client/networkApiCalls/ApiClient.java @@ -34,7 +34,7 @@ public static void changeApiBaseUrl(String newApiBaseUrl) { public static S createService(Class serviceClass) { HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); - loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); + loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.NONE); client.addInterceptor(loggingInterceptor); client.connectTimeout(70, TimeUnit.SECONDS); client.readTimeout(70, TimeUnit.SECONDS);