Cleaning design
This commit is contained in:
parent
cb2272d636
commit
6ef57618bb
@ -11,6 +11,7 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@ -63,16 +64,34 @@ public class EditPropertyActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
boolean soldOrNot;
|
||||
Date dateToEdit = null;
|
||||
try {
|
||||
dateToEdit = new SimpleDateFormat("yyyy-MM-dd").parse(dateOfSale.getEditableText().toString());
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final String propertyTypeEdit = type.getEditableText().toString();
|
||||
final int propertyNumberRoomsEdit = Integer.parseInt(numberRooms.getEditableText().toString());
|
||||
final double propertyPriceEdit = Double.parseDouble(price.getEditableText().toString());
|
||||
final double propertySurfaceEdit = Double.parseDouble(surface.getEditableText().toString());
|
||||
final String propertyDescriptionEdit = description.getEditableText().toString();
|
||||
final String sold = statue.getEditableText().toString();
|
||||
if(sold == "Sold")
|
||||
{
|
||||
soldOrNot = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
soldOrNot = false;
|
||||
}
|
||||
property.propertyType.setTypeDescription(propertyTypeEdit);
|
||||
property.propertyType.setNumberRooms(propertyNumberRoomsEdit);
|
||||
property.propertyStatue.setPrice(propertyPriceEdit);
|
||||
property.propertyType.setSurfaceArea(propertySurfaceEdit);
|
||||
property.setDescription(propertyDescriptionEdit);
|
||||
property.propertyStatue.setStatueSale(soldOrNot);
|
||||
property.propertyStatue.setSoldDate(dateToEdit);
|
||||
PropertyRepository propertyRepository = new PropertyRepository(MyApp.getInstance());
|
||||
propertyRepository.updateProperty(property);
|
||||
finish();
|
||||
@ -93,8 +112,8 @@ public class EditPropertyActivity extends AppCompatActivity {
|
||||
|
||||
type.setText(property.propertyType.typeDescription);
|
||||
numberRooms.setText(Integer.toString(property.propertyType.numberRooms));
|
||||
price.setText((new DecimalFormat("##.##").format(property.propertyStatue.price)));
|
||||
surface.setText((new DecimalFormat("##.##").format(property.propertyType.surfaceArea)));
|
||||
price.setText((new DecimalFormat("##.##").format(property.propertyStatue.price)).replace(',', '.'));
|
||||
surface.setText((new DecimalFormat("##.##").format(property.propertyType.surfaceArea)).replace(',', '.'));
|
||||
description.setText(property.description);
|
||||
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
@ -53,6 +53,7 @@ public class AddPropertyActivityViewModel extends AndroidViewModel {
|
||||
Property propertyToAdd = new Property(propertyDescription, propertyAddress, longitude, latitude, this.agency.getAgencyId(), new PropertyStatue(false, null, propertyPrice),
|
||||
new PropertyType(propertyType, propertyNumberRooms, propertySurface));
|
||||
propertyRepository.insertProperty(propertyToAdd);
|
||||
|
||||
event.postValue(Event.ResetForm);
|
||||
}
|
||||
else
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="82dp"
|
||||
android:layout_height="31dp"
|
||||
android:layout_marginTop="60dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/price"
|
||||
app:layout_constraintEnd_toStartOf="@+id/editPropertyPrice"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
@ -145,19 +145,19 @@
|
||||
android:text="@string/Number_of_room"
|
||||
app:layout_constraintBottom_toTopOf="@+id/editPropertyPrice"
|
||||
app:layout_constraintEnd_toStartOf="@+id/editPropertyNumberOfRooms"
|
||||
app:layout_constraintHorizontal_bias="0.347"
|
||||
app:layout_constraintHorizontal_bias="0.13"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView"
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
app:layout_constraintVertical_bias="0.55" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="83dp"
|
||||
android:layout_height="34dp"
|
||||
android:layout_marginTop="56dp"
|
||||
android:layout_marginTop="28dp"
|
||||
android:text="@string/surface"
|
||||
app:layout_constraintEnd_toStartOf="@+id/editPropertySurface"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView3" />
|
||||
|
||||
@ -165,10 +165,10 @@
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="84dp"
|
||||
android:layout_height="33dp"
|
||||
android:layout_marginTop="40dp"
|
||||
android:text="@string/statueSale"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/edit_sold"
|
||||
app:layout_constraintEnd_toStartOf="@+id/editPropertyStatueSale"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView4"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView4" />
|
||||
|
||||
@ -177,7 +177,7 @@
|
||||
android:layout_width="78dp"
|
||||
android:layout_height="39dp"
|
||||
android:layout_marginTop="36dp"
|
||||
android:text="@string/soldDate"
|
||||
android:text="@string/editSoldDate"
|
||||
app:layout_constraintEnd_toStartOf="@+id/editPropertySoldDate"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView5"
|
||||
|
||||
@ -17,5 +17,7 @@
|
||||
<string name="latitude">Latitude</string>
|
||||
<string name="longitude">Longitude</string>
|
||||
<string name="cannot_add_property">Cannot add the property</string>
|
||||
<string name="edit_sold">Enter "Sold" or "Not sold"</string>
|
||||
<string name="editSoldDate">Enter like yyyy-mm-dd !</string>
|
||||
<string name="converter">Convert</string>
|
||||
</resources>
|
||||
Loading…
Reference in New Issue
Block a user