master
Chloe Fontenot 🏳️‍⚧️ 2024-03-19 17:35:47 +07:00
parent 674417d57f
commit a0c43c41d0
18 changed files with 240 additions and 21 deletions

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AppInsightsSettings">
<option name="tabSettings">
<map>
<entry key="Firebase Crashlytics">
<value>
<InsightsFilterSettings>
<option name="connection">
<ConnectionSetting>
<option name="appId" value="PLACEHOLDER" />
<option name="mobileSdkAppId" value="" />
<option name="projectId" value="" />
<option name="projectNumber" value="" />
</ConnectionSetting>
</option>
<option name="signal" value="SIGNAL_UNSPECIFIED" />
<option name="timeIntervalDays" value="THIRTY_DAYS" />
<option name="visibilityType" value="ALL" />
</InsightsFilterSettings>
</value>
</entry>
</map>
</option>
</component>
</project>

@ -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;

@ -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<Crime> crimeList = (List<Crime>) 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());
}
}

@ -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<Crime> 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;
}
}
}

@ -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<Crime> crimeList;
private void updateUI(){
CrimeLab crimeLab = CrimeLab.get(getActivity());
List<Crime> crimes = crimeLab.getCrimes();
List<Crime> 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<Crime>) 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 {
}
}

@ -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<Crime>) 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();
}
}

@ -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<Crime> 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<Crime>) 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);

@ -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();

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AppInsightsSettings">
<option name="tabSettings">
<map>
<entry key="Firebase Crashlytics">
<value>
<InsightsFilterSettings>
<option name="connection">
<ConnectionSetting>
<option name="appId" value="PLACEHOLDER" />
<option name="mobileSdkAppId" value="" />
<option name="projectId" value="" />
<option name="projectNumber" value="" />
</ConnectionSetting>
</option>
<option name="signal" value="SIGNAL_UNSPECIFIED" />
<option name="timeIntervalDays" value="THIRTY_DAYS" />
<option name="visibilityType" value="ALL" />
</InsightsFilterSettings>
</value>
</entry>
</map>
</option>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<value>
<entry key="app">
<State />
</entry>
</value>
</component>
</project>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="ASK" />
<option name="description" value="" />
</component>
</project>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveExternalAnnotations" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>