use of com.zendesk.rememberthedate.model.DateModel in project sdk_demo_app_android by zendesk.
the class DateFragment method showRemoveDialog.
private void showRemoveDialog(final DateModel item) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
// set title
alertDialogBuilder.setTitle("Confirm").setMessage("Remove this date?").setCancelable(true).setPositiveButton("Yes", (dialog, id) -> {
// data.remove(arg2);
long millis = item.getDateInMillis();
AlarmManager alarmManager = (AlarmManager) DateFragment.this.getActivity().getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(DateFragment.this.getActivity(), LocalNotification.class);
intent.putExtra("message", item.getTitle());
PendingIntent pendingIntent = PendingIntent.getBroadcast(DateFragment.this.getActivity(), (int) millis, intent, PendingIntent.FLAG_ONE_SHOT);
Map<String, DateModel> mapData = storage.loadMapData();
mapData.remove(Long.toString(item.getDateInMillis()));
storage.storeMapData(mapData);
alarmManager.cancel(pendingIntent);
reloadAdapter();
}).setNegativeButton("No", (dialogInterface, i) -> dialogInterface.dismiss());
// create alert dialog
alertDialogBuilder.create().show();
}
use of com.zendesk.rememberthedate.model.DateModel in project sdk_demo_app_android by zendesk.
the class EditDateActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_date);
bindViews();
setSupportActionBar(findViewById(R.id.toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (getIntent().getExtras() != null) {
key = getIntent().getExtras().getString("key");
}
storage = Global.getStorage(getApplicationContext());
DateModel selectedDate = storage.loadMapData().get(key);
if (selectedDate != null) {
Date date = selectedDate.getDate();
currentlySelectedDate = new GregorianCalendar();
currentlySelectedDate.setTime(date);
currentlySelectedTime = date;
String dateString = Constants.HUMAN_READABLE_DATE.format(date);
String timeString = Constants.HUMAN_READABLE_TIME.format(date);
title.setText(selectedDate.getTitle());
dateView.setText(dateString);
timeView.setText(timeString);
}
}
Aggregations