-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now you can see vehicle details by clicking it on the list.
- Loading branch information
1 parent
84b5d95
commit 5bdb521
Showing
9 changed files
with
284 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
68 changes: 68 additions & 0 deletions
68
app/src/main/java/com/carlostojal/myvehicles/VehicleDetails.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,68 @@ | ||
package com.carlostojal.myvehicles; | ||
|
||
// | ||
// Copyright © Carlos Tojal (carlostojal) | ||
// VehicleDetails.java | ||
// MyVehicles | ||
// github.com/carlostojal/MyVehicles | ||
// | ||
|
||
import android.os.Bundle; | ||
|
||
import com.google.android.material.floatingactionbutton.FloatingActionButton; | ||
import com.google.android.material.snackbar.Snackbar; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.appcompat.widget.Toolbar; | ||
|
||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class VehicleDetails extends AppCompatActivity { | ||
|
||
ArrayList<Vehicle> vehicles; | ||
Vehicle vehicle; | ||
VehicleManager vehicleManager; | ||
|
||
TextView brand; | ||
TextView model; | ||
TextView displacement; | ||
TextView year; | ||
TextView registration; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_vehicle_details); | ||
|
||
brand = (TextView) findViewById(R.id.brand_value_details); | ||
model = (TextView) findViewById(R.id.model_value_details); | ||
displacement = (TextView) findViewById(R.id.displacement_value_details); | ||
year = (TextView) findViewById(R.id.year_value_details); | ||
registration = (TextView) findViewById(R.id.registration_value_details); | ||
|
||
vehicleManager = new VehicleManager(); | ||
|
||
Bundle extras = getIntent().getExtras(); | ||
String searchedRegistration = extras.getString("registration"); | ||
int searchedType = extras.getInt("type"); | ||
vehicles = vehicleManager.loadVehicles(getApplicationContext(),searchedType); | ||
for(int i=0;i<vehicles.size();i++) { | ||
//searches selected vehicle in the list | ||
if(vehicles.get(i).getRegistration().equals(searchedRegistration)) { | ||
vehicle = vehicles.get(i); | ||
break; | ||
} | ||
} | ||
//sets car brand and model as activity title | ||
setTitle(vehicle.getBrand()+" "+vehicle.getModel()); | ||
|
||
brand.setText(vehicle.getBrand().toString()); | ||
model.setText(vehicle.getModel().toString()); | ||
displacement.setText(String.valueOf(vehicle.getDisplacement())); | ||
year.setText(String.valueOf(vehicle.getYear())); | ||
registration.setText(vehicle.getRegistration().toString()); | ||
} | ||
} |
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,166 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/coordinatorLayout2" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".VehicleDetails" > | ||
|
||
<TextView | ||
android:id="@+id/brand_details" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="16dp" | ||
android:text="@string/brand1" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/brand_value_details" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:text="TextView" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/brand_details" /> | ||
|
||
<TextView | ||
android:id="@+id/model_details" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="16dp" | ||
android:text="@string/model1" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/brand_value_details" /> | ||
|
||
<TextView | ||
android:id="@+id/model_value_details" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:text="TextView" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/model_details" /> | ||
|
||
<TextView | ||
android:id="@+id/displacement_details" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="16dp" | ||
android:text="@string/displacement" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/model_value_details" /> | ||
|
||
<TextView | ||
android:id="@+id/displacement_value_details" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:text="TextView" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/displacement_details" /> | ||
|
||
<TextView | ||
android:id="@+id/year_details" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="16dp" | ||
android:text="@string/year" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/displacement_value_details" /> | ||
|
||
<TextView | ||
android:id="@+id/year_value_details" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:text="TextView" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/year_details" /> | ||
|
||
<TextView | ||
android:id="@+id/registration_details" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="16dp" | ||
android:text="@string/registration1" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/year_value_details" /> | ||
|
||
<TextView | ||
android:id="@+id/registration_value_details" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:text="TextView" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/registration_details" /> | ||
|
||
<Button | ||
android:id="@+id/insurances" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="24dp" | ||
android:layout_marginEnd="16dp" | ||
android:text="@string/insurances" | ||
android:background="@color/colorPrimary" | ||
android:textColor="@color/colorAccent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/registration_value_details" /> | ||
|
||
<Button | ||
android:id="@+id/inspections" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="5dp" | ||
android:layout_marginEnd="16dp" | ||
android:text="@string/inspections" | ||
android:background="@color/colorPrimary" | ||
android:textColor="@color/colorAccent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/insurances" /> | ||
|
||
<Button | ||
android:id="@+id/taxes" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="5dp" | ||
android:layout_marginEnd="16dp" | ||
android:background="@color/colorPrimary" | ||
android:text="@string/taxes" | ||
android:textColor="@color/colorAccent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/inspections" /> | ||
|
||
<Button | ||
android:id="@+id/revisions" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="5dp" | ||
android:layout_marginEnd="16dp" | ||
android:text="@string/revisions" | ||
android:background="@color/colorPrimary" | ||
android:textColor="@color/colorAccent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/taxes" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
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