Search in sources :

Example 1 with ConfigureReminders

use of nodomain.freeyourgadget.gadgetbridge.activities.ConfigureReminders in project Gadgetbridge by Freeyourgadget.

the class GBReminderListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
    final Reminder reminder = reminderList.get(position);
    holder.container.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ((ConfigureReminders) mContext).configureReminder(reminder);
        }
    });
    holder.container.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            new AlertDialog.Builder(v.getContext()).setTitle(R.string.reminder_delete_confirm_title).setMessage(R.string.reminder_delete_confirm_description).setIcon(R.drawable.ic_warning).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                public void onClick(final DialogInterface dialog, final int whichButton) {
                    ((ConfigureReminders) mContext).deleteReminder(reminder);
                }
            }).setNegativeButton(android.R.string.no, null).show();
            return true;
        }
    });
    holder.reminderMessage.setText(reminder.getMessage());
    final Date time = reminder.getDate();
    final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
    int stringResId = 0;
    switch(reminder.getRepetition()) {
        case Reminder.ONCE:
            stringResId = R.string.reminder_time_once;
            break;
        case Reminder.EVERY_DAY:
            stringResId = R.string.reminder_time_every_day;
            break;
        case Reminder.EVERY_WEEK:
            stringResId = R.string.reminder_time_every_week;
            break;
        case Reminder.EVERY_MONTH:
            stringResId = R.string.reminder_time_every_month;
            break;
        case Reminder.EVERY_YEAR:
            stringResId = R.string.reminder_time_every_year;
            break;
    }
    final String reminderTimeText = mContext.getString(stringResId, format.format(time));
    holder.reminderTime.setText(reminderTimeText);
}
Also used : AlertDialog(android.app.AlertDialog) Reminder(nodomain.freeyourgadget.gadgetbridge.entities.Reminder) DialogInterface(android.content.DialogInterface) ConfigureReminders(nodomain.freeyourgadget.gadgetbridge.activities.ConfigureReminders) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) Date(java.util.Date) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 View (android.view.View)1 TextView (android.widget.TextView)1 CardView (androidx.cardview.widget.CardView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 ConfigureReminders (nodomain.freeyourgadget.gadgetbridge.activities.ConfigureReminders)1 Reminder (nodomain.freeyourgadget.gadgetbridge.entities.Reminder)1