|
|
|
@ -1,6 +1,8 @@
@@ -1,6 +1,8 @@
|
|
|
|
|
package cc.niushuai.dididone.ui.calendar; |
|
|
|
|
|
|
|
|
|
import android.app.AlertDialog; |
|
|
|
|
import android.content.Context; |
|
|
|
|
import android.graphics.Color; |
|
|
|
|
import android.os.Bundle; |
|
|
|
|
import android.util.Log; |
|
|
|
|
import android.view.Gravity; |
|
|
|
@ -18,8 +20,10 @@ import androidx.lifecycle.ViewModelProvider;
@@ -18,8 +20,10 @@ import androidx.lifecycle.ViewModelProvider;
|
|
|
|
|
import com.github.clans.fab.FloatingActionButton; |
|
|
|
|
import com.github.clans.fab.FloatingActionMenu; |
|
|
|
|
import com.lxj.xpopup.XPopup; |
|
|
|
|
import com.lxj.xpopup.interfaces.OnConfirmListener; |
|
|
|
|
import com.mikepenz.iconics.IconicsDrawable; |
|
|
|
|
import com.mikepenz.iconics.view.IconicsImageView; |
|
|
|
|
import com.mikepenz.ionicons_typeface_library.Ionicons; |
|
|
|
|
import com.necer.calendar.BaseCalendar; |
|
|
|
|
import com.necer.entity.Lunar; |
|
|
|
|
import com.necer.enumeration.DateChangeBehavior; |
|
|
|
@ -339,11 +343,41 @@ public class CalendarFragment extends Fragment {
@@ -339,11 +343,41 @@ public class CalendarFragment extends Fragment {
|
|
|
|
|
TextView dateTextView = this.getTextView(IntSnowflake.next_id(), DateUtil.date(record.getCreateDate()).toString(DatePattern.NORM_DATETIME_PATTERN), dateLayout, R.color._666666, 12, Gravity.TOP); |
|
|
|
|
itemLayout.addView(dateTextView); |
|
|
|
|
|
|
|
|
|
itemLayout.setOnLongClickListener(new View.OnLongClickListener() { |
|
|
|
|
@Override |
|
|
|
|
public boolean onLongClick(View v) { |
|
|
|
|
|
|
|
|
|
XLog.d("project: {} {} {} record: {} {} {} long clicked", project.getName(), project.getIcon(), record.getId(), |
|
|
|
|
record.getProjectId(), record.getName(), record.getCheckDate()); |
|
|
|
|
|
|
|
|
|
AlertDialog alertDialog = new AlertDialog.Builder(getContext()) |
|
|
|
|
.setTitle(StrUtil.format("确定要删除 [{}]", record.getName())) |
|
|
|
|
.setIcon(new IconicsDrawable(getContext()).icon(Ionicons.Icon.ion_android_warning).color(Color.RED)) |
|
|
|
|
.setPositiveButton("确定", (dialog, which) -> { |
|
|
|
|
// 删除
|
|
|
|
|
deleteRecord(project, record); |
|
|
|
|
// 更新视图
|
|
|
|
|
binding.cCalendarCheckInList.removeView(itemLayout); |
|
|
|
|
binding.cCalendarCheckInList.requestLayout(); |
|
|
|
|
}) |
|
|
|
|
.setNegativeButton("取消", ((dialog, which) -> dialog.dismiss())) |
|
|
|
|
.create(); |
|
|
|
|
alertDialog.show(); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// binding.cCalendarCheckInList.removeAllViews();
|
|
|
|
|
binding.cCalendarCheckInList.addView(itemLayout, 0); |
|
|
|
|
binding.cCalendarCheckInList.requestLayout(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void deleteRecord(Project project, Record record) { |
|
|
|
|
//
|
|
|
|
|
DBManager.INSTANCE.recordDao().deleteById(record.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private TextView getTextView(int id, String text, ViewGroup.LayoutParams textLayoutParams, int textColor, int textSize, int gravity) { |
|
|
|
|
TextView textView = new TextView(getContext()); |
|
|
|
|
|
|
|
|
|