diff --git a/apk/MyVehicles.apk b/apk/MyVehicles.apk index dbd835d..09aeb62 100644 Binary files a/apk/MyVehicles.apk and b/apk/MyVehicles.apk differ diff --git a/app/src/main/java/com/carlostojal/myvehicles/AddInsuranceInspectionTaxRevision.java b/app/src/main/java/com/carlostojal/myvehicles/AddInsuranceInspectionTaxRevision.java index 2e2a235..75d95e6 100644 --- a/app/src/main/java/com/carlostojal/myvehicles/AddInsuranceInspectionTaxRevision.java +++ b/app/src/main/java/com/carlostojal/myvehicles/AddInsuranceInspectionTaxRevision.java @@ -16,13 +16,111 @@ import androidx.appcompat.widget.Toolbar; import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import java.util.ArrayList; +import java.util.Calendar; public class AddInsuranceInspectionTaxRevision extends AppCompatActivity { + ArrayList vehicles; + Vehicle vehicle; + VehicleManager vehicleManager; + int type; + + TextView label; + EditText value; + Button add; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_insurance_inspection_tax_revision); + + label = findViewById(R.id.value_add); + value = findViewById(R.id.value_value_add); + add = findViewById(R.id.add); + + Bundle extras = getIntent().getExtras(); + type = extras.getInt("type"); + + vehicleManager = new VehicleManager(); + vehicles = vehicleManager.loadVehicles(getApplicationContext(),extras.getInt("vehicleType")); + + for(int i=0;i list; + Calendar calendar = Calendar.getInstance(); + Date date = new Date(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH), calendar.get(Calendar.YEAR)); + InsuranceInspectionTaxRevision newRegister = new InsuranceInspectionTaxRevision(date, Integer.parseInt(value.getText().toString())); + + if (type == 1) { + list = vehicle.getInsurance(); + list.add(newRegister); + vehicle.setInsurance(list); + } + else if (type == 2) { + list = vehicle.getInspection(); + list.add(newRegister); + vehicle.setInspection(list); + } + else if (type == 3) { + list = vehicle.getTax(); + list.add(newRegister); + vehicle.setTax(list); + } + else { + list = vehicle.getRevision(); + list.add(newRegister); + vehicle.setRevision(list); + } + + vehicleManager.cleanVehicles(getApplicationContext()); + vehicleManager.addVehicle(getApplicationContext(),vehicle); + + for(int i=0;i vehicles; Vehicle vehicle; + int type; TextView label; TextView history; @@ -45,7 +46,7 @@ protected void onCreate(Bundle savedInstanceState) { Bundle extras = getIntent().getExtras(); String registration = extras.getString("registration"); //vehicle registration int vehicleType = extras.getInt("vehicleType"); - int type = extras.getInt("type"); + type = extras.getInt("type"); vehicles = vehicleManager.loadVehicles(getApplicationContext(),vehicleType); for(int i=0;i loadVehicles(Context context, int searchedType) { int year; String registration; int ninsurances; - ArrayList insurance = new ArrayList<>(); int ninspections; - ArrayList inspection = new ArrayList<>(); int ntaxes; - ArrayList tax = new ArrayList<>(); int nrevisions; - ArrayList revision = new ArrayList<>(); while((line=bufferedReader.readLine())!=null) { String[] splitStr = line.split("; "); + ArrayList insurance = new ArrayList<>(); + ArrayList inspection = new ArrayList<>(); + ArrayList tax = new ArrayList<>(); + ArrayList revision = new ArrayList<>(); type = Integer.parseInt(splitStr[0]); brand = splitStr[1]; model = splitStr[2]; diff --git a/app/src/main/res/layout/activity_add_insurance_inspection_tax_revision.xml b/app/src/main/res/layout/activity_add_insurance_inspection_tax_revision.xml index f4b74a4..49f8d6e 100644 --- a/app/src/main/res/layout/activity_add_insurance_inspection_tax_revision.xml +++ b/app/src/main/res/layout/activity_add_insurance_inspection_tax_revision.xml @@ -8,4 +8,39 @@ tools:context=".AddInsuranceInspectionTaxRevision"> + + + + +