Android Assignment
parent
a0c43c41d0
commit
ca4d18d1b6
Binary file not shown.
@ -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<Crime> 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<Crime> getCrimes() {
|
||||
return crimes;
|
||||
}
|
||||
public Crime getCrime(UUID id) {
|
||||
for (Crime crime : crimes) {
|
||||
if (crime.getId().equals(id)) {
|
||||
return crime;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TimePicker xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/timePickerDialog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible" />
|
Binary file not shown.
Loading…
Reference in New Issue