From 7ab5449b2d22b68345dcc1d38484391de370b44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 14:58:28 +0900 Subject: [PATCH 01/15] =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E4=BD=9C=E6=88=90WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/res/layout/lacerta_dialog_create_tag.xml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/component/common/src/main/res/layout/lacerta_dialog_create_tag.xml b/component/common/src/main/res/layout/lacerta_dialog_create_tag.xml index 4e72834f..9a8fd21f 100644 --- a/component/common/src/main/res/layout/lacerta_dialog_create_tag.xml +++ b/component/common/src/main/res/layout/lacerta_dialog_create_tag.xml @@ -7,9 +7,14 @@ - - + android:layout_height="wrap_content" + android:layout_marginVertical="16dp"/> + + \ No newline at end of file From 9bff04ce2e15f971d8403533846d15d4891d98c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 14:59:56 +0900 Subject: [PATCH 02/15] =?UTF-8?q?=E5=AE=9F=E8=A3=85WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/LacertaCreateTagDialog.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java new file mode 100644 index 00000000..d87f2de1 --- /dev/null +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java @@ -0,0 +1,24 @@ +package one.nem.lacerta.component.common; + +import android.app.Dialog; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; + +import androidx.fragment.app.DialogFragment; + +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + +public class LacertaCreateTagDialog extends DialogFragment { + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + LayoutInflater inflater = requireActivity().getLayoutInflater(); + View view = inflater.inflate(R.layout.lacerta_dialog_create_tag, null); + builder.setView(view); + return builder.create(); + } + + +} From c4bd3d761e43f180f13d4024bf8e96454dff6620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:00:53 +0900 Subject: [PATCH 03/15] =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB?= =?UTF-8?q?=E3=81=AA=E3=81=A9=E3=81=AEGetter/Setter=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/LacertaCreateTagDialog.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java index d87f2de1..9256d530 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java @@ -11,6 +11,36 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder; public class LacertaCreateTagDialog extends DialogFragment { + private String title; + + private String message; + + private String positiveButtonText; + + private String negativeButtonText; + + + + public LacertaCreateTagDialog setTitle(String title) { + this.title = title; + return this; + } + + public LacertaCreateTagDialog setMessage(String message) { + this.message = message; + return this; + } + + public LacertaCreateTagDialog setPositiveButtonText(String positiveButtonText) { + this.positiveButtonText = positiveButtonText; + return this; + } + + public LacertaCreateTagDialog setNegativeButtonText(String negativeButtonText) { + this.negativeButtonText = negativeButtonText; + return this; + } + @Override public Dialog onCreateDialog(Bundle savedInstanceState) { MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); From 4cc41512542ccefe8e11f04e449d8a665adc2fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:03:24 +0900 Subject: [PATCH 04/15] =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=83=8A=E4=BD=9C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/common/LacertaCreateTagDialogListener.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialogListener.java diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialogListener.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialogListener.java new file mode 100644 index 00000000..fce79957 --- /dev/null +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialogListener.java @@ -0,0 +1,8 @@ +package one.nem.lacerta.component.common; + +public interface LacertaCreateTagDialogListener { + + void onPositiveClick(String tag_name, String tag_color); + + void onNegativeClick(); +} From cf623c5640fb1e391b293fb0180541d9763350d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:04:20 +0900 Subject: [PATCH 05/15] =?UTF-8?q?=E3=83=AD=E3=82=B8=E3=83=83=E3=82=AF,=20?= =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=83=8A=E5=AE=9F=E8=A3=85WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/LacertaCreateTagDialog.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java index 9256d530..06940715 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java @@ -4,6 +4,7 @@ import android.app.Dialog; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; +import android.widget.EditText; import androidx.fragment.app.DialogFragment; @@ -19,7 +20,14 @@ public class LacertaCreateTagDialog extends DialogFragment { private String negativeButtonText; + private LacertaCreateTagDialogListener listener; + // Setter + + public LacertaCreateTagDialog setListener(LacertaCreateTagDialogListener listener) { + this.listener = listener; + return this; + } public LacertaCreateTagDialog setTitle(String title) { this.title = title; @@ -46,6 +54,25 @@ public class LacertaCreateTagDialog extends DialogFragment { MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); LayoutInflater inflater = requireActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.lacerta_dialog_create_tag, null); + + // TextEdit + EditText tag_name_edit_text = view.findViewById(R.id.tag_name_edit_text); + EditText tag_color_edit_text = view.findViewById(R.id.tag_color_edit_text); + + // Button + builder.setPositiveButton(positiveButtonText, (dialog, which) -> { + String tag_name = tag_name_edit_text.getText().toString(); + String tag_color = tag_color_edit_text.getText().toString(); + if (listener != null) { + listener.onPositiveClick(tag_name, tag_color); + } + }); + builder.setNegativeButton(negativeButtonText, (dialog, which) -> { + if (listener != null) { + listener.onNegativeClick(); + } + }); + builder.setView(view); return builder.create(); } From 515a8814283b4e17b0f8504ce2e7f28882a10504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:05:07 +0900 Subject: [PATCH 06/15] =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/setting/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/feature/setting/build.gradle b/feature/setting/build.gradle index db8a19e6..235283ff 100644 --- a/feature/setting/build.gradle +++ b/feature/setting/build.gradle @@ -46,6 +46,8 @@ dependencies { // shared implementation project(':shared:ui') + implementation project(':component:common') + implementation project(':data') implementation project(':model') From 6902fbebbddaf7c3ae36312adaca02f12c4a3277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:06:32 +0900 Subject: [PATCH 07/15] =?UTF-8?q?=E5=AE=9F=E8=A3=85WIP(=E3=83=87=E3=83=90?= =?UTF-8?q?=E3=83=83=E3=82=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/setting/SettingTagManageFragment.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java index 46f96a7a..ddf918b8 100644 --- a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java +++ b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java @@ -16,6 +16,7 @@ import android.widget.Toast; import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; +import one.nem.lacerta.component.common.LacertaCreateTagDialog; import one.nem.lacerta.data.LacertaLibrary; /** @@ -102,6 +103,8 @@ public class SettingTagManageFragment extends Fragment { toolbar.setOnMenuItemClickListener(item -> { if (item.getItemId() == R.id.setting_tag_manage_menu_add) { Toast.makeText(getContext(), "Add Clicked", Toast.LENGTH_SHORT).show(); + LacertaCreateTagDialog dialog = new LacertaCreateTagDialog(); + dialog.show(getParentFragmentManager(), "create_tag_dialog"); return true; } else { return false; From 3960c07482b5a0bdafd340b6f207a1cd6e752a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:12:22 +0900 Subject: [PATCH 08/15] =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/layout/lacerta_dialog_create_tag.xml | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/component/common/src/main/res/layout/lacerta_dialog_create_tag.xml b/component/common/src/main/res/layout/lacerta_dialog_create_tag.xml index 9a8fd21f..8cd6efb9 100644 --- a/component/common/src/main/res/layout/lacerta_dialog_create_tag.xml +++ b/component/common/src/main/res/layout/lacerta_dialog_create_tag.xml @@ -4,17 +4,33 @@ android:layout_height="match_parent" android:orientation="vertical"> - + android:paddingTop="8dp" + android:paddingHorizontal="16dp" + style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> - - + + + + android:paddingTop="8dp" + android:paddingHorizontal="16dp" + style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> + + + + \ No newline at end of file From fc56781c205d0bd1f1ef4e5c137248a2a2cb9d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:17:43 +0900 Subject: [PATCH 09/15] =?UTF-8?q?=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E6=8C=99=E5=8B=95=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/common/LacertaCreateTagDialog.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java index 06940715..6a187926 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaCreateTagDialog.java @@ -57,17 +57,23 @@ public class LacertaCreateTagDialog extends DialogFragment { // TextEdit EditText tag_name_edit_text = view.findViewById(R.id.tag_name_edit_text); + com.google.android.material.textfield.TextInputLayout tag_name_text_input_layout = view.findViewById(R.id.tag_name_text_input_layout); + tag_name_text_input_layout.setHint("タグの名前"); EditText tag_color_edit_text = view.findViewById(R.id.tag_color_edit_text); + com.google.android.material.textfield.TextInputLayout tag_color_text_input_layout = view.findViewById(R.id.tag_color_text_input_layout); + tag_color_text_input_layout.setHint("タグの色(カラーコード)"); + + builder.setTitle(this.title == null ? "Create new tag" : this.title); // Button - builder.setPositiveButton(positiveButtonText, (dialog, which) -> { + builder.setPositiveButton(positiveButtonText == null ? "OK" : positiveButtonText, (dialog, which) -> { String tag_name = tag_name_edit_text.getText().toString(); String tag_color = tag_color_edit_text.getText().toString(); if (listener != null) { listener.onPositiveClick(tag_name, tag_color); } }); - builder.setNegativeButton(negativeButtonText, (dialog, which) -> { + builder.setNegativeButton(negativeButtonText == null ? "Cancel" : negativeButtonText, (dialog, which) -> { if (listener != null) { listener.onNegativeClick(); } From 2f9df5a225ef4ae8a606404a11d60435e823ea9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:18:32 +0900 Subject: [PATCH 10/15] =?UTF-8?q?=E3=82=AF=E3=83=AA=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88=E3=82=B9=E3=82=BF=E3=83=96?= =?UTF-8?q?=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/setting/SettingTagManageFragment.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java index ddf918b8..53660f69 100644 --- a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java +++ b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java @@ -17,6 +17,7 @@ import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.component.common.LacertaCreateTagDialog; +import one.nem.lacerta.component.common.LacertaCreateTagDialogListener; import one.nem.lacerta.data.LacertaLibrary; /** @@ -104,6 +105,17 @@ public class SettingTagManageFragment extends Fragment { if (item.getItemId() == R.id.setting_tag_manage_menu_add) { Toast.makeText(getContext(), "Add Clicked", Toast.LENGTH_SHORT).show(); LacertaCreateTagDialog dialog = new LacertaCreateTagDialog(); + dialog.setListener(new LacertaCreateTagDialogListener() { + @Override + public void onPositiveClick(String tagName, String tagColor) { + Toast.makeText(getContext(), "Positive Clicked", Toast.LENGTH_SHORT).show(); + } + + @Override + public void onNegativeClick() { + Toast.makeText(getContext(), "Negative Clicked", Toast.LENGTH_SHORT).show(); + } + }); dialog.show(getParentFragmentManager(), "create_tag_dialog"); return true; } else { From 8acbe6338bff50e635d5cf7047644e4a5f0a7e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:26:04 +0900 Subject: [PATCH 11/15] =?UTF-8?q?ID=E3=81=8C=E6=8C=87=E5=AE=9A=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AB=E8=87=AA=E5=8B=95=E3=81=A7=E7=94=9F=E6=88=90=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java index 88ef000f..816bf706 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -244,6 +245,9 @@ public class LacertaLibraryImpl implements LacertaLibrary { public CompletableFuture createTag(DocumentTag tag) { return CompletableFuture.supplyAsync(() -> { TagEntity tagEntity = convertDocumentTagToTagEntity(tag); + if (Objects.isNull(tagEntity.id) || tagEntity.id.isEmpty()) { + tagEntity.id = UUID.randomUUID().toString(); + } database.tagDao().insert(tagEntity); logger.debug("LacertaLibraryImpl", "Database Query: Inserted TagEntity (" + tag.getId() + ")"); return null; From fad9fcc48af4861c82988295dada137d6b3ead72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:26:19 +0900 Subject: [PATCH 12/15] =?UTF-8?q?=E3=82=BF=E3=82=B0=E3=82=92=E5=AE=9F?= =?UTF-8?q?=E9=9A=9B=E3=81=AB=E7=94=9F=E6=88=90=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/setting/SettingTagManageFragment.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java index 53660f69..2211a60c 100644 --- a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java +++ b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java @@ -19,6 +19,7 @@ import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.component.common.LacertaCreateTagDialog; import one.nem.lacerta.component.common.LacertaCreateTagDialogListener; import one.nem.lacerta.data.LacertaLibrary; +import one.nem.lacerta.model.document.tag.DocumentTag; /** * A simple {@link Fragment} subclass. @@ -109,6 +110,10 @@ public class SettingTagManageFragment extends Fragment { @Override public void onPositiveClick(String tagName, String tagColor) { Toast.makeText(getContext(), "Positive Clicked", Toast.LENGTH_SHORT).show(); + DocumentTag newTag = new DocumentTag(); + newTag.setName(tagName); + newTag.setColor(tagColor); + lacertaLibrary.createTag(newTag).join(); } @Override From 21b198bc35c10d75d39e42a05237d3134770f5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:28:41 +0900 Subject: [PATCH 13/15] =?UTF-8?q?=E3=82=BF=E3=82=B0=E3=83=AA=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=AE=E6=9B=B4=E6=96=B0=E3=82=92=E5=88=87=E3=82=8A?= =?UTF-8?q?=E5=87=BA=E3=81=97,=20=E8=BF=BD=E5=8A=A0=E5=BE=8C=E3=81=AB?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../setting/SettingTagManageFragment.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java index 2211a60c..f01d82f3 100644 --- a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java +++ b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java @@ -32,6 +32,10 @@ public class SettingTagManageFragment extends Fragment { @Inject LacertaLibrary lacertaLibrary; + private RecyclerView recyclerView; + + private TagListItemAdapter adapter; + public SettingTagManageFragment() { // Required empty public constructor } @@ -65,19 +69,22 @@ public class SettingTagManageFragment extends Fragment { public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - RecyclerView recyclerView = view.findViewById(R.id.tag_item_recycler_view); - TagListItemAdapter adapter = new TagListItemAdapter((tagId, tagName, tagColor) -> { + this.recyclerView = view.findViewById(R.id.tag_item_recycler_view); + this.adapter = new TagListItemAdapter((tagId, tagName, tagColor) -> { Toast.makeText(getContext(), "Tag Clicked", Toast.LENGTH_SHORT).show(); }); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - lacertaLibrary.getTagList().thenAccept(documentTags -> { - adapter.setDocumentTags(documentTags); - adapter.notifyDataSetChanged(); - }); + updateTagList(); + } + private void updateTagList() { + lacertaLibrary.getTagList().thenAccept(documentTags -> { + this.adapter.setDocumentTags(documentTags); + this.adapter.notifyDataSetChanged(); + }); } /** @@ -114,6 +121,7 @@ public class SettingTagManageFragment extends Fragment { newTag.setName(tagName); newTag.setColor(tagColor); lacertaLibrary.createTag(newTag).join(); + updateTagList(); } @Override From b0effa21a4cb5614a93a2aefb06743c9617a66a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:32:47 +0900 Subject: [PATCH 14/15] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=87=A6=E7=90=86?= =?UTF-8?q?=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/setting/SettingTagManageFragment.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java index f01d82f3..98a2dde0 100644 --- a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java +++ b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java @@ -80,10 +80,17 @@ public class SettingTagManageFragment extends Fragment { updateTagList(); } + /** + * タグリストを更新する + */ private void updateTagList() { lacertaLibrary.getTagList().thenAccept(documentTags -> { + int currentTagCount = this.adapter.getItemCount(); this.adapter.setDocumentTags(documentTags); - this.adapter.notifyDataSetChanged(); + if (currentTagCount != this.adapter.getItemCount()) { + this.adapter.notifyItemRangeRemoved(0, currentTagCount); + this.adapter.notifyItemRangeInserted(0, this.adapter.getItemCount()); + } }); } From 513af3fda86dba938c3babf57e2f428f8b3e2d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 15:41:15 +0900 Subject: [PATCH 15/15] =?UTF-8?q?Cancel=E3=81=A7=E3=82=82=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/setting/SettingTagManageFragment.java | 1 + 1 file changed, 1 insertion(+) diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java index 98a2dde0..05a3267a 100644 --- a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java +++ b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java @@ -134,6 +134,7 @@ public class SettingTagManageFragment extends Fragment { @Override public void onNegativeClick() { Toast.makeText(getContext(), "Negative Clicked", Toast.LENGTH_SHORT).show(); + updateTagList(); } }); dialog.show(getParentFragmentManager(), "create_tag_dialog");