|
43 | 43 | import static org.openimis.imisclaims.BuildConfig.API_BASE_URL; |
44 | 44 |
|
45 | 45 | public class EnquireActivity extends ImisActivity { |
46 | | - public static final String LOG_TAG = "ENQUIRE"; |
47 | | - public static final int REQUEST_QR_SCAN_CODE = 1; |
| 46 | + private static final String LOG_TAG = "ENQUIRE"; |
| 47 | + private static final int REQUEST_QR_SCAN_CODE = 1; |
48 | 48 |
|
49 | 49 | private Picasso picasso; |
50 | 50 |
|
@@ -277,7 +277,7 @@ private void getInsureeInfo() { |
277 | 277 | } else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) { |
278 | 278 | runOnUiThread(() -> showDialog(getResources().getString(R.string.RecordNotFound))); |
279 | 279 | } else { |
280 | | - runOnUiThread(() -> showDialog(rest.getHttpError(this, responseCode))); |
| 280 | + runOnUiThread(() -> showDialog(rest.getHttpError(this, responseCode, response.getStatusLine().getReasonPhrase()))); |
281 | 281 | } |
282 | 282 | } catch (Exception e) { |
283 | 283 | Log.e(LOG_TAG, "Fetching online enquire failed", e); |
@@ -312,39 +312,24 @@ public void renderResult() { |
312 | 312 | tvDOB.setText(jsonObject.getString("dob"));//Adjust |
313 | 313 | tvGender.setText(jsonObject.getString("gender")); |
314 | 314 |
|
315 | | - if (global.isNetworkAvailable()) { |
316 | | - if (JsonUtils.isStringEmpty(jsonObject, "photoBase64", true)) { |
317 | | - try { |
318 | | - byte[] imageBytes = Base64.decode(jsonObject.getString("photoBase64").getBytes(), Base64.DEFAULT); |
319 | | - Bitmap image = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); |
320 | | - iv.setImageBitmap(image); |
321 | | - } catch (Exception e) { |
322 | | - Log.e(LOG_TAG, "Error while processing Base64 image", e); |
323 | | - iv.setImageDrawable(getResources().getDrawable(R.drawable.person)); |
324 | | - } |
325 | | - } else if (JsonUtils.isStringEmpty(jsonObject, "photoPath", true)) { |
326 | | - String photo_url_str = API_BASE_URL + jsonObject.getString("photoPath"); |
327 | | - iv.setImageResource(R.drawable.person); |
328 | | - picasso.load(photo_url_str) |
329 | | - .placeholder(R.drawable.person) |
330 | | - .error(R.drawable.person) |
331 | | - .into(iv); |
332 | | - } else { |
| 315 | + if (!JsonUtils.isStringEmpty(jsonObject, "photoBase64", true)) { |
| 316 | + try { |
| 317 | + byte[] imageBytes = Base64.decode(jsonObject.getString("photoBase64").getBytes(), Base64.DEFAULT); |
| 318 | + Bitmap image = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); |
| 319 | + iv.setImageBitmap(image); |
| 320 | + } catch (Exception e) { |
| 321 | + Log.e(LOG_TAG, "Error while processing Base64 image", e); |
333 | 322 | iv.setImageDrawable(getResources().getDrawable(R.drawable.person)); |
334 | 323 | } |
| 324 | + } else if (!JsonUtils.isStringEmpty(jsonObject, "photoPath", true) && global.isNetworkAvailable()) { |
| 325 | + String photo_url_str = API_BASE_URL + jsonObject.getString("photoPath"); |
| 326 | + iv.setImageResource(R.drawable.person); |
| 327 | + picasso.load(photo_url_str) |
| 328 | + .placeholder(R.drawable.person) |
| 329 | + .error(R.drawable.person) |
| 330 | + .into(iv); |
335 | 331 | } else { |
336 | | - if (theImage != null) { |
337 | | - iv.setImageBitmap(theImage); |
338 | | - } else { |
339 | | - byte[] photo = jsonObject.getString("photoPath").getBytes(); |
340 | | - ByteArrayInputStream is = new ByteArrayInputStream(photo); |
341 | | - theImage = BitmapFactory.decodeStream(is); |
342 | | - if (theImage != null) { |
343 | | - iv.setImageBitmap(theImage); |
344 | | - } else { |
345 | | - iv.setImageResource(R.drawable.person); |
346 | | - } |
347 | | - } |
| 332 | + iv.setImageDrawable(getResources().getDrawable(R.drawable.person)); |
348 | 333 | } |
349 | 334 |
|
350 | 335 | jsonArray = new JSONArray(jsonObject.getString("details")); |
|
0 commit comments