-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Sql lock on ECRegister by Replace FormUtils #4
- Loading branch information
Showing
31 changed files
with
6,369 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
204 changes: 204 additions & 0 deletions
204
...bidan-cloudant-nofr/src/main/java/org/smartregister/bidan/activity/DetailANCActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
package org.smartregister.bidan.activity; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.ImageButton; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import org.smartregister.Context; | ||
import org.smartregister.bidan.R; | ||
import org.smartregister.commonregistry.AllCommonsRepository; | ||
import org.smartregister.commonregistry.CommonPersonObject; | ||
import org.smartregister.commonregistry.CommonPersonObjectClient; | ||
import org.smartregister.repository.DetailsRepository; | ||
import org.smartregister.view.activity.DrishtiApplication; | ||
|
||
import java.io.File; | ||
import java.util.HashMap; | ||
|
||
import static org.smartregister.util.StringUtil.humanize; | ||
|
||
//import org.smartregister.bidan.lib.FlurryFacade; | ||
|
||
/** | ||
* Created by Iq on 07/09/16. | ||
*/ | ||
public class DetailANCActivity extends Activity { | ||
|
||
//image retrieving | ||
private static final String TAG = DetailANCActivity.class.getSimpleName(); | ||
public static CommonPersonObjectClient ancClient; | ||
static String entityid; | ||
private static HashMap<String, String> hash; | ||
private boolean updateMode = false; | ||
|
||
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) { | ||
super.onCreate(savedInstanceState); | ||
Context context = Context.getInstance(); | ||
setContentView(R.layout.child_detail_activity); | ||
|
||
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); | ||
TextView txt_beratLahir = (TextView) findViewById(R.id.txt_beratLahir); | ||
TextView tinggi = (TextView) findViewById(R.id.txt_hasilPengukuranTinggiBayihasilPengukuranTinggiBayi); | ||
TextView berat = (TextView) findViewById(R.id.txt_indikatorBeratBedanBayi); | ||
TextView asi = (TextView) findViewById(R.id.txt_pemberianAsiEksklusif); | ||
TextView status_gizi = (TextView) findViewById(R.id.txt_statusGizi); | ||
TextView kpsp = (TextView) findViewById(R.id.txt_hasilDilakukannyaKPSP); | ||
TextView vita = (TextView) findViewById(R.id.txt_pelayananVita); | ||
TextView hb0 = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiHb07); | ||
TextView pol1 = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiBCGdanPolio1); | ||
TextView pol2 = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiDPTHB1Polio2); | ||
TextView pol3 = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiDPTHB2Polio3); | ||
TextView pol4 = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiDPTHB3Polio4); | ||
TextView campak = (TextView) findViewById(R.id.txt_tanggalpemberianimunisasiCampak); | ||
|
||
TextView growthChartButton = (TextView)findViewById(R.id.chart_label); | ||
ImageButton back = (ImageButton) findViewById(org.smartregister.R.id.btn_back_to_home); | ||
|
||
growthChartButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
finish(); | ||
DetailANCActivity.ancClient = ancClient; | ||
startActivity(new Intent(DetailANCActivity.this, DetailANCActivity.class)); | ||
overridePendingTransition(0, 0); | ||
} | ||
}); | ||
back.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
finish(); | ||
startActivity(new Intent(DetailANCActivity.this, NativeKIAnakSmartRegisterActivity.class)); | ||
overridePendingTransition(0, 0); | ||
} | ||
}); | ||
|
||
|
||
DetailsRepository detailsRepository = Context.getInstance().detailsRepository(); | ||
detailsRepository.updateDetails(ancClient); | ||
|
||
String gender = ancClient.getDetails().containsKey("gender") ? ancClient.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, ancClient.getCaseId());//required when saving file to disk | ||
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 | ||
// DrishtiApplication.getCachedImageLoaderInstance().getImageByClientId(ancClient.getCaseId(), OpenSRPImageLoader.getStaticImageListener(childview, placeholderDrawable, placeholderDrawable)); | ||
|
||
DetailANCActivity.setImagetoHolderFromUri(this, | ||
DrishtiApplication.getAppDir() + File.separator + ancClient.getDetails().get("base_entity_id") + ".JPEG", | ||
childview, ancClient.getDetails().get("gender").equals("female") ? R.drawable.child_girl_infant : R.drawable.child_boy_infant); | ||
} | ||
|
||
//end profile image | ||
|
||
AllCommonsRepository childRepository = Context.getInstance().allCommonsRepositoryobjects("ec_anak"); | ||
|
||
CommonPersonObject childobject = childRepository.findByCaseID(ancClient.entityId()); | ||
|
||
// AllCommonsRepository iburep = org.smartregister.Context.getInstance().allCommonsRepositoryobjects("ec_ibu"); | ||
// final CommonPersonObject ibuparent = iburep.findByCaseID(childobject.getColumnmaps().get("relational_id")); | ||
|
||
AllCommonsRepository kirep = Context.getInstance().allCommonsRepositoryobjects("ec_kartu_ibu"); | ||
final CommonPersonObject kiparent = kirep.findByCaseID(childobject.getColumnmaps().get("relational_id")); | ||
|
||
|
||
nama.setText(String.format("%s%s", getResources().getString(R.string.name), humanize(ancClient.getColumnmaps().get("namaBayi") != null ? ancClient.getColumnmaps().get("namaBayi") : "-"))); | ||
mother.setText(String.format("%s%s", getResources().getString(R.string.child_details_mothers_name_label), humanize(kiparent.getColumnmaps().get("namalengkap") != null ? kiparent.getColumnmaps().get("namalengkap") : "-"))); | ||
father.setText(String.format("%s%s", getResources().getString(R.string.child_details_fathers_name_label), humanize(kiparent.getColumnmaps().get("namaSuami") != null ? kiparent.getColumnmaps().get("namaSuami") : "-"))); | ||
dob.setText(String.format("%s%s", getResources().getString(R.string.date_of_birth), humanize(ancClient.getColumnmaps().get("tanggalLahirAnak") != null ? ancClient.getColumnmaps().get("tanggalLahirAnak") : "-"))); | ||
|
||
txt_noBayi.setText(String.format("%s: ", humanize(ancClient.getDetails().get("noBayi") != null ? ancClient.getDetails().get("noBayi") : "-"))); | ||
txt_jenisKelamin.setText(String.format(": %s", humanize(ancClient.getDetails().get("gender") != null ? ancClient.getDetails().get("gender") : "-"))); | ||
txt_beratLahir.setText(String.format(": %s", humanize(ancClient.getDetails().get("beratLahir") != null ? ancClient.getDetails().get("beratLahir") : "-"))); | ||
tinggi.setText(String.format(": %s", humanize(ancClient.getDetails().get("hasilPengukuranTinggiBayihasilPengukuranTinggiBayi") != null ? ancClient.getDetails().get("hasilPengukuranTinggiBayihasilPengukuranTinggiBayi") : "-"))); | ||
berat.setText(String.format(": %s", humanize(ancClient.getDetails().get("indikatorBeratBedanBayi") != null ? ancClient.getDetails().get("indikatorBeratBedanBayi") : "-"))); | ||
asi.setText(String.format(": %s", humanize(ancClient.getDetails().get("pemberianAsiEksklusif") != null ? ancClient.getDetails().get("pemberianAsiEksklusif") : "-"))); | ||
status_gizi.setText(String.format(": %s", humanize(ancClient.getDetails().get("statusGizi") != null ? ancClient.getDetails().get("statusGizi") : "-"))); | ||
kpsp.setText(String.format(": %s", humanize(ancClient.getDetails().get("hasilDilakukannyaKPSP") != null ? ancClient.getDetails().get("hasilDilakukannyaKPSP") : "-"))); | ||
hb0.setText(String.format(": %s", humanize(ancClient.getDetails().get("hb0") != null ? ancClient.getDetails().get("hb0") : "-"))); | ||
pol1.setText(String.format(": %s", humanize(ancClient.getDetails().get("polio1") != null ? ancClient.getDetails().get("polio1") : ancClient.getDetails().get("bcg") != null ? ancClient.getDetails().get("bcg") : "-"))); | ||
pol2.setText(String.format(": %s", humanize(ancClient.getDetails().get("dptHb1") != null ? ancClient.getDetails().get("dptHb1") : ancClient.getDetails().get("polio2") != null ? ancClient.getDetails().get("polio2") : "-"))); | ||
pol3.setText(String.format(": %s", humanize(ancClient.getDetails().get("dptHb2") != null ? ancClient.getDetails().get("dptHb2") : ancClient.getDetails().get("polio3") != null ? ancClient.getDetails().get("polio3") : "-"))); | ||
pol4.setText(String.format(": %s", humanize(ancClient.getDetails().get("dptHb3") != null ? ancClient.getDetails().get("dptHb3") : ancClient.getDetails().get("polio4") != null ? ancClient.getDetails().get("polio4") : "-"))); | ||
campak.setText(String.format(": %s", humanize(ancClient.getDetails().get("campak") != null ? ancClient.getDetails().get("campak") : "-"))); | ||
vita.setText(String.format(": %s", humanize(ancClient.getDetails().get("pelayananVita") != null ? ancClient.getDetails().get("pelayananVita") : "-"))); | ||
|
||
// hash = Tools.retrieveHash(context.applicationContext()); | ||
|
||
childview.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
|
||
// FlurryFacade.logEvent("taking_child_pictures_on_anak_detail_view"); | ||
entityid = ancClient.entityId(); | ||
// if (hash.containsValue(entityid)) { | ||
// updateMode = true; | ||
// } | ||
Toast.makeText(DetailANCActivity.this, "Replace for Camera", Toast.LENGTH_SHORT).show(); | ||
// Intent takePictureIntent = new Intent(DetailChildActivity.this, SmartShutterActivity.class); | ||
// takePictureIntent.putExtra("org.sid.sidface.SmartShutterActivity.updated", updateMode); | ||
// takePictureIntent.putExtra("IdentifyPerson", false); | ||
// takePictureIntent.putExtra("org.sid.sidface.ImageConfirmation.id", entityid); | ||
// takePictureIntent.putExtra("org.sid.sidface.ImageConfirmation.origin", TAG); // send Class Name | ||
// startActivityForResult(takePictureIntent, 2); | ||
|
||
} | ||
}); | ||
|
||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
finish(); | ||
startActivity(new Intent(this, NativeKIAnakSmartRegisterActivity.class)); | ||
overridePendingTransition(0, 0); | ||
} | ||
|
||
@Override | ||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) { | ||
// refresh | ||
Log.e(TAG, "onActivityResult: refresh" ); | ||
finish(); | ||
startActivity(getIntent()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.