Skip to content

Commit

Permalink
WD| FIX search on Child Cohort #4
Browse files Browse the repository at this point in the history
  • Loading branch information
baksosapi committed Nov 29, 2017
1 parent caf08b3 commit 476b6fd
Show file tree
Hide file tree
Showing 8 changed files with 321 additions and 286 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import org.smartregister.Context;
import org.smartregister.bidan.R;
//import org.smartregister.bidan.lib.FlurryFacade;
import org.smartregister.commonregistry.AllCommonsRepository;
import org.smartregister.commonregistry.CommonPersonObject;
import org.smartregister.commonregistry.CommonPersonObjectClient;
Expand All @@ -25,6 +24,8 @@

import static org.smartregister.util.StringUtil.humanize;

//import org.smartregister.bidan.lib.FlurryFacade;

/**
* Created by Iq on 07/09/16.
*/
Expand All @@ -33,10 +34,19 @@ public class AnakDetailActivity extends Activity {
//image retrieving
private static final String TAG = AnakDetailActivity.class.getSimpleName();
public static CommonPersonObjectClient childclient;

static String entityid;
private static HashMap<String, String> hash;
private boolean updateMode = false;
static String entityid;

public static void setImagetoHolderFromUri(Activity activity, String file, ImageView view, int placeholder) {
view.setImageDrawable(activity.getResources().getDrawable(placeholder));
File externalFile = new File(file);
if (externalFile.exists()) {
Uri external = Uri.fromFile(externalFile);
view.setImageURI(external);
}

}

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -47,19 +57,19 @@ protected void onCreate(Bundle savedInstanceState) {
final ImageView childview = (ImageView)findViewById(R.id.childdetailprofileview);
//header
// TextView today = (TextView) findViewById(R.id.detail_today);

//profile
TextView nama = (TextView) findViewById(R.id.txt_child_name);
TextView mother = (TextView) findViewById(R.id.txt_mother_name);
TextView father = (TextView) findViewById(R.id.txt_father_number);
TextView dob = (TextView) findViewById(R.id.txt_dob);

// TextView phone = (TextView) findViewById(R.id.txt_contact_phone_number);
// TextView risk1 = (TextView) findViewById(R.id.txt_risk1);
// TextView risk2 = (TextView) findViewById(R.id.txt_risk2);
// TextView risk3 = (TextView) findViewById(R.id.txt_risk3);
// TextView risk4 = (TextView) findViewById(R.id.txt_risk4);

//detail data
TextView txt_noBayi = (TextView) findViewById(R.id.txt_noBayi);
TextView txt_jenisKelamin = (TextView) findViewById(R.id.txt_jenisKelamin);
Expand Down Expand Up @@ -106,11 +116,10 @@ public void onClick(View v) {


//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 ):
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
// DrishtiApplication.getCachedImageLoaderInstance().getImageByClientId(childclient.getCaseId(), OpenSRPImageLoader.getStaticImageListener(childview, placeholderDrawable, placeholderDrawable));

Expand All @@ -127,7 +136,7 @@ public void onClick(View v) {

// AllCommonsRepository iburep = org.smartregister.Context.getInstance().allCommonsRepositoryobjects("ec_ibu");
// final CommonPersonObject ibuparent = iburep.findByCaseID(childobject.getColumnmaps().get("relational_id"));

AllCommonsRepository kirep = org.smartregister.Context.getInstance().allCommonsRepositoryobjects("ec_kartu_ibu");
final CommonPersonObject kiparent = kirep.findByCaseID(childobject.getColumnmaps().get("relational_id"));

Expand Down Expand Up @@ -161,9 +170,9 @@ public void onClick(View v) {

// FlurryFacade.logEvent("taking_child_pictures_on_anak_detail_view");
entityid = childclient.entityId();
if (hash.containsValue(entityid)) {
updateMode = true;
}
// if (hash.containsValue(entityid)) {
// updateMode = true;
// }
Toast.makeText(AnakDetailActivity.this, "Replace for Camera", Toast.LENGTH_SHORT).show();
// Intent takePictureIntent = new Intent(AnakDetailActivity.this, SmartShutterActivity.class);
// takePictureIntent.putExtra("org.sid.sidface.SmartShutterActivity.updated", updateMode);
Expand All @@ -184,7 +193,6 @@ public void onBackPressed() {
overridePendingTransition(0, 0);
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
// refresh
Expand All @@ -193,14 +201,4 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
startActivity(getIntent());

}

public static void setImagetoHolderFromUri(Activity activity, String file, ImageView view, int placeholder){
view.setImageDrawable(activity.getResources().getDrawable(placeholder));
File externalFile = new File(file);
if (externalFile.exists()) {
Uri external = Uri.fromFile(externalFile);
view.setImageURI(external);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package org.smartregister.bidan.activity;

import android.app.Activity;

/**
* Created by sid-tech on 11/28/17.
*/

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
Expand All @@ -16,25 +10,22 @@
import android.util.Log;
import android.widget.Toast;

//import com.flurry.android.FlurryAgent;
//import org.smartregister.bidan.lib.FlurryFacade;

import org.smartregister.bidan.utils.Support;
import org.smartregister.domain.form.FormSubmission;
import org.json.JSONObject;
import org.smartregister.bidan.R;
import org.smartregister.bidan.fragment.NativeKIAnakSmartRegisterFragment;
import org.smartregister.bidan.pageradapter.BaseRegisterActivityPagerAdapter;
import org.smartregister.bidan.utils.Support;
import org.smartregister.domain.form.FormSubmission;
import org.smartregister.enketo.view.fragment.DisplayFormFragment;
import org.smartregister.provider.SmartRegisterClientsProvider;
import org.smartregister.service.ZiggyService;
import org.smartregister.sync.ClientProcessor;
import org.smartregister.util.FormUtils;
import org.smartregister.view.activity.SecuredNativeSmartRegisterActivity;
import org.smartregister.view.dialog.DialogOption;
import org.smartregister.view.dialog.OpenFormOption;
import org.smartregister.enketo.view.fragment.DisplayFormFragment;
import org.smartregister.view.fragment.SecuredNativeSmartRegisterFragment;
import org.smartregister.view.viewpager.OpenSRPViewPager;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand All @@ -52,27 +43,54 @@
import static org.smartregister.bidan.utils.AllConstantsINA.FormNames.KARTU_IBU_ANAK_CLOSE;
import static org.smartregister.bidan.utils.AllConstantsINA.FormNames.KOHORT_BAYI_KUNJUNGAN;

/**
* Created by sid-tech on 11/28/17.
*/
//import com.flurry.android.FlurryAgent;
//import org.smartregister.bidan.lib.FlurryFacade;

/**
* Created by Dimas Ciputra on 4/7/15.
*/
public class NativeKIAnakSmartRegisterActivity extends SecuredNativeSmartRegisterActivity {

SimpleDateFormat timer = new SimpleDateFormat("hh:mm:ss");
public static final String TAG = NativeKIAnakSmartRegisterFragment.class.getSimpleName();
SimpleDateFormat timer = new SimpleDateFormat("hh:mm:ss");
@Bind(R.id.view_pager)
OpenSRPViewPager mPager;
ZiggyService ziggyService;
// WD need for initialize queries
NativeKIAnakSmartRegisterFragment nf = new NativeKIAnakSmartRegisterFragment();
Map<String, String> FS = new HashMap<>();
private FragmentPagerAdapter mPagerAdapter;
private int currentPage;

private String[] formNames = new String[]{};
private android.support.v4.app.Fragment mBaseFragment = null;
private DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String face_end = timer.format(new Date());
FS.put("face_end", face_end);

ZiggyService ziggyService;
if (which == -1) {
nf.setCriteria("!");
currentPage = 0;
Log.e(TAG, "onClick: YES " + currentPage);
// FlurryAgent.logEvent(TAG+"search_by_face OK", FS, true);

// WD need for initialize queries
NativeKIAnakSmartRegisterFragment nf = new NativeKIAnakSmartRegisterFragment();
} else {
nf.setCriteria("!");
onBackPressed();
Log.e(TAG, "onClick: NO " + currentPage);
// FlurryAgent.logEvent(TAG + "search_by_face NOK", FS, true);

Intent intent = new Intent(NativeKIAnakSmartRegisterActivity.this, NativeKIAnakSmartRegisterActivity.class);
startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
}

Map<String, String> FS = new HashMap<>();

}
};

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -146,7 +164,6 @@ public void onPageSelected(int position) {
ziggyService = context().ziggyService();
}


public void onPageChanged(int page){
setRequestedOrientation(page == 0 ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
LoginActivity.setLanguage();
Expand Down Expand Up @@ -183,7 +200,6 @@ public DialogOption[] getEditOptions() {
new OpenFormOption(getString(R.string.str_anak_balita_visit), BALITA_KUNJUNGAN, formController),
new OpenFormOption(getString(R.string.str_child_immunizations), BAYI_IMUNISASI, formController),
new OpenFormOption(getString(R.string.str_child_close), KARTU_IBU_ANAK_CLOSE, formController),

};
}

Expand Down Expand Up @@ -336,31 +352,5 @@ private boolean currentActivityIsShowingForm(){
return currentPage != 0;
}

private DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String face_end = timer.format(new Date());
FS.put("face_end", face_end);

if (which == -1 ){
nf.setCriteria("!");
currentPage = 0;
Log.e(TAG, "onClick: YES " + currentPage);
// FlurryAgent.logEvent(TAG+"search_by_face OK", FS, true);

} else {
nf.setCriteria("!");
onBackPressed();
Log.e(TAG, "onClick: NO " + currentPage);
// FlurryAgent.logEvent(TAG + "search_by_face NOK", FS, true);

Intent intent= new Intent(NativeKIAnakSmartRegisterActivity.this, NativeKIAnakSmartRegisterActivity.class);
startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
}


}
};


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package org.smartregister.bidan.fragment;

import android.text.Editable;
import android.text.TextWatcher;

import org.smartregister.cursoradapter.SecuredNativeSmartRegisterCursorAdapterFragment;
import org.smartregister.provider.SmartRegisterClientsProvider;
import org.smartregister.view.activity.SecuredNativeSmartRegisterActivity;

import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static org.apache.commons.lang3.StringUtils.isEmpty;

/**
* Created by sid-tech on 11/29/17.
*/

public class BaseSmartRegisterFragment extends SecuredNativeSmartRegisterCursorAdapterFragment {
protected final TextWatcher textWatcher = 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) {
filter(cs.toString(), "", "");
}

@Override
public void afterTextChanged(Editable editable) {

}
};

@Override
protected SecuredNativeSmartRegisterActivity.DefaultOptionsProvider getDefaultOptionsProvider() {
return null;
}

@Override
protected SecuredNativeSmartRegisterActivity.NavBarOptionsProvider getNavBarOptionsProvider() {
return null;
}

@Override
protected SmartRegisterClientsProvider clientsProvider() {
return null;
}

@Override
protected void onInitialization() {

}

@Override
protected void startRegistration() {

}

@Override
protected void onCreation() {

}

protected void filter(String filterString, String joinTableString, String mainConditionString) {
filters = filterString;
joinTable = joinTableString;
mainCondition = mainConditionString;
getSearchCancelView().setVisibility(isEmpty(filterString) ? INVISIBLE : VISIBLE);
CountExecute();
filterandSortExecute();
}

}
Loading

0 comments on commit 476b6fd

Please sign in to comment.