diff --git a/Assignments/CriminalIntent12/.idea/appInsightsSettings.xml b/Assignments/CriminalIntent12/.idea/appInsightsSettings.xml
new file mode 100644
index 0000000..371f2e2
--- /dev/null
+++ b/Assignments/CriminalIntent12/.idea/appInsightsSettings.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/Crime.java b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/Crime.java
index 03ab790..e62abf9 100644
--- a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/Crime.java
+++ b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/Crime.java
@@ -1,9 +1,11 @@
package asdv.lisset.criminalintent;
+import java.io.Serial;
+import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
-public class Crime {
+public class Crime implements Serializable {
private UUID id;
private String title;
private Date date;
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 fdcc576..0dbbd9f 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
@@ -16,8 +16,10 @@ import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
+import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.List;
import java.util.UUID;
public class CrimeFragment extends Fragment {
@@ -38,11 +40,11 @@ public class CrimeFragment extends Fragment {
// getActivity().getIntent()
// .getSerializableExtra(CrimeActivity.EXTRA_CRIME_ID);
// crime = CrimeLab.get(getActivity()).getCrime(crimeId);
+ List crimeList = (List) getArguments().getSerializable("CrimeArrayList");
UUID crimeId = (UUID)
- getArguments().getSerializable(ARG_CRIME_ID);
- crime =
- CrimeLab.get(getActivity()).getCrime(crimeId);
-
+ getArguments().getSerializable("CRIME_ID");
+ int arrayIndex = (Integer) getArguments().getSerializable("POSITION");
+ this.crime = crimeList.get(arrayIndex);
}
@Override
@@ -105,8 +107,7 @@ public class CrimeFragment extends Fragment {
}
@Override
- public void onActivityResult(int requestCode, int
- resultCode, Intent data) {
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != Activity.RESULT_OK) {
return;
}
@@ -115,6 +116,9 @@ public class CrimeFragment extends Fragment {
.getSerializableExtra(DatePickerFragment.EXTRA_DATE);
crime.setDate(date);
updateDate();
+ Intent intent = new Intent();
+ intent.putExtra("CRIME", crime);
+ getActivity().setResult(777, intent);
}
}
@@ -122,4 +126,7 @@ public class CrimeFragment extends Fragment {
{
dateButton.setText(crime.getDate().toString());
}
+
+
+
}
\ No newline at end of file
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 53932f2..40a3847 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
@@ -1,10 +1,41 @@
package asdv.lisset.criminalintent;
+import android.content.Intent;
+import android.os.Bundle;
+
+import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
-public class CrimeListActivity extends SingleFragmentActivity{
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CrimeListActivity extends SingleFragmentActivity {
+ private List crimes;
+ private Crime newCrime;
@Override
protected Fragment createFragment() {
- return new CrimeListFragment();
+ crimes = new ArrayList<>();
+ for (int i =0; i < 100; ++i)
+ {
+ Crime crime = new Crime();
+ crime.setTitle("Crime #" + i);
+ crime.setSolved(i % 2 == 1); //every other one
+ crimes.add(crime);
+ }
+ CrimeListFragment crimeList = new CrimeListFragment();
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("CrimeArrayList", (Serializable) crimes);
+ crimeList.setArguments(bundle);
+ return crimeList;
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (resultCode == 777) {
+ newCrime = (Crime) data.getSerializableExtra("CRIME");
+ int x = 10;
+ }
}
}
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 d18875d..e5afae2 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
@@ -11,19 +11,23 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+import java.io.Serializable;
+import java.util.ArrayList;
import java.util.List;
public class CrimeListFragment extends Fragment {
private RecyclerView crimeRecyclerView;
private CrimeAdapter adapter;
+ List crimeList;
+
private void updateUI(){
- CrimeLab crimeLab = CrimeLab.get(getActivity());
- List crimes = crimeLab.getCrimes();
+ List crimes = crimeList;
if(this.adapter == null) {
adapter = new CrimeAdapter(crimes);
crimeRecyclerView.setAdapter(adapter);
@@ -33,6 +37,14 @@ public class CrimeListFragment extends Fragment {
this.adapter.notifyDataSetChanged();
}
}
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Bundle b = getArguments();
+ this.crimeList = (List) b.getSerializable("CrimeArrayList");
+ }
+
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container,
@@ -78,8 +90,17 @@ public class CrimeListFragment extends Fragment {
@Override
public void onClick(View v)
{
- Intent intent = CrimePagerActivity.newIntent(getActivity(), crime.getId());
- startActivity(intent);
+ SingleFragmentActivity A = (SingleFragmentActivity) getActivity();
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("CrimeArrayList", (Serializable) crimeList);
+ bundle.putSerializable("CRIME_ID", crime.getId());
+ Intent intent = new Intent(A, CrimePagerActivity.class);
+ intent.putExtra("arrayBundle", bundle);
+
+ //Intent intent = CrimePagerActivity.newIntent(getActivity(), b);
+ //intent.putExtra("CrimeArrayList", crimeList);
+ //startActivity(intent);
+ startActivityForResult(intent,888);
}
}
@@ -112,4 +133,5 @@ public class CrimeListFragment extends Fragment {
}
+
}
diff --git a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimePagerActivity.java b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimePagerActivity.java
index fbfe726..d048827 100644
--- a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimePagerActivity.java
+++ b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/CrimePagerActivity.java
@@ -14,6 +14,7 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;
+import java.io.Serializable;
import java.util.List;
import java.util.UUID;
@@ -36,10 +37,16 @@ public class CrimePagerActivity extends AppCompatActivity
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_crime_pager);
- UUID crimeId = (UUID) getIntent().getSerializableExtra(EXTRA_CRIME_ID);
+
+ Intent intent = getIntent();
+ Bundle bundle = intent.getBundleExtra("arrayBundle");
+ mCrimes = (List) bundle.getSerializable("CrimeArrayList");
+ UUID crimeId = (UUID) bundle.getSerializable("CRIME_ID");
+ //UUID crimeId = (UUID) getIntent().getSerializableExtra(EXTRA_CRIME_ID);
+
mViewPager = (ViewPager)
findViewById(R.id.crime_view_pager);
- mCrimes = CrimeLab.get(this).getCrimes();
+ //mCrimes = CrimeLab.get(this).getCrimes();
FragmentManager fragmentManager =
getSupportFragmentManager();
mViewPager.setAdapter(new FragmentStatePagerAdapter(fragmentManager)
@@ -47,8 +54,17 @@ public class CrimePagerActivity extends AppCompatActivity
@Override
public Fragment getItem(int position)
{
- Crime crime = mCrimes.get(position);
- return CrimeFragment.newInstance(crime.getId());
+ //Crime crime = mCrimes.get(position);
+ Bundle args = new Bundle();
+ args.putSerializable("CRIME_ID", crimeId);
+ args.putSerializable("CrimeArrayList", (Serializable) mCrimes);
+ args.putSerializable("POSITION", (Serializable) position);
+ CrimeFragment fragment = new CrimeFragment();
+
+ fragment.setArguments(args);
+
+ return fragment;
+ //return CrimeFragment.newInstance(crime.getId());
}
@Override
public int getCount()
@@ -65,4 +81,9 @@ public class CrimePagerActivity extends AppCompatActivity
}
}
}
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ }
}
\ No newline at end of file
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 e6353ac..aa7aaf8 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
@@ -15,11 +15,14 @@ import androidx.fragment.app.DialogFragment;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.UUID;
public class DatePickerFragment extends DialogFragment
{
private static final String ARG_DATE = "date";
private DatePicker mDatePicker;
+ List crimeList;
public static final String EXTRA_DATE = "com.bignerdranch.android.criminalintent.date";
public static DatePickerFragment newInstance(Date date)
@@ -44,10 +47,15 @@ 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/SingleFragmentActivity.java b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/SingleFragmentActivity.java
index 585d634..7df9526 100644
--- a/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/SingleFragmentActivity.java
+++ b/Assignments/CriminalIntent12/app/src/main/java/asdv/lisset/criminalintent/SingleFragmentActivity.java
@@ -8,8 +8,13 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
public abstract class SingleFragmentActivity extends AppCompatActivity {
+ Fragment fragment;
protected abstract Fragment createFragment();
+ public Fragment getFragment() {
+ return fragment;
+ }
+
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -17,7 +22,7 @@ public abstract class SingleFragmentActivity extends AppCompatActivity {
setContentView(R.layout.activity_fragment);
FragmentManager fm =
getSupportFragmentManager();
- Fragment fragment =
+ fragment =
fm.findFragmentById(R.id.fragment_container);
if (fragment == null) {
fragment = createFragment();
diff --git a/Assignments/recycler_click/.idea/.gitignore b/Assignments/recycler_click/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/Assignments/recycler_click/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/Assignments/recycler_click/.idea/.name b/Assignments/recycler_click/.idea/.name
new file mode 100644
index 0000000..9698395
--- /dev/null
+++ b/Assignments/recycler_click/.idea/.name
@@ -0,0 +1 @@
+FragmentToFragmentMap
\ No newline at end of file
diff --git a/Assignments/recycler_click/.idea/appInsightsSettings.xml b/Assignments/recycler_click/.idea/appInsightsSettings.xml
new file mode 100644
index 0000000..371f2e2
--- /dev/null
+++ b/Assignments/recycler_click/.idea/appInsightsSettings.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assignments/recycler_click/.idea/compiler.xml b/Assignments/recycler_click/.idea/compiler.xml
new file mode 100644
index 0000000..b589d56
--- /dev/null
+++ b/Assignments/recycler_click/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assignments/recycler_click/.idea/deploymentTargetDropDown.xml b/Assignments/recycler_click/.idea/deploymentTargetDropDown.xml
new file mode 100644
index 0000000..0c0c338
--- /dev/null
+++ b/Assignments/recycler_click/.idea/deploymentTargetDropDown.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assignments/recycler_click/.idea/discord.xml b/Assignments/recycler_click/.idea/discord.xml
new file mode 100644
index 0000000..30bab2a
--- /dev/null
+++ b/Assignments/recycler_click/.idea/discord.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assignments/recycler_click/.idea/gradle.xml b/Assignments/recycler_click/.idea/gradle.xml
new file mode 100644
index 0000000..32522c1
--- /dev/null
+++ b/Assignments/recycler_click/.idea/gradle.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assignments/recycler_click/.idea/migrations.xml b/Assignments/recycler_click/.idea/migrations.xml
new file mode 100644
index 0000000..f8051a6
--- /dev/null
+++ b/Assignments/recycler_click/.idea/migrations.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assignments/recycler_click/.idea/misc.xml b/Assignments/recycler_click/.idea/misc.xml
new file mode 100644
index 0000000..0ad17cb
--- /dev/null
+++ b/Assignments/recycler_click/.idea/misc.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assignments/recycler_click/.idea/vcs.xml b/Assignments/recycler_click/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/Assignments/recycler_click/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file