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