Show toast when no calendars found

pull/437/head
Alex Baker 8 years ago
parent 18af12ad33
commit de6779c069

@ -1,9 +1,11 @@
package org.tasks.activities;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.widget.Toast;
import com.google.common.base.Function;
@ -13,6 +15,7 @@ import org.tasks.calendars.CalendarProvider;
import org.tasks.dialogs.AlertDialogBuilder;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ForActivity;
import org.tasks.injection.InjectingDialogFragment;
import java.util.List;
@ -39,6 +42,7 @@ public class CalendarSelectionDialog extends InjectingDialogFragment {
@Inject DialogBuilder dialogBuilder;
@Inject CalendarProvider calendarProvider;
@Inject @ForActivity Context context;
private CalendarSelectionHandler handler;
private boolean enableNone;
@ -53,6 +57,11 @@ public class CalendarSelectionDialog extends InjectingDialogFragment {
}
});
if (calendarNames.isEmpty()) {
Toast.makeText(context, R.string.no_calendars_found, Toast.LENGTH_LONG).show();
handler.dismiss();
}
AlertDialogBuilder builder = dialogBuilder.newDialog()
.setItems(calendarNames, new DialogInterface.OnClickListener() {
@Override

@ -1,6 +1,7 @@
package org.tasks.injection;
import android.app.Activity;
import android.content.Context;
import android.support.v4.app.DialogFragment;
import dagger.Module;
@ -18,4 +19,10 @@ public class DialogFragmentModule {
public Activity getActivity() {
return dialogFragment.getActivity();
}
@Provides
@ForActivity
public Context getContext() {
return dialogFragment.getActivity();
}
}

@ -905,5 +905,6 @@ File %1$s contained %2$s.\n\n
<string name="led_notification">LED Notification</string>
<string name="hardware_support_required">Hardware support required</string>
<string name="led_color">LED color</string>
<string name="no_calendars_found">No calendars found</string>
</resources>

Loading…
Cancel
Save