public void saveInspection() { String exception = ""; if (edtException.getText().toString().length() > 0) { exception = edtException.getText().toString(); } if (exception.length() > 200) { Toast.makeText( getApplicationContext(), "Exception must be less then 200 character.", Toast.LENGTH_LONG) .show(); return; } String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date()); inspection.deleteRelatedPestsRecords(); if (isCleanInspection) { m_inspectionPests = new ArrayList<InspectionPest>(); inspection.evidence = ""; } inspection.trap_number = trapscan_info.number; inspection.trap_type_id = trapscan_info.trap_type_id; int bait = 0, trap = 0; if (!spnBaitCondition.getSelectedItem().toString().equalsIgnoreCase("Bait Conditions")) { bait = BaitConditionsInfo.getIdByName(spnBaitCondition.getSelectedItem().toString()); } if (!spnTrapCondition.getSelectedItem().toString().equalsIgnoreCase("Trap Conditions")) { trap = TrapConditionsInfo.getIdByName(spnTrapCondition.getSelectedItem().toString()); } inspection.bait_condition_id = bait; inspection.trap_condition_id = trap; currentDateTimeString = Utils.Instance() .getFormatedDate( currentDateTimeString, "MMM dd, yyyy hh:mm:ss a", "yyyy-MM-dd hh:mm a"); inspection.exception = exception; inspection.removed = isRemoved; inspection.scanned_on = currentDateTimeString; try { inspection.save(); } catch (ActiveRecordException e) { e.printStackTrace(); } AddTraps(m_inspectionPests, inspection); // if (m_list.size() == 1) { // if (m_list.get(0).count == 0 && m_list.get(0).pest_type_id == 0) { // m_list = new ArrayList<InspectionPest>(); // AddTraps(m_list, inspection); // } else { // AddTraps(m_list, inspection); // } // } else { // } }
public void LoadSpinners() { ArrayList<BaitConditionsInfo> m_baits = new ArrayList<BaitConditionsInfo>(); m_baits = BaitConditionsList.Instance().getBaitConditionsList(); ArrayList<TrapConditionsInfo> m_trapconditions = new ArrayList<TrapConditionsInfo>(); m_trapconditions = TrapConditionsList.Instance().getTrapConditionsList(); if (!isFromUnChecked) { BaitConditionsInfo d = new BaitConditionsInfo(); d.name = "Bait Conditions"; m_baits.add(0, d); setSpinnerValues("name", m_baits, BaitConditionsInfo.class, spnBaitCondition); TrapConditionsInfo tci = new TrapConditionsInfo(); tci.name = "Trap Conditions"; m_trapconditions.add(0, tci); setSpinnerValues("name", m_trapconditions, TrapConditionsInfo.class, spnTrapCondition); if (isEdit) { int b = 0; for (int i = 0; i < m_baits.size(); i++) { if (inspection.bait_condition_id == m_baits.get(i).id) { b = i; break; } } spnBaitCondition.setSelection(b); int t = 0; for (int i = 0; i < m_trapconditions.size(); i++) { if (inspection.trap_condition_id == m_trapconditions.get(i).id) { t = i; break; } } spnTrapCondition.setSelection(t); tgbRemoved.setSelected(inspection.removed); if (inspection.exception != null && inspection.exception.length() > 0) { edtException.setText(inspection.exception); txtExceptionCount.setText("" + inspection.exception.length() + " / 200"); } else { txtExceptionCount.setText("0/ 200"); } } } }