diff --git a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/anc/ANCDetailActivity.java b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/anc/ANCDetailActivity.java index 9637df795..f56cb5d07 100644 --- a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/anc/ANCDetailActivity.java +++ b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/anc/ANCDetailActivity.java @@ -14,16 +14,15 @@ import android.widget.TextView; import org.ei.opensrp.Context; -import org.ei.opensrp.commonregistry.AllCommonsRepository; -import org.ei.opensrp.commonregistry.CommonPersonObject; import org.ei.opensrp.commonregistry.CommonPersonObjectClient; import org.ei.opensrp.domain.ProfileImage; import org.ei.opensrp.indonesia.R; +import org.ei.opensrp.indonesia.application.BidanApplication; import org.ei.opensrp.indonesia.kartu_ibu.NativeKISmartRegisterActivity; import org.ei.opensrp.indonesia.lib.FlurryFacade; import org.ei.opensrp.repository.DetailsRepository; import org.ei.opensrp.repository.ImageRepository; -import org.ei.opensrp.view.activity.NativeANCSmartRegisterActivity; +import org.ei.opensrp.util.OpenSRPImageLoader; import java.io.File; import java.io.IOException; @@ -237,11 +236,10 @@ public void onClick(View v) { ancKe.setText(": "+(ancclient.getDetails().get("ancKe") != null ? ancclient.getDetails().get("ancKe") : "-")); ancDate.setText(": "+ (ancclient.getDetails().get("ancDate") != null ? ancclient.getDetails().get("ancDate") : "-")); - if(ancclient.getDetails().get("profilepic")!= null){ - setImagetoHolderFromUri(ANCDetailActivity.this, ancclient.getDetails().get("profilepic"), kiview, R.mipmap.woman_placeholder); - } - else { - kiview.setImageDrawable(getResources().getDrawable(R.mipmap.woman_placeholder)); + + if(ancclient.getCaseId()!=null){//image already in local storage most likey ): + //set profile image by passing the client id.If the image doesn't exist in the image repository then download and save locally + BidanApplication.getInstance().getCachedImageLoaderInstance().getImageByClientId(ancclient.getCaseId(), OpenSRPImageLoader.getStaticImageListener(kiview, R.mipmap.woman_placeholder, R.mipmap.woman_placeholder)); } nama.setText(getResources().getString(R.string.name)+ (ancclient.getColumnmaps().get("namalengkap") != null ? ancclient.getColumnmaps().get("namalengkap") : "-")); diff --git a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/anc/KIANCClientsProvider.java b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/anc/KIANCClientsProvider.java index 62bf71279..885c22df3 100644 --- a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/anc/KIANCClientsProvider.java +++ b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/anc/KIANCClientsProvider.java @@ -24,7 +24,6 @@ import org.ei.opensrp.indonesia.application.BidanApplication; import org.ei.opensrp.repository.DetailsRepository; import org.ei.opensrp.service.AlertService; -import org.ei.opensrp.util.FileUtilities; import org.ei.opensrp.util.OpenSRPImageLoader; import org.ei.opensrp.view.contract.SmartRegisterClient; import org.ei.opensrp.view.contract.SmartRegisterClients; @@ -167,14 +166,10 @@ public void getView(SmartRegisterClient smartRegisterClient, View convertView) { final ImageView kiview = (ImageView)convertView.findViewById(R.id.img_profile); //start profile image viewHolder.profilepic.setTag(R.id.entity_id, pc.getColumnmaps().get("_id"));//required when saving file to disk - if(pc.getDetails().containsKey("imageid") && pc.getDetails().get("imageid")!=null && !pc.getDetails().get("imageid").isEmpty()){//image already in local storage most likey ): - mImageLoader.getImageWithId(pc.getColumnmaps().get("_id"), OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.drawable.woman_placeholder, R.drawable.woman_placeholder)); - - }else{ - //create the url for download the image - String url= FileUtilities.getImageUrl(pc.getColumnmaps().get("_id")); - mImageLoader.get(url, OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.drawable.woman_placeholder, R.drawable.woman_placeholder)); + if(pc.getColumnmaps().get("_id")!=null){//image already in local storage most likey ): + //set profile image by passing the client id.If the image doesn't exist in the image repository then download and save locally + BidanApplication.getInstance().getCachedImageLoaderInstance().getImageByClientId(pc.getColumnmaps().get("_id"), OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.drawable.woman_placeholder, R.drawable.woman_placeholder)); } //end profile image diff --git a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/child/AnakDetailActivity.java b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/child/AnakDetailActivity.java index 23ddbca77..2386eaf99 100644 --- a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/child/AnakDetailActivity.java +++ b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/child/AnakDetailActivity.java @@ -19,9 +19,11 @@ import org.ei.opensrp.commonregistry.CommonPersonObjectClient; import org.ei.opensrp.domain.ProfileImage; import org.ei.opensrp.indonesia.R; +import org.ei.opensrp.indonesia.application.BidanApplication; import org.ei.opensrp.indonesia.kartu_ibu.NativeKISmartRegisterActivity; import org.ei.opensrp.repository.DetailsRepository; import org.ei.opensrp.repository.ImageRepository; +import org.ei.opensrp.util.OpenSRPImageLoader; import java.io.File; import java.io.IOException; @@ -35,7 +37,6 @@ import util.ImageFetcher; import static org.ei.opensrp.util.StringUtil.humanize; -import static org.ei.opensrp.util.StringUtil.humanizeAndDoUPPERCASE; /** * Created by Iq on 07/09/16. */ @@ -51,6 +52,7 @@ public class AnakDetailActivity extends Activity { private static ImageFetcher mImageFetcher; public static CommonPersonObjectClient childclient; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -105,19 +107,19 @@ public void onClick(View v) { DetailsRepository detailsRepository = org.ei.opensrp.Context.getInstance().detailsRepository(); detailsRepository.updateDetails(childclient); - if(childclient.getDetails().get("profilepic")!= null){ - setImagetoHolderFromUri(AnakDetailActivity.this, childclient.getDetails().get("profilepic"), childview, R.drawable.child_boy_infant); - } - else { - if(childclient.getDetails().get("gender") != null && childclient.getDetails().get("gender").equals("laki")) { - childview.setImageDrawable(getResources().getDrawable(R.drawable.child_boy_infant)); - } else if(childclient.getDetails().get("gender") != null && childclient.getDetails().get("gender").equals("male")) { - childview.setImageDrawable(getResources().getDrawable(R.drawable.child_boy_infant)); - } - else { - childview.setImageDrawable(getResources().getDrawable(R.drawable.child_girl_infant)); - } + String gender=childclient.getDetails().containsKey("gender")?childclient.getDetails().get("gender"):"laki"; + + + //start profile image + + int placeholderDrawable= gender.equalsIgnoreCase("male")?R.drawable.child_boy_infant:R.drawable.child_girl_infant; + childview.setTag(R.id.entity_id, childclient.getCaseId());//required when saving file to disk + if(childclient.getCaseId()!=null){//image already in local storage most likey ): + //set profile image by passing the client id.If the image doesn't exist in the image repository then download and save locally + BidanApplication.getInstance().getCachedImageLoaderInstance().getImageByClientId(childclient.getCaseId(), OpenSRPImageLoader.getStaticImageListener(childview, placeholderDrawable, placeholderDrawable)); + } + //end profile image AllCommonsRepository childRepository = org.ei.opensrp.Context.getInstance().allCommonsRepositoryobjects("ec_anak"); diff --git a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/child/AnakRegisterClientsProvider.java b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/child/AnakRegisterClientsProvider.java index 29d8cb135..a2f118070 100644 --- a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/child/AnakRegisterClientsProvider.java +++ b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/child/AnakRegisterClientsProvider.java @@ -21,7 +21,6 @@ import org.ei.opensrp.indonesia.application.BidanApplication; import org.ei.opensrp.repository.DetailsRepository; import org.ei.opensrp.service.AlertService; -import org.ei.opensrp.util.FileUtilities; import org.ei.opensrp.util.OpenSRPImageLoader; import org.ei.opensrp.view.contract.SmartRegisterClient; import org.ei.opensrp.view.contract.SmartRegisterClients; @@ -160,15 +159,11 @@ else if(pc.getDetails().get("gender") != null && pc.getDetails().get("gender").e viewHolder.berat_lahir.setText(pc.getDetails().get("beratLahir")!=null?pc.getDetails().get("beratLahir"):""); //start profile image - viewHolder.profilepic.setTag(R.id.entity_id, pc.getColumnmaps().get("_id"));//required when saving file to disk - if(pc.getDetails().containsKey("imageid") && pc.getDetails().get("imageid")!=null && !pc.getDetails().get("imageid").isEmpty()){//image already in local storage most likey ): - mImageLoader.getImageWithId(pc.getColumnmaps().get("_id"), OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.drawable.woman_placeholder, R.drawable.woman_placeholder)); - - }else{ - //create the url for download the image - String url= FileUtilities.getImageUrl(pc.getColumnmaps().get("_id")); - mImageLoader.get(url, OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.drawable.woman_placeholder, R.drawable.woman_placeholder)); + viewHolder.profilepic.setTag(R.id.entity_id, pc.getCaseId());//required when saving file to disk + if(pc.getCaseId()!=null){//image already in local storage most likey ): + //set profile image by passing the client id.If the image doesn't exist in the image repository then download and save locally + BidanApplication.getInstance().getCachedImageLoaderInstance().getImageByClientId(pc.getCaseId(), OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.mipmap.woman_placeholder, R.mipmap.woman_placeholder)); } //end profile image diff --git a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kartu_ibu/KIClientsProvider.java b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kartu_ibu/KIClientsProvider.java index bf3c3a931..0951695e4 100644 --- a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kartu_ibu/KIClientsProvider.java +++ b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kartu_ibu/KIClientsProvider.java @@ -22,7 +22,6 @@ import org.ei.opensrp.indonesia.application.BidanApplication; import org.ei.opensrp.repository.DetailsRepository; import org.ei.opensrp.service.AlertService; -import org.ei.opensrp.util.FileUtilities; import org.ei.opensrp.util.OpenSRPImageLoader; import org.ei.opensrp.view.contract.SmartRegisterClient; import org.ei.opensrp.view.contract.SmartRegisterClients; @@ -153,14 +152,9 @@ public void getView(SmartRegisterClient smartRegisterClient, View convertView) { viewHolder.visit_status.setText(""); //start profile image viewHolder.profilepic.setTag(R.id.entity_id, pc.getColumnmaps().get("_id"));//required when saving file to disk - if(pc.getDetails().containsKey("imageid") && pc.getDetails().get("imageid")!=null && !pc.getDetails().get("imageid").isEmpty()){//image already in local storage most likey ): - mImageLoader.getImageWithId(pc.getColumnmaps().get("_id"), OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.drawable.woman_placeholder, R.drawable.woman_placeholder)); - - }else{ - //create the url for download the image - String url= FileUtilities.getImageUrl(pc.getColumnmaps().get("_id")); - mImageLoader.get(url, OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.drawable.woman_placeholder, R.drawable.woman_placeholder)); - + if(pc.getCaseId()!=null){//image already in local storage most likey ): + //set profile image by passing the client id.If the image doesn't exist in the image repository then download and save locally + BidanApplication.getInstance().getCachedImageLoaderInstance().getImageByClientId(pc.getCaseId(), OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.mipmap.woman_placeholder, R.mipmap.woman_placeholder)); } //end profile image AllCommonsRepository iburep = org.ei.opensrp.Context.getInstance().allCommonsRepositoryobjects("ec_ibu"); diff --git a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kartu_ibu/KIDetailActivity.java b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kartu_ibu/KIDetailActivity.java index 764c148d5..32072b6da 100644 --- a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kartu_ibu/KIDetailActivity.java +++ b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kartu_ibu/KIDetailActivity.java @@ -14,14 +14,14 @@ import android.widget.TextView; import org.ei.opensrp.Context; -import org.ei.opensrp.commonregistry.AllCommonsRepository; -import org.ei.opensrp.commonregistry.CommonPersonObject; import org.ei.opensrp.commonregistry.CommonPersonObjectClient; import org.ei.opensrp.domain.ProfileImage; import org.ei.opensrp.indonesia.R; +import org.ei.opensrp.indonesia.application.BidanApplication; import org.ei.opensrp.indonesia.lib.FlurryFacade; import org.ei.opensrp.repository.DetailsRepository; import org.ei.opensrp.repository.ImageRepository; +import org.ei.opensrp.util.OpenSRPImageLoader; import java.io.File; import java.io.IOException; @@ -31,10 +31,11 @@ import java.util.Map; import java.util.UUID; -import static org.ei.opensrp.util.StringUtil.humanize; import util.ImageCache; import util.ImageFetcher; +import static org.ei.opensrp.util.StringUtil.humanize; + /** * Created by Iq on 07/09/16. */ @@ -133,13 +134,10 @@ public void onClick(View v) { DetailsRepository detailsRepository = org.ei.opensrp.Context.getInstance().detailsRepository(); detailsRepository.updateDetails(kiclient); - if(kiclient.getDetails().get("profilepic")!= null){ - setImagetoHolderFromUri(KIDetailActivity.this, kiclient.getDetails().get("profilepic"), kiview, R.mipmap.woman_placeholder); - } - else { - kiview.setImageDrawable(getResources().getDrawable(R.mipmap.woman_placeholder)); - } - + //set profile image by passing the client id.If the image doesn't exist in the image repository then download and save locally + BidanApplication.getInstance().getCachedImageLoaderInstance().getImageByClientId(kiclient.getCaseId(), OpenSRPImageLoader.getStaticImageListener(kiview, R.mipmap.woman_placeholder, R.mipmap.woman_placeholder)); + + nama.setText(getResources().getString(R.string.name)+ (kiclient.getColumnmaps().get("namalengkap") != null ? kiclient.getColumnmaps().get("namalengkap") : "-")); nik.setText(getResources().getString(R.string.nik)+ (kiclient.getDetails().get("nik") != null ? kiclient.getDetails().get("nik") : "-")); husband_name.setText(getResources().getString(R.string.husband_name)+ (kiclient.getColumnmaps().get("namaSuami") != null ? kiclient.getColumnmaps().get("namaSuami") : "-")); diff --git a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kb/KBClientsProvider.java b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kb/KBClientsProvider.java index 232f728aa..7e280f532 100644 --- a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kb/KBClientsProvider.java +++ b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kb/KBClientsProvider.java @@ -20,7 +20,6 @@ import org.ei.opensrp.indonesia.application.BidanApplication; import org.ei.opensrp.repository.DetailsRepository; import org.ei.opensrp.service.AlertService; -import org.ei.opensrp.util.FileUtilities; import org.ei.opensrp.util.OpenSRPImageLoader; import org.ei.opensrp.view.contract.SmartRegisterClient; import org.ei.opensrp.view.contract.SmartRegisterClients; @@ -139,14 +138,9 @@ public void getView(SmartRegisterClient smartRegisterClient, View convertView) { final ImageView kiview = (ImageView)convertView.findViewById(R.id.img_profile); //start profile image viewHolder.profilepic.setTag(R.id.entity_id, pc.getColumnmaps().get("_id"));//required when saving file to disk - if(pc.getDetails().containsKey("imageid") && pc.getDetails().get("imageid")!=null && !pc.getDetails().get("imageid").isEmpty()){//image already in local storage most likey ): - mImageLoader.getImageWithId(pc.getColumnmaps().get("_id"), OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.drawable.woman_placeholder, R.drawable.woman_placeholder)); - - }else{ - //create the url for download the image - String url= FileUtilities.getImageUrl(pc.getColumnmaps().get("_id")); - mImageLoader.get(url, OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.drawable.woman_placeholder, R.drawable.woman_placeholder)); - + if(pc.getCaseId()!=null){//image already in local storage most likey ): + //set profile image by passing the client id.If the image doesn't exist in the image repository then download and save locally + BidanApplication.getInstance().getCachedImageLoaderInstance().getImageByClientId(pc.getCaseId(), OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.mipmap.woman_placeholder, R.mipmap.woman_placeholder)); } //end profile image diff --git a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kb/KBDetailActivity.java b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kb/KBDetailActivity.java index 4e66ee285..f7838b486 100644 --- a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kb/KBDetailActivity.java +++ b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/kb/KBDetailActivity.java @@ -19,10 +19,12 @@ import org.ei.opensrp.commonregistry.CommonPersonObjectClient; import org.ei.opensrp.domain.ProfileImage; import org.ei.opensrp.indonesia.R; +import org.ei.opensrp.indonesia.application.BidanApplication; import org.ei.opensrp.indonesia.kartu_ibu.NativeKISmartRegisterActivity; import org.ei.opensrp.indonesia.lib.FlurryFacade; import org.ei.opensrp.repository.DetailsRepository; import org.ei.opensrp.repository.ImageRepository; +import org.ei.opensrp.util.OpenSRPImageLoader; import java.io.File; import java.io.IOException; @@ -147,13 +149,13 @@ public void onClick(View v) { DetailsRepository detailsRepository = org.ei.opensrp.Context.getInstance().detailsRepository(); detailsRepository.updateDetails(kiclient); - if(kiclient.getDetails().get("profilepic")!= null){ - setImagetoHolderFromUri(KBDetailActivity.this, kiclient.getDetails().get("profilepic"), kiview, R.mipmap.woman_placeholder); + if(kiclient.getCaseId()!=null){//image already in local storage most likey ): + //set profile image by passing the client id.If the image doesn't exist in the image repository then download and save locally + BidanApplication.getInstance().getCachedImageLoaderInstance().getImageByClientId(kiclient.getCaseId(), OpenSRPImageLoader.getStaticImageListener(kiview, R.mipmap.woman_placeholder, R.mipmap.woman_placeholder)); } - nama.setText(getResources().getString(R.string.name)+ (kiclient.getColumnmaps().get("namalengkap") != null ? kiclient.getColumnmaps().get("namalengkap") : "-")); nik.setText(getResources().getString(R.string.nik)+ (kiclient.getDetails().get("nik") != null ? kiclient.getDetails().get("nik") : "-")); husband_name.setText(getResources().getString(R.string.husband_name)+ (kiclient.getColumnmaps().get("namaSuami") != null ? kiclient.getColumnmaps().get("namaSuami") : "-")); diff --git a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/pnc/KIPNCClientsProvider.java b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/pnc/KIPNCClientsProvider.java index 04e286846..423483bb9 100644 --- a/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/pnc/KIPNCClientsProvider.java +++ b/opensrp-indonesia/src/main/java/org/ei/opensrp/indonesia/pnc/KIPNCClientsProvider.java @@ -22,7 +22,6 @@ import org.ei.opensrp.indonesia.application.BidanApplication; import org.ei.opensrp.repository.DetailsRepository; import org.ei.opensrp.service.AlertService; -import org.ei.opensrp.util.FileUtilities; import org.ei.opensrp.util.OpenSRPImageLoader; import org.ei.opensrp.view.contract.SmartRegisterClient; import org.ei.opensrp.view.contract.SmartRegisterClients; @@ -190,14 +189,9 @@ public void getView(SmartRegisterClient smartRegisterClient, View convertView) { //start profile image viewHolder.profilepic.setTag(R.id.entity_id, pc.getColumnmaps().get("_id"));//required when saving file to disk - if(pc.getDetails().containsKey("imageid") && pc.getDetails().get("imageid")!=null && !pc.getDetails().get("imageid").isEmpty()){//image already in local storage most likey ): - mImageLoader.getImageWithId(pc.getColumnmaps().get("_id"), OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.drawable.woman_placeholder, R.drawable.woman_placeholder)); - - }else{ - //create the url for download the image - String url= FileUtilities.getImageUrl(pc.getColumnmaps().get("_id")); - mImageLoader.get(url, OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.drawable.woman_placeholder, R.drawable.woman_placeholder)); - + if(pc.getCaseId()!=null){//image already in local storage most likey ): + //set profile image by passing the client id.If the image doesn't exist in the image repository then download and save locally + BidanApplication.getInstance().getCachedImageLoaderInstance().getImageByClientId(pc.getCaseId(), OpenSRPImageLoader.getStaticImageListener(viewHolder.profilepic, R.mipmap.woman_placeholder, R.mipmap.woman_placeholder)); } //end profile image