Marshall and unmarshall Timers passed to and from AsyncTimersTableUpdateHandler, TimerRingtoneService, and TimesUpActivity.

This commit is contained in:
Phillip Hsu 2017-02-28 18:01:08 -08:00
parent fb67a28e34
commit 6444092d3a
3 changed files with 14 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.SystemClock;
import android.support.v4.app.NotificationCompat;
import android.view.ViewGroup;
@ -129,6 +130,11 @@ public class TimesUpActivity extends RingtoneActivity<Timer> {
postExpiredTimerNote();
}
@Override
protected Parcelable.Creator<Timer> getParcelableCreator() {
return Timer.CREATOR;
}
private void postExpiredTimerNote() {
Notification note = new NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.timer_expired))

View File

@ -19,6 +19,7 @@ package com.philliphsu.clock2.ringtone.playback;
import android.app.Notification;
import android.content.Intent;
import android.net.Uri;
import android.os.Parcelable;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.support.v4.app.NotificationCompat;
@ -121,4 +122,9 @@ public class TimerRingtoneService extends RingtoneService<Timer> {
getString(R.string.key_timer_silence_after), "15");
return Integer.parseInt(value);
}
@Override
protected Parcelable.Creator<Timer> getParcelableCreator() {
return Timer.CREATOR;
}
}

View File

@ -27,6 +27,7 @@ import com.philliphsu.clock2.timers.Timer;
import com.philliphsu.clock2.list.ScrollHandler;
import com.philliphsu.clock2.timers.TimerNotificationService;
import com.philliphsu.clock2.ringtone.TimesUpActivity;
import com.philliphsu.clock2.util.ParcelableUtil;
/**
* Created by Phillip Hsu on 8/2/2016.
@ -75,8 +76,7 @@ public final class AsyncTimersTableUpdateHandler extends AsyncDatabaseTableUpdat
// TODO: Consider changing to just a long id param
private PendingIntent createTimesUpIntent(Timer timer) {
Intent intent = new Intent(getContext(), TimesUpActivity.class);
// intent.putExtra(TimesUpActivity.EXTRA_ITEM_ID, timer.getId());
intent.putExtra(TimesUpActivity.EXTRA_RINGING_OBJECT, timer);
intent.putExtra(TimesUpActivity.EXTRA_RINGING_OBJECT, ParcelableUtil.marshall(timer));
// There's no point to determining whether to retrieve a previous instance, because
// we chose to ignore it since we had issues with NPEs. TODO: Perhaps these issues
// were caused by you using the same reference variable for every Intent/PI that