added field checking, fixed some errors
This commit is contained in:
parent
c5f5157ef1
commit
46ffe2b2e5
7 changed files with 50 additions and 18 deletions
|
@ -8,6 +8,7 @@ import android.os.Bundle;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class EditServiceDialogFragment extends DialogFragment{
|
public class EditServiceDialogFragment extends DialogFragment{
|
||||||
|
|
||||||
|
@ -47,12 +48,19 @@ public interface NoticeDialogListener {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString("name", (String)getArguments().get("name"));
|
args.putString("name", (String)getArguments().get("name"));
|
||||||
EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput);
|
EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput);
|
||||||
double rate = Double.parseDouble(rateInput.getText().toString());
|
if(rateInput.getText().toString().length()>0){
|
||||||
|
Double rate = Double.parseDouble(rateInput.getText().toString());
|
||||||
args.putDouble("rate", rate);
|
args.putDouble("rate", rate);
|
||||||
|
|
||||||
EditServiceDialogFragment.this.setArguments(args);
|
EditServiceDialogFragment.this.setArguments(args);
|
||||||
mListener.onDialogEdit(EditServiceDialogFragment.this);
|
mListener.onDialogEdit(EditServiceDialogFragment.this);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
Toast.makeText(getContext(), "Rate cannot be empty", Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() {
|
.setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.support.annotation.Nullable;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.rengwuxian.materialedittext.MaterialEditText;
|
import com.rengwuxian.materialedittext.MaterialEditText;
|
||||||
|
|
||||||
|
@ -63,14 +64,19 @@ public class NewServiceDialogFragment extends DialogFragment {
|
||||||
EditText nameInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.NameInput);
|
EditText nameInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.NameInput);
|
||||||
EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput);
|
EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput);
|
||||||
String name = nameInput.getText().toString();
|
String name = nameInput.getText().toString();
|
||||||
double rate = Double.parseDouble(rateInput.getText().toString());
|
if (rateInput.getText().toString().length()>0 && name.length()>0 && name.matches("[a-zA-Z]*")){
|
||||||
|
Double rate = Double.parseDouble(rateInput.getText().toString());
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString("name", name);
|
args.putString("name", name);
|
||||||
args.putDouble("rate", rate);
|
args.putDouble("rate", rate);
|
||||||
NewServiceDialogFragment.this.setArguments(args);
|
NewServiceDialogFragment.this.setArguments(args);
|
||||||
mListener.onDialogNew(NewServiceDialogFragment.this);
|
mListener.onDialogNew(NewServiceDialogFragment.this);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Toast.makeText(getContext(), "Service must have an alphanumeric name and a rate", Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.GridView;
|
import android.widget.GridView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -91,6 +92,7 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF
|
||||||
DBHelper dbHelper = new DBHelper(this);
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
String name = (String)dialog.getArguments().get("name");
|
String name = (String)dialog.getArguments().get("name");
|
||||||
dbHelper.deleteService(name);
|
dbHelper.deleteService(name);
|
||||||
|
Toast.makeText(this, "Service \""+(String)dialog.getArguments().get("name")+"\" has been deleted", Toast.LENGTH_LONG).show();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
this.recreate();
|
this.recreate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="Hourly Rate"
|
android:text="Hourly Rate($)"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
|
@ -67,11 +67,22 @@
|
||||||
android:layout_height="250dp"/>
|
android:layout_height="250dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Title3"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Click on service to edit or delete"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="15sp" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/newService"
|
android:id="@+id/newService"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="5dp"
|
||||||
android:text="Add New Service"
|
android:text="Add New Service"
|
||||||
android:onClick="addService"
|
android:onClick="addService"
|
||||||
android:theme="@style/AppTheme.Button" />
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
android:inputType="numberDecimal"
|
android:inputType="numberDecimal"
|
||||||
android:textCursorDrawable="@color/colorWhite"
|
android:textCursorDrawable="@color/colorWhite"
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
|
android:text=""
|
||||||
app:met_baseColor="@android:color/black"
|
app:met_baseColor="@android:color/black"
|
||||||
app:met_floatingLabel="highlight"
|
app:met_floatingLabel="highlight"
|
||||||
app:met_primaryColor="@color/colorBlack"
|
app:met_primaryColor="@color/colorBlack"
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
android:hint="@string/servicename"
|
android:hint="@string/servicename"
|
||||||
android:textCursorDrawable="@color/colorWhite"
|
android:textCursorDrawable="@color/colorWhite"
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
|
android:text=""
|
||||||
app:met_baseColor="@android:color/black"
|
app:met_baseColor="@android:color/black"
|
||||||
app:met_floatingLabel="highlight"
|
app:met_floatingLabel="highlight"
|
||||||
app:met_primaryColor="@color/colorBlack"
|
app:met_primaryColor="@color/colorBlack"
|
||||||
|
@ -28,6 +29,7 @@
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:hint="@string/servicerate"
|
android:hint="@string/servicerate"
|
||||||
|
android:text=""
|
||||||
android:inputType="numberDecimal"
|
android:inputType="numberDecimal"
|
||||||
android:textCursorDrawable="@color/colorWhite"
|
android:textCursorDrawable="@color/colorWhite"
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="45dp"
|
android:layout_height="wrap_content"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:background="@drawable/customborder"
|
android:background="@drawable/customborder"
|
||||||
android:layout_marginBottom="5dp">
|
android:layout_marginBottom="5dp">
|
||||||
|
@ -9,7 +9,8 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="6dp"
|
||||||
|
android:paddingBottom="6dp"
|
||||||
android:id="@+id/Name"
|
android:id="@+id/Name"
|
||||||
android:layout_width="80dp"
|
android:layout_width="80dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -21,7 +22,8 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/Rate"
|
android:id="@+id/Rate"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="6dp"
|
||||||
|
android:paddingBottom="6dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
|
Loading…
Reference in a new issue