From df890a6563ceee8f6b396ace0e82c4e91d1ea706 Mon Sep 17 00:00:00 2001 From: "mib.iqbal" Date: Wed, 29 Mar 2017 19:55:33 +0800 Subject: [PATCH] MI | Updating register activity to EC #433 Signed-off-by: mib.iqbal --- opensrp-app/res/xml/preferences.xml | 2 +- .../java/org/ei/opensrp/AllConstants.java | 2 +- .../ei/opensrp/sync/CloudantSyncHandler.java | 2 +- opensrp-sdidtk/build.gradle | 2 +- .../ei/opensrp/ddtk/NativeHomeActivity.java | 44 ++- ...r.java => SdidtkNavigationController.java} | 15 +- .../ddtk/FormulirDdtkServiceModeOption.java | 2 +- .../FormulirDdtkSmartClientsProvider.java | 207 +++++++------ .../FormulirDdtkSmartRegisterActivity.java | 36 +-- .../ddtk/ddtk/KICommonObjectFilterOption.java | 37 +++ .../FormulirDdtkSmartRegisterFragment.java | 280 ++++++++++++++---- .../BaseRegisterActivityPagerAdapter.java | 28 +- .../res/layout/smart_register_ddtk_client.xml | 18 +- .../src/main/res/values/strings.xml | 2 +- 14 files changed, 475 insertions(+), 202 deletions(-) rename opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/{TestNavigationController.java => SdidtkNavigationController.java} (61%) create mode 100644 opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/KICommonObjectFilterOption.java diff --git a/opensrp-app/res/xml/preferences.xml b/opensrp-app/res/xml/preferences.xml index 051e67be0..acfa196b8 100644 --- a/opensrp-app/res/xml/preferences.xml +++ b/opensrp-app/res/xml/preferences.xml @@ -8,7 +8,7 @@ android:summary="Defines the base server url that handles requests" android:dialogTitle="OpenSRP base URL" android:dialogMessage="Enter Base Server Url" - android:defaultValue="http://192.168.12.1:8080/opensrp" + android:defaultValue="http://192.168.12.1:8080/opensrp-demo" android:persistent="true"/> diff --git a/opensrp-app/src/main/java/org/ei/opensrp/AllConstants.java b/opensrp-app/src/main/java/org/ei/opensrp/AllConstants.java index 7efa6bb80..9ee5ce68b 100644 --- a/opensrp-app/src/main/java/org/ei/opensrp/AllConstants.java +++ b/opensrp-app/src/main/java/org/ei/opensrp/AllConstants.java @@ -338,7 +338,7 @@ public static class CloudantSync { public static final String BATCHES_REPLICATED = "BATCHES_REPLICATED"; public static final String COUCHDB_PORT = "5984"; - public static final String COUCH_DATABASE_NAME = "opensrp2"; + public static final String COUCH_DATABASE_NAME = "opensrp-demo"; public static final String COUCH_DATABASE_USER = "admin"; public static final String COUCH_DATABASE_PASS = "Satu2345"; } diff --git a/opensrp-app/src/main/java/org/ei/opensrp/sync/CloudantSyncHandler.java b/opensrp-app/src/main/java/org/ei/opensrp/sync/CloudantSyncHandler.java index 2c5b6261e..a948f0ad8 100644 --- a/opensrp-app/src/main/java/org/ei/opensrp/sync/CloudantSyncHandler.java +++ b/opensrp-app/src/main/java/org/ei/opensrp/sync/CloudantSyncHandler.java @@ -191,7 +191,7 @@ public void reloadReplicationSettings(PullFilter pullFilter) throws URISyntaxExc CloudantDataHandler mCloudantDataHandler = CloudantDataHandler.getInstance(mContext); Datastore mDatastore = mCloudantDataHandler.getDatastore(); - ReplicatorBuilder.Pull mPullBuilder = ReplicatorBuilder.pull().to(mDatastore).from(pullUri); + ReplicatorBuilder.Pull mPullBuilder = ReplicatorBuilder.pull().to(mDatastore).from(uri); ReplicatorBuilder.Push mPushBuilder = ReplicatorBuilder.push().from(mDatastore).to(uri); String username = AllConstants.CloudantSync.COUCH_DATABASE_USER; diff --git a/opensrp-sdidtk/build.gradle b/opensrp-sdidtk/build.gradle index ec14b0b34..504bb1b13 100644 --- a/opensrp-sdidtk/build.gradle +++ b/opensrp-sdidtk/build.gradle @@ -18,7 +18,7 @@ android { buildToolsVersion androidBuildToolsVersion defaultConfig { - applicationId "org.ei.opensrp.sdidtk" + applicationId "org.ei.opensrp.ec_sdidtk" minSdkVersion 16 targetSdkVersion 21 versionCode 21 diff --git a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/NativeHomeActivity.java b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/NativeHomeActivity.java index a6bbd6f7a..96e8aa428 100644 --- a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/NativeHomeActivity.java +++ b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/NativeHomeActivity.java @@ -1,5 +1,6 @@ package org.ei.opensrp.ddtk; +import android.database.Cursor; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -9,6 +10,7 @@ import org.ei.opensrp.Context; import org.ei.opensrp.commonregistry.CommonPersonObjectController; +import org.ei.opensrp.cursoradapter.SmartRegisterQueryBuilder; import org.ei.opensrp.event.Listener; import org.ei.opensrp.service.PendingFormSubmissionService; @@ -20,6 +22,12 @@ import org.ei.opensrp.view.controller.NativeAfterANMDetailsFetchListener; import org.ei.opensrp.view.controller.NativeUpdateANMDetailsTask; import org.ei.opensrp.view.fragment.DisplayFormFragment; +import org.opensrp.api.domain.Location; +import org.opensrp.api.util.EntityUtils; +import org.opensrp.api.util.LocationTree; +import org.opensrp.api.util.TreeNode; + +import java.util.Map; import static android.widget.Toast.LENGTH_SHORT; import static java.lang.String.valueOf; @@ -69,13 +77,13 @@ public void onEvent(String data) { }; private TextView ecRegisterClientCountView; - + private int childcount; @Override protected void onCreation() { //home dashboard setContentView(R.layout.smart_registers_ddtk_home); - navigationController = new TestNavigationController(this,anmController); + navigationController = new org.ei.opensrp.ddtk.SdidtkNavigationController(this,anmController,context()); setupViews(); initialize(); DisplayFormFragment.formInputErrorMessage = getResources().getString(R.string.forminputerror); @@ -86,7 +94,7 @@ protected void onCreation() { private void setupViews() { findViewById(R.id.btn_test_register).setOnClickListener(onRegisterStartListener); - // findViewById(R.id.btn_test2_register).setOnClickListener(onRegisterStartListener); + // findViewById(R.id.btn_test2_register).setOnClickListener(onRegisterStartListener); findViewById(R.id.btn_reporting).setOnClickListener(onButtonsClickListener); @@ -129,13 +137,14 @@ public void afterFetch(HomeContext anmDetails) { } private void updateRegisterCounts(HomeContext homeContext) { - CommonPersonObjectController hhcontroller = new CommonPersonObjectController(context().allCommonsRepositoryobjects("anak"), - context().allBeneficiaries(), context().listCache(), - context().personObjectClientsCache(),"nama_anak","Jenis_kelamin","nama_ibu", CommonPersonObjectController.ByColumnAndByDetails.byDetails); - - + SmartRegisterQueryBuilder sqb = new SmartRegisterQueryBuilder(); + Cursor childcountcursor = context().commonrepository("anak").RawCustomQueryForAdapter(sqb.queryForCountOnRegisters("ec_anak_search", "ec_anak_search.is_closed=0")); + childcountcursor.moveToFirst(); + childcount= childcountcursor.getInt(0); + childcountcursor.close(); - ecRegisterClientCountView.setText(valueOf(hhcontroller.getClients().size())); + ecRegisterClientCountView.setText(valueOf(childcount)); + // ecRegisterClientCountView.setText(valueOf(hhcontroller.getClients().size())); } @@ -170,7 +179,7 @@ public boolean onOptionsItemSelected(MenuItem item) { this.recreate(); return true; case R.id.help: - // startActivity(new Intent(this, tutorialCircleViewFlow.class)); + // startActivity(new Intent(this, tutorialCircleViewFlow.class)); return true; default: return super.onOptionsItemSelected(item); @@ -182,6 +191,11 @@ public void updateFromServer() { this, context().actionService(), context().formSubmissionSyncService(), new SyncProgressIndicator(), context().allFormVersionSyncService()); updateActionsTask.updateFromServer(new SyncAfterFetchListener()); + String locationjson = context().anmLocationController().get(); + LocationTree locationTree = EntityUtils.fromJson(locationjson, LocationTree.class); + + Map> locationMap = + locationTree.getLocationsHierarchy(); } @Override @@ -226,18 +240,16 @@ public void onClick(View view) { navigationController.startECSmartRegistry(); break; - // case R.id.btn_test2_register: - // navigationController.startANCSmartRegistry(); - // break; + // case R.id.btn_test2_register: + // navigationController.startANCSmartRegistry(); + // break; /* case R.id.btn_pnc_register: // navigationController.startPNCSmartRegistry(); break; - case R.id.btn_child_register: // navigationController.startChildSmartRegistry(); break; - case R.id.btn_fp_register: // navigationController.startFPSmartRegistry(); break; */ @@ -258,4 +270,4 @@ public void onClick(View view) { } } }; -} +} \ No newline at end of file diff --git a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/TestNavigationController.java b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/SdidtkNavigationController.java similarity index 61% rename from opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/TestNavigationController.java rename to opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/SdidtkNavigationController.java index 5dacc34e8..7b623380c 100644 --- a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/TestNavigationController.java +++ b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/SdidtkNavigationController.java @@ -11,30 +11,35 @@ import static android.preference.PreferenceManager.getDefaultSharedPreferences; -public class TestNavigationController extends org.ei.opensrp.view.controller.NavigationController { +public class SdidtkNavigationController extends org.ei.opensrp.view.controller.NavigationController { private Activity activity; private ANMController anmController; + private org.ei.opensrp.Context context; - public TestNavigationController(Activity activity, ANMController anmController) { + public SdidtkNavigationController(Activity activity, ANMController anmController) { super(activity,anmController); this.activity = activity; this.anmController = anmController; } + public SdidtkNavigationController(Activity activity, ANMController anmController, org.ei.opensrp.Context context) { + this(activity,anmController); + this.context=context; + } @Override public void startECSmartRegistry() { activity.startActivity(new Intent(activity, FormulirDdtkSmartRegisterActivity.class)); - /// activity.startActivity(new Intent(activity, HouseHoldSmartRegisterActivity.class)); + /// activity.startActivity(new Intent(activity, HouseHoldSmartRegisterActivity.class)); SharedPreferences sharedPreferences = getDefaultSharedPreferences(this.activity); if(sharedPreferences.getBoolean("firstlauch",true)) { sharedPreferences.edit().putBoolean("firstlauch",false).commit(); - // activity.startActivity(new Intent(activity, tutorialCircleViewFlow.class)); + // activity.startActivity(new Intent(activity, tutorialCircleViewFlow.class)); } } @Override public void startFPSmartRegistry() { - // activity.startActivity(new Intent(activity, ElcoSmartRegisterActivity.class)); + // activity.startActivity(new Intent(activity, ElcoSmartRegisterActivity.class)); } @Override public void startANCSmartRegistry() { diff --git a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkServiceModeOption.java b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkServiceModeOption.java index ce4300479..e1e007a5c 100644 --- a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkServiceModeOption.java +++ b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkServiceModeOption.java @@ -43,7 +43,7 @@ public int weightSum() { @Override public int[] weights() { - return new int[]{10,7,7,8,8,8}; + return new int[]{11,7,7,8,8,6}; } @Override diff --git a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkSmartClientsProvider.java b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkSmartClientsProvider.java index cf92fbab2..34f1de596 100644 --- a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkSmartClientsProvider.java +++ b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkSmartClientsProvider.java @@ -14,9 +14,13 @@ import android.widget.LinearLayout; import android.widget.TextView; +import org.ei.opensrp.commonregistry.AllCommonsRepository; +import org.ei.opensrp.commonregistry.CommonPersonObject; import org.ei.opensrp.commonregistry.CommonPersonObjectClient; import org.ei.opensrp.commonregistry.CommonPersonObjectController; +import org.ei.opensrp.cursoradapter.SmartRegisterCLientsProviderForCursorAdapter; import org.ei.opensrp.provider.SmartRegisterClientsProvider; +import org.ei.opensrp.repository.DetailsRepository; import org.ei.opensrp.service.AlertService; import org.ei.opensrp.ddtk.R; import org.ei.opensrp.view.contract.SmartRegisterClient; @@ -27,29 +31,29 @@ import org.ei.opensrp.view.viewHolder.OnClickFormLauncher; +import java.text.SimpleDateFormat; + import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; /** * Created by user on 2/12/15. */ -public class FormulirDdtkSmartClientsProvider implements SmartRegisterClientsProvider{ - +public class FormulirDdtkSmartClientsProvider implements SmartRegisterCLientsProviderForCursorAdapter { private final LayoutInflater inflater; - public final Context context; + private final Context context; private final View.OnClickListener onClickListener; - + private Drawable iconPencilDrawable; private final int txtColorBlack; private final AbsListView.LayoutParams clientViewLayoutParams; - private Drawable iconPencilDrawable; + protected CommonPersonObjectController controller; AlertService alertService; - public FormulirDdtkSmartClientsProvider(Context context, View.OnClickListener onClickListener, - CommonPersonObjectController controller, AlertService alertService) { + AlertService alertService) { this.onClickListener = onClickListener; - this.controller = controller; +// this.controller = controller; this.context = context; this.alertService = alertService; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); @@ -61,22 +65,25 @@ public FormulirDdtkSmartClientsProvider(Context context, } @Override - public View getView(SmartRegisterClient smartRegisterClient, View convertView, ViewGroup viewGroup) { - + public void getView(SmartRegisterClient smartRegisterClient, View convertView) { ViewHolder viewHolder; - ViewGroup itemView = viewGroup; - if (convertView == null){ - convertView = (ViewGroup) inflater().inflate(R.layout.smart_register_ddtk_client, null); + + if(convertView.getTag() == null || !(convertView.getTag() instanceof ViewHolder)){ + viewHolder = new ViewHolder(); viewHolder.profilelayout = (LinearLayout)convertView.findViewById(R.id.profile_info_layout); viewHolder.nama_anak = (TextView)convertView.findViewById(R.id.text_nama_anak); viewHolder.jenis_kelamin = (TextView)convertView.findViewById(R.id.text_jenis_kelamin); viewHolder.umur = (TextView)convertView.findViewById(R.id.text_umur); viewHolder.nama_ibu = (TextView)convertView.findViewById(R.id.text_nama_ibu); + + //kpsp + viewHolder.tgl_kpsp = (TextView)convertView.findViewById(R.id.text_kpsp_test_date); viewHolder.berat = (TextView)convertView.findViewById(R.id.text_berat); viewHolder.tinggi = (TextView)convertView.findViewById(R.id.text_tinggi); viewHolder.lingkar_kepala = (TextView)convertView.findViewById(R.id.text_lingkar_kepala); - viewHolder.kpsp_test_date1 = (TextView)convertView.findViewById(R.id.text_kpsp_test_date); + + /* viewHolder.kpsp_test_date1 = (TextView)convertView.findViewById(R.id.text_kpsp_test_date); viewHolder.status_kembang1 = (TextView)convertView.findViewById(R.id.text_status_kembang); viewHolder.status_kembang2 = (TextView)convertView.findViewById(R.id.text_status_kembang); viewHolder.kpsp_test_date2 = (TextView)convertView.findViewById(R.id.text_kpsp_test_date); @@ -98,17 +105,17 @@ public View getView(SmartRegisterClient smartRegisterClient, View convertView, V viewHolder.sight_test_date = (TextView)convertView.findViewById(R.id.text_sight_test_date); viewHolder.mental_test_date = (TextView)convertView.findViewById(R.id.text_mental_test_date); viewHolder.autis_test_date = (TextView)convertView.findViewById(R.id.text_autis_test_date); - viewHolder.gpph_test_date = (TextView)convertView.findViewById(R.id.text_gpph_test_date); - viewHolder.profilepic =(ImageView)convertView.findViewById(R.id.childdetailprofileview); + viewHolder.gpph_test_date = (TextView)convertView.findViewById(R.id.text_gpph_test_date);*/ + viewHolder.profilepic =(ImageView)convertView.findViewById(R.id.img_profile); viewHolder.follow_up = (ImageButton)convertView.findViewById(R.id.btn_edit); convertView.setTag(viewHolder); - }else{ + } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.follow_up.setOnClickListener(onClickListener); viewHolder.follow_up.setTag(smartRegisterClient); - viewHolder.profilelayout.setOnClickListener(onClickListener); + viewHolder.profilelayout.setOnClickListener(onClickListener); viewHolder.profilelayout.setTag(smartRegisterClient); CommonPersonObjectClient pc = (CommonPersonObjectClient) smartRegisterClient; if (iconPencilDrawable == null) { @@ -116,42 +123,60 @@ public View getView(SmartRegisterClient smartRegisterClient, View convertView, V } viewHolder.follow_up.setImageDrawable(iconPencilDrawable); viewHolder.follow_up.setOnClickListener(onClickListener); - // viewHolder.follow_up.setTag(client); + // viewHolder.follow_up.setTag(client); /* // List alertlist_for_client = alertService.findByEntityIdAndAlertNames(pc.entityId(), "FW CENSUS"); */ - - //set image picture - final ImageView childview = (ImageView)convertView.findViewById(R.id.childdetailprofileview); - - if (pc.getDetails().get("profilepic") == null) { - if (pc.getDetails().get("jenis_kelamin").equalsIgnoreCase("laki_laki")) { - viewHolder.profilepic.setImageResource(org.ei.opensrp.R.drawable.child_boy_infant); - - } else { - - viewHolder.profilepic.setImageResource(org.ei.opensrp.R.drawable.child_girl_infant); - - } - - } if (pc.getDetails().get("profilepic") != null) { - ChildDetailActivity.setImagetoHolderFromUri((Activity) context, pc.getDetails().get("profilepic"), childview, R.drawable.ic_dristhi_logo); + DetailsRepository detailsRepository = org.ei.opensrp.Context.getInstance().detailsRepository(); + detailsRepository.updateDetails(pc); + //set image picture + final ImageView childview = (ImageView)convertView.findViewById(R.id.img_profile); + /* if (pc.getDetails().get("profilepic") != null) { + ChildDetailActivity.setImagetoHolderFromUri((Activity) context, pc.getDetails().get("profilepic"), childview, R.drawable.child_boy_infant); childview.setTag(smartRegisterClient); } - + else { + if(pc.getDetails().get("gender") != null && pc.getDetails().get("gender").equals("male")) { + viewHolder.profilepic.setImageDrawable(context.getResources().getDrawable(R.drawable.child_boy_infant)); + } + else if(pc.getDetails().get("gender") != null && pc.getDetails().get("gender").equals("laki")) { + viewHolder.profilepic.setImageDrawable(context.getResources().getDrawable(R.drawable.child_boy_infant)); + } + else + viewHolder.profilepic.setImageDrawable(context.getResources().getDrawable(R.drawable.child_girl_infant)); + }*/ //viewHolder.profilepic.setImageDrawable(context.getResources().getDrawable(R.drawable.child_boy_infant)); //viewHolder.village.setText(pc.getDetails().get("village") != null ? pc.getDetails().get("village") : ""); - viewHolder.nama_anak.setText(pc.getDetails().get("nama_anak") != null ? pc.getDetails().get("nama_anak").replaceAll("_", " ") : "-"); - viewHolder.jenis_kelamin.setText(pc.getDetails().get("jenis_kelamin") != null ? pc.getDetails().get("jenis_kelamin").replaceAll("_", " ") : "-"); - viewHolder.umur.setText(pc.getDetails().get("umur")!=null?pc.getDetails().get("umur").replaceAll("_", " ")+" Bulan" :"-"); - viewHolder.nama_ibu.setText(pc.getDetails().get("nama_ibu") != null ? pc.getDetails().get("nama_ibu").replaceAll("_", " ") : "-"); - viewHolder.berat.setText("Berat: "+ (pc.getDetails().get("berat")!=null?pc.getDetails().get("berat").replaceAll("_", " "):"-")); + viewHolder.nama_anak.setText(pc.getDetails().get("namaBayi") != null ? pc.getDetails().get("namaBayi").replaceAll("_", " ") : "-"); + String ages = pc.getColumnmaps().get("tanggalLahirAnak").substring(0, pc.getColumnmaps().get("tanggalLahirAnak").indexOf("T")); + viewHolder.umur.setText(pc.getDetails().get("tanggalLahirAnak") != null ? Integer.toString(monthRangeToToday(ages))+"B" : ""); + viewHolder.jenis_kelamin.setText(pc.getDetails().get("gender")!=null?pc.getDetails().get("gender") :"-"); + + AllCommonsRepository childRepository = org.ei.opensrp.Context.getInstance().allCommonsRepositoryobjects("ec_anak"); + CommonPersonObject childobject = childRepository.findByCaseID(pc.entityId()); + AllCommonsRepository kirep = org.ei.opensrp.Context.getInstance().allCommonsRepositoryobjects("ec_kartu_ibu"); + final CommonPersonObject kiparent = kirep.findByCaseID(childobject.getColumnmaps().get("relational_id")); + + if(kiparent != null) { + detailsRepository.updateDetails(kiparent); + String namaayah = kiparent.getDetails().get("namaSuami") != null ? kiparent.getDetails().get("namaSuami") : ""; + String namaibu = kiparent.getColumnmaps().get("namalengkap") != null ? kiparent.getColumnmaps().get("namalengkap") : ""; + + viewHolder.nama_ibu.setText(namaibu + "," + namaayah); + // viewHolder.village_name.setText(kiparent.getDetails().get("address1")!=null?kiparent.getDetails().get("address1") :"-"); + } + + + + /* viewHolder.berat.setText("Berat: "+ (pc.getDetails().get("berat")!=null?pc.getDetails().get("berat").replaceAll("_", " "):"-")); viewHolder.tinggi.setText("Tinggi: "+ (pc.getDetails().get("tinggi") != null ? pc.getDetails().get("tinggi").replaceAll("_", " ") : "-")); viewHolder.lingkar_kepala.setText("Lingkar Kepala: "+ (pc.getDetails().get("lingkar_kepala")!=null?pc.getDetails().get("lingkar_kepala").replaceAll("_", " "):"-")); viewHolder.kpsp_test_date1.setText("Tanggal: "+ (pc.getDetails().get("kpsp_test_date1")!=null?pc.getDetails().get("kpsp_test_date1").replaceAll("_", " "):"-")); + + viewHolder.kpsp_test_date2.setText(pc.getDetails().get("kpsp_test_date2")!=null?pc.getDetails().get("kpsp_test_date2").replaceAll("_", " "):"-"); viewHolder.status_kembang2.setText(pc.getDetails().get("status_kembang2")!=null?pc.getDetails().get("status_kembang2").replaceAll("_", " "):"-"); viewHolder.kpsp_test_date3.setText(pc.getDetails().get("kpsp_test_date3")!=null?pc.getDetails().get("kpsp_test_date3").replaceAll("_", " "):"-"); @@ -177,12 +202,11 @@ public View getView(SmartRegisterClient smartRegisterClient, View convertView, V viewHolder.hear_test_date.setText("Tanggal: "+ (pc.getDetails().get("hear_test_date")!=null?pc.getDetails().get("hear_test_date").replaceAll("_", " "):"-")); // viewHolder.headofhouseholdname.setText(pc.getDetails().get("FWHOHFNAME")!=null?pc.getDetails().get("FWHOHFNAME"):""); // viewHolder.no_of_mwra.setText(pc.getDetails().get("ELCO")!=null?pc.getDetails().get("ELCO"):""); - // Date lastdate = null; + // Date lastdate = null;*/ convertView.setLayoutParams(clientViewLayoutParams); - return convertView; } CommonPersonObjectController householdelcocontroller; @@ -190,7 +214,6 @@ public View getView(SmartRegisterClient smartRegisterClient, View convertView, V - @Override public SmartRegisterClients getClients() { return controller.getClients(); } @@ -214,49 +237,61 @@ public OnClickFormLauncher newFormLauncher(String formName, String entityId, Str public LayoutInflater inflater() { return inflater; } + @Override + public View inflatelayoutForCursorAdapter() { + View View = inflater().inflate(R.layout.smart_register_ddtk_client, null); + return View; + } + private int monthRangeToToday(String lastVisitDate){ + String currentDate[] = new SimpleDateFormat("yyyy-MM").format(new java.util.Date()).substring(0,7).split("-"); + return ((Integer.parseInt(currentDate[0]) - Integer.parseInt(lastVisitDate.substring(0,4)))*12 + + (Integer.parseInt(currentDate[1]) - Integer.parseInt(lastVisitDate.substring(5,7)))); + } - class ViewHolder { - - TextView today ; - TextView umur; - TextView village; - TextView husbandname; - LinearLayout profilelayout; - LinearLayout antrolayout; - ImageView profilepic; - FrameLayout due_date_holder; - Button warnbutton; - ImageButton follow_up; - TextView nama_anak; - TextView jenis_kelamin; - TextView nama_ibu; - TextView berat; - TextView tinggi; - TextView lingkar_kepala; - TextView status_kembang1; - TextView status_kembang2; - TextView status_kembang3; - TextView status_kembang4; - TextView status_kembang5; - TextView status_kembang6; - TextView daya_dengar; - TextView daya_lihat; - TextView mental_emosional; - TextView autis; - TextView gpph; - TextView anthropometry_date; - TextView hear_test_date; - TextView sight_test_date; - TextView mental_test_date; - TextView autis_test_date; - TextView kpsp_test_date1; - TextView kpsp_test_date2; - TextView kpsp_test_date3; - TextView kpsp_test_date4; - TextView kpsp_test_date5; - TextView kpsp_test_date6; - TextView gpph_test_date; - } + class ViewHolder { + + TextView today ; + TextView umur; + TextView village; + TextView husbandname; + LinearLayout profilelayout; + LinearLayout antrolayout; + ImageView profilepic; + FrameLayout due_date_holder; + Button warnbutton; + ImageButton follow_up; + TextView nama_anak; + TextView jenis_kelamin; + TextView nama_ibu; + TextView berat; + TextView tinggi; + TextView lingkar_kepala; + TextView status_kembang1; + TextView status_kembang2; + TextView status_kembang3; + TextView status_kembang4; + TextView status_kembang5; + TextView status_kembang6; + TextView daya_dengar; + TextView daya_lihat; + TextView mental_emosional; + TextView autis; + TextView gpph; + TextView anthropometry_date; + TextView hear_test_date; + TextView sight_test_date; + TextView mental_test_date; + TextView autis_test_date; + TextView kpsp_test_date1; + TextView kpsp_test_date2; + TextView kpsp_test_date3; + TextView kpsp_test_date4; + TextView kpsp_test_date5; + TextView kpsp_test_date6; + TextView gpph_test_date; + TextView village_name; + TextView tgl_kpsp; + } } diff --git a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkSmartRegisterActivity.java b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkSmartRegisterActivity.java index 1a6baa58c..d59f32bdf 100644 --- a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkSmartRegisterActivity.java +++ b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/FormulirDdtkSmartRegisterActivity.java @@ -106,21 +106,21 @@ public void startRegistration() { } public DialogOption[] getEditOptions() { - return new DialogOption[]{ - new OpenFormOption("Antropometri", "antropometri", formController), - new OpenFormOption("Kpsp Bayi 1 Tahun", "kpsp_bayi_1thn", formController), - new OpenFormOption("Kpsp Balita 2 Tahun", "kpsp_balita_2thn", formController), - new OpenFormOption("Kpsp Balita 3 Tahun", "kpsp_balita_3thn", formController), - new OpenFormOption("Kpsp Balita 4 Tahun", "kpsp_balita_4thn", formController), - new OpenFormOption("Kpsp Balita 5 Tahun", "kpsp_balita_5thn", formController), - new OpenFormOption("Kpsp Balita 6 Tahun", "kpsp_balita_6thn", formController), - new OpenFormOption("Tes Daya Dengar", "tes_daya_dengar", formController), - new OpenFormOption("Tes Daya Lihat", "tes_daya_lihat", formController), - new OpenFormOption("Masalah Mental Emosional", "masalah_mental_emosional", formController), - new OpenFormOption("Deteksi Dini Autis", "deteksi_dini_autis", formController), - new OpenFormOption("GPPH", "gangguan_konsentrasi_hiperaktivitas", formController), - - }; + return new DialogOption[]{ + new OpenFormOption("Antropometri", "antropometri", formController), + new OpenFormOption("Kpsp Bayi 1 Tahun", "kpsp_bayi_1thn", formController), + new OpenFormOption("Kpsp Balita 2 Tahun", "kpsp_balita_2thn", formController), + new OpenFormOption("Kpsp Balita 3 Tahun", "kpsp_balita_3thn", formController), + new OpenFormOption("Kpsp Balita 4 Tahun", "kpsp_balita_4thn", formController), + new OpenFormOption("Kpsp Balita 5 Tahun", "kpsp_balita_5thn", formController), + new OpenFormOption("Kpsp Balita 6 Tahun", "kpsp_balita_6thn", formController), + new OpenFormOption("Tes Daya Dengar", "tes_daya_dengar", formController), + new OpenFormOption("Tes Daya Lihat", "tes_daya_lihat", formController), + new OpenFormOption("Masalah Mental Emosional", "masalah_mental_emosional", formController), + new OpenFormOption("Deteksi Dini Autis", "deteksi_dini_autis", formController), + new OpenFormOption("GPPH", "gangguan_konsentrasi_hiperaktivitas", formController), + + }; } @@ -169,7 +169,7 @@ public void saveFormSubmission(String formSubmission, String id, String formName @Override public void startFormActivity(String formName, String entityId, String metaData) { - // Log.v("fieldoverride", metaData); + // Log.v("fieldoverride", metaData); try { int formIndex = FormUtils.getIndexForFormName(formName, formNames) + 1; // add the offset if (entityId != null || metaData != null){ @@ -183,7 +183,7 @@ public void startFormActivity(String formName, String entityId, String metaData) DisplayFormFragment displayFormFragment = getDisplayFormFragmentAtIndex(formIndex); if (displayFormFragment != null) { displayFormFragment.setFormData(data); - // displayFormFragment.loadFormData(); + // displayFormFragment.loadFormData(); displayFormFragment.setRecordId(entityId); displayFormFragment.setFieldOverides(metaData); } @@ -213,7 +213,7 @@ public void run() { if (displayFormFragment != null) { displayFormFragment.hideTranslucentProgressDialog(); displayFormFragment.setFormData(null); - // displayFormFragment.loadFormData(); + // displayFormFragment.loadFormData(); } displayFormFragment.setRecordId(null); diff --git a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/KICommonObjectFilterOption.java b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/KICommonObjectFilterOption.java new file mode 100644 index 000000000..2b601ef15 --- /dev/null +++ b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/ddtk/KICommonObjectFilterOption.java @@ -0,0 +1,37 @@ +package org.ei.opensrp.ddtk.ddtk; + +import org.ei.opensrp.cursoradapter.CursorFilterOption; +import org.ei.opensrp.view.contract.SmartRegisterClient; + +public class KICommonObjectFilterOption implements CursorFilterOption { + public final String criteria; + public final String fieldname; + private final String filterOptionName; + + @Override + public String filter() { + + + return " and ec_anak.relational_id IN (SELECT DISTINCT base_entity_id FROM ec_details WHERE value MATCH '"+criteria+"')"; + + } + + + + public KICommonObjectFilterOption(String criteria, String fieldname, String filteroptionname) { + this.criteria = criteria; + this.fieldname = fieldname; + this.filterOptionName = filteroptionname; + } + + @Override + public String name() { + return filterOptionName; + } + + @Override + public boolean filter(SmartRegisterClient client) { + + return false; + } +} diff --git a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/fragment/FormulirDdtkSmartRegisterFragment.java b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/fragment/FormulirDdtkSmartRegisterFragment.java index 8f4aeddf7..ccebf8406 100644 --- a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/fragment/FormulirDdtkSmartRegisterFragment.java +++ b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/fragment/FormulirDdtkSmartRegisterFragment.java @@ -1,19 +1,30 @@ package org.ei.opensrp.ddtk.fragment; +import android.app.AlertDialog; import android.app.Fragment; import android.app.FragmentTransaction; +import android.content.DialogInterface; import android.content.Intent; import android.text.Editable; import android.text.TextWatcher; import android.view.View; +import android.widget.EditText; +import android.widget.Toast; import org.ei.opensrp.Context; import org.ei.opensrp.adapter.SmartRegisterPaginatedAdapter; import org.ei.opensrp.commonregistry.CommonObjectSort; import org.ei.opensrp.commonregistry.CommonPersonObjectClient; import org.ei.opensrp.commonregistry.CommonPersonObjectController; +import org.ei.opensrp.commonregistry.CommonRepository; +import org.ei.opensrp.cursoradapter.CursorCommonObjectFilterOption; +import org.ei.opensrp.cursoradapter.CursorCommonObjectSort; +import org.ei.opensrp.cursoradapter.SecuredNativeSmartRegisterCursorAdapterFragment; +import org.ei.opensrp.cursoradapter.SmartRegisterPaginatedCursorAdapter; +import org.ei.opensrp.cursoradapter.SmartRegisterQueryBuilder; import org.ei.opensrp.ddtk.LoginActivity; import org.ei.opensrp.ddtk.ddtk.FormulirDdtkServiceModeOption; +import org.ei.opensrp.ddtk.ddtk.KICommonObjectFilterOption; import org.ei.opensrp.provider.SmartRegisterClientsProvider; import org.ei.opensrp.ddtk.R; @@ -21,6 +32,8 @@ import org.ei.opensrp.ddtk.ddtk.FormulirDdtkSmartRegisterActivity; import org.ei.opensrp.ddtk.ddtk.FormulirDdtkSearchOption; import org.ei.opensrp.ddtk.ddtk.FormulirDdtkSmartClientsProvider; +import org.ei.opensrp.sync.ClientProcessor; +import org.ei.opensrp.util.StringUtil; import org.ei.opensrp.view.activity.SecuredNativeSmartRegisterActivity; import org.ei.opensrp.view.contract.ECClient; import org.ei.opensrp.view.contract.SmartRegisterClient; @@ -32,6 +45,7 @@ import org.ei.opensrp.view.dialog.DialogOptionModel; import org.ei.opensrp.view.dialog.EditOption; import org.ei.opensrp.view.dialog.FilterOption; +import org.ei.opensrp.view.dialog.LocationSelectorDialogFragment; import org.ei.opensrp.view.dialog.NameSort; import org.ei.opensrp.view.dialog.ServiceModeOption; import org.ei.opensrp.view.dialog.SortOption; @@ -53,25 +67,24 @@ /** * Created by koros on 10/12/15. */ -public class FormulirDdtkSmartRegisterFragment extends SecuredNativeSmartRegisterFragment { +public class FormulirDdtkSmartRegisterFragment extends SecuredNativeSmartRegisterCursorAdapterFragment { private SmartRegisterClientsProvider clientProvider = null; private CommonPersonObjectController controller; private VillageController villageController; private DialogOptionMapper dialogOptionMapper; - + private ClientProcessor clientProcessor; private final ClientActionHandler clientActionHandler = new ClientActionHandler(); private String locationDialogTAG = "locationDialogTAG"; - @Override protected void onCreation() { // } - @Override - protected SmartRegisterPaginatedAdapter adapter() { - return new SmartRegisterPaginatedAdapter(clientsProvider()); - } +// @Override +// protected SmartRegisterPaginatedAdapter adapter() { +// return new SmartRegisterPaginatedAdapter(clientsProvider()); +// } @Override protected SecuredNativeSmartRegisterActivity.DefaultOptionsProvider getDefaultOptionsProvider() { @@ -79,8 +92,7 @@ protected SecuredNativeSmartRegisterActivity.DefaultOptionsProvider getDefaultOp @Override public ServiceModeOption serviceMode() { - - return new FormulirDdtkServiceModeOption(clientsProvider()); + return new FormulirDdtkServiceModeOption(clientsProvider()); } @Override @@ -91,7 +103,6 @@ public FilterOption villageFilter() { @Override public SortOption sortOption() { return new NameSort(); - // return new HouseholdCensusDueDateSort(); } @@ -108,19 +119,17 @@ protected SecuredNativeSmartRegisterActivity.NavBarOptionsProvider getNavBarOpti @Override public DialogOption[] filterOptions() { - + // FlurryAgent.logEvent("click_filter_option_on_kohort_ibu_dashboard"); ArrayList dialogOptionslist = new ArrayList(); - dialogOptionslist.add(new AllClientsFilter()); - // dialogOptionslist.add( new NOHHMWRAEXISTFilterOption("0","ELCO", NOHHMWRAEXISTFilterOption.ByColumnAndByDetails.byDetails)); - // dialogOptionslist.add(new HHMWRAEXISTFilterOption("0","ELCO", HHMWRAEXISTFilterOption.ByColumnAndByDetails.byDetails)); + dialogOptionslist.add(new CursorCommonObjectFilterOption(getString(R.string.filter_by_all_label),filterStringForAll())); String locationjson = context().anmLocationController().get(); LocationTree locationTree = EntityUtils.fromJson(locationjson, LocationTree.class); Map> locationMap = locationTree.getLocationsHierarchy(); - // addChildToList(dialogOptionslist,locationMap); + addChildToList(dialogOptionslist,locationMap); DialogOption[] dialogOptions = new DialogOption[dialogOptionslist.size()]; for (int i = 0;i < dialogOptionslist.size();i++){ dialogOptions[i] = dialogOptionslist.get(i); @@ -136,14 +145,14 @@ public DialogOption[] serviceModeOptions() { @Override public DialogOption[] sortingOptions() { + // FlurryFacade.logEvent("click_sorting_option_on_kohort_ibu_dashboard"); return new DialogOption[]{ // new HouseholdCensusDueDateSort(), - new CommonObjectSort(CommonObjectSort.ByColumnAndByDetails.byDetails, false, "nama_anak", getResources().getString(R.string.child_alphabetical_sort)), - new CommonObjectSort(CommonObjectSort.ByColumnAndByDetails.byDetails, false, "nama_ibu", getResources().getString(R.string.mothername_alphabetical_sort)), - new CommonObjectSort(CommonObjectSort.ByColumnAndByDetails.byDetails, false, "umur", getResources().getString(R.string.age_alphabetical_sort)), -//"" -// new CommonObjectSort(true,false,true,"age") + + new CursorCommonObjectSort(getResources().getString(R.string.sort_by_name_label),KiSortByNameAZ()), + new CursorCommonObjectSort(getResources().getString(R.string.sort_by_name_label_reverse),KiSortByNameZA()), + }; } @@ -154,13 +163,15 @@ public String searchHint() { }; } + + @Override protected SmartRegisterClientsProvider clientsProvider() { - if (clientProvider == null) { - clientProvider = new FormulirDdtkSmartClientsProvider( - getActivity(),clientActionHandler , controller,context().alertService()); - } - return clientProvider; +// if (clientProvider == null) { +// clientProvider = new HouseHoldSmartClientsProvider( +// getActivity(),clientActionHandler , context().alertService()); +// } + return null; } private DialogOption[] getEditOptions() { @@ -169,18 +180,7 @@ private DialogOption[] getEditOptions() { @Override protected void onInitialization() { - if (controller == null) { - controller = new CommonPersonObjectController(context().allCommonsRepositoryobjects("anak"), - context().allBeneficiaries(), context().listCache(), - context().personObjectClientsCache(), "nama_anak", "jenis_kelamin", "nama_ibu", - CommonPersonObjectController.ByColumnAndByDetails.byDetails.byDetails); - - } - //controller = new CommonPersonObjectController(context().allCommonsRepositoryobjects("mother"), - // context().allBeneficiaries(), context().listCache(), - // context().personObjectClientsCache(),"nama","mother"); - dialogOptionMapper = new DialogOptionMapper(); - // context().formSubmissionRouter().getHandlerMap().put("census_enrollment_form",new CensusEnrollmentHandler()); + // context().formSubmissionRouter().getHandlerMap().put("census_enrollment_form", new CensusEnrollmentHandler()); } @Override @@ -189,12 +189,55 @@ public void setupViews(View view) { super.setupViews(view); view.findViewById(R.id.btn_report_month).setVisibility(INVISIBLE); - - setServiceModeViewDrawableRight(null); + view.findViewById(R.id.service_mode_selection).setVisibility(View.GONE); + clientsView.setVisibility(View.VISIBLE); + clientsProgressView.setVisibility(View.INVISIBLE); +// list.setBackgroundColor(Color.RED); + initializeQueries(); + } + private String filterStringForAll(){ + return ""; + } + private String sortByAlertmethod() { + return " CASE WHEN alerts.status = 'urgent' THEN '1'" + + + "WHEN alerts.status = 'upcoming' THEN '2'\n" + + "WHEN alerts.status = 'normal' THEN '3'\n" + + "WHEN alerts.status = 'expired' THEN '4'\n" + + "WHEN alerts.status is Null THEN '5'\n" + + "Else alerts.status END ASC"; + } + public void initializeQueries(){ + FormulirDdtkSmartClientsProvider kiscp = new FormulirDdtkSmartClientsProvider(getActivity(),clientActionHandler,context().alertService()); + clientAdapter = new SmartRegisterPaginatedCursorAdapter(getActivity(), null, kiscp, new CommonRepository("ec_anak",new String []{"tanggalLahirAnak","namaBayi"})); + clientsView.setAdapter(clientAdapter); + + setTablename("ec_anak"); + SmartRegisterQueryBuilder countqueryBUilder = new SmartRegisterQueryBuilder(); + countqueryBUilder.SelectInitiateMainTableCounts("ec_anak"); + mainCondition = " is_closed = 0 "; + countSelect = countqueryBUilder.mainCondition(" is_closed = 0 "); + // mainCondition = " isClosed !='true' "; + super.CountExecute(); + + SmartRegisterQueryBuilder queryBUilder = new SmartRegisterQueryBuilder(); + queryBUilder.SelectInitiateMainTable("ec_anak", new String[]{"ec_anak.relationalid","ec_anak.is_closed","ec_anak.details","tanggalLahirAnak","namaBayi"}); + mainSelect = queryBUilder.mainCondition(" is_closed = 0 "); + // Sortqueries = KiSortByNameAZ(); + + currentlimit = 20; + currentoffset = 0; + + super.filterandSortInInitializeQueries(); + +// setServiceModeViewDrawableRight(null); updateSearchView(); -// checkforNidMissing(view); + refresh(); + + } + @Override public void startRegistration() { FragmentTransaction ft = getActivity().getFragmentManager().beginTransaction(); @@ -202,24 +245,34 @@ public void startRegistration() { if (prev != null) { ft.remove(prev); } + + // String uniqueIdJson = LoginActivity.generator.uniqueIdController().getUniqueIdJson(); + /* if(uniqueIdJson == null || uniqueIdJson.isEmpty()){ + Toast.makeText(getActivity(),"No unique id",Toast.LENGTH_LONG).show(); + return; + }*/ + ft.addToBackStack(null); - TestLocationSelectorDialogFragment - .newInstance((FormulirDdtkSmartRegisterActivity) getActivity(), new EditDialogOptionModel(), context().anmLocationController().get(), "formulir_ddtk") + LocationSelectorDialogFragment +//<<<<<<< HEAD +// .newInstance((GiziSmartRegisterActivity) getActivity(), new EditDialogOptionModel(), context.anmLocationController().get(), "registrasi_gizi") +//======= + .newInstance((FormulirDdtkSmartRegisterActivity) getActivity(), new EditDialogOptionModel(), context().anmLocationController().get(), "registrasi_gizi") +//>>>>>>> a226fad729247ae36c3882a71e1d3f15be4ade8a .show(ft, locationDialogTAG); } private class ClientActionHandler implements View.OnClickListener { - @Override public void onClick(View view) { switch (view.getId()) { case R.id.profile_info_layout: + CharSequence selections[] = new CharSequence[] {"Detail View", "Charts"}; ChildDetailActivity.childclient = (CommonPersonObjectClient) view.getTag(); - Intent intent = new Intent(getActivity(), ChildDetailActivity.class); - startActivity(intent); - getActivity().finish(); + break; //untuk follow up button case R.id.btn_edit: + // FlurryFacade.logEvent("click_button_edit_vaksinator"); showFragmentDialog(new EditDialogOptionModel(), view.getTag()); break; } @@ -230,25 +283,64 @@ private void showProfileView(ECClient client) { } } + + + private String KiSortByNameAZ() { + return " namaBayi ASC"; + } + private String KiSortByNameZA() { + return " namaBayi DESC"; + } + private String KiSortByAgeASC() { + return " tanggalLahirAnak DESC"; + } + private String KiSortByAgeDESC() { + return " tanggalLahirAnak ASC"; + } + + private String KiSortByAge() { + return " umur DESC"; + } + private String KiSortByNoIbu() { + return " noIbu ASC"; + } + + private String KiSortByEdd() { + return " htp IS NULL, htp"; + } + + private class EditDialogOptionModel implements DialogOptionModel { @Override public DialogOption[] getDialogOptions() { return getEditOptions(); } - @Override public void onDialogOptionSelection(DialogOption option, Object tag) { + + + /*if(option.name().equalsIgnoreCase(getString(R.string.str_register_anc_form)) ) { + CommonPersonObjectClient pc = KIDetailActivity.kiclient; + if(pc.getDetails().get("ibu.type")!= null) { + if (pc.getDetails().get("ibu.type").equals("anc") || pc.getDetails().get("ibu.type").equals("pnc")) { + Toast.makeText(getActivity().getApplicationContext(), getString(R.string.mother_already_registered), Toast.LENGTH_SHORT).show(); + return; + } + } + }*/ onEditSelection((EditOption) option, (SmartRegisterClient) tag); } } @Override protected void onResumption() { - super.onResumption(); +// super.onResumption(); getDefaultOptionsProvider(); - updateSearchView(); - //checkforNidMissing(mView); - + if(isPausedOrRefreshList()) { + initializeQueries(); + } + // updateSearchView(); +// try{ LoginActivity.setLanguage(); }catch (Exception e){ @@ -256,6 +348,57 @@ protected void onResumption() { } } + @Override + public void setupSearchView(View view) { + searchView = (EditText) view.findViewById(org.ei.opensrp.R.id.edt_search); + searchView.setHint(getNavBarOptionsProvider().searchHint()); + searchView.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { + } + + @Override + public void onTextChanged(final CharSequence cs, int start, int before, int count) { + + (new AsyncTask() { + SmartRegisterClients filteredClients; + + @Override + protected Object doInBackground(Object[] params) { +// currentSearchFilter = +// setCurrentSearchFilter(new HHSearchOption(cs.toString())); +// filteredClients = getClientsAdapter().getListItemProvider() +// .updateClients(getCurrentVillageFilter(), getCurrentServiceModeOption(), +// getCurrentSearchFilter(), getCurrentSortOption()); +// + filters = cs.toString(); + joinTable = ""; + mainCondition = " is_closed = 0 AND namaBayi !='' "; + return null; + } + + @Override + protected void onPostExecute(Object o) { +// clientsAdapter +// .refreshList(currentVillageFilter, currentServiceModeOption, +// currentSearchFilter, currentSortOption); +// getClientsAdapter().refreshClients(filteredClients); +// getClientsAdapter().notifyDataSetChanged(); + getSearchCancelView().setVisibility(isEmpty(cs) ? INVISIBLE : VISIBLE); + CountExecute(); + filterandSortExecute(); + super.onPostExecute(o); + } + }).execute(); + } + + @Override + public void afterTextChanged(Editable editable) { + } + }); + searchCancelView = view.findViewById(org.ei.opensrp.R.id.btn_search_cancel); + searchCancelView.setOnClickListener(searchCancelHandler); + } public void updateSearchView(){ getSearchView().addTextChangedListener(new TextWatcher() { @@ -271,12 +414,15 @@ public void onTextChanged(final CharSequence cs, int start, int before, int coun @Override protected Object doInBackground(Object[] params) { // currentSearchFilter = - setCurrentSearchFilter(new FormulirDdtkSearchOption(cs.toString())); - filteredClients = getClientsAdapter().getListItemProvider() - .updateClients(getCurrentVillageFilter(), getCurrentServiceModeOption(), - getCurrentSearchFilter(), getCurrentSortOption()); - +// setCurrentSearchFilter(new HHSearchOption(cs.toString())); +// filteredClients = getClientsAdapter().getListItemProvider() +// .updateClients(getCurrentVillageFilter(), getCurrentServiceModeOption(), +// getCurrentSearchFilter(), getCurrentSortOption()); +// + filters = cs.toString(); + joinTable = ""; + mainCondition = " is_closed = 0 AND namaBayi !='' "; return null; } @@ -285,9 +431,10 @@ protected void onPostExecute(Object o) { // clientsAdapter // .refreshList(currentVillageFilter, currentServiceModeOption, // currentSearchFilter, currentSortOption); - getClientsAdapter().refreshClients(filteredClients); - getClientsAdapter().notifyDataSetChanged(); +// getClientsAdapter().refreshClients(filteredClients); +// getClientsAdapter().notifyDataSetChanged(); getSearchCancelView().setVisibility(isEmpty(cs) ? INVISIBLE : VISIBLE); + filterandSortExecute(); super.onPostExecute(o); } }).execute(); @@ -307,7 +454,22 @@ public void afterTextChanged(Editable editable) { } }); } + public void addChildToList(ArrayList dialogOptionslist,Map> locationMap){ + for(Map.Entry> entry : locationMap.entrySet()) { + + if(entry.getValue().getChildren() != null) { + addChildToList(dialogOptionslist,entry.getValue().getChildren()); + + }else{ + StringUtil.humanize(entry.getValue().getLabel()); + String name = StringUtil.humanize(entry.getValue().getLabel()); + dialogOptionslist.add(new KICommonObjectFilterOption(name,"desa", name)); + + } + } + } + -} +} \ No newline at end of file diff --git a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/pageradapter/BaseRegisterActivityPagerAdapter.java b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/pageradapter/BaseRegisterActivityPagerAdapter.java index abfd3cbbd..6001f1609 100644 --- a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/pageradapter/BaseRegisterActivityPagerAdapter.java +++ b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/pageradapter/BaseRegisterActivityPagerAdapter.java @@ -14,12 +14,23 @@ public class BaseRegisterActivityPagerAdapter extends FragmentPagerAdapter { public static final String ARG_PAGE = "page"; String[] dialogOptions; Fragment mBaseFragment; + Fragment mProfileFragment; + public int offset = 0; public BaseRegisterActivityPagerAdapter(FragmentManager fragmentManager, String[] dialogOptions, Fragment baseFragment) { super(fragmentManager); this.dialogOptions = dialogOptions; this.mBaseFragment = baseFragment; + offset += 1; } + public BaseRegisterActivityPagerAdapter(FragmentManager fragmentManager, String[] dialogOptions, Fragment baseFragment, Fragment mProfileFragment) { + super(fragmentManager); + this.dialogOptions = dialogOptions; + this.mBaseFragment = baseFragment; + this.mProfileFragment = mProfileFragment; + offset += 2; + } + @Override public Fragment getItem(int position) { @@ -28,9 +39,13 @@ public Fragment getItem(int position) { case 0: fragment = mBaseFragment; break; - + case 1: + if(mProfileFragment != null) { + fragment = mProfileFragment; + break; + } default: - String formName = dialogOptions[position - 1]; // account for the base fragment + String formName = dialogOptions[position - offset]; // account for the base fragment DisplayFormFragment f = new DisplayFormFragment(); f.setFormName(formName); fragment = f; @@ -45,6 +60,11 @@ public Fragment getItem(int position) { @Override public int getCount() { - return dialogOptions.length + 1; // index 0 is always occupied by the base fragment + return dialogOptions.length + offset; // index 0 is always occupied by the base fragment + } + + public int offset() { + return offset; } -} + +} \ No newline at end of file diff --git a/opensrp-sdidtk/src/main/res/layout/smart_register_ddtk_client.xml b/opensrp-sdidtk/src/main/res/layout/smart_register_ddtk_client.xml index db04b1599..702764d29 100644 --- a/opensrp-sdidtk/src/main/res/layout/smart_register_ddtk_client.xml +++ b/opensrp-sdidtk/src/main/res/layout/smart_register_ddtk_client.xml @@ -10,7 +10,7 @@ android:orientation="horizontal" android:layout_width="0dp" android:layout_height="fill_parent" - android:layout_weight="1.8" + android:layout_weight="2.13" android:id="@+id/profile_info_layout"> @@ -39,7 +39,7 @@ style="@style/CustomFontTextViewStyle.ListView.Medium" android:text="Medium Text" android:id="@+id/text_nama_anak" - android:textSize="15dp" /> + android:textSize="13dp" /> + android:textSize="13dp" + android:id="@+id/text_nama_ibu" /> + android:textSize="13dp" + android:id="@+id/text_jenis_kelamin" /> + android:textSize="13dp" + android:id="@+id/text_umur" /> + + - SDIDTK + EC SDIDTK Masukan nama pengguna Masukan password Log In