diff --git a/Assignments/CriminalIntent12/.idea/deploymentTargetDropDown.xml b/Assignments/CriminalIntent12/.idea/deploymentTargetDropDown.xml
index 3086d1c..89435ac 100644
--- a/Assignments/CriminalIntent12/.idea/deploymentTargetDropDown.xml
+++ b/Assignments/CriminalIntent12/.idea/deploymentTargetDropDown.xml
@@ -4,18 +4,18 @@
-
+
-
+
-
-
+
+
-
-
+
+
diff --git a/Assignments/CriminalIntent12/CriminalIntent_MP3_CalebFontenot.zip b/Assignments/CriminalIntent12/CriminalIntent_MP3_CalebFontenot.zip
new file mode 100644
index 0000000..6d9540d
Binary files /dev/null and b/Assignments/CriminalIntent12/CriminalIntent_MP3_CalebFontenot.zip differ
diff --git a/Assignments/CriminalIntent12/app/build.gradle.kts b/Assignments/CriminalIntent12/app/build.gradle.kts
index 799297a..98d09ab 100644
--- a/Assignments/CriminalIntent12/app/build.gradle.kts
+++ b/Assignments/CriminalIntent12/app/build.gradle.kts
@@ -8,7 +8,7 @@ android {
defaultConfig {
applicationId = "asdv.lisset.criminalintent3"
- minSdk = 21
+ minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
diff --git a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeFragment.java b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeFragment.java
index 0dbbd9f..7298975 100644
--- a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeFragment.java
+++ b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeFragment.java
@@ -3,6 +3,9 @@ package asdv.lisset.criminalintent;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+
+import androidx.annotation.Nullable;
+import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@@ -32,6 +35,7 @@ public class CrimeFragment extends Fragment {
private static final String DIALOG_DATE =
"DialogDate";
private static final int REQUEST_DATE = 0;
+ public static final int REQUEST_TIME = 101;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -64,6 +68,7 @@ public class CrimeFragment extends Fragment {
@Override
public void onClick(View v)
{
+ // Open DatePickerFragment
FragmentManager manager = getFragmentManager();
DatePickerFragment dialog = DatePickerFragment.newInstance(crime.getDate());
dialog.setTargetFragment(CrimeFragment.this, REQUEST_DATE);
@@ -107,19 +112,37 @@ public class CrimeFragment extends Fragment {
}
@Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode != Activity.RESULT_OK) {
- return;
- }
+ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_DATE) {
Date date = (Date) data
.getSerializableExtra(DatePickerFragment.EXTRA_DATE);
crime.setDate(date);
+
+ // Open TimePickerFragment
+ DialogFragment timePicker = new TimePickerFragment();
+ timePicker.show(getActivity().getSupportFragmentManager(), "timePicker");
+
updateDate();
+
Intent intent = new Intent();
intent.putExtra("CRIME", crime);
getActivity().setResult(777, intent);
}
+ if (requestCode == REQUEST_TIME) {
+ int hour = data.getIntExtra("TIME_HOUR",0);
+ int minute = data.getIntExtra("TIME_MINUTE", 0);
+ Date date = crime.getDate();
+ date.setHours(hour);
+ date.setMinutes(minute);
+ crime.setDate(date);
+ updateDate();
+ getActivity().setResult(778, data);
+
+ }
+ //if (resultCode != Activity.RESULT_OK) {
+ // return;
+ //}
}
private void updateDate()
diff --git a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeLab.java b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeLab.java
deleted file mode 100644
index 8cec043..0000000
--- a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeLab.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package asdv.lisset.criminalintent;
-
-import android.content.Context;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-public class CrimeLab {
- private static CrimeLab crimeLab;
- private List crimes;
- public static CrimeLab get(Context context) {
- if (crimeLab == null) {
- crimeLab = new CrimeLab(context);
- }
- return crimeLab;
- }
- private CrimeLab(Context context) {
- crimes = new ArrayList<>();
- for (int i =0; i < 100; ++i)
- {
- Crime crime = new Crime();
- crime.setTitle("Crime #" + i);
- crime.setSolved(i % 2 == 0); //every other one
- crimes.add(crime);
- }
- }
- public List getCrimes() {
- return crimes;
- }
- public Crime getCrime(UUID id) {
- for (Crime crime : crimes) {
- if (crime.getId().equals(id)) {
- return crime;
- }
- }
- return null;
- }
-}
diff --git a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeListActivity.java b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeListActivity.java
index 40a3847..aa1e7ac 100644
--- a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeListActivity.java
+++ b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeListActivity.java
@@ -35,7 +35,17 @@ public class CrimeListActivity extends SingleFragmentActivity {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == 777) {
newCrime = (Crime) data.getSerializableExtra("CRIME");
- int x = 10;
+ for (int i = 0; i < crimes.size(); ++i) {
+ if (crimes.get(i).getId().equals(newCrime.getId())) {
+ crimes.set(i, newCrime);
+ break;
+ }
+ }
}
+ CrimeListFragment crimeList = (CrimeListFragment) this.getFragment();
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("CrimeArrayList", (Serializable) crimes);
+ crimeList.setArguments(bundle);
+
}
}
diff --git a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeListFragment.java b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeListFragment.java
index e5afae2..5ffe3fc 100644
--- a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeListFragment.java
+++ b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimeListFragment.java
@@ -67,6 +67,8 @@ public class CrimeListFragment extends Fragment {
}
//CRIME HOLDER
+ // ... it holds crimes
+ // CRIMES AGAINST PROGRAMMING
private class CrimeHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
private Crime crime;
private TextView titleTextView;
diff --git a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/DatePickerFragment.java b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/DatePickerFragment.java
index aa7aaf8..0f509d4 100644
--- a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/DatePickerFragment.java
+++ b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/DatePickerFragment.java
@@ -3,15 +3,18 @@ package asdv.lisset.criminalintent;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
+import android.app.TimePickerDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.DatePicker;
+import android.widget.TimePicker;
import androidx.fragment.app.DialogFragment;
+import java.sql.Time;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -47,15 +50,12 @@ public class DatePickerFragment extends DialogFragment
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
- // Date date = (Date) getArguments().getSerializable(ARG_DATE);
+ Date date = (Date) getArguments().getSerializable(ARG_DATE);
Bundle b = getArguments();
- this.crimeList = (List) b.getSerializable("CrimeArrayList");
- UUID crimeUUID = (UUID) b.getSerializable("CRIME_ID");
-
Calendar calendar = Calendar.getInstance();
- //calendar.setTime(date);
+ calendar.setTime(date);
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
diff --git a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/TimePickerFragment.java b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/TimePickerFragment.java
new file mode 100644
index 0000000..0c4bad9
--- /dev/null
+++ b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/TimePickerFragment.java
@@ -0,0 +1,41 @@
+package asdv.lisset.criminalintent;
+
+import static android.app.PendingIntent.getActivity;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.app.TimePickerDialog;
+import android.content.Intent;
+import android.icu.util.Calendar;
+import android.os.Bundle;
+import android.text.format.DateFormat;
+import android.widget.TimePicker;
+
+import androidx.fragment.app.DialogFragment;
+
+public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ // Use the current time as the default values for the picker.
+ final Calendar c = Calendar.getInstance();
+ int hour = c.get(Calendar.HOUR_OF_DAY);
+ int minute = c.get(Calendar.MINUTE);
+
+ // Create a new instance of TimePickerDialog and return it.
+ return new TimePickerDialog(getActivity(), this, hour, minute,
+ DateFormat.is24HourFormat(getActivity()));
+ }
+
+ public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
+ // Pass data back to our caller.
+ Intent i = new Intent();
+ i.putExtra("TIME_HOUR", hourOfDay);
+ i.putExtra("TIME_MINUTE", minute);
+ getActivity().setResult(CrimeFragment.REQUEST_TIME, i);
+ //getActivity().finish();
+
+ }
+}
+
+
diff --git a/Assignments/CriminalIntent12/app/src/main/res/layout/dialog_time.xml b/Assignments/CriminalIntent12/app/src/main/res/layout/dialog_time.xml
new file mode 100644
index 0000000..23b381a
--- /dev/null
+++ b/Assignments/CriminalIntent12/app/src/main/res/layout/dialog_time.xml
@@ -0,0 +1,6 @@
+
+
\ No newline at end of file
diff --git a/Assignments/CriminalIntent12/app/src/main/res/layout/list_item_crime.xml b/Assignments/CriminalIntent12/app/src/main/res/layout/list_item_crime.xml
index 945c15c..e54c10c 100644
--- a/Assignments/CriminalIntent12/app/src/main/res/layout/list_item_crime.xml
+++ b/Assignments/CriminalIntent12/app/src/main/res/layout/list_item_crime.xml
@@ -13,9 +13,10 @@
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
+ android:layout_marginBottom="16dp"
android:text="Crime Title"
- android:textColor="#000000"
android:textSize="18sp"
+ app:layout_constraintBottom_toTopOf="@+id/crime_date"
app:layout_constraintEnd_toStartOf="@+id/imageView_green_cross"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
diff --git a/Assignments/FragmentToFragmentMap-5.zip b/Assignments/FragmentToFragmentMap-5.zip
new file mode 100644
index 0000000..0e565f6
Binary files /dev/null and b/Assignments/FragmentToFragmentMap-5.zip differ