Skip to content

Commit

Permalink
#38 - added male and female count fields in herd sightings
Browse files Browse the repository at this point in the history
  • Loading branch information
vintuwei committed Nov 20, 2015
1 parent c5e4eb7 commit 1d8b3fc
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 29 deletions.
42 changes: 21 additions & 21 deletions gen/com/ihub/rangerapp/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -1790,8 +1790,8 @@ public static final class id {
public static final int always=0x7f090014;
public static final int animalNameView=0x7f090046;
public static final int animalView=0x7f090071;
public static final int bagsActionTakenSpinner=0x7f090062;
public static final int bagsLayout=0x7f09005f;
public static final int bagsActionTakenSpinner=0x7f090064;
public static final int bagsLayout=0x7f090061;
public static final int beginning=0x7f09001b;
public static final int cameraBtn=0x7f090087;
public static final int checkbox=0x7f090029;
Expand All @@ -1811,17 +1811,17 @@ public static final class id {
public static final int end=0x7f09001c;
public static final int expand_activities_button=0x7f090022;
public static final int expanded_menu=0x7f090028;
public static final int extraNotes=0x7f090056;
public static final int extraNotes=0x7f090058;
public static final int extraNotesView=0x7f090092;
public static final int femaleCountView=0x7f090067;
public static final int freshnessLevelSpinner=0x7f09005c;
public static final int femaleCountView=0x7f090054;
public static final int freshnessLevelSpinner=0x7f09005e;
public static final int fromGallery=0x7f09009c;
public static final int genderGroup=0x7f090047;
public static final int goBtn=0x7f090079;
public static final int gpsBtn=0x7f090089;
public static final int herdDistanceSeenView=0x7f090053;
public static final int herdDistanceSeenView=0x7f090055;
public static final int herdLayout=0x7f09004d;
public static final int herdNameView=0x7f090054;
public static final int herdNameView=0x7f090056;
public static final int herdNoOfAnimalsView=0x7f09004f;
public static final int home=0x7f090000;
public static final int homeAsUp=0x7f09000e;
Expand All @@ -1831,26 +1831,26 @@ public static final class id {
public static final int imageView=0x7f090076;
public static final int individualLayout=0x7f090045;
public static final int juvenilesCountView=0x7f090052;
public static final int kilnActionTakenSpinner=0x7f09005e;
public static final int kilnsLayout=0x7f09005a;
public static final int kilnActionTakenSpinner=0x7f090060;
public static final int kilnsLayout=0x7f09005c;
public static final int leaderView=0x7f09007b;
public static final int leftTuskWeightView=0x7f09006e;
public static final int levelOfWaterSpinner=0x7f090085;
public static final int list=0x7f090072;
public static final int listMode=0x7f09000a;
public static final int list_item=0x7f090025;
public static final int logo=0x7f090077;
public static final int maleCountView=0x7f090066;
public static final int maleCountView=0x7f090053;
public static final int middle=0x7f09001d;
public static final int modeOfTransportSpinner=0x7f090061;
public static final int modeOfTransportSpinner=0x7f090063;
public static final int modeSpinner=0x7f09007e;
public static final int multiAnimalsView=0x7f090065;
public static final int multiAnimalsView=0x7f090067;
public static final int name=0x7f090094;
public static final int nameView=0x7f090090;
public static final int never=0x7f090017;
public static final int noOfAnimalsView=0x7f090064;
public static final int noOfBagsView=0x7f090060;
public static final int noOfKilnsView=0x7f09005b;
public static final int noOfAnimalsView=0x7f090066;
public static final int noOfBagsView=0x7f090062;
public static final int noOfKilnsView=0x7f09005d;
public static final int noOfMembersView=0x7f09007c;
public static final int noRecordsLabel=0x7f090086;
public static final int none=0x7f09000f;
Expand All @@ -1862,21 +1862,21 @@ public static final class id {
public static final int purposeView=0x7f090081;
public static final int radio=0x7f09002b;
public static final int radioGroup=0x7f090042;
public static final int radio_bags=0x7f090059;
public static final int radio_bags=0x7f09005b;
public static final int radio_gender_female=0x7f090049;
public static final int radio_gender_male=0x7f090048;
public static final int radio_gender_unknown=0x7f09004a;
public static final int radio_herd=0x7f090044;
public static final int radio_individual=0x7f090043;
public static final int radio_kilns=0x7f090058;
public static final int radio_kilns=0x7f09005a;
public static final int radio_no=0x7f09006c;
public static final int radio_yes=0x7f09006b;
public static final int ranchSpinner=0x7f090055;
public static final int ranchSpinner=0x7f090057;
public static final int rangerID=0x7f090078;
public static final int reportsBtn=0x7f090073;
public static final int rightTuskWeightView=0x7f09006f;
public static final int routeView=0x7f09007d;
public static final int saveBtn=0x7f090057;
public static final int saveBtn=0x7f090059;
public static final int scollView=0x7f090040;
public static final int search_badge=0x7f090035;
public static final int search_bar=0x7f090034;
Expand Down Expand Up @@ -1906,8 +1906,8 @@ public static final class id {
public static final int text=0x7f09008e;
public static final int title=0x7f090027;
public static final int toolbar=0x7f09003f;
public static final int toolsUsedSpinner=0x7f090063;
public static final int treeUsedView=0x7f09005d;
public static final int toolsUsedSpinner=0x7f090065;
public static final int treeUsedView=0x7f09005f;
public static final int tusksFlagGroup=0x7f09006a;
public static final int tusksWeightLayout=0x7f09006d;
public static final int typeSpeciesView=0x7f09004e;
Expand Down
66 changes: 66 additions & 0 deletions res/layout/activity_animals_sightings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,72 @@

</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingRight="3dp" >

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1" >

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/male"
android:textSize="18sp"
android:textColor="@color/bg"
android:layout_marginBottom="5dp" />

<EditText
android:id="@+id/maleCountView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:inputType="number" />

</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1" >

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/female"
android:textSize="18sp"
android:textColor="@color/bg"
android:layout_marginBottom="5dp" />

<EditText
android:id="@+id/femaleCountView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:inputType="number" />

</LinearLayout>
</LinearLayout>













<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
37 changes: 35 additions & 2 deletions src/com/ihub/rangerapp/AnimalsSightingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class AnimalsSightingsActivity extends CameraGPSActionBarActivity {
EditText extraNotes;
Button saveBtn;

EditText maleCountView;
EditText femaleCountView;
EditText herdNameView;
AutoCompleteTextView typeSpeciesView;
EditText herdNoOfAnimalsView;
Expand Down Expand Up @@ -124,6 +126,9 @@ public void onClick(View v) {
semiAdultsCountView = (EditText) findViewById(R.id.semiAdultsCountView);
adultsCountView = (EditText) findViewById(R.id.adultsCountView);
herdDistanceSeenView = (EditText) findViewById(R.id.herdDistanceSeenView);

maleCountView = (EditText) findViewById(R.id.maleCountView);
femaleCountView = (EditText) findViewById(R.id.femaleCountView);

saveBtn.setOnClickListener(new View.OnClickListener() {

Expand Down Expand Up @@ -164,8 +169,8 @@ public void onClick(DialogInterface dialog, int id) {

} else
if(isHerdValid()) {
View[] fields = new View[] {herdNameView, typeSpeciesView, herdNoOfAnimalsView, adultsCountView, semiAdultsCountView, juvenilesCountView, herdDistanceSeenView, extraNotes};
String fieldNames[] = {"Name / Identity of Herd", "Species", "Number of Animals", "Adults", "Sub-Adults", "Juveniles", "Distance Seen", "Extra Notes"};
View[] fields = new View[] {herdNameView, typeSpeciesView, herdNoOfAnimalsView, adultsCountView, semiAdultsCountView, juvenilesCountView, maleCountView, femaleCountView, herdDistanceSeenView, extraNotes};
String fieldNames[] = {"Name / Identity of Herd", "Species", "Number of Animals", "Adults", "Sub-Adults", "Juveniles", "Male Count", "Female Count", "Distance Seen", "Extra Notes"};

if(hasInvalidFields(fields)) {

Expand Down Expand Up @@ -289,6 +294,8 @@ private void initHerdData() {
Integer adultsCount = 0;
Integer semiAdultsCount = 0;
Integer juvenileCount= 0;
Integer maleCount = 0;
Integer femaleCount = 0;

try {
adultsCount = getIntent().getIntExtra("adultsCount", 0);
Expand All @@ -302,12 +309,23 @@ private void initHerdData() {
juvenileCount = getIntent().getIntExtra("juvenileCount", 0);
} catch (Exception e) {}

try {
maleCount = getIntent().getIntExtra("maleCount", 0);
} catch (Exception e) {}

try {
femaleCount = getIntent().getIntExtra("femaleCount", 0);
} catch (Exception e) {}

if(adultsCount > 0)
adultsCountView.setText(adultsCount + "");
if(semiAdultsCount > 0)
semiAdultsCountView.setText(semiAdultsCount + "");
if(juvenileCount > 0)
juvenilesCountView.setText(juvenileCount + "");

maleCountView.setText(maleCount + "");
femaleCountView.setText(femaleCount + "");

if(getIntent().hasExtra("distanceSeen"))
herdDistanceSeenView.setText(getIntent().getIntExtra("distanceSeen", 0) + "");
Expand Down Expand Up @@ -402,6 +420,8 @@ protected void saveHerd() {
Integer adultsCount = 0;
Integer semiAdultsCount = 0;
Integer juvenileCount= 0;
Integer maleCount = 0;
Integer femaleCount = 0;

try {
adultsCount = Integer.valueOf(adultsCountView.getText().toString());
Expand All @@ -415,6 +435,14 @@ protected void saveHerd() {
juvenileCount = Integer.valueOf(juvenilesCountView.getText().toString());
} catch (Exception e) {}

try {
maleCount = Integer.valueOf(maleCountView.getText().toString());
} catch (Exception e) {}

try {
femaleCount = Integer.valueOf(femaleCountView.getText().toString());
} catch (Exception e) {}

Integer id = -1;
if(mode == 2)
id = getIntent().getIntExtra("id", -1);
Expand All @@ -429,6 +457,8 @@ protected void saveHerd() {
adultsCount,
semiAdultsCount,
juvenileCount,
maleCount,
femaleCount,
distanceSeen,
extraNotes.getText().toString(),
imagePath,
Expand All @@ -446,6 +476,9 @@ protected void saveHerd() {
data.putExtra("adultsCount", adultsCount);
data.putExtra("semiAdultsCount", semiAdultsCount);
data.putExtra("juvenileCount", juvenileCount);
data.putExtra("maleCount", maleCount);
data.putExtra("femaleCount", femaleCount);

data.putExtra("distanceSeen", distanceSeen);
data.putExtra("extraNotes", extraNotes.getText().toString());
data.putExtra("ranch", ranch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public Map<String, Object> saveHerd(
Integer adultsCount,
Integer semiAdultsCount,
Integer juvenileCount,
Integer maleCount,
Integer femaleCount,
Integer distanceSeen,
String extraNotes,
String imagePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public Map<String, Object> saveIndividualAnimal(Integer id, String name, String
}

@Override
public Map<String, Object> saveHerd(Integer id, String name, String species, Integer noOfAnimals, Integer adultsCount, Integer semiAdultsCount, Integer juvenileCount, Integer distanceSeen, String extraNotes, String imagePath, String waypoint, String ranch) {
public Map<String, Object> saveHerd(Integer id, String name, String species, Integer noOfAnimals,
Integer adultsCount, Integer semiAdultsCount, Integer juvenileCount, Integer maleCount, Integer femaleCount,
Integer distanceSeen, String extraNotes, String imagePath, String waypoint, String ranch) {

Map<String, Object> result = new HashMap<String, Object>();

Expand All @@ -93,6 +95,9 @@ public Map<String, Object> saveHerd(Integer id, String name, String species, Int
values.put(Schemas.AnimalHerdSighting.SEMI_ADULTS_COUNT, semiAdultsCount);
values.put(Schemas.AnimalHerdSighting.JUVENILE_COUNT, juvenileCount);

values.put(Schemas.AnimalHerdSighting.MALE_COUNT, maleCount);
values.put(Schemas.AnimalHerdSighting.FEMALE_COUNT, femaleCount);

values.put(Schemas.AnimalHerdSighting.DISTANCE_SEEN, distanceSeen);
values.put(Schemas.AnimalHerdSighting.EXTRA_NOTES, extraNotes);
values.put(Schemas.AnimalHerdSighting.IMAGE_PATH, imagePath);
Expand Down Expand Up @@ -230,6 +235,8 @@ public void syncHerd(Integer id, AsyncHttpResponseHandler handler) {
Integer distanceSeen = cursor.getInt(7);
String ranch = cursor.getString(17);

Integer maleCount = cursor.getInt(18);
Integer femaleCount = cursor.getInt(19);

params.put("name", name);
params.put("type", type);
Expand All @@ -240,17 +247,20 @@ public void syncHerd(Integer id, AsyncHttpResponseHandler handler) {
params.put("distance_seen", distanceSeen + "");
params.put("ranch", ranch);

params.put("male_count", maleCount);
params.put("female_count", femaleCount);

String extraNotes = cursor.getString(8);
String waypoint = cursor.getString(9);
String imagePath = cursor.getString(10);
String dateCreated = cursor.getString(11);
Integer shiftID = cursor.getInt(12);


params.put("waypoint", waypoint);
params.put("extra_notes", extraNotes);

try {

File myFile = new File(imagePath);
params.put("image", myFile);

Expand Down
5 changes: 5 additions & 0 deletions src/com/ihub/rangerapp/loader/HerdsLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public List<Model> loadFromLocalDb(PagingLoadConfig config) {
String imagePath = cursor.getString(10);
String dateCreated = cursor.getString(11);
String ranch = cursor.getString(17);

Integer maleCount = cursor.getInt(18);
Integer femaleCount = cursor.getInt(19);

HerdModel model = new HerdModel();
model.setId(id);
Expand All @@ -65,6 +68,8 @@ public List<Model> loadFromLocalDb(PagingLoadConfig config) {
model.setImagePath(imagePath);
model.setDateCreated(dateCreated);
model.setRanch(ranch);
model.setMaleCount(maleCount);
model.setFemaleCount(femaleCount);

data.add(model);

Expand Down
Loading

0 comments on commit 1d8b3fc

Please sign in to comment.