Skip to content

Commit

Permalink
Fixed null pointer exception on Vitals
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarS23 committed Aug 5, 2020
1 parent 0b03a6c commit 1bf90a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -1774,40 +1773,33 @@ 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);
// Create a print job with name and adapter instance
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);
// Create a print job with name and adapter instance
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);
// Create a print job with name and adapter instance
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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void changeApiBaseUrl(String newApiBaseUrl) {
public static <S> S createService(Class<S> 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);
Expand Down

0 comments on commit 1bf90a5

Please sign in to comment.