Fix NPE when calendar permissions are revoked

pull/513/head
Alex Baker 8 years ago
parent 80affce5d8
commit 004b14c0d7

@ -34,15 +34,11 @@ public class CalendarSelectionActivity extends ThemedInjectingAppCompatActivity
private void showDialog() {
FragmentManager fragmentManager = getSupportFragmentManager();
CalendarSelectionDialog fragmentByTag =
(CalendarSelectionDialog)
fragmentManager.findFragmentByTag(FRAG_TAG_CALENDAR_PREFERENCE_SELECTION);
if (fragmentByTag == null) {
if (fragmentManager.findFragmentByTag(FRAG_TAG_CALENDAR_PREFERENCE_SELECTION) == null) {
Intent intent = getIntent();
fragmentByTag = newCalendarSelectionDialog(intent.getStringExtra(EXTRA_CALENDAR_NAME));
fragmentByTag.show(fragmentManager, FRAG_TAG_CALENDAR_PREFERENCE_SELECTION);
newCalendarSelectionDialog(intent.getStringExtra(EXTRA_CALENDAR_NAME))
.show(fragmentManager, FRAG_TAG_CALENDAR_PREFERENCE_SELECTION);
}
fragmentByTag.setCalendarSelectionHandler(this);
}
@Override

@ -2,6 +2,7 @@ package org.tasks.activities;
import static com.google.common.collect.Lists.transform;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@ -82,6 +83,13 @@ public class CalendarSelectionDialog extends InjectingDialogFragment {
.show();
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
handler = (CalendarSelectionHandler) activity;
}
@Override
public void onResume() {
super.onResume();
@ -103,10 +111,6 @@ public class CalendarSelectionDialog extends InjectingDialogFragment {
component.inject(this);
}
public void setCalendarSelectionHandler(CalendarSelectionHandler handler) {
this.handler = handler;
}
public interface CalendarSelectionHandler {
void selectedCalendar(AndroidCalendar calendar);

Loading…
Cancel
Save